コード例 #1
0
    /*
     *
     * Public functions
     *
     */

    public void TakeDamage(int damage)
    {
        playerHealth.AdjustCurrentHealth(-damage);
        if (playerHealth.curHealth <= 20 && !burnParticles.isPlaying)
        {
            burnParticles.Play();
        }

        if (playerHealth.curHealth == 0 && !GameManagerBoss.isGamePaused())
        {
            //GameOver
            animator.SetBool("isMoving", false);
            animator.SetBool("isKilled", true);
            explodeParticles.Play();
            gameManager.FinishGame(SecondPlayer);
            soundManager.PlayDeath();
        }
        else
        {
            soundManager.PlayHurt();
        }
    }
コード例 #2
0
    /*
     *
     * Public functions
     *
     */

    public void TakeDamage(int damage)
    {
        int current = playerHealth.curHealth;

        Debug.Log(current);

        playerHealth.AdjustCurrentHealth(-damage);

        current -= damage;


        if (current >= 40 && burnParticles.isPlaying)
        {
            // playerHealth.curHealth = current;
            burnParticles.Stop();
        }

        if (current <= 40 && !burnParticles.isPlaying)
        {
            //playerHealth.curHealth = current;
            burnParticles.Play();
        }

        if (playerHealth.curHealth == 0 && !GameManagerBoss.isGamePaused())
        {
            //GameOver
            animator.SetBool("isMoving", false);
            animator.SetBool("isKilled", true);
            explodeParticles.Play();
            gameManager.FinishGame(SecondPlayer);
            soundManager.PlayDeath();
        }
        else
        {
            soundManager.PlayHurt();
        }
    }