creative-jam-20/Assets/Scripts/DimensionController.cs
TheDaringDan 989f2ef6fc Enemies now have HP values
They give points on destruction
Points update on UI based on GameManager info
2022-05-15 11:28:52 -04:00

30 lines
679 B
C#

using UnityEngine;
public class DimensionController : MonoBehaviour
{
[SerializeField] private int dimensionId;
[SerializeField] private int maxHp;
private float _hp;
private void Start()
{
_hp = maxHp;
}
private void OnTriggerEnter(Collider other)
{
var enemy = other.GetComponent<Enemy>();
if (ReferenceEquals(enemy, null)) return;
// Update HP (temp for now)
_hp -= enemy.DamageDealt();
// Destroy projectile
Destroy(other.gameObject);
// Check loss condition
if (_hp <= 0) GameManager.Instance.TriggerGameOver(dimensionId);
}
}