public void KillEnemy(Tower tower) { if (isAlive) { isAlive = false; if (UIManager.Instance.CurrentEnemy == this.gameObject) { UIManager.Instance.ToggleStatsUIOff(); } // If the enemy was killed by a tower award xp to that tower. // Need to account for when a projectile is still in the air but we delete the tower before collision. MIGHT want to handle this on projecile side... if (tower) { tower.AddExp((Level * 2) + 1); } WaveManager.Instance.RemoveEnemey(gameObject); Destroy(gameObject); } else if (!isAlive) { // Something went wrong... Debug.Log($"{this.gameObject.name} has to be destroyed."); WaveManager.Instance.RemoveEnemey(gameObject); Destroy(gameObject); } }