added basic ui for dash points

This commit is contained in:
Lilith Schier 2026-07-18 13:58:23 +02:00
parent ca4c73191d
commit 944399ac53
4 changed files with 45 additions and 11 deletions

View file

@ -0,0 +1,19 @@
namespace Dancer;
[Meta(typeof(IAutoNode))]
public sealed partial class DashPointBar : ProgressBar
{
public override void _Notification(int what) => this.Notify(what);
[Export] private Player Player { get; set; } = null!;
public void OnReady() => SetProcess(true);
public void OnProcess(double delta)
{
MinValue = 0;
MaxValue = Player.MaxDashPoints;
Value = Player.DashPoints;
}
}

View file

@ -0,0 +1 @@
uid://i2ts2auxd3na

View file

@ -64,8 +64,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
[Export] public float MaxHealth { get; set; } = 5f;
[Export] public float Health { get; set; }
[Export] public bool CanTurn { get; set; } = true;
[Export] public TileMapLayer WaterTileMap { get; set; } = null!;
[Export] public float MaxDashPoints { get; set; } = 2f;
private ulong MaxInputBufferTimeMicroseconds => (ulong)(MaxInputBufferTime * 1_000_000);
public bool IsJumping => JumpTicker.IsRunning;
@ -85,7 +84,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private Ticker DashCooldown { get; } = new();
private Ticker JumpTicker { get; } = new();
private Vector2 DashDirection { get; set; }
private float DashPoints { get; set; }
public float DashPoints { get; set; }
[Node] private AnimationTree AnimationTree { get; set; } = null!;
[Node] private Area2D SubmersedSensor { get; set; } = null!;
@ -224,7 +223,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
WaterJumpAllowedTicker.Tick(deltaF);
DashTicker.Tick(deltaF);
DashCooldown.Tick(deltaF);
if (IsInWater) DashPoints = Mathf.Min(2, DashPoints + 1f * deltaF);
if (IsInWater) DashPoints = Mathf.Min(MaxDashPoints, DashPoints + 1f * deltaF);
if (IsOnCeiling()) JumpTicker.Reset();
}