void OnCollisionEnter2D(Collision2D coll) { if (coll.transform.CompareTag("Bullet")) { //TODO: Add health? if (coll.transform.GetComponent <Bullet>().IsPlayers()) { GUIScore.UpdateScore((transform.localScale.x > 1) ? 1 : (transform.localScale.x > 0.6f ? 2 : 4)); } for (int i = 0; i < 5; i++) { Transform p = Instantiate(particle); p.transform.position = coll.transform.position; p.GetComponent <ParticleHandler>().direction = Mathf.Atan2((coll.transform.position - transform.position).y, (coll.transform.position - transform.position).x) * Mathf.Rad2Deg + (i / 4f * 90f - 45f); } Transform s = Instantiate(sound, transform.position, transform.rotation); s.GetComponent <AudioSource>().clip = explosion; s.GetComponent <AudioSource>().Play(); if (transform.localScale.x <= 0.25f) { Destroy(gameObject); Destroy(coll.gameObject); return; } Split(coll); //Destroy bullet or else... Oh God! Destroy(coll.gameObject); } else if (coll.transform.CompareTag("Enemy")) { for (int i = 0; i < 5; i++) { Transform p = Instantiate(particle); p.transform.position = coll.transform.position; p.GetComponent <ParticleHandler>().direction = Mathf.Atan2((coll.transform.position - transform.position).y, (coll.transform.position - transform.position).x) * Mathf.Rad2Deg + (i / 4f * 90f - 45f); } Transform s = Instantiate(sound, transform.position, transform.rotation); s.GetComponent <AudioSource>().clip = explosion; s.GetComponent <AudioSource>().Play(); if (transform.localScale.x <= 0.25f) { Destroy(gameObject); Destroy(coll.gameObject); return; } Split(coll); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { GUIScore gc = (GUIScore)master.GetComponent("GUIScore"); gc.Damage(-1); other.gameObject.transform.position = spawnPoint.position; blok.afgeschoten = false; } }
void OnCollisionEnter2D(Collision2D coll) { Kill(); if (coll.gameObject.CompareTag("Bullet")) { if (coll.transform.GetComponent <Bullet>().IsPlayers()) { GUIScore.UpdateScore(5); } Destroy(coll.gameObject); } }