1
Fork 0
mirror of https://github.com/Steffo99/beat-td.git synced 2024-11-24 00:04:20 +00:00
beat-td/Assets/Scripts/EnemyStatus.cs
2018-04-22 23:17:06 +02:00

40 lines
829 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)
{
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);
}
}