Basic enemy attack pattern

This commit is contained in:
2024-09-04 23:05:49 -07:00
parent 6fc9568137
commit 54d9dcf9fa
14 changed files with 282 additions and 54 deletions

View File

@@ -73,6 +73,8 @@ namespace GameJamDungeon
[Node] public ProgressBar VTBar { get; set; } = default!;
[Node] public IArea3D CollisionDetector { get; set; } = default!;
private IAutoProp<WeaponInfo> EquippedWeapon { get; set; } = default!;
private AutoProp<double> _currentHP { get; set; } = default!;
@@ -112,6 +114,7 @@ namespace GameJamDungeon
VTBar.Value = _currentVT.Value;
HealthTimer.Timeout += OnHealthTimerTimeout;
CollisionDetector.AreaEntered += OnEnemyHitBoxEntered;
}
public void OnResolved()
@@ -144,6 +147,20 @@ namespace GameJamDungeon
SetPhysicsProcess(true);
}
private void OnEnemyHitBoxEntered(Area3D area)
{
if (area is IHitbox hitBox)
{
if (_currentHP.Value > 0)
{
var enemy = hitBox.GetParent<IEnemy>();
var damage = DamageCalculator.CalculateEnemyDamage(hitBox.Damage, PlayerStatInfo, enemy.EnemyStatInfo);
_currentHP.OnNext(_currentHP.Value - damage);
GD.Print($"Player hit for {damage} damage.");
}
}
}
public void OnPhysicsProcess(double delta)
{
PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta));