Damage calculation including elemental buff/resistance

This commit is contained in:
2024-09-04 01:24:37 -07:00
parent 9a24ebf058
commit d7a49ba974
23 changed files with 311 additions and 70 deletions

View File

@@ -11,6 +11,8 @@ namespace GameJamDungeon
{
public interface IPlayer : ICharacterBody3D
{
PlayerStatInfo PlayerStatInfo { get; }
PlayerLogic PlayerLogic { get; }
PlayerData PlayerData { get; }
@@ -46,6 +48,9 @@ namespace GameJamDungeon
[Export(PropertyHint.Range, "0, 100, 0.1")]
public float Acceleration { get; set; } = 4f;
[Export]
public PlayerStatInfo PlayerStatInfo { get; set; }
public PlayerLogic.Settings Settings { get; set; } = default!;
public PlayerLogic PlayerLogic { get; set; } = default!;
@@ -62,6 +67,10 @@ namespace GameJamDungeon
private IAutoProp<WeaponInfo> EquippedWeapon { get; set; } = default!;
private AutoProp<double> _currentHP { get; set; } = default!;
private IAutoProp<int> _currentVT { get; set; } = default!;
public void Initialize()
{
AnimationPlayer.AnimationFinished += OnAnimationFinished;
@@ -69,9 +78,7 @@ namespace GameJamDungeon
public void Setup()
{
Settings = new PlayerLogic.Settings(
RotationSpeed,
MoveSpeed);
Settings = new PlayerLogic.Settings(RotationSpeed, MoveSpeed);
PlayerLogic = new PlayerLogic();
PlayerLogic.Set(this as IPlayer);
@@ -82,6 +89,8 @@ namespace GameJamDungeon
GameRepo.SetPlayerGlobalPosition(GlobalPosition);
EquippedWeapon = new AutoProp<WeaponInfo>(WeaponInfo.Default);
_currentHP = new AutoProp<double>(PlayerStatInfo.MaximumHP);
_currentVT = new AutoProp<int>(PlayerStatInfo.MaximumVT);
GameRepo.PlayerGlobalPosition.Sync += OnPlayerPositionUpdated;
}
@@ -108,6 +117,7 @@ namespace GameJamDungeon
PlayerLogic.Start();
EquippedWeapon.Sync += OnEquippedWeaponChanged;
_currentHP.Sync += OnHPChanged;
SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2;
}
@@ -166,6 +176,12 @@ namespace GameJamDungeon
private void OnEquippedWeaponChanged(WeaponInfo info) => Hitbox.Damage = info.Damage;
private void OnHPChanged(double newHP)
{
if (newHP <= 0.0)
PlayerLogic.Input(new PlayerLogic.Input.Killed());
}
private void OnPlayerPositionUpdated(Vector3 globalPosition) => GlobalPosition = globalPosition;
}
}