// Use this for initialization void Start() { //Possibly Change This To A Public Variable Assigning Instead To Be More Efficient unit = base_unit.GetComponent <Better_AI> (); Enemies_in_range = new List <GameObject>(); Things_To_Remove = new List <GameObject>(); }
private IEnumerator Attack(GameObject Target) { if (can_attack) { Debug.Log("Attempting To Attack"); can_attack = false; if (Target.GetComponent <SpawnableGuy>()) { Target.GetComponent <SpawnableGuy>().current_health -= attack_damage; } else if (Target.GetComponent <TowerScript>()) { Target.GetComponent <TowerScript>().currenthealth -= (int)attack_damage; } else if (Target.GetComponent <NoTowerScript>()) { //Target.GetComponent<NoTowerScript>().currentHealth -= (int)attack_damage; Target.GetComponent <NoTowerScript>().currentHealth -= 10; Debug.Log("ATTACKED NO TOWER"); } else if (Target.GetComponent <BaseScript>()) { Target.GetComponent <BaseScript>().current_health -= (int)attack_damage; } if (Target.GetComponent <Better_AI> ()) { Better_AI target_unit = Target.GetComponent <Better_AI> (); target_unit.Current_Target = this.gameObject; } StartCoroutine(Spawn_Hit_Indicator(Target)); yield return(new WaitForSeconds(attack_speed)); can_attack = true; } }