| | |
| | | // 防止外部实例化 |
| | | private EventBroadcast() { } |
| | | |
| | | ~EventBroadcast() { |
| | | eventDict.Clear(); |
| | | } |
| | | |
| | | #region 添加监听 |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | public void Distribute() |
| | | { |
| | | while (actionPacks.Count > 0) |
| | | { |
| | | GameNetPackBasic pack = actionPacks.Dequeue(); |
| | | |
| | | Debug.LogError("CustomB421ActionPack distribute pack " + pack.GetType().Name); |
| | | |
| | | if (pack is CustomHB426CombinePack) |
| | | { |
| | | var b426Pack = pack as CustomHB426CombinePack; |
| | | b426Pack.Distribute(); |
| | | } |
| | | else |
| | | { |
| | | PackageRegedit.Distribute(pack); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | public void SetHB426End(int _toIndex, HB426_tagSCTurnFightTag _endTag) |
| | | { |
| | | if (endTag.Sign != 1) |
| | | if (_endTag.Sign != 1) |
| | | { |
| | | Debug.LogError("HB426_tagSCTurnFightTag Sign must be 1 for end tag, but got: " + endTag.Sign); |
| | | Debug.LogError("HB426_tagSCTurnFightTag Sign must be 1 for end tag, but got: " + _endTag.Sign); |
| | | return; |
| | | } |
| | | endTag = _endTag; |
| | | toIndex = _toIndex; |
| | | |
| | | packList = CombineToSkillPackFromList(guid, packList); |
| | | } |
| | |
| | | |
| | | public bool IsEndPack(HB426_tagSCTurnFightTag tag) |
| | | { |
| | | if (endTag == null) |
| | | if (tag == null) |
| | | { |
| | | Debug.LogError("endTag is null, please set it first."); |
| | | return false; |
| | | } |
| | | |
| | | return endTag.Tag == tag.Tag && endTag.Sign == 1; |
| | | if (startTag == null) |
| | | { |
| | | Debug.LogError("startTag is null, please set it first."); |
| | | return false; |
| | | } |
| | | |
| | | return startTag.Tag == tag.Tag && tag.Sign == 1; |
| | | } |
| | | |
| | | |
| | |
| | | combinePack = new CustomHB426CombinePack(); |
| | | combinePack.guid = _guid; |
| | | combinePack.SetHB426Start(i, tag); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | HB423_tagMCTurnFightObjReborn vNetData = vNetPack as HB423_tagMCTurnFightObjReborn; |
| | | BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID); |
| | | // battleField.OnObjReborn(vNetData.ObjID); |
| | | battleField.OnObjReborn(vNetData); |
| | | } |
| | | } |
| | |
| | | Register(typeof(HA709_tagObjInfoListRefresh), typeof(DTCA709_tagObjInfoListRefresh)); |
| | | Register(typeof(H0113_tagServerHeart), typeof(DTC0113_tagServerHeart)); |
| | | Register(typeof(H0111_tagOnlineReply), typeof(DTC0111_tagOnlineReply)); |
| | | Register(typeof(HB428_tagSCBuffRefresh), typeof(DTCB428_tagSCBuffRefresh)); |
| | | Register(typeof(HB429_tagSCBuffDel), typeof(DTCB429_tagSCBuffDel)); |
| | | Register(typeof(H0608_tagNPCDie), typeof(DTC0608_tagNPCDie)); |
| | | Register(typeof(H0612_tagClearObjBuff), typeof(DTC0612_tagClearObjBuff)); |
| | | Register(typeof(HA3A1_tagMCModuleFightPowerInfo), typeof(DTCA3A1_tagMCModuleFightPowerInfo)); |
| | |
| | | Register(typeof(HB423_tagMCTurnFightObjReborn), typeof(DTCB423_tagMCTurnFightObjReborn)); |
| | | Register(typeof(HB424_tagSCTurnFightInit), typeof(DTCB424_tagSCTurnFightInit)); |
| | | Register(typeof(HB425_tagSCTurnFightReportSign), typeof(DTCB425_tagSCTurnFightReportSign)); |
| | | Register(typeof(HB426_tagSCTurnFightTag), typeof(DTCB426_tagSCTurnFightTag)); |
| | | Register(typeof(HB427_tagSCUseSkill), typeof(DTCB427_tagSCUseSkill)); |
| | | Register(typeof(HB428_tagSCBuffRefresh), typeof(DTCB428_tagSCBuffRefresh)); |
| | | Register(typeof(HB429_tagSCBuffDel), typeof(DTCB429_tagSCBuffDel)); |
| | | Register(typeof(HB430_tagSCTurnFightReport), typeof(DTCB430_tagSCTurnFightReport)); |
| | | Register(typeof(H0407_tagNPCDisappear), typeof(DTC0407_tagNPCDisappear)); |
| | | Register(typeof(HB418_tagSCObjPropertyRefreshView), typeof(DTCB418_tagSCObjPropertyRefreshView)); |
| | | Register(typeof(HB427_tagSCUseSkill), typeof(DTCB427_tagSCUseSkill)); |
| | | Register(typeof(HB124_tagSCLineupInfo), typeof(DTCB124_tagSCLineupInfo)); |
| | | Register(typeof(HA207_tagSCPackBuyInfo), typeof(DTCA207_tagSCPackBuyInfo)); |
| | | } |
| | |
| | | // TurnNum; // 当前轮次 |
| | | // Len; |
| | | // Msg; //size = Len + |
| | | |
| | | if (State == 4) |
| | | { |
| | | //已经结束并结算 |
| | |
| | | Debug.Log("战斗回合 : " + turnNum + ",状态 " + State); |
| | | } |
| | | |
| | | |
| | | DistributeNextPackage(); |
| | | |
| | | // 做一个Action 通知UI翻下牌子 然后结束Action |
| | | // TurnFightStateAction turnFightStateAction = new TurnFightStateAction(this, turnNum, State, FuncLineID, extendData); |
| | |
| | | { |
| | | obj.motionBase.PlayAnimation(MotionName.run, true); |
| | | RectTransform trans = obj.heroRectTrans; |
| | | tween = trans.DOMove(obj.GetAliasTeamNode().position, 0.5f).SetEase(Ease.Linear); |
| | | trans.anchoredPosition = new Vector2(-800, 0); |
| | | tween = trans.DOAnchorPos(Vector2.zero, 1f).SetEase(Ease.Linear); |
| | | battleTweenMgr.OnPlayTween(tween); |
| | | } |
| | | |
| | |
| | | isFinish = true; |
| | | // 完成就开始显示UI |
| | | EventBroadcast.Instance.Broadcast(EventName.DISPLAY_BATTLE_UI, battleField.guid, true); |
| | | |
| | | battleField.DistributeNextPackage(); |
| | | }); |
| | | |
| | | isRun = true; |
| | |
| | | |
| | | private void OnDeathAnimationEnd() |
| | | { |
| | | // 只有主线掉落物品 |
| | | if (battleField.MapID == 1 || battleField.MapID == 2) |
| | | { |
| | | var dropItemPack = PackManager.Instance.GetSinglePack(PackType.DropItem); |
| | | if (dropItemPack != null) |
| | | { |
| | | var items = dropItemPack.GetAllItems(); |
| | | foreach (ItemModel item in items.Values) |
| | | { |
| | | // 掉落物品 |
| | | battleField.OnObjDropItem(battleObject.teamHero.positionNum, item); |
| | | battleField.OnObjDropExp(battleObject); |
| | | |
| | | } |
| | | } |
| | | } |
| | | // 掉落物品 增加经验 |
| | | |
| | | isFinish = true; |
| | |
| | | public override void OnBattleEnd(JsonData turnFightStateData) |
| | | { |
| | | base.OnBattleEnd(turnFightStateData); |
| | | |
| | | HaveRest(); |
| | | } |
| | | |
| | | // public override void Run() |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using LitJson; |
| | | |
| | | |
| | | |
| | | using System; |
| | | |
| | | public class BattleManager : GameSystemManager<BattleManager> |
| | | { |
| | |
| | | |
| | | protected LogicUpdate logicUpdate = new LogicUpdate(); |
| | | |
| | | public Action<string, BattleField> onBattleFieldCreate; |
| | | |
| | | public Action<string, BattleField> onBattleFieldDestroy; |
| | | |
| | | public override void Init() |
| | | { |
| | | base.Init(); |
| | | // StartStoryBattle(); |
| | | logicUpdate.Start(Run); |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | } |
| | |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | #region 截断网络派发包 只收入当前包的后续 b425是主线的 非主线的包并不会走b425 |
| | | private bool allow = true; |
| | |
| | | List<GameNetPackBasic> packQueueSnapshot = new List<GameNetPackBasic>(packQueue); |
| | | |
| | | List<GameNetPackBasic> newPackList = new List<GameNetPackBasic>(); |
| | | HashSet<int> skipIndexes = new HashSet<int>(); |
| | | |
| | | // 这里已经是按照Dequeue的顺序了 |
| | | for (int i = 0; i < packQueueSnapshot.Count; i++) |
| | | { |
| | | if (skipIndexes.Contains(i)) continue; |
| | | |
| | | GameNetPackBasic pack = packQueueSnapshot[i]; |
| | | |
| | | // 碰到B421 截断 往下收集b421里的全部内容 |
| | |
| | | HB421_tagMCTurnFightObjAction b421Pack = pack as HB421_tagMCTurnFightObjAction; |
| | | |
| | | List<GameNetPackBasic> b421PackList = new List<GameNetPackBasic>(); |
| | | |
| | | i++; // 跳过当前的B421包 |
| | | |
| | | for (; i < packQueueSnapshot.Count; i++) |
| | |
| | | else |
| | | { |
| | | b421PackList.Add(nextPack); |
| | | skipIndexes.Add(i); // 标记已被合包 |
| | | } |
| | | } |
| | | |
| | | // 可能没用了 主要就是利用一下skill的combine 暂留 看之后还有没有别的需求 |
| | | CustomB421ActionPack actionPack = CustomB421ActionPack.CreateB421ActionPack(GetGUID(b421Pack.packUID), b421PackList); |
| | | |
| | | while (actionPack.actionPacks.Count > 0) |
| | | { |
| | | GameNetPackBasic actionPackItem = actionPack.actionPacks.Dequeue(); |
| | | newPackList.Add(actionPackItem); |
| | | } |
| | | newPackList.Add(actionPack); |
| | | } |
| | | else |
| | | { |
| | |
| | | DistributeNextPackage(); |
| | | } |
| | | |
| | | // 专属于主线战斗的派发 |
| | | public bool DistributeNextPackage() |
| | | { |
| | | if (packQueue.Count > 0) |
| | |
| | | { |
| | | CustomHB426CombinePack combinePack = pack as CustomHB426CombinePack; |
| | | combinePack.Distribute(); |
| | | } |
| | | else if (pack is CustomB421ActionPack) |
| | | { |
| | | CustomB421ActionPack actionPack = pack as CustomB421ActionPack; |
| | | actionPack.Distribute(); |
| | | } |
| | | else |
| | | { |
| | |
| | | return battleField; |
| | | } |
| | | |
| | | |
| | | |
| | | public string GetGUID(ulong packUID) |
| | | { |
| | | foreach (var kv in battlePackRelationList) |
| | |
| | | } |
| | | return string.Empty; |
| | | } |
| | | |
| | | |
| | | public void DistributeNextReportPackage(string guid) |
| | | { |
| | |
| | | |
| | | battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList); |
| | | |
| | | onBattleFieldCreate?.Invoke(guid, battleField); |
| | | |
| | | if (string.IsNullOrEmpty(guid)) |
| | | { |
| | | storyBattleField = (StoryBattleField)battleField; |
| | |
| | | return; |
| | | } |
| | | |
| | | onBattleFieldDestroy?.Invoke(battleField.guid, battleField); |
| | | |
| | | string guid = battleField.guid; |
| | | |
| | | if (battleFields.ContainsKey(guid)) |
| | | { |
| | | battleFields.Remove(guid); |
| | | } |
| | | |
| | | |
| | | if (storyBattleField == battleField) |
| | | { |
| | | storyBattleField = null; |
| | | } |
| | | |
| | | GameObject.DestroyImmediate(battleField.battleRootNode.gameObject); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public void Run() |
| | | { |
| | | // if (null != storyBattleField) |
| | | // { |
| | | // storyBattleField.Run(); |
| | | // } |
| | | |
| | | foreach (var battleField in battleFields) |
| | | { |
| | | battleField.Value?.Run(); |
| | |
| | | Hand,//手动战斗 |
| | | Auto,//自动战斗 |
| | | Record,//战报 |
| | | |
| | | Stop, //暂停模式 |
| | | } |
| | |
| | | for (int i = 0; i < teamBase.serverHeroes.Length; i++) |
| | | { |
| | | TeamHero teamHero = teamBase.serverHeroes[i]; |
| | | if (teamHero != null && teamHero.heroId > 0) |
| | | if (teamHero != null) |
| | | { |
| | | BattleObject battleObj = BattleObjectFactory.CreateBattleObject(battleField, posNodeList, teamHero, _Camp); |
| | | allBattleObjDict.Add(battleObj.ObjID, battleObj); |
| | |
| | | return null; |
| | | } |
| | | |
| | | Debug.LogError("1 BattleObjectFactory.CreateBattleObject: Creating BattleObject for " + teamHero.ObjID + " at position " + teamHero.positionNum); |
| | | |
| | | GameObject goParent = posNodeList[teamHero.positionNum]; |
| | | BattleObject battleObject = new BattleObject(_battleField); |
| | | battleObject.ObjID = teamHero.ObjID; |
| | |
| | | return null; |
| | | } |
| | | |
| | | Debug.LogError("2 BattleObjectFactory.CreateBattleObject: Creating BattleObject for " + teamHero.ObjID + " at position " + teamHero.positionNum); |
| | | |
| | | |
| | | float finalScaleRate = modelScaleRate * teamHero.modelScale; |
| | | |
| | | skeletonGraphic.skeletonDataAsset = skeletonDataAsset; |
| | | skeletonGraphic.Initialize(true); |
| | | realGO.name = battleObject.ObjID.ToString(); |
| | | realGO.transform.localScale = new Vector3((_Camp == BattleCamp.Red ? 1 : -1f) * finalScaleRate, finalScaleRate, finalScaleRate); |
| | | realGO.transform.localScale = new Vector3(finalScaleRate, finalScaleRate, finalScaleRate); |
| | | battleObject.Init(realGO, teamHero, _Camp); |
| | | |
| | | Debug.LogError(realGO.name + " /3 BattleObjectFactory.CreateBattleObject: Creating BattleObject for " + teamHero.ObjID + " at position " + teamHero.positionNum); |
| | | |
| | | |
| | | return battleObject; |
| | | } |
| | | |
| | |
| | | using UnityEngine; |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public class BattleWin : UIBase |
| | |
| | | { |
| | | base.OnPreOpen(); |
| | | // SetBattleField(BattleManager.Instance.storyBattleField); |
| | | BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | base.OnPreClose(); |
| | | UIManager.Instance.CloseWindow<BattleHUDWin>(); |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | } |
| | | |
| | | private void OnCreateBattleField(string arg1, BattleField field) |
| | | { |
| | | if (field.GetType() == battleField.GetType()) |
| | | { |
| | | SetBattleField(field); |
| | | } |
| | | } |
| | | |
| | | protected override void OnOpen() |
| | |
| | | /// </summary> |
| | | public class MotionBase |
| | | { |
| | | public static float MotionTimeScale = 2f; |
| | | |
| | | public static List<string> AttackMotionList = new List<string> |
| | | { |
| | | MotionName.attack.ToString(), |
| | |
| | | private Spine.TrackEntry currentTrackEntry; |
| | | |
| | | #region 初始化方法 |
| | | |
| | | |
| | | /// <summary> |
| | | /// 初始化动画组件 |
| | | /// </summary> |
| | |
| | | public virtual void Init(SkeletonGraphic skeletonGraphic) |
| | | { |
| | | this.skeletonGraphic = skeletonGraphic; |
| | | |
| | | |
| | | if (skeletonGraphic != null) |
| | | { |
| | | spineAnimationState = skeletonGraphic.AnimationState; |
| | | spineAnimationState.TimeScale = MotionTimeScale; |
| | | skeletonGraphic.timeScale = MotionTimeScale; |
| | | |
| | | skeleton = skeletonGraphic.Skeleton; |
| | | |
| | | |
| | | // 设置动画混合时间 |
| | | if (spineAnimationState != null) |
| | | { |
| | | spineAnimationState.Data.DefaultMix = defaultMixDuration; |
| | | } |
| | | |
| | | |
| | | // 播放默认动画 |
| | | PlayAnimation(MotionName.idle, true); |
| | | |
| | | |
| | | // 设置动画事件监听 |
| | | SetupAnimationHandlers(); |
| | | } |
| | |
| | | { |
| | | Debug.LogError("缺少SkeletonGraphic组件!"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public virtual void Release() |
| | |
| | | |
| | | public virtual void Pause() |
| | | { |
| | | if (currentTrackEntry != null) |
| | | currentTrackEntry.TimeScale = 0f; |
| | | spineAnimationState.TimeScale = 0f; |
| | | skeletonGraphic.timeScale = 0f; |
| | | } |
| | | |
| | | public virtual void Resume() |
| | | { |
| | | if (currentTrackEntry != null) |
| | | currentTrackEntry.TimeScale = 1f; |
| | | spineAnimationState.TimeScale = MotionTimeScale; |
| | | skeletonGraphic.timeScale = MotionTimeScale; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | // DashToTarget(() => BackToOrigin(OnSkillFinished)); |
| | | // break; |
| | | default: |
| | | Debug.LogError("暂时不支持其他的方式释放 有需求请联系策划"); |
| | | Debug.LogError("暂时不支持其他的方式释放 有需求请联系策划" + skillConfig.SkillID); |
| | | OnSkillFinished(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | NPCConfig npcConfig = NPCConfig.Get((int)fightObj.NPCID); |
| | | Country = (HeroCountry)npcConfig.Country; |
| | | SkinID = npcConfig.SkinID; |
| | | Debug.LogError("npc skin id is " + SkinID); |
| | | modelScale = npcConfig.ModelScale; |
| | | } |
| | | else |
| | |
| | | var heroConfig = HeroConfig.Get(heroId); |
| | | Country = (HeroCountry)heroConfig.Country; |
| | | SkinID = (int)fightObj.SkinID; |
| | | Debug.LogError("normal hero skin id is " + SkinID); |
| | | modelScale = 1f; |
| | | } |
| | | |