Refactor more stuff (Audio mostly)
This commit is contained in:
60
Zennysoft.Game.Ma.Implementation/Player/IPlayer.cs
Normal file
60
Zennysoft.Game.Ma.Implementation/Player/IPlayer.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Chickensoft.Collections;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
public interface IPlayer : IKillable
|
||||
{
|
||||
public void Attack();
|
||||
|
||||
public void PlayerPause();
|
||||
|
||||
public void TakeDamage(double damage, ElementType elementType = ElementType.None, bool isCriticalHit = false);
|
||||
|
||||
public void Knockback(float impulse);
|
||||
|
||||
public void GainExp(double expGained);
|
||||
|
||||
public void LevelUp();
|
||||
|
||||
public void Move(float delta);
|
||||
|
||||
public void TeleportPlayer(Transform3D newTransform);
|
||||
|
||||
public void HealHP(int amount);
|
||||
|
||||
public void RaiseHP(int amount);
|
||||
|
||||
public void HealVT(int amount);
|
||||
|
||||
public void RaiseVT(int amount);
|
||||
|
||||
public void ModifyBonusAttack(int amount);
|
||||
|
||||
public void ModifyBonusDefense(int amount);
|
||||
|
||||
public void ModifyMaximumHP(int amount);
|
||||
|
||||
public void ModifyMaximumVT(int amount);
|
||||
|
||||
public void ModifyBonusLuck(double amount);
|
||||
|
||||
public IInventory Inventory { get; }
|
||||
|
||||
public PlayerStatController Stats { get; }
|
||||
|
||||
public Vector3 CurrentPosition { get; }
|
||||
|
||||
public Basis CurrentBasis { get; }
|
||||
|
||||
public IAutoProp<EquipableItem> EquippedWeapon { get; }
|
||||
|
||||
public IAutoProp<EquipableItem> EquippedArmor { get; }
|
||||
|
||||
public IAutoProp<EquipableItem> EquippedAccessory { get; }
|
||||
|
||||
public void Equip(EquipableItem equipable);
|
||||
|
||||
public void Unequip(EquipableItem equipable);
|
||||
}
|
||||
118
Zennysoft.Game.Ma.Implementation/Player/PlayerStatController.cs
Normal file
118
Zennysoft.Game.Ma.Implementation/Player/PlayerStatController.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
namespace Zennysoft.Ma.Adapter;
|
||||
|
||||
using Chickensoft.Collections;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Ma;
|
||||
|
||||
public class PlayerStatController
|
||||
{
|
||||
public void Init(PlayerStats playerStats)
|
||||
{
|
||||
_currentHP.OnNext(playerStats.CurrentHP);
|
||||
_maximumHP.OnNext(playerStats.MaximumHP);
|
||||
_currentVT.OnNext(playerStats.CurrentVT);
|
||||
_maximumVT.OnNext(playerStats.MaximumVT);
|
||||
_currentExp.OnNext(playerStats.CurrentExp);
|
||||
_currentLevel.OnNext(playerStats.CurrentLevel);
|
||||
_currentAttack.OnNext(playerStats.CurrentAttack);
|
||||
_bonusAttack.OnNext(playerStats.BonusAttack);
|
||||
_maxAttack.OnNext(playerStats.MaxAttack);
|
||||
_currentDefense.OnNext(playerStats.CurrentDefense);
|
||||
_bonusDefense.OnNext(playerStats.BonusDefense);
|
||||
_maxDefense.OnNext(playerStats.MaxDefense);
|
||||
_expToNextLevel.OnNext(playerStats.ExpToNextLevel);
|
||||
_luck.OnNext(playerStats.Luck);
|
||||
}
|
||||
|
||||
public IAutoProp<int> CurrentHP => _currentHP;
|
||||
public IAutoProp<int> MaximumHP => _maximumHP;
|
||||
public IAutoProp<int> CurrentVT => _currentVT;
|
||||
public IAutoProp<int> MaximumVT => _maximumVT;
|
||||
public IAutoProp<int> CurrentAttack => _currentAttack;
|
||||
public IAutoProp<int> MaxAttack => _maxAttack;
|
||||
public IAutoProp<int> BonusAttack => _bonusAttack;
|
||||
public IAutoProp<int> CurrentDefense => _currentDefense;
|
||||
public IAutoProp<int> MaxDefense => _maxDefense;
|
||||
public IAutoProp<int> BonusDefense => _bonusDefense;
|
||||
public IAutoProp<double> CurrentExp => _currentExp;
|
||||
public IAutoProp<int> ExpToNextLevel => _expToNextLevel;
|
||||
public IAutoProp<int> CurrentLevel => _currentLevel;
|
||||
public IAutoProp<double> Luck => _luck;
|
||||
|
||||
public void SetCurrentHP(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumHP.Value);
|
||||
_currentHP.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumHP(int newValue)
|
||||
{
|
||||
_maximumHP.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentVT(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumVT.Value);
|
||||
_currentVT.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumVT(int newValue)
|
||||
{
|
||||
_maximumVT.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentExp(double newValue)
|
||||
{
|
||||
_currentExp.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentLevel(int newValue)
|
||||
{
|
||||
_currentLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentAttack(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxAttack.Value);
|
||||
_currentAttack.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusAttack(int newValue)
|
||||
{
|
||||
_bonusAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxAttack(int newValue)
|
||||
{
|
||||
_maxAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentDefense(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxDefense.Value);
|
||||
_currentDefense.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusDefense(int newValue)
|
||||
{
|
||||
_bonusDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxDefense(int newValue)
|
||||
{
|
||||
_maxDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetExpToNextLevel(int newValue)
|
||||
{
|
||||
_expToNextLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetLuck(double newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, 1.0);
|
||||
_luck.OnNext(clampedValue);
|
||||
}
|
||||
|
||||
private readonly AutoProp<int> _currentHP = new(-1);
|
||||
private readonly AutoProp<int> _maximumHP = new(-1);
|
||||
private readonly AutoProp<int> _currentVT = new(-1);
|
||||
private readonly AutoProp<int> _maximumVT = new(-1);
|
||||
private readonly AutoProp<double> _currentExp = new(-1);
|
||||
private readonly AutoProp<int> _currentLevel = new(-1);
|
||||
private readonly AutoProp<int> _currentAttack = new(-1);
|
||||
private readonly AutoProp<int> _bonusAttack = new(-1);
|
||||
private readonly AutoProp<int> _maxAttack = new(-1);
|
||||
private readonly AutoProp<int> _currentDefense = new(-1);
|
||||
private readonly AutoProp<int> _bonusDefense = new(-1);
|
||||
private readonly AutoProp<int> _maxDefense = new(-1);
|
||||
private readonly AutoProp<int> _expToNextLevel = new(-1);
|
||||
private readonly AutoProp<double> _luck = new(-1);
|
||||
}
|
||||
@@ -37,116 +37,3 @@ public partial record PlayerStats
|
||||
[Save("luck")]
|
||||
public double Luck { get; init; }
|
||||
}
|
||||
|
||||
public class PlayerStatController
|
||||
{
|
||||
public void Init(PlayerStats playerStats)
|
||||
{
|
||||
_currentHP.OnNext(playerStats.CurrentHP);
|
||||
_maximumHP.OnNext(playerStats.MaximumHP);
|
||||
_currentVT.OnNext(playerStats.CurrentVT);
|
||||
_maximumVT.OnNext(playerStats.MaximumVT);
|
||||
_currentExp.OnNext(playerStats.CurrentExp);
|
||||
_currentLevel.OnNext(playerStats.CurrentLevel);
|
||||
_currentAttack.OnNext(playerStats.CurrentAttack);
|
||||
_bonusAttack.OnNext(playerStats.BonusAttack);
|
||||
_maxAttack.OnNext(playerStats.MaxAttack);
|
||||
_currentDefense.OnNext(playerStats.CurrentDefense);
|
||||
_bonusDefense.OnNext(playerStats.BonusDefense);
|
||||
_maxDefense.OnNext(playerStats.MaxDefense);
|
||||
_expToNextLevel.OnNext(playerStats.ExpToNextLevel);
|
||||
_luck.OnNext(playerStats.Luck);
|
||||
}
|
||||
|
||||
public IAutoProp<int> CurrentHP => _currentHP;
|
||||
public IAutoProp<int> MaximumHP => _maximumHP;
|
||||
public IAutoProp<int> CurrentVT => _currentVT;
|
||||
public IAutoProp<int> MaximumVT => _maximumVT;
|
||||
public IAutoProp<int> CurrentAttack => _currentAttack;
|
||||
public IAutoProp<int> MaxAttack => _maxAttack;
|
||||
public IAutoProp<int> BonusAttack => _bonusAttack;
|
||||
public IAutoProp<int> CurrentDefense => _currentDefense;
|
||||
public IAutoProp<int> MaxDefense => _maxDefense;
|
||||
public IAutoProp<int> BonusDefense => _bonusDefense;
|
||||
public IAutoProp<double> CurrentExp => _currentExp;
|
||||
public IAutoProp<int> ExpToNextLevel => _expToNextLevel;
|
||||
public IAutoProp<int> CurrentLevel => _currentLevel;
|
||||
public IAutoProp<double> Luck => _luck;
|
||||
|
||||
public void SetCurrentHP(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumHP.Value);
|
||||
_currentHP.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumHP(int newValue)
|
||||
{
|
||||
_maximumHP.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentVT(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaximumVT.Value);
|
||||
_currentVT.OnNext(clampedValue);
|
||||
}
|
||||
public void SetMaximumVT(int newValue)
|
||||
{
|
||||
_maximumVT.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentExp(double newValue)
|
||||
{
|
||||
_currentExp.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentLevel(int newValue)
|
||||
{
|
||||
_currentLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentAttack(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxAttack.Value);
|
||||
_currentAttack.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusAttack(int newValue)
|
||||
{
|
||||
_bonusAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxAttack(int newValue)
|
||||
{
|
||||
_maxAttack.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentDefense(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, MaxDefense.Value);
|
||||
_currentDefense.OnNext(clampedValue);
|
||||
}
|
||||
public void SetBonusDefense(int newValue)
|
||||
{
|
||||
_bonusDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetMaxDefense(int newValue)
|
||||
{
|
||||
_maxDefense.OnNext(newValue);
|
||||
}
|
||||
public void SetExpToNextLevel(int newValue)
|
||||
{
|
||||
_expToNextLevel.OnNext(newValue);
|
||||
}
|
||||
public void SetLuck(double newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, 1.0);
|
||||
_luck.OnNext(clampedValue);
|
||||
}
|
||||
|
||||
private readonly AutoProp<int> _currentHP = new(-1);
|
||||
private readonly AutoProp<int> _maximumHP = new(-1);
|
||||
private readonly AutoProp<int> _currentVT = new(-1);
|
||||
private readonly AutoProp<int> _maximumVT = new(-1);
|
||||
private readonly AutoProp<double> _currentExp = new(-1);
|
||||
private readonly AutoProp<int> _currentLevel = new(-1);
|
||||
private readonly AutoProp<int> _currentAttack = new(-1);
|
||||
private readonly AutoProp<int> _bonusAttack = new(-1);
|
||||
private readonly AutoProp<int> _maxAttack = new(-1);
|
||||
private readonly AutoProp<int> _currentDefense = new(-1);
|
||||
private readonly AutoProp<int> _bonusDefense = new(-1);
|
||||
private readonly AutoProp<int> _maxDefense = new(-1);
|
||||
private readonly AutoProp<int> _expToNextLevel = new(-1);
|
||||
private readonly AutoProp<double> _luck = new(-1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user