added basic ui for dash points
This commit is contained in:
parent
ca4c73191d
commit
944399ac53
4 changed files with 45 additions and 11 deletions
File diff suppressed because one or more lines are too long
19
src/player/DashPointBar.cs
Normal file
19
src/player/DashPointBar.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1
src/player/DashPointBar.cs.uid
Normal file
1
src/player/DashPointBar.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://i2ts2auxd3na
|
||||||
|
|
@ -64,8 +64,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
[Export] public float MaxHealth { get; set; } = 5f;
|
[Export] public float MaxHealth { get; set; } = 5f;
|
||||||
[Export] public float Health { get; set; }
|
[Export] public float Health { get; set; }
|
||||||
[Export] public bool CanTurn { get; set; } = true;
|
[Export] public bool CanTurn { get; set; } = true;
|
||||||
|
[Export] public float MaxDashPoints { get; set; } = 2f;
|
||||||
[Export] public TileMapLayer WaterTileMap { get; set; } = null!;
|
|
||||||
|
|
||||||
private ulong MaxInputBufferTimeMicroseconds => (ulong)(MaxInputBufferTime * 1_000_000);
|
private ulong MaxInputBufferTimeMicroseconds => (ulong)(MaxInputBufferTime * 1_000_000);
|
||||||
public bool IsJumping => JumpTicker.IsRunning;
|
public bool IsJumping => JumpTicker.IsRunning;
|
||||||
|
|
@ -85,7 +84,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
private Ticker DashCooldown { get; } = new();
|
private Ticker DashCooldown { get; } = new();
|
||||||
private Ticker JumpTicker { get; } = new();
|
private Ticker JumpTicker { get; } = new();
|
||||||
private Vector2 DashDirection { get; set; }
|
private Vector2 DashDirection { get; set; }
|
||||||
private float DashPoints { get; set; }
|
public float DashPoints { get; set; }
|
||||||
|
|
||||||
[Node] private AnimationTree AnimationTree { get; set; } = null!;
|
[Node] private AnimationTree AnimationTree { get; set; } = null!;
|
||||||
[Node] private Area2D SubmersedSensor { 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);
|
WaterJumpAllowedTicker.Tick(deltaF);
|
||||||
DashTicker.Tick(deltaF);
|
DashTicker.Tick(deltaF);
|
||||||
DashCooldown.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();
|
if (IsOnCeiling()) JumpTicker.Reset();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue