init
This commit is contained in:
commit
e0a842f222
796 changed files with 361371 additions and 0 deletions
41
Assets/Scripts/Player/PlayerDeath.cs
Normal file
41
Assets/Scripts/Player/PlayerDeath.cs
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue