void OnTriggerEnter2D(Collider2D collider) { FireDamager fire = collider.gameObject.GetComponent <FireDamager> (); if (fire != null) { //explode immediately StartCoroutine(ExplodeAfter(0)); } IceDamager ice = collider.gameObject.GetComponent <IceDamager> (); if (ice != null) { GameObject iceBlock = Instantiate(iceBlockPrefab); iceBlock.transform.position = transform.position; iceBlock.GetComponent <BlockIce> ().bombTimer = timer - (Time.time - birthTime); iceBlock.GetComponent <BlockIce> ().respawner = respawner; Destroy(gameObject); } WindDamager wind = collider.gameObject.GetComponent <WindDamager> (); if (wind != null) { rigidBody.AddForce(collider.gameObject.GetComponent <Rigidbody2D> ().velocity / 2, ForceMode2D.Impulse); } }
void OnTriggerEnter2D(Collider2D collider) { //TODO: use durability class? FireDamager fire = collider.gameObject.GetComponent <FireDamager> (); if (fire != null) { if (bombTimer >= 0) { GameObject bomb = Instantiate(bombPrefab); bomb.transform.position = transform.position; bomb.GetComponent <Bomb> ().timer = bombTimer; bomb.GetComponent <Bomb> ().respawner = respawner; } if (respawner != null) { respawner.enabled = true; } Destroy(gameObject); } WindDamager wind = collider.gameObject.GetComponent <WindDamager> (); if (wind != null) { rigidBody.AddForce(collider.gameObject.GetComponent <Rigidbody2D> ().velocity * 20, ForceMode2D.Impulse); } }