Beispiel #1
0
 public void UpdateHealthBar(float damage)
 {
     if (m_HealthBar)
     {
         m_HealthBar.fillAmount = m_StatusComponent.GetCurrentHealth() / m_StatusComponent.GetMaxHealth(); // get pct of fill
     }
     if (m_HealthText)
     {
         m_HealthText.text = ((int)m_StatusComponent.GetCurrentHealth()).ToString() + " / " + ((int)m_StatusComponent.GetMaxHealth()).ToString(); // update txt
     }
 }
 void UpdateHealth(float f, GameplayStatics.DamageType type)
 {
     if (m_HealthSlider && m_StatusComponent)
     {
         m_HealthSlider.fillAmount = m_StatusComponent.GetCurrentHealth() / m_StatusComponent.GetMaxHealth();
     }
 }
Beispiel #3
0
    public override void PickupItem(Collider2D target, GameObject src)
    {
        GameObject obj = target.gameObject;

        if (obj.CompareTag("Player")) // Check if it was the player that tried to pic the item
        {
            //get player status component
            StatusComponent comp = obj.GetComponent <StatusComponent>();
            comp.Heal(m_HealAmount); // heal the player
            Debug.Log("Current Health = " + comp.GetCurrentHealth());
            if (m_OnPickup != null)
            {
                m_OnPickup.Invoke(target, obj); // call auxiliary m_OnPickup function if there's one
            }
            DestroyItem();                      // destroy the potion, since it was used
        }
    }
Beispiel #4
0
 public float GetCurrentHealth()
 {
     return(_statusComponent.GetCurrentHealth());
 }