using System.Collections; using System.Collections.Generic; using UnityEngine; public class AddEnemyTower : MonoBehaviour { [SerializeField] private GameObject _towerPrefab; [SerializeField] private PlayerState _actualState; public List controllList; public int count ; private void Update() { if(gameObject.GetComponent() != null) { List towers = new List(); controllList = new List(); foreach(ToweHealthController controll in controllList) { if(controll.gameObject.name != gameObject.name) { controllList.Add(controll); } count = controllList.Count; } } /* if(gameObject.GetComponent() != null) AddTower(); */ } public void AddTower() { if( _towerPrefab.gameObject.name != gameObject.name && _towerPrefab.GetComponent().ownerIndex != _actualState.ownerIndex) { _actualState.enemies.Add(FindObjectOfType().GetComponent()); } } }