Esempio n. 1
0
 private void HandlePartsHPChanged(HPInfo info)
 {
     _previousHP = _hp;
     _hp        -= (info.previous - info.current);
     OnHitPointsChanged?.Invoke(new HPInfo {
         max = _maxHP, current = _hp, previous = _previousHP
     });
 }
Esempio n. 2
0
 public void Hit(int damage)
 {
     if (hitPoints >= 0 && damage > 0)
     {
         hitPoints = System.Math.Max(0, hitPoints - damage);
         OnHitPointsChanged?.Invoke(new HPInfo {
             current = hitPoints, max = _startingHP
         });
         if (hitPoints <= 0 && destroyWhenHPzero)
         {
             Destroy(gameObject);
         }
     }
 }
Esempio n. 3
0
 public void Hit(Vector3 position, int damage)
 {
     if (hitPoints >= 0 && damage > 0)
     {
         _previousHP = hitPoints;
         hitPoints   = System.Math.Max(0, hitPoints - damage);
         OnHitPointsChanged?.Invoke(new HPInfo {
             current = hitPoints, max = _startingHP, previous = _previousHP
         });
         if (hitPoints <= 0 && destroyWhenHPzero)
         {
             Destroy(gameObject);
         }
     }
 }
Esempio n. 4
0
 public void Reset()
 {
     _previousHP = hitPoints;
     hitPoints   = _startingHP;
     OnHitPointsChanged?.Invoke(GetHPInfo());
 }