Add knockback to secondary attack
This commit is contained in:
@@ -3,6 +3,7 @@ using Chickensoft.Collections;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
@@ -34,6 +35,10 @@ namespace GameJamDungeon
|
||||
|
||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
|
||||
[Node] public AnimationTree AnimationTree { get; set; } = default!;
|
||||
|
||||
[Node] public Timer AttackTimer { get; set; } = default!;
|
||||
@@ -42,6 +47,10 @@ namespace GameJamDungeon
|
||||
|
||||
[Node] public Area3D Hitbox { get; set; } = default!;
|
||||
|
||||
[Node] public Area3D AttackBox { get; set; } = default!;
|
||||
|
||||
[Node] public Area3D SecondaryAttackBox { get; set; } = default!;
|
||||
|
||||
public AutoProp<double> CurrentHP { get; set; }
|
||||
|
||||
public void Setup()
|
||||
@@ -69,6 +78,28 @@ namespace GameJamDungeon
|
||||
AttackTimer.Timeout += AttackTimer_Timeout;
|
||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
HitAnimation.AnimationFinished += HitAnimation_AnimationFinished;
|
||||
AttackBox.AreaEntered += AttackBox_AreaEntered;
|
||||
SecondaryAttackBox.AreaEntered += SecondaryAttackBox_AreaEntered;
|
||||
}
|
||||
|
||||
private void AttackBox_AreaEntered(Area3D area)
|
||||
{
|
||||
var bossHitDamage = DamageCalculator.CalculateEnemyAttackDamage(GameRepo.PlayerData.CurrentDefense.Value + GameRepo.PlayerData.BonusDefense,
|
||||
BossResource,
|
||||
GameRepo.PlayerData.Inventory.EquippedArmor.Value.ArmorStats,
|
||||
false);
|
||||
GameRepo.PlayerData.SetCurrentHP(GameRepo.PlayerData.CurrentHP.Value - Mathf.RoundToInt(bossHitDamage));
|
||||
}
|
||||
|
||||
private void SecondaryAttackBox_AreaEntered(Area3D area)
|
||||
{
|
||||
var bossHitDamage = DamageCalculator.CalculateEnemyAttackDamage(GameRepo.PlayerData.CurrentDefense.Value + GameRepo.PlayerData.BonusDefense,
|
||||
BossResource,
|
||||
GameRepo.PlayerData.Inventory.EquippedArmor.Value.ArmorStats,
|
||||
false);
|
||||
var nerfDamage = bossHitDamage *= 0.25f;
|
||||
GameRepo.PlayerData.SetCurrentHP(GameRepo.PlayerData.CurrentHP.Value - Mathf.RoundToInt(nerfDamage));
|
||||
Game.Player.ApplyCentralImpulseToPlayer(GlobalBasis.Z.Normalized());
|
||||
}
|
||||
|
||||
private void HitAnimation_AnimationFinished(StringName animName)
|
||||
|
||||
Reference in New Issue
Block a user