private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { if (testHit(other.gameObject)) { other.gameObject.GetComponent <DeathScript>().Death(); } } else if (other.gameObject.tag == "Enemy" || other.gameObject.tag == "Tank") { Debug.Log("hit"); if (testHit(other.gameObject)) { Debug.Log("hit after"); other.gameObject.GetComponent <DeathScript>().Death(); } } else if (other.gameObject.tag == "Map") { windowScript window = other.gameObject.GetComponent <windowScript>(); wallScript wall = other.gameObject.GetComponent <wallScript>(); if (window) { window.Broken(); } else if (wall) { wall.getHit(); } } }
// Use this for initialization void Start() { if (wall != null && wallIsNotSeted) { wallIsNotSeted = false; wScript = wall.GetComponent <wallScript> (); wScript.addEnemyForOpen(); } }
public void setWall(GameObject wall) { this.wall = wall; if (wall != null && wallIsNotSeted) { wallIsNotSeted = false; wScript = wall.GetComponent <wallScript> (); wScript.addEnemyForOpen(); } }