parent
17a807365b
commit
0d152e62eb
3 changed files with 21 additions and 2 deletions
|
|
@ -79,6 +79,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
[Node] private Timer DashCooldownTimer { get; set; } = null!;
|
||||
[Node] private Timer GlobalDamageImmunityTimer { get; set; } = null!;
|
||||
[Node] private Timer PlatformIgnoreTimer { get; set; } = null!;
|
||||
[Node] private Timer ParryTimer { get; set; } = null!;
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
|
|
@ -284,7 +285,9 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
|
||||
public void OnProcess(double delta)
|
||||
{
|
||||
GetNode<Node2D>("%Body").Scale = new(IsFacingRight ? 1 : -1, 1);
|
||||
var body = GetNode<Node2D>("%Body");
|
||||
body.Scale = new(IsFacingRight ? 1 : -1, 1);
|
||||
body.Modulate = ParryTimer.IsStopped() ? Colors.White : new(2f, 2f, 2f);
|
||||
}
|
||||
|
||||
public readonly struct BufferedInput
|
||||
|
|
@ -300,6 +303,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
Jump,
|
||||
Attack,
|
||||
Dash,
|
||||
Parry,
|
||||
}
|
||||
|
||||
private void HandleBufferedInputs()
|
||||
|
|
@ -369,6 +373,10 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
Dash();
|
||||
return true;
|
||||
|
||||
case { Action: Action.Parry, IsPressed: true }:
|
||||
Parry();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -430,6 +438,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
DashHitbox.StartAttack();
|
||||
}
|
||||
|
||||
private void Parry() => ParryTimer.Start();
|
||||
|
||||
private static Vector2 To8DirectionVector(Vector2 input)
|
||||
{
|
||||
if (input.IsZeroApprox()) return Vector2.Zero;
|
||||
|
|
@ -454,6 +464,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
|
||||
public void GetAttacked(in Attack attack)
|
||||
{
|
||||
if (!ParryTimer.IsStopped()) return;
|
||||
TakeDamage(attack.Damage);
|
||||
}
|
||||
|
||||
|
|
@ -477,7 +488,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
|
||||
public void OnAttacked(Hurtbox hurtbox, in Attack attack)
|
||||
{
|
||||
TakeDamage(attack.Damage);
|
||||
GetAttacked(attack);
|
||||
}
|
||||
|
||||
public void OnHurtboxAdded(Hurtbox hurtbox)
|
||||
|
|
@ -501,6 +512,7 @@ public static class GameActionExtensions
|
|||
(ActionName.Attack, Player.Action.Attack),
|
||||
(ActionName.Dash, Player.Action.Dash),
|
||||
(ActionName.Jump, Player.Action.Jump),
|
||||
(ActionName.Parry, Player.Action.Parry),
|
||||
];
|
||||
|
||||
extension(Player.Action)
|
||||
|
|
|
|||
|
|
@ -477,3 +477,9 @@ one_shot = true
|
|||
unique_name_in_owner = true
|
||||
process_callback = 0
|
||||
one_shot = true
|
||||
|
||||
[node name="ParryTimer" type="Timer" parent="." unique_id=279087565]
|
||||
unique_name_in_owner = true
|
||||
process_callback = 0
|
||||
wait_time = 0.2
|
||||
one_shot = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue