private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Projectile")) { anim.SetTrigger("TookDmg"); playerLives.TakeDamage(1); FindObjectOfType <AudioManager>().Play("Oof"); Destroy(collision.gameObject); } }
public PlayerLifeManager(EverLite game) { this.game = game; lives = new PlayerLives(10); player = Player.Instance(); sound = SoundManager.Instance; volume = VolumeManager.Instance; display = new PlayerLivesDisplay(lives); player.OnCollide += (sender, e) => { lives.TakeDamage(); }; lives.OnDeath += (sender, e) => { this.sound.Losing.Play(volume: volume.SoundLevel, pitch: 0.0f, pan: 0.0f); this.game.SceneManager.ChangeMusic(this.sound.Megalovania); this.game.SceneManager.SwitchScene(this.game.SceneManager.GameOver); }; }