added dash points
This commit is contained in:
parent
4f5ae4ac60
commit
ca4c73191d
4 changed files with 26 additions and 26 deletions
|
|
@ -8,5 +8,5 @@ script="rider-plugin.gd"
|
|||
|
||||
[presets]
|
||||
|
||||
active="on"
|
||||
active="off"
|
||||
presets="presets.json"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
[runnable_presets]
|
||||
|
||||
Linux="Linux"
|
||||
|
||||
[preset.0]
|
||||
|
||||
name="Linux"
|
||||
platform="Linux"
|
||||
runnable=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../Desktop/export/Dancer.x86_64"
|
||||
export_path="../../Desktop/Exports/Dancer.x86_64"
|
||||
patches=PackedStringArray()
|
||||
patch_delta_encoding=false
|
||||
patch_delta_compression_level_zstd=19
|
||||
|
|
@ -27,7 +30,7 @@ script_export_mode=2
|
|||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=true
|
||||
binary_format/embed_pck=false
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
shader_baker/enabled=false
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ project/assembly_name="Dancer"
|
|||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg", "res://addons/BehaviorDebug/plugin.cfg", "res://addons/TileMapDual/plugin.cfg", "res://addons/rider-plugin/plugin.cfg")
|
||||
enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg", "res://addons/BehaviorDebug/plugin.cfg", "res://addons/TileMapDual/plugin.cfg")
|
||||
|
||||
[input]
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
public float DashSpeed { get; set; } = 400.0f;
|
||||
|
||||
[Export(PropertyHint.None, "suffix:s")]
|
||||
public float DashCooldownDuration { get; set; } = 0.6f;
|
||||
public float DashCooldownDuration { get; set; } = 0.4f;
|
||||
|
||||
/// <summary>The angle difference from perfect left/right that still counts.</summary>
|
||||
[Export(PropertyHint.Range, "0,360,0.1,radians_as_degrees")]
|
||||
|
|
@ -85,6 +85,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; }
|
||||
|
||||
[Node] private AnimationTree AnimationTree { get; set; } = null!;
|
||||
[Node] private Area2D SubmersedSensor { get; set; } = null!;
|
||||
|
|
@ -140,18 +141,15 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
|
||||
if (CanTurn) AdjustFacing();
|
||||
|
||||
// Water movement
|
||||
if (IsInWater)
|
||||
{
|
||||
if (DashTicker.IsRunning)
|
||||
{
|
||||
velocity = DashDirection * DashSpeed;
|
||||
}
|
||||
else
|
||||
// Water movement
|
||||
else if (IsInWater)
|
||||
{
|
||||
velocity += _currentDirection.Normalized() * WaterAccel * deltaF;
|
||||
}
|
||||
}
|
||||
// Walking on the floor
|
||||
else if (IsOnFloor())
|
||||
{
|
||||
|
|
@ -226,6 +224,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 (IsOnCeiling()) JumpTicker.Reset();
|
||||
}
|
||||
|
|
@ -295,7 +294,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
{
|
||||
if (MatchInput(_inputBuffer[i]))
|
||||
{
|
||||
_inputBuffer = _inputBuffer.GetRange(i + 1, _inputBuffer.Count - i - 1);
|
||||
_inputBuffer.RemoveRange(0, i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -342,7 +341,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
return true;
|
||||
|
||||
case { Action: Action.Dash, IsPressed: true }
|
||||
when (IsInWater && !DashCooldown.IsRunning):
|
||||
when !DashCooldown.IsRunning && DashPoints >= 1f:
|
||||
Dash();
|
||||
return true;
|
||||
|
||||
|
|
@ -398,6 +397,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
private void Dash()
|
||||
{
|
||||
AdjustFacing();
|
||||
DashPoints -= 1f;
|
||||
DashTicker.Start();
|
||||
DashCooldown.Start();
|
||||
DashDirection = (_currentDirection.IsZeroApprox()
|
||||
|
|
@ -409,15 +409,12 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
private static Vector2 To8DirectionVector(Vector2 input)
|
||||
{
|
||||
if (input.IsZeroApprox()) return Vector2.Zero;
|
||||
|
||||
const float tan225 = 0.4142135623730950488f; // tan(22.5°) = √2 - 1
|
||||
float ax = Mathf.Sign(input.X), ay = Mathf.Abs(input.Y);
|
||||
float sx = Mathf.Sign(input.X), sy = Mathf.Sign(input.Y);
|
||||
|
||||
const float tan225 = 0.414213562373f; // tan(22.5°)
|
||||
Vector2 a = input.Abs(), s = input.Sign();
|
||||
return
|
||||
ay < ax * tan225 ? new(sx, 0) :
|
||||
ax < ay * tan225 ? new(0, sy) :
|
||||
new(sx, sy);
|
||||
a.Y < a.X * tan225 ? new(s.X, 0) :
|
||||
a.X < a.Y * tan225 ? new(0, s.Y) :
|
||||
s;
|
||||
}
|
||||
|
||||
private void OnEnemyHit(Hitbox hitbox, Node2D enemy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue