Rework game over logic and game initialization
This commit is contained in:
@@ -19,10 +19,19 @@ public class HealthComponent : IHealthComponent
|
||||
|
||||
public bool AtFullHealth => CurrentHP.Value == MaximumHP.Value;
|
||||
|
||||
private readonly int _initialValue;
|
||||
|
||||
public HealthComponent(int initialHP)
|
||||
{
|
||||
_maximumHP = new AutoProp<int>(initialHP);
|
||||
_currentHP = new AutoProp<int>(initialHP);
|
||||
_initialValue = initialHP;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_maximumHP.OnNext(_initialValue);
|
||||
_currentHP.OnNext(_initialValue);
|
||||
}
|
||||
|
||||
public void Heal(int healAmount)
|
||||
@@ -42,12 +51,17 @@ public class HealthComponent : IHealthComponent
|
||||
DamageTaken?.Invoke();
|
||||
}
|
||||
|
||||
public void SetHealth(int health)
|
||||
public void SetCurrentHealth(int health)
|
||||
{
|
||||
var cappedAmount = Math.Min(health, _maximumHP.Value);
|
||||
_currentHP.OnNext(cappedAmount);
|
||||
}
|
||||
|
||||
public void SetMaximumHealth(int health)
|
||||
{
|
||||
_maximumHP.OnNext(health);
|
||||
}
|
||||
|
||||
public void RaiseMaximumHP(int raiseAmount)
|
||||
{
|
||||
_maximumHP.OnNext(raiseAmount);
|
||||
|
||||
Reference in New Issue
Block a user