| | |
| | | Burned = 1 << 5 |
| | | } |
| | | |
| | | public class BattleObject |
| | | public abstract class BattleObject |
| | | { |
| | | public BattleField battleField; |
| | | |
| | | public BattleObjectBuffMgr buffMgr; |
| | | |
| | | public BattleObjectLayerMgr layerMgr; |
| | | |
| | |
| | | |
| | | public BattleCamp Camp { get; protected set; } |
| | | |
| | | public TeamHero teamHero { get; protected set; } |
| | | |
| | | public MotionBase motionBase; |
| | | |
| | | public GameObject heroGo |
| | | { |
| | | get; |
| | | private set; |
| | | } |
| | | |
| | | protected BattleDrops m_battleDrops; |
| | | |
| | | private RectTransform m_heroRectTrans; |
| | | |
| | | |
| | | public RectTransform heroRectTrans |
| | | { |
| | | get |
| | | { |
| | | if (m_heroRectTrans == null) |
| | | { |
| | | m_heroRectTrans = heroGo.GetComponent<RectTransform>(); |
| | | } |
| | | return m_heroRectTrans; |
| | | } |
| | | } |
| | | |
| | | protected Action onDeathAnimationComplete; |
| | | |
| | | protected Renderer[] renderers; |
| | | |
| | | private List<HB405_tagMCAddExp> hB405_tagMCAddExps = new List<HB405_tagMCAddExp>(); |
| | | public BattleHeroInfoBar heroInfoBar; |
| | | |
| | | public BattleObject(BattleField _battleField) |
| | | { |
| | | battleField = _battleField; |
| | | } |
| | | |
| | | public virtual void Init(GameObject _heroGo, TeamHero _teamHero, BattleCamp _camp) |
| | | // ============ 抽象访问方法(子类返回各自的Team类型信息) ============ |
| | | |
| | | public abstract int GetPositionNum(); |
| | | public abstract float GetModelScale(); |
| | | public abstract string GetName(); |
| | | |
| | | // Buff 管理器访问方法(Hero 有 buff,Mingge 返回 null) |
| | | public abstract BattleObjectBuffMgr GetBuffMgr(); |
| | | |
| | | // 状态查询抽象方法 |
| | | protected abstract bool GetIsStunned(); |
| | | protected abstract bool GetIsFrozen(); |
| | | protected abstract bool GetIsStoned(); |
| | | protected abstract bool GetIsSlient(); |
| | | protected abstract bool GetIsDisarmed(); |
| | | protected abstract bool GetIsInvincible(); |
| | | protected abstract bool GetIsDead(); |
| | | public abstract int GetRage(); |
| | | |
| | | // 血量相关抽象方法(Hero 特有,Mingge 返回默认值) |
| | | public abstract long GetCurHp(); |
| | | public abstract long GetMaxHp(); |
| | | public abstract void SetCurHp(long value); |
| | | public abstract void SetIsDead(bool value); |
| | | |
| | | // 其他属性访问方法 |
| | | public abstract int GetNPCID(); |
| | | public abstract long GetFightPower(); |
| | | |
| | | public abstract void Run(); |
| | | |
| | | public abstract void Pause(); |
| | | |
| | | public abstract void Resume(); |
| | | |
| | | public abstract void Destroy(); |
| | | |
| | | // ============ 动画相关抽象方法(替代 motionBase 直接调用) ============ |
| | | |
| | | /// <summary> |
| | | /// 播放动画 |
| | | /// </summary> |
| | | public abstract void PlayAnimation(MotionName motionName, bool loop); |
| | | |
| | | /// <summary> |
| | | /// 显示幻影残影 |
| | | /// </summary> |
| | | public abstract void ShowIllusionShadow(bool show, Color? color = null); |
| | | |
| | | /// <summary> |
| | | /// 播放技能动画 |
| | | /// </summary> |
| | | public abstract Spine.TrackEntry PlaySkillAnimation(SkillConfig skillConfig, SkillBase skillBase, bool isCounter, Action onComplete); |
| | | |
| | | /// <summary> |
| | | /// 检查是否可以开始死亡 |
| | | /// </summary> |
| | | public abstract bool CanStartDeath(); |
| | | |
| | | /// <summary> |
| | | /// 检查是否可以释放技能 |
| | | /// </summary> |
| | | public abstract bool CanCastSkillAnimation(SkillConfig skillConfig); |
| | | |
| | | /// <summary> |
| | | /// 获取骨骼动画组件(用于特效挂载等) |
| | | /// </summary> |
| | | public abstract SkeletonAnimation GetSkeletonAnimation(); |
| | | |
| | | /// <summary> |
| | | /// 设置骨骼动画透明度 |
| | | /// </summary> |
| | | public abstract void SetSkeletonAlpha(float alpha); |
| | | |
| | | /// <summary> |
| | | /// 获取 RectTransform(用于移动等操作) |
| | | /// </summary> |
| | | public virtual RectTransform GetRectTransform() => null; |
| | | |
| | | /// <summary> |
| | | /// 获取 GameObject |
| | | /// </summary> |
| | | public virtual GameObject GetGameObject() => null; |
| | | |
| | | /// <summary> |
| | | /// 获取 Transform(用于特效挂载等) |
| | | /// </summary> |
| | | public virtual Transform GetTransform() => null; |
| | | |
| | | /// <summary> |
| | | /// 获取世界坐标位置 |
| | | /// </summary> |
| | | public virtual Vector3 GetPosition() => Vector3.zero; |
| | | |
| | | /// <summary> |
| | | /// 获取血条信息栏 |
| | | /// </summary> |
| | | public virtual BattleHeroInfoBar GetHeroInfoBar() => null; |
| | | |
| | | /// <summary> |
| | | /// 刷新Buff显示 |
| | | /// </summary> |
| | | public virtual void RefreshBuff(List<HB428_tagSCBuffRefresh> buffList) { } |
| | | |
| | | /// <summary> |
| | | /// 更新血量显示 |
| | | /// </summary> |
| | | public virtual void UpdateHP(float percentage) { } |
| | | |
| | | /// <summary> |
| | | /// 是否正在复活中 |
| | | /// </summary> |
| | | public virtual bool IsReborning() => false; |
| | | |
| | | /// <summary> |
| | | /// 设置复活状态 |
| | | /// </summary> |
| | | public virtual void SetReborning(bool value) { } |
| | | |
| | | /// <summary> |
| | | /// 设置 GameObject 激活状态 |
| | | /// </summary> |
| | | public virtual void SetActive(bool active) { } |
| | | |
| | | /// <summary> |
| | | /// 重置位置到原点 |
| | | /// </summary> |
| | | public virtual void ResetPosition() { } |
| | | |
| | | /// <summary> |
| | | /// 设置朝向(通过缩放) |
| | | /// </summary> |
| | | public virtual void SetFacing(float direction) { } |
| | | |
| | | /// <summary> |
| | | /// 重置朝向(朝向右边) |
| | | /// </summary> |
| | | public virtual void ResetFacing() { } |
| | | |
| | | /// <summary> |
| | | /// 停止所有移动动画 |
| | | /// </summary> |
| | | public virtual void StopMoveAnimation() { } |
| | | |
| | | /// <summary> |
| | | /// 显示提示信息(简单版本) |
| | | /// </summary> |
| | | public virtual void ShowTips(string message, bool useArtText = false, bool followCharacter = true, float scaleRatio = 1f) { } |
| | | |
| | | /// <summary> |
| | | /// 显示提示信息(完整版本) |
| | | /// </summary> |
| | | public virtual void ShowTips(BattleHeroInfoBar.TipsInfo tipsInfo) { } |
| | | |
| | | /// <summary> |
| | | /// 设置死亡状态(Hero 特定) |
| | | /// </summary> |
| | | public virtual void SetDeath() { } |
| | | |
| | | /// <summary> |
| | | /// 复活后处理(Hero 特定) |
| | | /// </summary> |
| | | public virtual void AfterReborn() { } |
| | | |
| | | /// <summary> |
| | | /// 复活前准备(Hero 特定) |
| | | /// </summary> |
| | | public virtual void PreReborn(bool reviveSelf = false) { } |
| | | |
| | | /// <summary> |
| | | /// 复活动作(Hero 特定) |
| | | /// </summary> |
| | | public virtual void OnReborn(HB427_tagSCUseSkill.tagSCUseSkillHurt vNetData, bool reviveSelf = false, RecordAction parentAction = null) { } |
| | | |
| | | public virtual void OnObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo) |
| | | { |
| | | heroGo = _heroGo; |
| | | teamHero = _teamHero; |
| | | Camp = _camp; |
| | | motionBase = new MotionBase(); |
| | | motionBase.Init(heroGo.GetComponentInChildren<SkeletonAnimation>(true)); |
| | | buffMgr = new BattleObjectBuffMgr(); |
| | | buffMgr.Init(this); |
| | | |
| | | buffMgr.onIsControlChanged += OnControledChange; |
| | | |
| | | layerMgr = new BattleObjectLayerMgr(); |
| | | layerMgr.Init(this); |
| | | |
| | | renderers = heroGo.GetComponentsInChildren<Renderer>(true); |
| | | |
| | | heroInfoBar = heroGo.GetComponentInChildren<BattleHeroInfoBar>(true); |
| | | heroInfoBar.SetBattleObject(this); |
| | | |
| | | // 根据阵营翻转血条 |
| | | var heroInfoBarScale = heroInfoBar.transform.localScale; |
| | | heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1; |
| | | heroInfoBar.transform.localScale = heroInfoBarScale; |
| | | |
| | | heroInfoBar.SetActive(true); |
| | | SetFront(); |
| | | } |
| | | |
| | | |
| | | public virtual void Run() |
| | | { |
| | | motionBase.Run(); |
| | | heroInfoBar.Run(); |
| | | buffMgr.Run(); |
| | | } |
| | | |
| | | public virtual void Pause() |
| | | { |
| | | motionBase.Pause(); |
| | | } |
| | | |
| | | public virtual void Resume() |
| | | { |
| | | motionBase.Resume(); |
| | | } |
| | | |
| | | public virtual void Destroy() |
| | | { |
| | | |
| | | motionBase.Release(); |
| | | motionBase = null; |
| | | buffMgr.onIsControlChanged -= OnControledChange; |
| | | buffMgr.Release(); |
| | | buffMgr = null; |
| | | teamHero = null; |
| | | ObjID = 0; |
| | | |
| | | if (heroGo != null) |
| | | { |
| | | GameObject.DestroyImmediate(heroGo); |
| | | heroGo = null; |
| | | } |
| | | } |
| | | |
| | | // 有变化了才会调用这个函数 |
| | | private void OnControledChange(int groupType, bool value) |
| | | { |
| | | // 这里是受到硬控时候 需要表现的动画 |
| | | if (groupType == BattleConst.HardControlGroup) |
| | | { |
| | | // 从没被硬控到被硬控 |
| | | if (value) |
| | | { |
| | | motionBase.SetControledAnimation(); |
| | | } |
| | | else |
| | | { |
| | | motionBase.CancelControledAnimation(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void OnObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo) |
| | | { |
| | | // 天子的挑战拦截血条逻辑 |
| | | BattleObject boss = battleField.FindBoss(); |
| | | if (boss != null && battleField.MapID == 30020 && boss.ObjID == _refreshInfo.ObjID) |
| | | return; |
| | | switch ((PlayerDataType)_refreshInfo.RefreshType) |
| | | { |
| | | case PlayerDataType.HP: |
| | | long toHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx); |
| | | heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp); |
| | | teamHero.curHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx); |
| | | break; |
| | | case PlayerDataType.MaxHP: |
| | | teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx); |
| | | heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp); |
| | | break; |
| | | case PlayerDataType.XP: |
| | | long toXp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx); |
| | | heroInfoBar.UpdateXP(teamHero.rage, toXp, 100); |
| | | teamHero.rage = (int)GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx); |
| | | break; |
| | | default: |
| | | Debug.LogError("BattleObject.ObjInfoRefresh 出现意外类型 " + _refreshInfo.RefreshType.ToString()); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public void ObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData) |
| | | { |
| | | // 天子的挑战拦截血条逻辑 |
| | | BattleObject boss = battleField.FindBoss(); |
| | | if (boss != null && battleField.MapID == 30020 && boss.ObjID == vNetData.ObjID) |
| | | return; |
| | | switch ((PlayerDataType)vNetData.RefreshType) |
| | | { |
| | | case PlayerDataType.HP: |
| | | long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp); |
| | | teamHero.curHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | break; |
| | | case PlayerDataType.MaxHP: |
| | | teamHero.maxHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp); |
| | | break; |
| | | case PlayerDataType.XP: |
| | | long toXp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | heroInfoBar.UpdateXP(teamHero.rage, toXp, 100); |
| | | teamHero.rage = (int)GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | break; |
| | | default: |
| | | Debug.LogError("BattleObject.ObjPropertyRefreshView 出现意外类型 " + vNetData.RefreshType.ToString()); |
| | | break; |
| | | } |
| | | // 子类实现 |
| | | } |
| | | |
| | | // 眩晕 |
| | | public bool IsStunned() |
| | | { |
| | | return teamHero.isStunned; |
| | | return GetIsStunned(); |
| | | } |
| | | |
| | | // 冰冻 |
| | | public bool IsFrozen() |
| | | { |
| | | return teamHero.isFrozen; |
| | | return GetIsFrozen(); |
| | | } |
| | | |
| | | // 石化 |
| | | public bool IsStoned() |
| | | { |
| | | return teamHero.isStoned; |
| | | return GetIsStoned(); |
| | | } |
| | | |
| | | // 被沉默 |
| | | public bool IsSlient() |
| | | { |
| | | return teamHero.isSlient; |
| | | return GetIsSlient(); |
| | | } |
| | | |
| | | // 被缴械 |
| | | public bool IsDisarmed() |
| | | { |
| | | return teamHero.isDisarmed; |
| | | return GetIsDisarmed(); |
| | | } |
| | | |
| | | // 是否无敌 |
| | | public bool IsInvincable() |
| | | { |
| | | return teamHero.isInvinceble; |
| | | return GetIsInvincible(); |
| | | } |
| | | |
| | | // 是否死亡 |
| | | public bool IsDead() |
| | | { |
| | | return teamHero.isDead; |
| | | return GetIsDead(); |
| | | } |
| | | |
| | | // 是否被控住了 |
| | |
| | | } |
| | | |
| | | // 看看怒气是否达到释放要求 |
| | | return teamHero.rage >= 100; |
| | | return GetRage() >= 100; |
| | | } |
| | | |
| | | public virtual bool IsCanNormalAttack() |
| | |
| | | return true; |
| | | } |
| | | |
| | | public virtual void Hurt(BattleHurtParam battleHurtParam) |
| | | { |
| | | bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1; |
| | | bool firstHit = battleHurtParam.hitIndex == 0; |
| | | BattleDmgInfo dmgInfo = PopDamage(battleHurtParam); |
| | | public abstract DeathRecordAction Hurt(BattleHurtParam battleHurtParam, SkillRecordAction _parentSkillAction = null); |
| | | |
| | | public abstract void OnDodgeBegin(DamageType damageType); |
| | | |
| | | // 这里 |
| | | if (dmgInfo.IsType(DamageType.Dodge) && !buffMgr.isControled[BattleConst.HardControlGroup]) |
| | | { |
| | | if (isLastHit) |
| | | { |
| | | DodgeFinishAction dodgeFinish = new DodgeFinishAction(battleField, this); |
| | | battleField.recordPlayer.InsertRecord(dodgeFinish); |
| | | } |
| | | public abstract void OnDodgeEnd(Action _complete = null); |
| | | |
| | | if (firstHit) |
| | | { |
| | | OnDodgeBegin(); |
| | | } |
| | | } |
| | | public abstract void OnDeath(Action _onDeathAnimationComplete, bool withoutAnime = false); |
| | | |
| | | protected abstract BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam); |
| | | |
| | | |
| | | bool isFatalAttack = (null != battleHurtParam.deadPack) && isLastHit; |
| | | |
| | | if (isFatalAttack) |
| | | { |
| | | if (null != battleHurtParam.battleDrops) |
| | | { |
| | | PushDropItems(battleHurtParam.battleDrops); |
| | | } |
| | | battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { battleHurtParam.deadPack }); |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (dmgInfo.IsType(DamageType.Block)) |
| | | { |
| | | battleField.battleEffectMgr.PlayEffect(this, 19999, heroRectTrans, Camp); |
| | | } |
| | | else |
| | | { |
| | | if ((dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsRealdamage())) |
| | | { |
| | | if (!buffMgr.isControled[BattleConst.HardControlGroup]) |
| | | { |
| | | motionBase.PlayAnimation(MotionName.hit, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | const float pingpongTime = 0.4f; |
| | | // 闪避开始 |
| | | public virtual void OnDodgeBegin() |
| | | { |
| | | RectTransform rectTrans = heroRectTrans; |
| | | var tween = rectTrans.DOAnchorPos(new Vector3(-30, 0, 0), pingpongTime) |
| | | .SetEase(Ease.OutCubic); |
| | | |
| | | motionBase.ShowIllusionShadow(true); |
| | | |
| | | tween.onComplete += () => |
| | | { |
| | | motionBase.ShowIllusionShadow(false); |
| | | }; |
| | | |
| | | battleField.battleTweenMgr.OnPlayTween(tween); |
| | | } |
| | | |
| | | // 闪避结束 |
| | | public virtual void OnDodgeEnd(Action _complete = null) |
| | | { |
| | | RectTransform rectTrans = heroRectTrans; |
| | | |
| | | var tween = rectTrans.DOAnchorPos(Vector3.zero, pingpongTime) |
| | | .SetEase(Ease.OutCubic); |
| | | |
| | | tween.onComplete += () => |
| | | { |
| | | _complete?.Invoke(); |
| | | }; |
| | | |
| | | battleField.battleTweenMgr.OnPlayTween(tween); |
| | | } |
| | | |
| | | public virtual void OnDeath(Action _onDeathAnimationComplete) |
| | | { |
| | | motionBase.PlayAnimation(MotionName.dead, false, () => |
| | | { |
| | | teamHero.isDead = true; |
| | | OnDeadAnimationComplete(); |
| | | _onDeathAnimationComplete?.Invoke(); |
| | | }); |
| | | } |
| | | |
| | | protected virtual void OnDeadAnimationComplete() |
| | | { |
| | | // 或许看看溶解特效? YYL TODO |
| | | heroGo.SetActive(false); |
| | | |
| | | buffMgr.RemoveAllBuff(); |
| | | } |
| | | |
| | | public void OnReborn(HB423_tagMCTurnFightObjReborn vNetData) |
| | | { |
| | | // 处理复活逻辑 |
| | | teamHero.curHp = GeneralDefine.GetFactValue(vNetData.HP, vNetData.HPEx); |
| | | heroGo.SetActive(true); |
| | | motionBase.PlayAnimation(MotionName.idle, true); |
| | | } |
| | | |
| | | // 伤害还要看 是否闪避 暴击 and so on 需要有一个DamageType 服务器应该会给 |
| | | protected virtual BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam) |
| | | { |
| | | BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam); |
| | | // 天子的挑战拦截血条逻辑 |
| | | BattleObject boss = battleField.FindBoss(); |
| | | if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurtObj.ObjID) |
| | | { |
| | | EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo); |
| | | return battleDmgInfo; |
| | | } |
| | | else |
| | | { |
| | | // 使用传入的 fromHp 和 toHp 更新血条显示 |
| | | heroInfoBar.UpdateHP(battleHurtParam.fromHp, battleHurtParam.toHp, teamHero.maxHp); |
| | | |
| | | // YYL TODO 是否需要挂在在自身的follow点上 |
| | | EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo); |
| | | return battleDmgInfo; |
| | | } |
| | | |
| | | } |
| | | protected abstract BattleDmgInfo PopDamageForCaster(BattleHurtParam battleHurtParam); |
| | | |
| | | public RectTransform GetAliasTeamNode() |
| | | { |
| | |
| | | return Camp == BattleCamp.Red ? BattleCamp.Blue : BattleCamp.Red; |
| | | } |
| | | |
| | | public void HaveRest() |
| | | { |
| | | // YYL TODO |
| | | // 休息状态 |
| | | // 多一个zzz的一个特效 |
| | | heroGo.SetActive(true); |
| | | motionBase.HaveRest(); |
| | | heroRectTrans.anchoredPosition = Vector2.zero; |
| | | public abstract void HaveRest(); |
| | | |
| | | heroInfoBar.SetActive(false); |
| | | SetFront(); |
| | | } |
| | | protected BattleDrops m_battleDrops; |
| | | |
| | | public void PushDropItems(BattleDrops _battleDrops) |
| | | public virtual void PushDropItems(BattleDrops _battleDrops) |
| | | { |
| | | m_battleDrops = _battleDrops; |
| | | } |
| | | |
| | | public void PerformDrop() |
| | | public virtual void PerformDrop() |
| | | { |
| | | if (null == m_battleDrops || m_battleDrops.dropItemPackIndex.Count == 0) |
| | | if (null == m_battleDrops) |
| | | return; |
| | | |
| | | EventBroadcast.Instance.Broadcast<string, BattleDrops, Action>( |
| | | EventName.BATTLE_DROP_ITEMS, battleField.guid, m_battleDrops, OnPerformDropFinish); |
| | | } |
| | | |
| | | protected void OnPerformDropFinish() |
| | | protected virtual void OnPerformDropFinish() |
| | | { |
| | | m_battleDrops = null; |
| | | } |
| | |
| | | layerMgr.SetFront(); |
| | | } |
| | | |
| | | public void SetSpeedRatio(float ratio) |
| | | { |
| | | motionBase.SetSpeedRatio(ratio); |
| | | heroInfoBar.SetSpeedRatio(ratio); |
| | | } |
| | | public abstract void SetSpeedRatio(float ratio); |
| | | |
| | | public abstract void OnObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData); |
| | | |
| | | |
| | | #if UNITY_EDITOR_STOP_USING |
| | | public void EditorRevive() |
| | | { |
| | | teamHero.curHp = 100; |
| | | heroGo.SetActive(true); |
| | | motionBase.PlayAnimation(MotionName.idle, true); |
| | | } |
| | | public abstract void EditorRevive(); |
| | | |
| | | public List<int> TryAttack(BattleObject obj, SkillConfig skillConfig) |
| | | { |
| | |
| | | } |
| | | #endif |
| | | |
| | | // BattleObject.cs |
| | | |
| | | public virtual void OnHurtTarget(BattleHurtParam battleHurtParam) |
| | | { |
| | | // 检查是否有吸血或反伤 |
| | | bool hasSuckHp = battleHurtParam.caster.suckHpList != null && battleHurtParam.caster.suckHpList.Count > 0; |
| | | bool hasReflectHp = battleHurtParam.caster.reflectHpList != null && battleHurtParam.caster.reflectHpList.Count > 0; |
| | | |
| | | if (!hasSuckHp && !hasReflectHp) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // ============ 应用施法者的血量和护盾变化 ============ |
| | | bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1; |
| | | ApplyHurtToCaster(battleHurtParam, isLastHit); |
| | | |
| | | // 和Hurt一样,调用PopDamage处理吸血/反伤的显示 |
| | | BattleDmgInfo casterDmgInfo = PopDamageForCaster(battleHurtParam); |
| | | |
| | | // 如果有反伤,施法者播放受击动画 |
| | | if (hasReflectHp && casterDmgInfo.casterDamageList != null && casterDmgInfo.casterDamageList.Count > 0) |
| | | { |
| | | long totalReflect = casterDmgInfo.casterDamageList.Sum(d => d.damage); |
| | | var buffMgr = GetBuffMgr(); |
| | | if (totalReflect > 0 && buffMgr != null && !buffMgr.isControled[BattleConst.HardControlGroup]) |
| | | { |
| | | OnPlayHitAnimation(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 应用施法者的血量和护盾变化(吸血和反伤) |
| | | /// </summary> |
| | | private void ApplyHurtToCaster(BattleHurtParam battleHurtParam, bool isLastHit) |
| | | { |
| | | BattleCastObj caster = battleHurtParam.caster; |
| | | |
| | | // 应用血量变化(由子类实现) |
| | | ApplyCasterHpChange(caster.toHp); |
| | | |
| | | // 打印所有角色的名字和当前血量跟总血量 |
| | | // foreach (var obj in battleField.battleObjMgr.allBattleObjDict.Values) |
| | | // { |
| | | // Debug.LogError($"[ApplyHurtToCaster] ObjID: {obj.ObjID}, Name: {obj.teamHero.heroConfig.Name}, CurHp: {obj.teamHero.curHp}, MaxHp: {obj.teamHero.maxHp} Skill {battleHurtParam.hB427_TagSCUseSkill.packUID} " ); |
| | | // } |
| | | |
| | | // 护盾值由buff系统自动管理,不需要手动设置 |
| | | |
| | | #if UNITY_EDITOR |
| | | // 最后一击时验证血量是否与服务器一致 |
| | | if (isLastHit) |
| | | { |
| | | BattleUtility.ValidateHpConsistencyForCaster(battleHurtParam, "施法者吸血/反伤"); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | public bool IsTianziBoss() |
| | | { |
| | | return battleField.MapID == 30020 && battleField.FindBoss() == this; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 播放受击动画(只有 Hero 有实现,Mingge 留空) |
| | | /// </summary> |
| | | protected abstract void OnPlayHitAnimation(); |
| | | |
| | | /// <summary> |
| | | /// 应用施法者血量变化(吸血/反伤) |
| | | /// </summary> |
| | | protected abstract void ApplyCasterHpChange(long newHp); |
| | | } |