This commit is contained in:
Scove
2026-03-26 20:27:19 +07:00
parent a94ab0e3f6
commit f42ef22a13
129 changed files with 5517 additions and 1134 deletions

View File

@@ -0,0 +1,58 @@
using UnityEngine;
namespace OnlyScove.Scripts
{
public class PlayerAirDashState : PlayerBaseState
{
private readonly int airDashHash = Animator.StringToHash("AirDash");
private float dashDuration = 0.2f;
private float dashTimer;
private Vector3 dashDirection;
public PlayerAirDashState(PlayerStateMachine stateMachine) : base(stateMachine) {}
public override void Enter()
{
dashTimer = dashDuration;
stateMachine.Anim.SetTrigger(airDashHash);
// Reset vertical velocity so we don't carry falling momentum into the dash
stateMachine.VelocityY = 0f;
// Determine dash direction
Vector2 input = stateMachine.Input.MoveInput;
if (input != Vector2.zero)
{
dashDirection = new Vector3(input.x, 0f, input.y).normalized;
if (stateMachine.Cam != null)
{
dashDirection = stateMachine.Cam.PlanarRotation * dashDirection;
}
stateMachine.transform.rotation = Quaternion.LookRotation(dashDirection);
}
else
{
dashDirection = stateMachine.transform.forward;
}
}
public override void Tick(float deltaTime)
{
dashTimer -= deltaTime;
// Move horizontally, ignoring gravity for this brief moment
stateMachine.Controller.Move(dashDirection * stateMachine.DashForce * deltaTime);
// When the air dash ends, return to falling
if (dashTimer <= 0f)
{
stateMachine.SwitchState(new PlayerFallState(stateMachine));
}
}
public override void PhysicsTick(float fixedDeltaTime) {}
public override void Exit() {}
}
}