This commit is contained in:
Gerard Gascón 2025-04-24 17:26:56 +02:00
commit e0a842f222
796 changed files with 361371 additions and 0 deletions

View file

@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerDeath : MonoBehaviour
{
bool invincible = true;
private void Start()
{
StartCoroutine(vincible(0.3f));
}
IEnumerator vincible(float t)
{
yield return new WaitForSeconds(t);
invincible = false;
}
private void OnTriggerEnter(Collider other)
{
if (!invincible)
{
if (other.gameObject.layer == 6)
{
Kill();
}
}
}
public void Kill()
{
GetComponentInChildren<Animator>().SetBool("Die", true);
GameManager.Instance.player.GetComponent<PlayerManager>().Player1.enabled = false;
GameManager.Instance.player.GetComponent<PlayerManager>().Player2.enabled = false;
Instantiate(GameManager.Instance.player.GetComponent<PlayerManager>().impactParticles, transform.position, Quaternion.identity);
GameManager.Instance.StopGame();
GetComponent<PlayerMovement>().enabled = false;
Debug.Log("You lose");
GameManager.Instance.Lose();
}
}