void OnTriggerEnter(Collider other) { Debug.Log(other.tag); if (other.tag == "Towers") { t = other.GetComponent <Tower> (); t.TakeHit(Damage); } else if (other.tag == "Castle") { c = other.GetComponent <Castle> (); c.TakeHit(Damage); } Destroy(gameObject); //destroy the bullet }
void Attack() { // Reset the timer. Stats.AttackSpeed = tempattspeed; timer = 0f; if (BuildingType) { if (C.Health > 0) { anim.SetTrigger("Attack"); C.TakeHit(Stats.AttackDamage); } else { BuildingDead = true; anim.SetBool("PlayerDead", true); if (gameObject.tag == "Dasher") { dmov.Stop = false; } else { enmov.Stop = false; } } } else { if (T.Health > 0) { anim.SetTrigger("Attack"); T.TakeHit(Stats.AttackDamage); } else { BuildingDead = true; if (gameObject.tag == "Dasher") { dmov.Stop = false; } else { enmov.Stop = false; } } } }
void OnTriggerEnter(Collider other) { //Debug.Log (other.tag); if (other.tag == "Towers") { T = other.GetComponentInParent <Tower> (); BuildingType = false; } else if (other.tag == "Castle") { C = other.GetComponentInParent <Castle> (); BuildingType = true; //anim.SetBool ("ToCastle", false); } if (BuildingType) { if (C.Health > 0) { C.TakeHit(Stats.AttackDamage); } else { Destroy(C.gameObject); } } else { if (T.Health > 0) { T.TakeHit(Stats.AttackDamage); } else { Destroy(T.gameObject); } } //Debug.Log (gameObject.name); var exp = Instantiate(explosion, transform.position, transform.rotation); // exp.transform.position = transform.position; // exp.transform.rotation = transform.rotation; Destroy(gameObject, 1f); Destroy(exp, 3f); }