|
using System;
|
using UnityEngine;
|
using Spine.Unity;
|
using System.Collections.Generic;
|
|
/// <summary>
|
/// 命格战斗对象 - 没有血量、没有实体,不会被攻击和选中,唯一作用是释放技能
|
/// </summary>
|
public class MinggeBattleObject : BattleObject
|
{
|
public TeamMingge teamMingge { get; private set; }
|
|
// Buff 管理器(命格现在也需要 buff 系统)
|
public BattleObjectBuffMgr buffMgr;
|
|
// 预留的命格 Buff 显示接口,供外部自定义显示逻辑
|
public Action<List<HB428_tagSCBuffRefresh>> OnMinggeBuffRefresh;
|
|
public MinggeBattleObject(BattleField _battleField) : base(_battleField)
|
{
|
}
|
|
public virtual void Init(TeamBase teamBase, TeamMingge _teamMingge, BattleCamp _camp)
|
{
|
teamMingge = _teamMingge;
|
Camp = _camp;
|
ObjID = teamMingge.ObjID;
|
|
// 初始化 buff 管理器
|
buffMgr = new BattleObjectBuffMgr();
|
buffMgr.Init(this);
|
|
layerMgr = new BattleObjectLayerMgr();
|
layerMgr.Init(this);
|
}
|
|
public override void Run()
|
{
|
// 更新 buff 管理器
|
buffMgr?.Run();
|
}
|
|
public override void Pause()
|
{
|
// 命格暂停
|
}
|
|
public override void Resume()
|
{
|
// 命格恢复
|
}
|
|
public override void Destroy()
|
{
|
// 清理显示回调
|
OnMinggeBuffRefresh = null;
|
|
// 清理 buff 管理器
|
if (buffMgr != null)
|
{
|
buffMgr.Release();
|
buffMgr = null;
|
}
|
}
|
|
// ============ 实现抽象访问方法 ============
|
|
public override BattleObjectBuffMgr GetBuffMgr() => buffMgr;
|
|
public override int GetPositionNum() => teamMingge.positionNum;
|
public override float GetModelScale() => teamMingge.modelScale;
|
public override string GetName() => teamMingge.name;
|
|
protected override bool GetIsStunned() => teamMingge.isStunned;
|
protected override bool GetIsFrozen() => teamMingge.isFrozen;
|
protected override bool GetIsStoned() => teamMingge.isStoned;
|
protected override bool GetIsSlient() => teamMingge.isSlient;
|
protected override bool GetIsDisarmed() => teamMingge.isDisarmed;
|
protected override bool GetIsInvincible() => teamMingge.isInvinceble;
|
protected override bool GetIsDead() => teamMingge.isDead;
|
public override int GetRage() => teamMingge.rage;
|
|
protected override void ApplyCasterHpChange(long newHp)
|
{
|
// 命格没有血量,忽略
|
}
|
|
public override long GetCurHp() => 0;
|
public override long GetMaxHp() => 0;
|
public override void SetCurHp(long value) { }
|
public override void SetIsDead(bool value) { }
|
|
public override int GetNPCID() => 0;
|
public override long GetFightPower() => 0;
|
|
// ============ 动画相关方法实现(命格没有动画) ============
|
|
public override void PlayAnimation(MotionName motionName, bool loop)
|
{
|
// 命格没有动画
|
}
|
|
public override void ShowIllusionShadow(bool show, Color? color = null)
|
{
|
// 命格没有幻影
|
}
|
|
public override Spine.TrackEntry PlaySkillAnimation(SkillConfig skillConfig, SkillBase skillBase, bool isCounter, Action onComplete)
|
{
|
// 命格没有技能动画,立即触发所有帧事件
|
int loopCount = skillConfig.LoopCount + 1; //默认会有一次
|
int frameCount = skillConfig.ActiveFrames.Length;
|
|
// 1. 技能开始
|
skillBase.OnSkillStart();
|
|
// 2. 前摇结束
|
skillBase.OnStartSkillFrameEnd();
|
|
// 3. 循环执行中摇
|
int triggerCount = 0;
|
for (int currentLoop = 0; currentLoop < loopCount; currentLoop++)
|
{
|
// 每个 loop 开始时调用 OnMiddleFrameStart
|
skillBase.OnMiddleFrameStart(currentLoop);
|
|
// 触发该 loop 的所有 ActiveFrame
|
for (int i = 0; i < frameCount; i++)
|
{
|
skillBase.OnMiddleFrameEnd(currentLoop, triggerCount++);
|
}
|
}
|
|
// 4. 后摇开始
|
skillBase.OnFinalFrameStart();
|
|
// 5. 完成回调
|
onComplete?.Invoke();
|
|
// 6. 后摇结束
|
skillBase.OnFinalFrameEnd();
|
|
return null;
|
}
|
|
public override bool CanStartDeath()
|
{
|
// 命格不会死亡
|
return false;
|
}
|
|
public override bool CanCastSkillAnimation(SkillConfig skillConfig)
|
{
|
// 命格总是可以释放技能(从动画角度)
|
return true;
|
}
|
|
public override SkeletonAnimation GetSkeletonAnimation()
|
{
|
// 命格没有骨骼动画
|
return null;
|
}
|
|
public override void SetSkeletonAlpha(float alpha)
|
{
|
// 命格没有骨骼动画
|
}
|
|
// ============ 以下方法命格不需要,但必须实现接口 ============
|
|
public override DeathRecordAction Hurt(BattleHurtParam battleHurtParam, SkillRecordAction _parentSkillAction = null)
|
{
|
// 命格不会被攻击
|
Debug.LogWarning("命格不应该被攻击");
|
return null;
|
}
|
|
public override void OnDodgeBegin(DamageType damageType)
|
{
|
// 命格不需要闪避
|
}
|
|
public override void OnDodgeEnd(Action _complete = null)
|
{
|
// 命格不需要闪避
|
_complete?.Invoke();
|
}
|
|
public override void OnDeath(Action _onDeathAnimationComplete, bool withoutAnime = false)
|
{
|
// 命格没有死亡
|
_onDeathAnimationComplete?.Invoke();
|
}
|
|
protected override BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam)
|
{
|
// 命格不显示伤害
|
return null;
|
}
|
|
protected override BattleDmgInfo PopDamageForCaster(BattleHurtParam battleHurtParam)
|
{
|
// 命格不显示伤害
|
return null;
|
}
|
|
public override void HaveRest()
|
{
|
// 清理 buff
|
buffMgr?.RemoveAllBuff();
|
}
|
|
public override void SetSpeedRatio(float ratio)
|
{
|
// 命格不需要速度控制
|
}
|
|
public override void OnObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData)
|
{
|
// 命格没有血量,不需要属性刷新
|
}
|
|
#if UNITY_EDITOR_STOP_USING
|
public override void EditorRevive()
|
{
|
// 命格不需要复活
|
}
|
#endif
|
|
protected override void OnPlayHitAnimation()
|
{
|
// 命格不需要受击动画
|
}
|
}
|