2024-04-20 22:19:23 +02:00
|
|
|
using System;
|
2024-04-19 23:32:37 +02:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.Assertions;
|
|
|
|
|
|
|
|
public abstract class Tower : MonoBehaviour
|
|
|
|
{
|
2024-04-20 22:19:23 +02:00
|
|
|
public Observer<bool> TowerSelected { get; set; } = new(false);
|
2024-04-20 15:56:26 +02:00
|
|
|
|
2024-04-20 13:15:33 +02:00
|
|
|
protected HealthComponent healthComp;
|
2024-04-19 23:32:37 +02:00
|
|
|
|
2024-04-20 01:40:53 +02:00
|
|
|
// Getters
|
|
|
|
|
|
|
|
protected virtual void Awake()
|
2024-04-19 23:32:37 +02:00
|
|
|
{
|
|
|
|
healthComp = GetComponent<HealthComponent>();
|
|
|
|
Assert.IsNotNull(healthComp);
|
2024-04-20 22:19:23 +02:00
|
|
|
|
|
|
|
TowerSelected.AddListener(DeselectTowers);
|
2024-04-20 14:23:55 +02:00
|
|
|
}
|
|
|
|
|
2024-04-20 22:19:23 +02:00
|
|
|
public static void DeselectTowers(bool selected)
|
|
|
|
{
|
|
|
|
if (selected)
|
|
|
|
{
|
|
|
|
foreach (var tower in GameObject.FindObjectsByType<Tower>(FindObjectsSortMode.None))
|
|
|
|
{
|
|
|
|
tower.TowerSelected.Value = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-19 23:32:37 +02:00
|
|
|
|
2024-04-20 13:15:33 +02:00
|
|
|
protected virtual void OnDestroy()
|
|
|
|
{
|
2024-04-19 23:32:37 +02:00
|
|
|
}
|
2024-04-20 19:22:52 +02:00
|
|
|
|
|
|
|
protected virtual void Update()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void FixedUpdate()
|
|
|
|
{
|
|
|
|
}
|
2024-04-19 23:32:37 +02:00
|
|
|
}
|