1
Fork 0
mirror of https://github.com/Steffo99/beat-td.git synced 2024-11-26 09:14:17 +00:00
beat-td/Assets/Scripts/EnemyStatus.cs

41 lines
829 B
C#
Raw Normal View History

2018-04-22 12:07:55 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyStatus : MonoBehaviour {
public int livesCost = 1;
public int health = 10;
2018-04-22 21:05:11 +00:00
public int masks = 1;
2018-04-22 12:07:55 +00:00
2018-04-22 21:05:11 +00:00
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);
}
2018-04-22 12:07:55 +00:00
}