Пример #1
0
    private void CreateHealthbar()
    {
        InstantiatedHealthBar = Instantiate(healthbarPreab, barPosition.position, Quaternion.identity);     //Instantiate healthbar
        InstantiatedHealthBar.transform.SetParent(transform);                                               //Parent this bar to the enemy instance

        scrEnemyHealthContainer container = InstantiatedHealthBar.GetComponent <scrEnemyHealthContainer>(); //Assigns the healthbar image sprite of the

        //scrEnemyHealthContainer script to this variable named container... I think.

        healthBar = container.MyFillAmount; //Assigns it to the health bar var
    }
Пример #2
0
 public void DealDamage(float damageRecieved)
 {
     CurrentHealth -= damageRecieved; //Take damage
     if (CurrentHealth <= 0)
     {
         InstantiatedHealthBar.SetActive(false); //Hide the healthbar when the defender dies
         CurrentHealth = 0;
         if (_creep != null)
         {
             creepDies(); //Kill the creep
         }
         if (_defender != null)
         {
             defenderDies(); //Kill the defender (if this is a defender)
         }
     }
     else //Remove this entire else statement later, when the animation is updated to trigger whilst enemy is in combat
     {
         OnEnemyBlocked?.Invoke(_creep);
     }
 }
Пример #3
0
 public void ResetHealth()
 {
     InstantiatedHealthBar.SetActive(true);      //Turn the healthbar back on as the defender respawns
     CurrentHealth        = stats.initialHealth; //Reset the health
     healthBar.fillAmount = 1f;                  //Reset the health bar
 }