void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "Ability") { return; } switch (damageType) { case 1: audioManager.fireHitAudio(); break; case 2: audioManager.poisonHitAudio(); break; case 3: audioManager.iceHitAudio(); break; case 4: audioManager.voidHitAudio(); break; } if (collision.gameObject.tag == "Enemy") { collision.gameObject.GetComponent <EnemyHealth>().TakeDamage(Random.Range(damageLowerBound, damageUpperBound), travelingLeft, true, damageType); Instantiate(explosionPrefab, new Vector3(collision.contacts[0].point.x, collision.contacts[0].point.y, 0), Quaternion.identity); enemyState = collision.gameObject.GetComponent <EnemyState>(); if (enemyState.isEffected == true) { Destroy(gameObject); } else { GameObject specialEffect = Instantiate(effect) as GameObject; Effect effectInfo = specialEffect.GetComponentInChildren <Effect>(); effectInfo.enemy = collision.gameObject.GetComponent <EnemyHealth>(); effectInfo.enemyState = enemyState; effectInfo.stats = stats; effectInfo.travelingLeft = travelingLeft; Destroy(gameObject); } } else if (collision.gameObject.tag != "FX" && collision.gameObject.tag != "Enemy") { Instantiate(explosionPrefab, new Vector3(collision.contacts[0].point.x, collision.contacts[0].point.y, 0), Quaternion.identity); Destroy(gameObject); } }