30 lines
661 B
C#
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);
|
|
}
|
|
}
|