Ejemplo n.º 1
0
    public void Setup() //performs the same actions as MonoBehaviour's Start() function
    {
        playerHealthManager = FindObjectOfType <PlayerHealthManager>();
        hurtEnemy           = FindObjectOfType <HurtEnemy>();

        maxHealth = playerHealthManager.GetMaxHealth();
    }
Ejemplo n.º 2
0
 void Update()
 {
     if (characterSelector.GetCharacterActive())                                                            //checks if the character is active
     {
         playerHealthManager = characterSelector.GetCharacterObject().GetComponent <PlayerHealthManager>(); //get the instantiated (or active) player's PlayerHealthManager script
         maxHealth           = playerHealthManager.GetMaxHealth();                                          //sets a variable to teh value of the character's max health
         currentHealth       = playerHealthManager.GetCurrentHealth();                                      //sets a variable to teh value of the character's max health
         healthBar.maxValue  = maxHealth;
         healthBar.value     = currentHealth;
         //healthText.text = "HP: " + ((currentHealth / maxHealth) * 100).ToString() + "%"; //sets the health text to the player's current health as a percentage
         healthText.text = "HP: " + (currentHealth.ToString() + " / " + maxHealth.ToString()); //sets the health text to the player's current health over max health //changed to avoid decimal percentages (since the Warrior and Archer's health isn't 100)
     }
 }
 void Update()
 {
     characterSelector = FindObjectOfType <CharacterSelector>();
     audioManager      = FindObjectOfType <AudioManager>();
     try                                                                                                        //hastily done because a non-gamebreaking error was being thrown once the player is killed
     {
         if (characterSelector.GetCharacterActive())                                                            //checks if the character is active
         {
             playerHealthManager = characterSelector.GetCharacterObject().GetComponent <PlayerHealthManager>(); //gets the current player instance's health manager
             maxHealth           = playerHealthManager.GetMaxHealth();
             currentHealth       = playerHealthManager.GetCurrentHealth();
         }
     }
     catch
     {
         //pass
     }
 }