1
Fork 0
mirror of https://github.com/Steffo99/beat-td.git synced 2024-11-22 23:34:19 +00:00
beat-td/Assets/Scripts/EnemyStatus.cs

41 lines
855 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyStatus : MonoBehaviour {
public int livesCost = 1;
public int health = 10;
public int masks = 1;
private GameStatus gameStatus;
void Start()
{
gameStatus = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameStatus>();
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log("HIT");
KickCollision kickCollision = collision.GetComponent("KickCollision") as KickCollision;
if (kickCollision != null)
{
health -= kickCollision.damage;
}
}
void Update()
{
if(health <= 0)
{
Die();
}
}
void Die()
{
gameStatus.money += masks;
Destroy(gameObject);
}
}