Labo_2_equ_2_a15/Assets/Scripts/CollisionCheck.cs
2015-11-25 13:16:53 -05:00

30 lines
582 B
C#

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class CollisionCheck : MonoBehaviour {
public Text health;
public void initText(int hp)
{
health.text = "Health: " + hp;
}
void OnCollisionEnter2D(Collision2D col)
{
if(col.gameObject.name == "Enemy")
{
health.text = "Health: " + gameObject.GetComponent<Health>().removeHP(1);
}
if(gameObject.GetComponent<Health>().getHP() == 0)
{
gameObject.GetComponent<PlayerBehavior>().Death();
}
}
}