32 lines
691 B
C#
32 lines
691 B
C#
using UnityEngine;
|
|
|
|
public class DimensionController : MonoBehaviour
|
|
{
|
|
public const int STARTING_HP = 25;
|
|
|
|
[SerializeField] private int dimensionId;
|
|
private float _hp;
|
|
private float _maxHp;
|
|
private void Start()
|
|
{
|
|
_maxHp = STARTING_HP;
|
|
_hp = _maxHp;
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
|
|
if (_hp <= 0) { return; }
|
|
|
|
var enemy = other.GetComponent<Enemy>();
|
|
if (ReferenceEquals(enemy, null)) return;
|
|
|
|
StartCoroutine(enemy.InstantDestroy());
|
|
// Update HP (temp for now)
|
|
_hp -= enemy.DamageDealt();
|
|
|
|
GameManager.Instance.DealDamage(dimensionId, _hp, _maxHp);
|
|
}
|
|
|
|
}
|