new fih image
This commit is contained in:
parent
5f667d6c1c
commit
ee8cbaa1dc
5 changed files with 471 additions and 122 deletions
|
|
@ -45,7 +45,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
public float SlashSpeedBoost { get; set; } = 90.0f;
|
||||
|
||||
[Export(PropertyHint.None, "suffix:px/s")]
|
||||
public float DashSpeed { get; set; } = 500.0f;
|
||||
public float DashSpeed { get; set; } = 400.0f;
|
||||
|
||||
/// <summary>The angle difference from perfect left/right that still counts.</summary>
|
||||
[Export(PropertyHint.Range, "0,360,0.1,radians_as_degrees")]
|
||||
|
|
@ -74,7 +74,6 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
private Vector2 _currentRawDirection = Vector2.Zero;
|
||||
|
||||
public bool IsFacingRight { get; private set; } = true;
|
||||
private AnimationNodeStateMachinePlayback _playback = null!;
|
||||
public List<BufferedInput> InputBuffer { get; } = [];
|
||||
public bool IsInWater { get; private set; }
|
||||
public bool IsDashing => !DashTimer.IsStopped();
|
||||
|
|
@ -104,7 +103,6 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
SetProcess(true);
|
||||
SetPhysicsProcess(true);
|
||||
Health = MaxHealth;
|
||||
_playback = AnimationTree.Get("parameters/playback").As<AnimationNodeStateMachinePlayback>();
|
||||
SubmersedSensor.BodyEntered += OnEnteredWater;
|
||||
SubmersedSensor.AreaEntered += OnEnteredWater;
|
||||
SubmersedSensor.BodyExited += OnLeftWater;
|
||||
|
|
@ -240,7 +238,9 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
velocity.X = Mathf.Clamp(velocity.X, -AirMaxSpeed, AirMaxSpeed);
|
||||
}
|
||||
|
||||
dragAmount = _currentDirection.Normalized().Dot(Velocity.Normalized()) < 0.1f ? 0.015f : 0.002f;
|
||||
dragAmount = _currentDirection.Normalized().Dot(Velocity.Normalized()) < 0.1f
|
||||
? 0.015f
|
||||
: 0.002f;
|
||||
}
|
||||
|
||||
// Move up while holding jump
|
||||
|
|
@ -259,7 +259,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
// Slow down descent while holding on to a wall
|
||||
if (IsHoldingWall)
|
||||
{
|
||||
if (velocity.Y >= 0f) velocity.Y = Mathf.MoveToward(velocity.Y * Mathf.Pow(0.0001f, deltaF), 0f, 750f * deltaF);
|
||||
if (velocity.Y >= 0f)
|
||||
velocity.Y = Mathf.MoveToward(velocity.Y * Mathf.Pow(0.0001f, deltaF), 0f, 750f * deltaF);
|
||||
IsFacingRight = Mathf.Sign(GetWallNormal().X) > 0;
|
||||
}
|
||||
|
||||
|
|
@ -354,6 +355,18 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
var body = GetNode<Node2D>("%Body");
|
||||
body.Scale = new(IsFacingRight ? 1 : -1, 1);
|
||||
body.Modulate = ParryTimer.IsStopped() ? Colors.White : new(2f, 2f, 2f);
|
||||
AnimationTree.Set("parameters/state/transition_request",
|
||||
IsInWater
|
||||
? "dive"
|
||||
: IsOnFloor()
|
||||
? "ground"
|
||||
: "air"
|
||||
);
|
||||
AnimationTree.Set("parameters/holding_wall/blend_amount", IsHoldingWall ? 1f : 0f);
|
||||
AnimationTree.Set("parameters/ground/blend_position", Mathf.Abs(Velocity.X));
|
||||
AnimationTree.Set("parameters/air/blend_position", Velocity.Y);
|
||||
AnimationTree.Set("parameters/dive/blend_position", new Vector2(Mathf.Abs(Velocity.X), Velocity.Y));
|
||||
AnimationTree.Set("parameters/dash_sm/dash/blend_position", new Vector2(Mathf.Abs(Velocity.X), Velocity.Y));
|
||||
}
|
||||
|
||||
public readonly struct BufferedInput
|
||||
|
|
@ -531,7 +544,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
|||
: _currentDirection
|
||||
).Normalized();
|
||||
DashHitbox.StartAttack();
|
||||
_playback.Travel("side_dash");
|
||||
AnimationTree.Set("parameters/dash/request", (int)AnimationNodeOneShot.OneShotRequest.Fire);
|
||||
}
|
||||
|
||||
private void Parry() => ParryTimer.Start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue