chore: initial commit

This commit is contained in:
2026-05-08 11:04:00 +08:00
commit f55d2a57c3
6278 changed files with 866081 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using UnityEngine;
namespace BaseGames.Player.States
{
/// <summary>下落状态。着地后转为 Idle 或 Run持有郊狼时间允许跳跃。</summary>
public class FallState : PlayerStateBase
{
public FallState(PlayerController owner) : base(owner) { }
public override void OnStateEnter()
{
if (AnimCfg?.Fall != null)
Anim.Play(AnimCfg.Fall);
}
public override void OnStateUpdate()
{
// 郊狼时间跳跃
if (Buffer.ConsumeJump() && Move.HasCoyoteTime)
{
_owner.TransitionTo(_owner.JumpState);
return;
}
// 着地
if (Move.IsGrounded)
{
Move.ZeroVelocity();
if (Mathf.Abs(Input.MoveInput.x) > 0.1f)
_owner.TransitionTo(_owner.RunState);
else
_owner.TransitionTo(_owner.IdleState);
return;
}
// 空中水平移动
if (Mathf.Abs(Input.MoveInput.x) > 0.01f)
Move.Move(Input.MoveInput.x * (Cfg != null ? Cfg.RunSpeed : 7f));
}
public override void OnStateFixedUpdate()
{
// 增强下落重力
if (Cfg != null && Move.Rb.velocity.y < 0f)
{
float extraGrav = Physics2D.gravity.y * (Cfg.FallGravityMult - 1f) * Time.fixedDeltaTime;
Move.Rb.velocity = new Vector2(
Move.Rb.velocity.x,
Mathf.Max(Move.Rb.velocity.y + extraGrav, -Cfg.MaxFallSpeed));
}
}
}
}