1
This commit is contained in:
@@ -278,9 +278,45 @@ public class FlyTurretData : TurretData
|
||||
// 飞行/悬停期间拦截状态动画(Attack/Idle 切换不打断起飞动画)
|
||||
if (IsFlying) return;
|
||||
|
||||
if (newState == TurretState.Attack)
|
||||
{
|
||||
// ⭐ XJMH 原版射击动画(Battery:Shoot):**每发** SetAnimation(0,"shot",false)——从头重播(连射时
|
||||
// 直接打断重放=原版"播放一半直接重新放")、非循环播完停住。
|
||||
// 基类是"进入状态播一次 + 循环播放",连射不重播 → 这里每次 Attack 都重播。
|
||||
// 首次进入先走基类同步状态(基类循环版动画同帧被下面重播覆盖,玩家不可见)
|
||||
if (CurrState != TurretState.Attack)
|
||||
base.ChangeState(newState);
|
||||
PlayShotAnim();
|
||||
return;
|
||||
}
|
||||
|
||||
base.ChangeState(newState);
|
||||
}
|
||||
|
||||
/// <summary>⚠ 覆写:XJMH 停火不打断最后一发(原版最后一发播完自动切待机=定格在尾帧,见基类说明)</summary>
|
||||
protected override bool KeepPoseOnEmptyIdleAnim => true;
|
||||
|
||||
/// <summary>同一帧内去重:自动开火"状态切换 + 手动发射"两条入口可能同帧都调本方法</summary>
|
||||
private int _lastShotFrame = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 播放一发射击动画(原版 Battery:Shoot → gunSkeleton SetAnimation(0,"shot",false)):
|
||||
/// ⭐ 每发从头重播(连射时打断当前播放重新开始);非循环,播完停在尾帧等下一发。
|
||||
/// 手动按住扫射的每发(不经过 ChangeState)由 GameMainPanel 在发射后调用;飞行中不播(原版 isPlaneState 时跳过)。
|
||||
/// </summary>
|
||||
public void PlayShotAnim()
|
||||
{
|
||||
if (IsFlying) return;
|
||||
if (_lastShotFrame == Time.frameCount) return; // 同一帧重复调用只播一次
|
||||
_lastShotFrame = Time.frameCount;
|
||||
|
||||
if (skeletonAnimation == null || skeletonAnimation.AnimationState == null) return;
|
||||
string anim = string.IsNullOrEmpty(attackAnim) ? "shot" : attackAnim;
|
||||
if (!HasSpineAnim(skeletonAnimation, anim)) return;
|
||||
|
||||
skeletonAnimation.AnimationState.SetAnimation(0, anim, false); // 每发从头(替换轨道=打断重放)
|
||||
}
|
||||
|
||||
// ==================== XJMH 进房入场动画(原版 Battery:EnterAction,进入房间时本地座位播一次) ====================
|
||||
// 原版链路(PW_Data.InitPlayer 收到自己"大飞机信息"):
|
||||
// GC.BatteryMgr.PlayEnterAction(chairId, PW_Data.EnterAction) —— 首次 false 播完整动画+声音,
|
||||
|
||||
@@ -303,6 +303,10 @@ public class TurretData : MonoBehaviour
|
||||
PlayState(newState);
|
||||
}
|
||||
|
||||
/// <summary>Idle 且没有配置待机动画时,是否保留当前姿态(不清轨道)。默认 false=清轨道(旧行为);
|
||||
/// XJMH(FlyTurretData)覆写 true:停火不打断射击动画,最后一发播完自然停住(原版行为)。</summary>
|
||||
protected virtual bool KeepPoseOnEmptyIdleAnim => false;
|
||||
|
||||
/// <summary>
|
||||
/// 播放"出现动画":各 SkeletonGraphic 上配置的 Spine startingAnimation(炮台容器/炮体上配的是 out、trans 等)。
|
||||
/// ⭐ Spine 只在 Awake(第一次激活)应用一次 startingAnimation,而 OnEnable 的 PlayState(Idle)
|
||||
@@ -419,6 +423,15 @@ public class TurretData : MonoBehaviour
|
||||
// 而 idleAnim 为空正好走这个分支,出现动画一帧就被清掉。
|
||||
if (Time.time < _appearAnimHoldUntil) return;
|
||||
|
||||
// ⭐ XJMH:停火不打断最后一发——射击动画还在播时先不清轨道,让它播完自然停住
|
||||
// (原版 Battery:Shoot 每发 SetAnimation(0,"shot",false),停止开火后不再重播、自然播完)
|
||||
if (KeepPoseOnEmptyIdleAnim && !string.IsNullOrEmpty(attackAnim))
|
||||
{
|
||||
var cur = skeletonAnimation.AnimationState.GetCurrent(0);
|
||||
if (cur != null && !cur.IsComplete && cur.Animation != null && cur.Animation.Name == attackAnim)
|
||||
return;
|
||||
}
|
||||
|
||||
skeletonAnimation.AnimationState.ClearTrack(0);
|
||||
skeletonAnimation.AnimationState.SetEmptyAnimation(0, 0f);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user