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