private void HandlePartsHPChanged(HPInfo info) { _previousHP = _hp; _hp -= (info.previous - info.current); OnHitPointsChanged?.Invoke(new HPInfo { max = _maxHP, current = _hp, previous = _previousHP }); }
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); } } }
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); } } }
public void Reset() { _previousHP = hitPoints; hitPoints = _startingHP; OnHitPointsChanged?.Invoke(GetHPInfo()); }