コード例 #1
0
    public static void TriggerPlayerDeath()
    {
        PlayerLives.RemoveLife();

        if (OnPlayerDeath != null)
        {
            OnPlayerDeath();
        }
    }
コード例 #2
0
    /// <summary>
    /// Detects if we are in a trap or not
    /// </summary>
    /// <param name="other">The colliding object</param>
    void OnCollisionEnter2D(Collision2D other)
    {
        // If we are colliding with a trap object...
        if (other.gameObject.CompareTag("BlackHole"))
        {
            // We want to splat the player on the ground and respawn them
            StartCoroutine(Die());

            // Pop a life out of the animtaion
            playerLives_UI.RemoveLife();
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        healthText.text = currentHealth.ToString() + "  %";

        if (lives.lifeCounter > 0 && currentHealth <= 0) // if the amount of lives is more than 0 and current health has hit 0 then ...
        {
            pc.transform.position = pc.respawnPoint;     // respawning the player back to the last checkpoint
            currentHealth         = maxHealth;           // updating the current health + text
            healthBar.value       = maxHealth;           // updating the slider's health value
            lives.RemoveLife();
        }


        //if (currentHealth <= 0) // if the current health is less or equal to 0
        //{
        //   // if(PlayerLives.lifeCounter > 0)
        //   // {

        //    // }
        //    // else if (PlayerLives.lifeCounter == 0)


        //        anim.SetBool("isDead", true); // plays the dead animation
        //        deadUI.gameObject.SetActive(true); // show the dead menu
        //        PlayerAudio.PlayOneShot(playerDied); // play the audio clip for player dying
        //        GetComponent<PlayerController>().enabled = false; // stops the player movement
        //        //GameObject<rangerController>().enabled = false; // stop the ranger from staying active when player is dead
        //        GameObject.Find("Archer Enemy").GetComponent<rangerController>().enabled = false; // attempt to stop the ranger from staying active
        //        GameObject.Find("Archer Enemy 2").GetComponent<rangerController>().enabled = false;
        //        GameObject.Find("Archer Enemy 3").GetComponent<rangerController>().enabled = false;
        //        GameObject.Find("Archer Enemy 4").GetComponent<rangerController>().enabled = false;



        //}
    }