void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Platform") { jumping = false; anim.SetBool("Jumping", false); } else if (other.tag == "Goal") { onGoal = true; } else if (other.tag == "Collectable") { Manager <SoundManager> .Instance.PlaySoundEffect(SoundManager.SoundEffect.Collect); Destroy(other.gameObject); OnCaughtObject.Invoke(); } else if (other.tag == "Enemy") { if (OnPlayerKilled != null) { Manager <SoundManager> .Instance.PlaySoundEffect(SoundManager.SoundEffect.PlayerDie); OnPlayerKilled.Invoke(); Destroy(this.gameObject); } } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.GetComponent <Obstacle>() != null && _navMesh.enabled == true) { KillPlayer(); PushPlayer(collision); OnPlayerKilled.Invoke(); } }
public static void NotifyPlayerKilled() { if (HighscoreEnemySoulsCollectedCount < EnemySoulsCollectedCount) { HighscoreEnemySoulsCollectedCount = EnemySoulsCollectedCount; } IsPlayerDead = true; OnPlayerKilled?.Invoke(); }
public void Kill() { if (m_IsDead) { return; } m_IsDead = true; m_Movement = 0f; m_Jump = false; OnPlayerKilled?.Invoke(this); }
/// <summary> /// Processes resulting logic from the player being killed /// </summary> public void PlayerKilled() { // Invoke the player killed action if it has methods subscribed to it OnPlayerKilled?.Invoke(); // Move all platforms off the screen and disable both the platform manager and player to save resources PlatformManager.current.gameObject.SetActive(false); PlatformManager.current.DisablePlatforms(); player.SetActive(false); // Update and enable the gameover screen gameoverCoinsCollectedLabel.text = CoinsCollected.ToString(); uiGameover.SetActive(true); SwitchGameMusic(musicClipGameover); }
public void TakeDamage(int baseDamage) { _hurtThisBeat = true; int damage = baseDamage; if (IsBlocking()) { damage -= _blockStrength; if (damage <= 0) { damage = 0; _hurtThisBeat = false; } } _currentHealth -= damage; OnPlayerDamaged?.Invoke(damage); if (_currentHealth <= 0) { _currentHealth = 0; GameMaster.Find <GameMaster>().GameOver(); OnPlayerKilled?.Invoke(); } }
public static void RaisePlayerKilled(IEnemy enemy) => OnPlayerKilled?.Invoke(enemy);