mirror of
https://github.com/Steffo99/beat-td.git
synced 2024-11-26 09:14:17 +00:00
40 lines
829 B
C#
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);
|
|
}
|
|
}
|