多轮审查和修复
This commit is contained in:
70
Assets/Scripts/Player/States/DownAttackState.cs
Normal file
70
Assets/Scripts/Player/States/DownAttackState.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using UnityEngine;
|
||||
using BaseGames.Combat;
|
||||
|
||||
namespace BaseGames.Player.States
|
||||
{
|
||||
/// <summary>
|
||||
/// 下劈(踩踏 Pogo)状态(架构 05_PlayerModule §2)。
|
||||
/// 需解锁 AbilityType.DownSlash 才能进入;
|
||||
/// 激活 HitBoxDown,着地或命中后弹跳。
|
||||
/// </summary>
|
||||
public class DownAttackState : PlayerStateBase
|
||||
{
|
||||
private bool _hasHitEnemy;
|
||||
private bool _exited;
|
||||
|
||||
public DownAttackState(PlayerController owner) : base(owner) { }
|
||||
|
||||
public override void OnStateEnter()
|
||||
{
|
||||
_hasHitEnemy = false;
|
||||
_exited = false;
|
||||
|
||||
Owner.Combat?.EnableWeaponHitBox(AttackDirection.Down);
|
||||
|
||||
var clip = Owner.Weapon?.ActiveWeapon?.downAttackClip;
|
||||
if (clip != null && clip.Clip != null)
|
||||
{
|
||||
var state = Anim.Play(clip);
|
||||
state.Events(this).OnEnd = OnClipEnd;
|
||||
}
|
||||
else if (AnimCfg?.DownAttack != null)
|
||||
{
|
||||
var state = Anim.Play(AnimCfg.DownAttack);
|
||||
state.Events(this).OnEnd = OnClipEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
OnClipEnd();
|
||||
}
|
||||
|
||||
// 施加向下的速度(下劈冲击)
|
||||
if (Move?.Rb != null)
|
||||
Move.Rb.velocity = new Vector2(Move.Rb.velocity.x, -18f);
|
||||
}
|
||||
|
||||
public override void OnStateExit()
|
||||
{
|
||||
_exited = true;
|
||||
Owner.Combat?.DisableAllWeaponHitBoxes();
|
||||
}
|
||||
|
||||
public override void OnStateUpdate()
|
||||
{
|
||||
// 着地时回到 Idle / Run
|
||||
if (Move.IsGrounded)
|
||||
{
|
||||
Owner.TransitionTo(Owner.GetState<IdleState>());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClipEnd()
|
||||
{
|
||||
if (_exited) return;
|
||||
if (!Move.IsGrounded)
|
||||
Owner.TransitionTo(Owner.GetState<FallState>());
|
||||
else
|
||||
Owner.TransitionTo(Owner.GetState<IdleState>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user