added basic out of water jump
This commit is contained in:
parent
0e68f347d6
commit
003cc7c589
1 changed files with 18 additions and 14 deletions
|
|
@ -66,14 +66,17 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
public float JumpAscentRemainingTime { get; private set; }
|
public float JumpAscentRemainingTime { get; private set; }
|
||||||
public bool IsJumping { get; private set; }
|
public bool IsJumping { get; private set; }
|
||||||
public float JumpAllowedTime { get; private set; }
|
public float JumpAllowedTime { get; private set; }
|
||||||
|
|
||||||
/// The direction the player is currently holding.
|
/// The direction the player is currently holding.
|
||||||
/// This vectors components should always be -1/0/1.
|
/// This vectors components should always be -1/0/1.
|
||||||
private Vector2 _currentDirection = Vector2.Zero;
|
private Vector2 _currentDirection = Vector2.Zero;
|
||||||
|
|
||||||
private bool _isFacingRight = true;
|
private bool _isFacingRight = true;
|
||||||
private AnimationNodeStateMachinePlayback _playback = null!;
|
private AnimationNodeStateMachinePlayback _playback = null!;
|
||||||
private List<BufferedInput> _inputBuffer = [];
|
private List<BufferedInput> _inputBuffer = [];
|
||||||
private bool _isInWater;
|
private bool _isInWater;
|
||||||
private float PlatformIgnoreTime { get; set; }
|
private float PlatformIgnoreTime { get; set; }
|
||||||
|
private float WaterJumpAllowedTime { 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!;
|
||||||
|
|
@ -199,6 +202,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
if (IsOnFloor())
|
if (IsOnFloor())
|
||||||
JumpAllowedTime = LateJumpTimeLimit;
|
JumpAllowedTime = LateJumpTimeLimit;
|
||||||
|
|
||||||
|
WaterJumpAllowedTime = Mathf.Max(0, WaterJumpAllowedTime - deltaF);
|
||||||
|
|
||||||
if (IsOnCeiling())
|
if (IsOnCeiling())
|
||||||
{
|
{
|
||||||
IsJumping = false;
|
IsJumping = false;
|
||||||
|
|
@ -206,18 +211,13 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnteredWater(Node2D body)
|
public void EnteredWater(Node2D body) => _isInWater = true;
|
||||||
{
|
|
||||||
if (_isInWater) return;
|
|
||||||
_isInWater = true;
|
|
||||||
GD.Print("Entered water!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LeftWater(Node2D body)
|
public void LeftWater(Node2D body)
|
||||||
{
|
{
|
||||||
if (!_isInWater || SubmersedSensor.HasOverlappingBodies()) return;
|
if (!_isInWater || SubmersedSensor.HasOverlappingBodies()) return;
|
||||||
GD.Print("Left water!");
|
|
||||||
_isInWater = false;
|
_isInWater = false;
|
||||||
|
WaterJumpAllowedTime = LateJumpTimeLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AdjustFacing()
|
private void AdjustFacing()
|
||||||
|
|
@ -271,7 +271,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
else if (
|
else if (
|
||||||
input.Event.IsPressed()
|
input.Event.IsPressed()
|
||||||
&& JumpAllowedTime > 0
|
&& JumpAllowedTime > 0
|
||||||
&& (!IsOnFloor() || input.Direction.Y <= 0))
|
&& (!IsOnFloor() || input.Direction.Y <= 0)
|
||||||
|
&& !_isInWater)
|
||||||
{
|
{
|
||||||
inputFound = true;
|
inputFound = true;
|
||||||
GroundJump();
|
GroundJump();
|
||||||
|
|
@ -281,6 +282,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
inputFound = true;
|
inputFound = true;
|
||||||
WallJump();
|
WallJump();
|
||||||
}
|
}
|
||||||
|
else if (input.Event.IsPressed() && WaterJumpAllowedTime > 0)
|
||||||
|
{
|
||||||
|
inputFound = true;
|
||||||
|
WaterExitJump();
|
||||||
|
}
|
||||||
else if (input.Event.IsReleased() && IsJumping)
|
else if (input.Event.IsReleased() && IsJumping)
|
||||||
{
|
{
|
||||||
JumpCut();
|
JumpCut();
|
||||||
|
|
@ -337,14 +343,12 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
_playback.Travel("front_kick");
|
_playback.Travel("front_kick");
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAtWaterSurface()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WaterExitJump()
|
private void WaterExitJump()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
AdjustFacing();
|
||||||
|
JumpAllowedTime = 0.0f;
|
||||||
|
JumpAscentRemainingTime = JumpAscentMaxTime * 1.5f;
|
||||||
|
IsJumping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector2 To8DirectionVector(Vector2 input)
|
private static Vector2 To8DirectionVector(Vector2 input)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue