//LayerMask l_everything; //RaycastHit[] things_hit; // Use this for initialization void Start() { Spawn_Guy = gameObject.GetComponent <SpawnableGuy> (); Enemy_Base = GameObject.FindGameObjectWithTag(Target_Base_Tag); Nav_Agent = gameObject.GetComponent <NavMeshAgent> (); aggro_script = Aggro_Object.GetComponent <Aggro_Range> (); can_attack = true; attack_damage = Spawn_Guy.attack_damage; Debug.Log("Getting to HERE"); if (aggro_script.Enemy_Tags.Contains("Base_1")) { Enemy_Base = GameObject.FindGameObjectWithTag("Base_1"); } else { Debug.Log("Base_2"); Enemy_Base = GameObject.FindGameObjectWithTag("Base_2"); } Current_Target = Enemy_Base; //l_everything = ~0; }
// Update is called once per frame void Update() { if (targets_in_range.Count > 0) { foreach (GameObject target in targets_in_range) { if (target.GetComponent <SpawnableGuy>() != null) { SpawnableGuy spawn_object = target.GetComponent <SpawnableGuy>(); if (spawn_object.current_health <= 0) { targets_in_range.Remove(target); //Network.Destroy(target); } else { if (this.CompareTag("Tower_1")) { if (spawn_object.CompareTag("Enemy_2")) { spawn_object.current_health -= (damage * multiplier) * Time.deltaTime; } } if (this.CompareTag("Tower_2")) { if (spawn_object.CompareTag("Enemy_1")) { spawn_object.current_health -= (damage * multiplier) * Time.deltaTime; } } } } } } if (currenthealth <= 0) { if (!dead) { CmdReactivate(); StartCoroutine(NetDestroy()); dead = true; } } }
public void refresh_attack() { //Debug.Log ("REPEAT PLEASE"); if (in_range && to_follow != null) { String _tag = to_follow.tag; if (_tag.Equals(No_Tower) && !(to_follow.GetComponent <NoTowerScript> ().Equals(null))) { NoTowerScript plot = to_follow.GetComponent <NoTowerScript> (); plot.currentHealth -= (int)attack_strength; Debug.Log("Attacked Plot"); } else if (_tag.Equals(tower) && !(to_follow.GetComponent <TowerScript> ().Equals(null))) { TowerScript tower = to_follow.GetComponent <TowerScript> (); tower.currenthealth -= (int)attack_strength; Debug.Log("Attacked Tower"); } else if (_tag.Equals(enemy_tag) && !(to_follow.GetComponent <SpawnableGuy> ().Equals(null))) { SpawnableGuy unit = to_follow.GetComponent <SpawnableGuy> (); unit.current_health -= attack_strength; Debug.Log("Attacked Unit"); } // try{ // Debug.Log ("ATTACK"); // SpawnableGuy unit = to_follow.GetComponent<SpawnableGuy>(); // unit.current_health -= gameObject.GetComponent<SpawnableGuy>().attack_damage; // }catch(Exception e){ // Debug.Log ("Thats A Tower"); // } } }