void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("PlayerShot")) { HellShots counter = other.GetComponent <HellShots> (); if (counter.getCount() > 0) { StartCoroutine(degradeGun()); if (getGun() == 0) { tracker.setGameAlive(); Instantiate(playerExplosion, transform.position, transform.rotation); Destroy(other.gameObject); Destroy(gameObject, 2); SpriteRenderer[] rend = GetComponentsInChildren <SpriteRenderer> (); Collider2D col = GetComponent <CircleCollider2D> (); colour.enabled = false; foreach (SpriteRenderer i in rend) { i.enabled = false; } col.enabled = false; } else { downgrade.Play(); } } } }
void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("EnemyA") || other.CompareTag("EnemyB")) { tracker.loseShip(); tracker.resestMulti(); Destroy(other.gameObject); } if (other.CompareTag("EnemyShot") || other.CompareTag("PlayerShot")) { HellShots counter = other.GetComponent <HellShots> (); counter.incCount(); if (other.CompareTag("PlayerShot")) { if (counter.getCount() == 3) { Destroy(other.gameObject); } } else { if (counter.getCount() == 2) { Destroy(other.gameObject); } } } if (other.transform.position.x >= 3.2 || other.transform.position.x <= -3.2) { other.transform.position = new Vector3(-other.transform.position.x, -other.transform.position.y, other.transform.position.z); } else { other.transform.position = new Vector3(other.transform.position.x, -other.transform.position.y, other.transform.position.z); } }