feat(enemy): EnemyLocomotion 按模式驱动步态动画(Idle/Walk/Alert/Run)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -487,6 +487,21 @@ namespace BaseGames.Enemies
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>按当前移动模式播放步态动画(由 EnemyLocomotion 在模式变化时调用)。</summary>
|
||||
public void PlayLocomotionClip(LocomotionMode mode)
|
||||
{
|
||||
if (_animancer == null || _animConfig == null) return;
|
||||
var clip = mode switch
|
||||
{
|
||||
LocomotionMode.Idle => _animConfig.Idle,
|
||||
LocomotionMode.Patrol => _animConfig.Walk,
|
||||
LocomotionMode.Face => _animConfig.Alert,
|
||||
LocomotionMode.Approach => _animConfig.Run,
|
||||
_ => null,
|
||||
};
|
||||
if (clip != null) _animancer.Play(clip);
|
||||
}
|
||||
|
||||
// ── 动画事件钩子(由 EnemyAnimationEvents 调用)────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace BaseGames.Enemies
|
||||
private LocomotionMode _mode = LocomotionMode.Idle;
|
||||
private Transform _approachTarget;
|
||||
private Vector2 _facePoint;
|
||||
private LocomotionMode _gaitMode;
|
||||
private bool _gaitInit;
|
||||
|
||||
public LocomotionMode CurrentMode => _mode;
|
||||
public bool IsMoving => _enemy != null && _enemy.Nav != null && _enemy.Nav.IsMoving;
|
||||
@@ -69,6 +71,12 @@ namespace BaseGames.Enemies
|
||||
private void Update()
|
||||
{
|
||||
if (_enemy == null) return;
|
||||
if (!_gaitInit || _gaitMode != _mode)
|
||||
{
|
||||
_enemy.PlayLocomotionClip(_mode);
|
||||
_gaitMode = _mode;
|
||||
_gaitInit = true;
|
||||
}
|
||||
switch (_mode)
|
||||
{
|
||||
case LocomotionMode.Idle:
|
||||
|
||||
Reference in New Issue
Block a user