| | |
| | | |
| | | public BattleObjectBuffMgr buffMgr; |
| | | |
| | | public BattleObjectLayerMgr layerMgr; |
| | | |
| | | public int ObjID { get; set; } |
| | | |
| | | public BattleCamp Camp { get; protected set; } |
| | | |
| | | public TeamHero teamHero { get; protected set; } |
| | | |
| | | // public BuffMgr buffMgr; |
| | | |
| | | public MotionBase motionBase; |
| | | |
| | |
| | | private set; |
| | | } |
| | | |
| | | protected BattleDrops m_battleDrops; |
| | | |
| | | private RectTransform m_heroRectTrans; |
| | | |
| | | |
| | | public RectTransform heroRectTrans |
| | | { |
| | |
| | | |
| | | protected Renderer[] renderers; |
| | | |
| | | public Transform effectNode; |
| | | |
| | | private List<HB405_tagMCAddExp> hB405_tagMCAddExps = new List<HB405_tagMCAddExp>(); |
| | | public BattleHeroInfoBar heroInfoBar; |
| | | |
| | | public BattleObject(BattleField _battleField) |
| | | { |
| | |
| | | teamHero = _teamHero; |
| | | Camp = _camp; |
| | | motionBase = new MotionBase(); |
| | | motionBase.Init(heroGo.GetComponentInChildren<SkeletonGraphic>(true)); |
| | | motionBase.onAnimationComplete += OnAnimationComplete; |
| | | motionBase.Init(heroGo.GetComponentInChildren<SkeletonAnimation>(true)); |
| | | buffMgr = new BattleObjectBuffMgr(); |
| | | buffMgr.Init(this); |
| | | |
| | | renderers = heroGo.GetComponentsInChildren<Renderer>(true); |
| | | } |
| | | 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; |
| | | if (battleField is StoryBattleField && (battleField as StoryBattleField).battleState == StoryBattleState.Break) |
| | | { |
| | | //主线关卡休息中的不显示血条 |
| | | heroInfoBar.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | heroInfoBar.SetActive(true); |
| | | } |
| | | SetFront(); |
| | | } |
| | | |
| | | |
| | | public virtual void Run() |
| | | { |
| | | motionBase.Run(); |
| | | heroInfoBar.Run(); |
| | | buffMgr.Run(); |
| | | } |
| | | |
| | | public virtual void Pause() |
| | |
| | | public virtual void Destroy() |
| | | { |
| | | |
| | | motionBase.onAnimationComplete -= OnAnimationComplete; |
| | | |
| | | motionBase.Release(); |
| | | motionBase = null; |
| | | buffMgr.onIsControlChanged -= OnControledChange; |
| | | buffMgr.Release(); |
| | | buffMgr = null; |
| | | teamHero = null; |
| | | ObjID = 0; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // 有变化了才会调用这个函数 |
| | | 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 && _refreshInfo.RefreshType != (ushort)PlayerDataType.XP) |
| | | return; |
| | | switch ((PlayerDataType)_refreshInfo.RefreshType) |
| | | { |
| | | case PlayerDataType.HP: |
| | | long toHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx); |
| | | heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false); |
| | | 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, false); |
| | | 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: |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // public void ObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData) |
| | | // { |
| | | // // 天子的挑战拦截血条,不拦截怒气 |
| | | // BattleObject boss = battleField.FindBoss(); |
| | | // if (boss != null && battleField.MapID == 30020 && boss.ObjID == vNetData.ObjID && vNetData.RefreshType != (ushort)PlayerDataType.XP) |
| | | // return; |
| | | // switch ((PlayerDataType)vNetData.RefreshType) |
| | | // { |
| | | // case PlayerDataType.HP: |
| | | // long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | // heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false); |
| | | // 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, false); |
| | | // 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 true; |
| | | } |
| | | |
| | | public virtual void Hurt(List<long> damageValues, long _totalDamage, uint attackType) |
| | | public virtual void Hurt(BattleHurtParam battleHurtParam) |
| | | { |
| | | PopDamage(teamHero.curHp, damageValues, attackType); |
| | | bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1; |
| | | bool firstHit = battleHurtParam.hitIndex == 0; |
| | | BattleDmgInfo dmgInfo = PopDamage(battleHurtParam); |
| | | |
| | | motionBase.PlayAnimation(MotionName.hit, false); |
| | | |
| | | // 扣血 |
| | | teamHero.curHp -= _totalDamage; |
| | | // 这里 |
| | | if (dmgInfo.IsType(DamageType.Dodge) /*&& !buffMgr.isControled[BattleConst.HardControlGroup]*/)//如果被控制了还闪避了 要看看服务器怎么处理了 |
| | | { |
| | | if (isLastHit) |
| | | { |
| | | DodgeFinishAction dodgeFinish = new DodgeFinishAction(battleField, this); |
| | | battleField.recordPlayer.InsertRecord(dodgeFinish); |
| | | } |
| | | |
| | | if (firstHit) |
| | | { |
| | | OnDodgeBegin(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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() |
| | | { |
| | | float pingpongTime = 0.2f; |
| | | RectTransform rectTrans = heroRectTrans; |
| | | var tween = rectTrans.DOAnchorPos(new Vector3(-50, 50, 0), pingpongTime) |
| | | var tween = rectTrans.DOAnchorPos(new Vector3(-30, 0, 0), pingpongTime) |
| | | .SetEase(Ease.OutCubic); |
| | | |
| | | motionBase.ShowIllusionShadow(true); |
| | | |
| | | DamageNumConfig damageNumConfig = DamageNumConfig.Get((int)DamageType.Dodge); |
| | | |
| | | string dodgeStr = ((char)damageNumConfig.prefix).ToString(); |
| | | |
| | | heroInfoBar.ShowTips(dodgeStr, true, false); |
| | | |
| | | tween.onComplete += () => |
| | | { |
| | | motionBase.ShowIllusionShadow(false); |
| | | }; |
| | | |
| | | battleField.battleTweenMgr.OnPlayTween(tween); |
| | | } |
| | | |
| | | // 闪避结束 |
| | | public virtual void OnDodgeEnd() |
| | | public virtual void OnDodgeEnd(Action _complete = null) |
| | | { |
| | | float pingpongTime = 0.2f; |
| | | 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) |
| | | { |
| | | onDeathAnimationComplete = _onDeathAnimationComplete; |
| | | motionBase.PlayAnimation(MotionName.dead, false); |
| | | } |
| | | |
| | | protected virtual void OnAnimationComplete(MotionName motionName) |
| | | { |
| | | if (motionName == MotionName.dead) |
| | | buffMgr.RemoveAllBuff(); |
| | | motionBase.PlayDeadAnimation(() => |
| | | { |
| | | teamHero.isDead = true; |
| | | OnDeadAnimationComplete(); |
| | | onDeathAnimationComplete?.Invoke(); |
| | | onDeathAnimationComplete = null; |
| | | } |
| | | _onDeathAnimationComplete?.Invoke(); |
| | | }); |
| | | } |
| | | |
| | | protected virtual void OnDeadAnimationComplete() |
| | | { |
| | | // 或许看看溶解特效? YYL TODO |
| | | heroGo.SetActive(false); |
| | | |
| | | // 防止给死亡对象又上buff |
| | | buffMgr.RemoveAllBuff(); |
| | | } |
| | | |
| | | public void OnReborn(HB423_tagMCTurnFightObjReborn vNetData) |
| | | { |
| | | // 处理复活逻辑 |
| | | teamHero.curHp = GeneralDefine.GetFactValue(vNetData.HP, vNetData.HPEx); |
| | | teamHero.isDead = false; |
| | | heroGo.SetActive(true); |
| | | motionBase.PlayAnimation(MotionName.idle, true); |
| | | } |
| | | |
| | | // 伤害还要看 是否闪避 暴击 and so on 需要有一个DamageType 服务器应该会给 |
| | | protected virtual void PopDamage(long curHp, List<long> damageValues, uint attackType) |
| | | protected virtual BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam) |
| | | { |
| | | // 其实应该通知出去给UI界面解耦 让UI界面自己来显示的 YYL TODO |
| | | // 播放伤害数字 |
| | | // 这里可以实现一个伤害数字的弹出效果 |
| | | // 比如使用一个UI组件来显示伤害数字 |
| | | foreach (var damage in damageValues) |
| | | BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam); |
| | | // 天子的挑战拦截血条逻辑 |
| | | BattleObject boss = battleField.FindBoss(); |
| | | if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurtObj.ObjID) |
| | | { |
| | | Debug.Log($"Damage: {damage}"); |
| | | EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo); |
| | | return battleDmgInfo; |
| | | } |
| | | else |
| | | { |
| | | heroInfoBar.UpdateDamage(battleDmgInfo); |
| | | |
| | | // YYL TODO 是否需要挂在在自身的follow点上 |
| | | EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo); |
| | | return battleDmgInfo; |
| | | } |
| | | |
| | | // YYL TODO 是否需要挂在在自身的follow点上 |
| | | EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleField.guid, this, damageValues); |
| | | } |
| | | |
| | | public RectTransform GetAliasTeamNode() |
| | |
| | | // YYL TODO |
| | | // 休息状态 |
| | | // 多一个zzz的一个特效 |
| | | heroGo.SetActive(true); |
| | | motionBase.HaveRest(); |
| | | heroRectTrans.anchoredPosition = Vector2.zero; |
| | | |
| | | motionBase.PlayAnimation(MotionName.idle, true); |
| | | heroInfoBar.SetActive(false); |
| | | SetFront(); |
| | | } |
| | | |
| | | public void PushExpPackList(List<HB405_tagMCAddExp> _hB405_tagMCAddExps) |
| | | public void PushDropItems(BattleDrops _battleDrops) |
| | | { |
| | | // YYL TODO 死亡后弹出经验掉落提醒 |
| | | hB405_tagMCAddExps = _hB405_tagMCAddExps; |
| | | m_battleDrops = _battleDrops; |
| | | } |
| | | |
| | | public void DropExp() |
| | | public void PerformDrop() |
| | | { |
| | | // YYL TODO |
| | | // hB405_tagMCAddExps |
| | | if (null == m_battleDrops) |
| | | return; |
| | | |
| | | EventBroadcast.Instance.Broadcast<string, BattleDrops, Action>( |
| | | EventName.BATTLE_DROP_ITEMS, battleField.guid, m_battleDrops, OnPerformDropFinish); |
| | | } |
| | | |
| | | protected void OnPerformDropFinish() |
| | | { |
| | | m_battleDrops = null; |
| | | } |
| | | |
| | | public void SetBack() |
| | | { |
| | | layerMgr.SetBack(); |
| | | } |
| | | |
| | | public void SetFront() |
| | | { |
| | | layerMgr.SetFront(); |
| | | } |
| | | |
| | | public void SetSpeedRatio(float ratio) |
| | | { |
| | | motionBase.SetSpeedRatio(ratio); |
| | | heroInfoBar.SetSpeedRatio(ratio); |
| | | } |
| | | |
| | | public void OnObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData) |
| | | { |
| | | // 天子的挑战拦截血条,不拦截怒气 |
| | | BattleObject boss = battleField.FindBoss(); |
| | | if (boss != null && battleField.MapID == 30020 && boss.ObjID == vNetData.ObjID && vNetData.RefreshType != (ushort)PlayerDataType.XP) |
| | | return; |
| | | |
| | | // public uint ObjID; |
| | | // public ushort RefreshType; // 同0418刷新类型,如血量、怒气 |
| | | // public uint AttackTypes; // 飘字类型汇总,支持多种类型并存,如无视防御且暴击同时被格挡,二进制或运算最终值;0-失败;1-普通;2-回血;5-格挡;6-无视防御;7-暴击;9-闪避 |
| | | // public uint Value; // 更新值 |
| | | // public uint ValueEx; // 更新值,如果是大数值的此值为整除亿部分 |
| | | // public byte DiffType; // 变化类型,0-减少;1-增加 |
| | | // public uint DiffValue; // 变化值 |
| | | // public uint DiffValueEx; // 变化值,如果是大数值的此值为整除亿部分 |
| | | // public uint SkillID; // 使用的技能表ID |
| | | // public uint RelatedSkillID; // 关联的技能ID,一般是主技能ID,非主技能额外触发的为0 |
| | | |
| | | long diffValue = GeneralDefine.GetFactValue(vNetData.DiffValue, vNetData.DiffValueEx); |
| | | diffValue *= vNetData.DiffType == 0 ? -1 : 1; |
| | | |
| | | long newValue = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | |
| | | |
| | | switch ((PlayerDataType)vNetData.RefreshType) |
| | | { |
| | | case PlayerDataType.HP: |
| | | long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx); |
| | | heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, true); |
| | | teamHero.curHp = newValue; |
| | | break; |
| | | case PlayerDataType.MaxHP: |
| | | teamHero.maxHp = newValue; |
| | | heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, true); |
| | | break; |
| | | case PlayerDataType.XP: |
| | | long toXp = newValue; |
| | | heroInfoBar.UpdateXP(teamHero.rage, toXp, 100); |
| | | teamHero.rage = (int)newValue; |
| | | |
| | | DamageNumConfig damageNumConfig = DamageNumConfig.Get((int)DamageType.RageUp); |
| | | string message = BattleUtility.ConvertToArtFont(damageNumConfig, diffValue); |
| | | heroInfoBar.ShowTips(new BattleHeroInfoBar.TipsInfo() |
| | | { |
| | | message = message, |
| | | useArtText = true, |
| | | followCharacter = true, |
| | | scaleRatio = 1f, |
| | | isRage = true |
| | | }); |
| | | break; |
| | | default: |
| | | Debug.LogError("BattleObject.ObjPropertyRefreshView 出现意外类型 " + vNetData.RefreshType.ToString()); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | #if UNITY_EDITOR_STOP_USING |