creative-jam-20/Assets/Scripts/DimensionController.cs
TheDaringDan 09c6fc05d9 Game Loop V1
Controls don't deactivate yet
2022-05-14 16:04:31 -04:00

30 lines
661 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 -= 1;
// Destroy projectile
Destroy(other.gameObject);
// Check loss condition
if (_hp <= 0) GameManager.Instance.TriggerGameOver(dimensionId);
}
}