private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Enemy") && !godMode) { if (IsDead) { AudioManager.Play("DeadHit"); } else { health--; UpdateColour(); if (health > 0) { AudioManager.Play(HitAudio); PickupManager.EnableHealthPickups(); } else if (health == 0) { AudioManager.Play(DeadAudio); PickupManager.DisableHealthPickups(); IsDead = true; Director.PlayerDied(); } } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Pickup")) { switch (collision.gameObject.GetComponent <Pickup>().PickupType) { case "Machine Gun": Gun.ChangeGun(1); break; case "Double Barrel": Gun.ChangeGun(2); break; case "Shotgun": Gun.ChangeGun(3); break; case "Health": if (health != MaxHealth) { health++; if (!godMode) { UpdateColour(); } if (health == MaxHealth) { PickupManager.DisableHealthPickups(); } } break; default: break; } Destroy(collision.gameObject); } }