using System; using UnityEngine; using UnityEngine.Assertions; public abstract class Tower : MonoBehaviour { public Observer TowerSelected { get; set; } = new(false); protected HealthComponent healthComp; // Getters protected virtual void Awake() { healthComp = GetComponent(); Assert.IsNotNull(healthComp); TowerSelected.AddListener(DeselectTowers); } public static void DeselectTowers(bool selected) { if (selected) { foreach (var tower in GameObject.FindObjectsByType(FindObjectsSortMode.None)) { tower.TowerSelected.Value = false; } } } protected virtual void OnDestroy() { } protected virtual void Update() { } protected virtual void FixedUpdate() { } }