8 directional attacks and dashes

This commit is contained in:
Lilith Schier 2026-09-05 15:55:46 +02:00
parent bed5e49547
commit 5b593c9bcc
4 changed files with 50 additions and 5 deletions

View file

@ -85,11 +85,13 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
[Node] private AnimationTree AnimationTree { get; set; } = null!;
[Node] private Area2D SubmersedSensor { get; set; } = null!;
[Node] private Hitbox DashHitbox { get; set; } = null!;
[Node] private Node2D HandAttachment { get; set; } = null!;
[Node] private Timer JumpTimer { get; set; } = null!;
[Node] private Timer WallJumpTimer { get; set; } = null!;
[Node] private Timer JumpAllowedTimer { get; set; } = null!;
[Node] private Timer WaterJumpAllowedTimer { get; set; } = null!;
[Node] private Timer DashTimer { get; set; } = null!;
[Node] private Timer DashDirectionChangeTimer { get; set; } = null!;
[Node] private Timer DashCooldownTimer { get; set; } = null!;
[Node] private Timer GlobalDamageImmunityTimer { get; set; } = null!;
[Node] private Timer PlatformIgnoreTimer { get; set; } = null!;
@ -161,6 +163,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
if (!DashTimer.IsStopped())
{
if (!DashDirectionChangeTimer.IsStopped())
{
DashDirection = _currentDirection;
}
velocity = DashDirection * DashSpeed;
}
// Water movement
@ -464,8 +471,20 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private void Attack()
{
AdjustFacing();
Velocity += (IsFacingRight ? Vector2.Right : Vector2.Left) * SlashSpeedBoost;
_playback.Travel("front_kick");
// Velocity += (IsFacingRight ? Vector2.Right : Vector2.Left) * SlashSpeedBoost;
// _playback.Travel("front_kick");
// placeholder for directional attacks
var attackPlaceholderScene =
GD.Load<PackedScene>("res://src/player/attack_placeholder.tscn");
var attackPlaceholder = attackPlaceholderScene.Instantiate<Node2D>();
attackPlaceholder.Position = HandAttachment.GlobalPosition - GlobalPosition;
var targetDir = _currentDirection.IsZeroApprox()
? FacingVector
: _currentDirection;
attackPlaceholder.Rotation = Vector2.Up.AngleTo(targetDir);
AddChild(attackPlaceholder);
CreateTween().TweenCallback(Callable.From(attackPlaceholder.QueueFree)).SetDelay(0.2f);
}
private void WaterExitJump()
@ -480,10 +499,16 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
AdjustFacing();
DashPoints -= 1f;
DashTimer.Start();
DashDirectionChangeTimer.Start();
DashCooldownTimer.Start();
CreateTween()
.SetIgnoreTimeScale()
.TweenProperty(Engine.Singleton, "time_scale", 1.0f, 0.15f)
.From(0.01f)
.SetEase(Tween.EaseType.Out);
DashDirection = (_currentDirection.IsZeroApprox()
? FacingVector
: To4DirectionVector(_currentRawDirection)
: _currentDirection
).Normalized();
DashHitbox.StartAttack();
_playback.Travel("side_dash");