Rework game over logic and game initialization
This commit is contained in:
@@ -10,21 +10,23 @@ public class AttackComponent : IAttackComponent
|
||||
|
||||
public IAutoProp<int> MaximumAttack => _maximumAttack;
|
||||
|
||||
public IAutoProp<int> BonusAttack => _bonusAttack;
|
||||
|
||||
public int TotalAttack => CurrentAttack.Value + BonusAttack.Value;
|
||||
|
||||
private readonly AutoProp<int> _currentAttack;
|
||||
|
||||
private readonly AutoProp<int> _maximumAttack;
|
||||
|
||||
private readonly AutoProp<int> _bonusAttack;
|
||||
private readonly int _initialValue;
|
||||
|
||||
public AttackComponent(int attackValue)
|
||||
{
|
||||
_maximumAttack = new AutoProp<int>(attackValue);
|
||||
_currentAttack = new AutoProp<int>(attackValue);
|
||||
_bonusAttack = new AutoProp<int>(0);
|
||||
_initialValue = attackValue;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_maximumAttack.OnNext(_initialValue);
|
||||
_currentAttack.OnNext(_initialValue);
|
||||
}
|
||||
|
||||
public void Restore(int restoreAmount)
|
||||
@@ -50,14 +52,4 @@ public class AttackComponent : IAttackComponent
|
||||
_maximumAttack.OnNext(raiseAmount);
|
||||
Restore(raiseAmount);
|
||||
}
|
||||
|
||||
public void RaiseBonusAttack(int raiseAmount)
|
||||
{
|
||||
_bonusAttack.OnNext(_bonusAttack.Value + raiseAmount);
|
||||
}
|
||||
|
||||
public void ResetBonusAttack()
|
||||
{
|
||||
_bonusAttack.OnNext(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,19 @@ public class DefenseComponent : IDefenseComponent
|
||||
|
||||
private readonly AutoProp<int> _maximumDefense;
|
||||
|
||||
private readonly int _initialValue;
|
||||
|
||||
public DefenseComponent(int defenseValue)
|
||||
{
|
||||
_maximumDefense = new AutoProp<int>(defenseValue);
|
||||
_currentDefense = new AutoProp<int>(defenseValue);
|
||||
_initialValue = defenseValue;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_maximumDefense.OnNext(_initialValue);
|
||||
_currentDefense.OnNext(_initialValue);
|
||||
}
|
||||
|
||||
public void Restore(int restoreAmount)
|
||||
|
||||
@@ -36,6 +36,13 @@ public class EquipmentComponent : IEquipmentComponent
|
||||
_equippedAccessory = new AutoProp<EquipableItem>(new Accessory());
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_equippedWeapon.OnNext(new Weapon());
|
||||
_equippedArmor.OnNext(new Armor());
|
||||
_equippedAccessory.OnNext(new Accessory());
|
||||
}
|
||||
|
||||
public void Equip(EquipableItem equipable)
|
||||
{
|
||||
if (equipable is Weapon weapon)
|
||||
|
||||
@@ -27,10 +27,19 @@ public class ExperiencePointsComponent : IExperiencePointsComponent
|
||||
var firstLevelExpRequirement = ExpToNextLevelCalculation(1);
|
||||
_expToNextLevel = new AutoProp<int>(firstLevelExpRequirement);
|
||||
_currentExp = new AutoProp<int>(0);
|
||||
_expGainRate = new AutoProp<double>(1.0);
|
||||
_expGainRate = new AutoProp<double>(1);
|
||||
_level = new AutoProp<int>(1);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_currentExp.OnNext(0);
|
||||
_expGainRate.OnNext(1);
|
||||
_level.OnNext(1);
|
||||
var firstLevelExpRequirement = ExpToNextLevelCalculation(1);
|
||||
_expToNextLevel.OnNext(firstLevelExpRequirement);
|
||||
}
|
||||
|
||||
public void Gain(int baseExpGain)
|
||||
{
|
||||
var modifiedExpGain = baseExpGain * _expGainRate.Value;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -8,10 +8,17 @@ public class LuckComponent : ILuckComponent
|
||||
public IAutoProp<int> Luck => _luck;
|
||||
|
||||
private AutoProp<int> _luck;
|
||||
private readonly int _initialValue;
|
||||
|
||||
public LuckComponent(int initialLuck)
|
||||
{
|
||||
_luck = new AutoProp<int>(initialLuck);
|
||||
_initialValue = initialLuck;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_luck.OnNext(_initialValue);
|
||||
}
|
||||
|
||||
public void IncreaseLuck(int value) => _luck.OnNext(_luck.Value + value);
|
||||
|
||||
@@ -14,12 +14,21 @@ public class VTComponent : IVTComponent
|
||||
|
||||
private readonly AutoProp<int> _maximumVT;
|
||||
|
||||
private readonly int _initialValue;
|
||||
|
||||
public bool AtFullVT => CurrentVT.Value == MaximumVT.Value;
|
||||
|
||||
public VTComponent(int initialVT)
|
||||
{
|
||||
_maximumVT = new AutoProp<int>(initialVT);
|
||||
_currentVT = new AutoProp<int>(initialVT);
|
||||
_initialValue = initialVT;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_maximumVT.OnNext(_initialValue);
|
||||
_currentVT.OnNext(_initialValue);
|
||||
}
|
||||
|
||||
public void Restore(int restoreAmount)
|
||||
|
||||
Reference in New Issue
Block a user