Ejemplo n.º 1
0
    private void EntityStats_OnHealthReplenish(object sender, System.EventArgs e)
    {
        for (int i = 0; i < healthBarList.Count; i++)
        {
            holdingData             = healthBarList[i];
            holdingData.sliderTimer = holdingData.sliderBarDeplenishTimer;
            healthBarList[i]        = holdingData;

            SetBarPercentage(healthBarList[i], EntityStats.Instance.GetNormalisedHealthOfEntity(healthBarList[i].name));
        }
    }
Ejemplo n.º 2
0
 private void EntityStats_OnDamage(object sender, System.EventArgs e)
 {
     for (int i = 0; i < healthBarList.Count; i++)
     {
         // If the health bar's current value is not equal to the new value, then the bar should update.
         if (healthBarList[i].foregroundBarImage.fillAmount != EntityStats.Instance.GetNormalisedHealthOfEntity(healthBarList[i].name))
         {
             holdingData             = healthBarList[i];
             holdingData.sliderTimer = holdingData.sliderBarDeplenishTimer;
             healthBarList[i]        = holdingData;
             SetBarPercentage(healthBarList[i], EntityStats.Instance.GetNormalisedHealthOfEntity(healthBarList[i].name));
         }
     }
 }
Ejemplo n.º 3
0
    private void Update()
    {
        for (int i = 0; i < healthBarList.Count; i++)
        {
            holdingData              = healthBarList[i];
            holdingData.sliderTimer -= Time.deltaTime;
            healthBarList[i]         = holdingData;

            if (healthBarList[i].sliderTimer < 0f)
            {
                if (healthBarList[i].foregroundBarImage.fillAmount < healthBarList[i].backgroundBarImage.fillAmount)
                {
                    healthBarList[i].backgroundBarImage.fillAmount -= healthBarList[i].sliderBarDeplenishSpeed * Time.deltaTime;
                }
            }
            else if (healthBarList[i].foregroundBarImage.fillAmount > healthBarList[i].backgroundBarImage.fillAmount)
            {
                healthBarList[i].backgroundBarImage.fillAmount = healthBarList[i].foregroundBarImage.fillAmount;
            }
            ;
        }
    }
Ejemplo n.º 4
0
 private void SetBarPercentage(healthBarData _healthBar, float _healthNormalized)
 {
     _healthBar.foregroundBarImage.fillAmount = _healthNormalized;
 }