コード例 #1
0
    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);
            }
        }
    }
コード例 #2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.GetComponent <Obstacle>() != null && _navMesh.enabled == true)
     {
         KillPlayer();
         PushPlayer(collision);
         OnPlayerKilled.Invoke();
     }
 }
コード例 #3
0
        public static void NotifyPlayerKilled()
        {
            if (HighscoreEnemySoulsCollectedCount < EnemySoulsCollectedCount)
            {
                HighscoreEnemySoulsCollectedCount = EnemySoulsCollectedCount;
            }

            IsPlayerDead = true;
            OnPlayerKilled?.Invoke();
        }
コード例 #4
0
    public void Kill()
    {
        if (m_IsDead)
        {
            return;
        }

        m_IsDead = true;

        m_Movement = 0f;
        m_Jump     = false;

        OnPlayerKilled?.Invoke(this);
    }
コード例 #5
0
    /// <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);
    }
コード例 #6
0
ファイル: PlayerScript.cs プロジェクト: Blaster391/Healthbar
    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();
        }
    }
コード例 #7
0
ファイル: GameEvents.cs プロジェクト: zimpzon/GFun
 public static void RaisePlayerKilled(IEnemy enemy) => OnPlayerKilled?.Invoke(enemy);