Added banked dash points
This commit is contained in:
parent
959ade4668
commit
74c888fa6e
5 changed files with 26 additions and 8 deletions
1
src/Util.cs.uid
Normal file
1
src/Util.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bhl0mh0d7oh4
|
||||
|
|
@ -88,6 +88,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
private Ticker JumpTicker { get; } = new();
|
||||
private Vector2 DashDirection { get; set; }
|
||||
public float DashPoints { get; set; }
|
||||
public float BankedDashPoints { get; set; }
|
||||
private Ticker GlobalDamageImmunityTicker { get; } = new();
|
||||
|
||||
[Node] private AnimationTree AnimationTree { get; set; } = null!;
|
||||
|
|
@ -97,6 +98,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
public void OnReady()
|
||||
{
|
||||
this.Provide();
|
||||
SetProcess(true);
|
||||
SetPhysicsProcess(true);
|
||||
Health = MaxHealth;
|
||||
_playback = AnimationTree.Get("parameters/playback").As<AnimationNodeStateMachinePlayback>();
|
||||
|
|
@ -241,11 +243,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
var collisionPos = collision.GetPosition() + collision.GetTravel();
|
||||
var mapCoords = tileMapLayer.GlobalToMap(collisionPos);
|
||||
|
||||
if (tileMapLayer.GetCellTileData(mapCoords) is not { } tileData
|
||||
|| !tileData.HasCustomData("damage"))
|
||||
if (tileMapLayer.GetCellTileData(mapCoords) is not { } tileData)
|
||||
continue;
|
||||
|
||||
if (tileData.GetCustomData("damage") is not { VariantType: Variant.Type.Float } variant)
|
||||
if (!tileData.HasCustomData("damage")
|
||||
|| tileData.GetCustomData("damage") is not { VariantType: Variant.Type.Float } variant)
|
||||
continue;
|
||||
|
||||
if (variant.AsSingle() is > 0f and var damage)
|
||||
|
|
@ -259,7 +261,16 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
WaterJumpAllowedTicker.Tick(deltaF);
|
||||
DashTicker.Tick(deltaF);
|
||||
DashCooldown.Tick(deltaF);
|
||||
if (IsInWater) DashPoints = Mathf.Min(MaxDashPoints, DashPoints + 3f * deltaF);
|
||||
{
|
||||
var addedDashPoints = 3f * deltaF;
|
||||
if (IsInWater)
|
||||
{
|
||||
DashPoints += BankedDashPoints;
|
||||
BankedDashPoints = 0;
|
||||
DashPoints = Mathf.Min(MaxDashPoints, DashPoints + addedDashPoints);
|
||||
}
|
||||
else BankedDashPoints = Mathf.Min(1, BankedDashPoints + 3f * addedDashPoints);
|
||||
}
|
||||
GlobalDamageImmunityTicker.Tick(deltaF);
|
||||
|
||||
if (IsOnCeiling()) JumpTicker.Reset();
|
||||
|
|
@ -293,7 +304,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
&& _currentDirection.X != 0;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
public void OnProcess(double delta)
|
||||
{
|
||||
GetNode<Node2D>("%Body").Scale = new(IsFacingRight ? 1 : -1, 1);
|
||||
}
|
||||
|
|
|
|||
BIN
src/player/player.aseprite
(Stored with Git LFS)
BIN
src/player/player.aseprite
(Stored with Git LFS)
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue