diff --git a/project.godot b/project.godot index 0a6f3e2..7acc358 100644 --- a/project.godot +++ b/project.godot @@ -34,7 +34,7 @@ project/assembly_name="Dancer" [editor_plugins] -enabled=PackedStringArray("res://addons/BehaviorDebug/plugin.cfg", "res://addons/TileMapDual/plugin.cfg") +enabled=PackedStringArray("res://addons/BehaviorDebug/plugin.cfg") [input] diff --git a/src/player/Player.cs b/src/player/Player.cs index 610d280..cae14d7 100644 --- a/src/player/Player.cs +++ b/src/player/Player.cs @@ -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("res://src/player/attack_placeholder.tscn"); + var attackPlaceholder = attackPlaceholderScene.Instantiate(); + 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"); diff --git a/src/player/attack_placeholder.tscn b/src/player/attack_placeholder.tscn new file mode 100644 index 0000000..31f2531 --- /dev/null +++ b/src/player/attack_placeholder.tscn @@ -0,0 +1,11 @@ +[gd_scene format=3 uid="uid://bycdn3lths1qq"] + +[node name="AttackPlaceholder" type="Polygon2D" unique_id=2118857772] +color = Color(1, 1, 1, 0.54901963) +offset = Vector2(0, 16) +polygon = PackedVector2Array(-32, -48, 32, -48, 16, -16, -16, -16) + +[node name="Area2D" type="Area2D" parent="." unique_id=578891655] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Area2D" unique_id=2127841935] +polygon = PackedVector2Array(-16, 0, -32, -32, 32, -32, 16, 0) diff --git a/src/player/player.tscn b/src/player/player.tscn index 68cc723..532709d 100644 --- a/src/player/player.tscn +++ b/src/player/player.tscn @@ -377,6 +377,9 @@ process_callback = 0 limit_enabled = false editor_draw_screen = false +[node name="AudioListener2D" type="AudioListener2D" parent="." unique_id=1944725412] +current = true + [node name="Body" type="Sprite2D" parent="." unique_id=567060128] unique_name_in_owner = true texture = ExtResource("2_mf2ua") @@ -510,7 +513,13 @@ one_shot = true [node name="DashTimer" type="Timer" parent="." unique_id=18391348] unique_name_in_owner = true process_callback = 0 -wait_time = 0.15 +wait_time = 0.2 +one_shot = true + +[node name="DashDirectionChangeTimer" type="Timer" parent="." unique_id=911466358] +unique_name_in_owner = true +process_callback = 0 +wait_time = 0.05 one_shot = true [node name="DashCooldownTimer" type="Timer" parent="." unique_id=452015930]