using System; using UnityEngine; using UnityEngine.Events; using UnityEngine.Assertions; public abstract class Tower : MonoBehaviour { [SerializeField] private GameObject selectedUI; protected bool selected = false; protected HealthComponent healthComp; protected Outline outline; protected Camera mainCam; [SerializeField] protected UnityEvent OnAttack; // Getters public virtual void TowerSelected(bool selected) { this.selected = selected; outline.enabled = selected; selectedUI.SetActive(selected); } public virtual void Placed() { // dont ask me why but this makes sure everything is initialized lol TowerSelected(true); TowerSelected(false); } protected virtual void Awake() { healthComp = GetComponent(); outline = GetComponent(); Assert.IsNotNull(healthComp); Assert.IsNotNull(outline); mainCam = Camera.main; } protected virtual void Start() { } protected virtual void OnDestroy() { } protected virtual void Update() { selectedUI.transform.LookAt(mainCam.transform.position); } protected virtual void FixedUpdate() { } }