yyl
9 天以前 7514dbcbb81bcbf8a517d14b0e4ddcf12c27457e
125 【战斗】战斗系统 战斗系统更新
17个文件已修改
172 ■■■■ 已修改文件
Main/Common/EventBroadcast.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/NetworkPackage/CustomServerPack/CustomB421ActionPack.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleField/BattleField.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleField/RecordActions/BattleStartAction.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleField/StoryBattleField.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleManager.cs 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleMode.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleObject/BattleObjMgr.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleObject/BattleObjectFactory.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/BattleWin.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/Motion/MotionBase.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Battle/Skill/SkillBase.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Team/TeamHero.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Common/EventBroadcast.cs
@@ -26,6 +26,10 @@
    // 防止外部实例化
    private EventBroadcast() { }
    ~EventBroadcast() {
        eventDict.Clear();
    }
    #region 添加监听
    /// <summary>
Main/Core/NetworkPackage/CustomServerPack/CustomB421ActionPack.cs
@@ -20,6 +20,21 @@
    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);
            }
        }
    }
}
Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs
@@ -24,12 +24,13 @@
    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);
    }
@@ -59,13 +60,18 @@
    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;
    }
@@ -83,6 +89,7 @@
                    combinePack = new CustomHB426CombinePack();
                    combinePack.guid = _guid;
                    combinePack.SetHB426Start(i, tag);
                    continue;
                }
                else
                {
Main/Core/NetworkPackage/DTCFile/ServerPack/HB4_FightDefine/DTCB423_tagMCTurnFightObjReborn.cs
@@ -11,6 +11,6 @@
        HB423_tagMCTurnFightObjReborn vNetData = vNetPack as HB423_tagMCTurnFightObjReborn;
        BattleField battleField = BattleManager.Instance.GetBattleField(vNetPack.packUID);
        // battleField.OnObjReborn(vNetData.ObjID);
        battleField.OnObjReborn(vNetData);
    }
}
Main/Core/NetworkPackage/DataToCtl/PackageRegedit.cs
@@ -49,8 +49,6 @@
        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));
@@ -98,10 +96,13 @@
        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));
    }
Main/System/Battle/BattleField/BattleField.cs
@@ -229,7 +229,6 @@
        //  TurnNum;    // 当前轮次
        //  Len;
        //  Msg;    //size = Len   +
        if (State == 4)
        {
            //已经结束并结算
@@ -250,7 +249,7 @@
            Debug.Log("战斗回合 : " + turnNum + ",状态 " + State);
        }
        DistributeNextPackage();
        // 做一个Action 通知UI翻下牌子 然后结束Action
        // TurnFightStateAction turnFightStateAction = new TurnFightStateAction(this, turnNum, State, FuncLineID, extendData);
@@ -363,7 +362,8 @@
        {
            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);
        }
Main/System/Battle/BattleField/RecordActions/BattleStartAction.cs
@@ -32,6 +32,8 @@
            isFinish = true;
            // 完成就开始显示UI
            EventBroadcast.Instance.Broadcast(EventName.DISPLAY_BATTLE_UI, battleField.guid, true);
            battleField.DistributeNextPackage();
        });
        isRun = true;
Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
@@ -30,6 +30,22 @@
    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;
Main/System/Battle/BattleField/StoryBattleField.cs
@@ -140,6 +140,8 @@
    public override void OnBattleEnd(JsonData turnFightStateData)
    {
        base.OnBattleEnd(turnFightStateData);
        HaveRest();
    }
    // public override void Run()
Main/System/Battle/BattleManager.cs
@@ -1,9 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
using LitJson;
using System;
public class BattleManager : GameSystemManager<BattleManager>
{
@@ -14,10 +12,13 @@
    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;
    }
@@ -64,7 +65,6 @@
    {
    }
    #region 截断网络派发包 只收入当前包的后续 b425是主线的 非主线的包并不会走b425
    private bool allow = true;
@@ -116,10 +116,13 @@
        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里的全部内容
@@ -128,7 +131,6 @@
                HB421_tagMCTurnFightObjAction b421Pack = pack as HB421_tagMCTurnFightObjAction;
                List<GameNetPackBasic> b421PackList = new List<GameNetPackBasic>();
                i++;    // 跳过当前的B421包
                for (; i < packQueueSnapshot.Count; i++)
@@ -144,17 +146,14 @@
                    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
            {
@@ -187,6 +186,7 @@
        DistributeNextPackage();
    }
    //  专属于主线战斗的派发
    public bool DistributeNextPackage()
    {
        if (packQueue.Count > 0)
@@ -197,6 +197,11 @@
            {
                CustomHB426CombinePack combinePack = pack as CustomHB426CombinePack;
                combinePack.Distribute();
            }
            else if (pack is CustomB421ActionPack)
            {
                CustomB421ActionPack actionPack = pack as CustomB421ActionPack;
                actionPack.Distribute();
            }
            else
            {
@@ -264,8 +269,6 @@
        return battleField;
    }
    public string GetGUID(ulong packUID)
    {
        foreach (var kv in battlePackRelationList)
@@ -277,7 +280,6 @@
        }
        return string.Empty;
    }
    public void DistributeNextReportPackage(string guid)
    {
@@ -311,6 +313,8 @@
        battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList);
        onBattleFieldCreate?.Invoke(guid, battleField);
        if (string.IsNullOrEmpty(guid))
        {
            storyBattleField = (StoryBattleField)battleField;
@@ -331,17 +335,21 @@
            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);
    }
@@ -363,11 +371,6 @@
    public void Run()
    {
        // if (null != storyBattleField)
        // {
        //     storyBattleField.Run();
        // }
        foreach (var battleField in battleFields)
        {
            battleField.Value?.Run();
Main/System/Battle/BattleMode.cs
@@ -5,4 +5,6 @@
    Hand,//手动战斗
    Auto,//自动战斗
    Record,//战报
    Stop,   //暂停模式
}
Main/System/Battle/BattleObject/BattleObjMgr.cs
@@ -42,7 +42,7 @@
        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);
Main/System/Battle/BattleObject/BattleObjectFactory.cs
@@ -29,6 +29,8 @@
            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;
@@ -43,13 +45,20 @@
            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;
    }
Main/System/Battle/BattleWin.cs
@@ -1,4 +1,5 @@
using UnityEngine;
using System;
using UnityEngine;
using UnityEngine.UI;
public class BattleWin : UIBase
@@ -41,12 +42,22 @@
    {
        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()
Main/System/Battle/Motion/MotionBase.cs
@@ -10,6 +10,8 @@
/// </summary>
public class MotionBase
{
    public static float MotionTimeScale = 2f;
    public static List<string> AttackMotionList = new List<string>
    {
        MotionName.attack.ToString(),
@@ -42,7 +44,7 @@
    private Spine.TrackEntry currentTrackEntry;
    #region 初始化方法
    /// <summary>
    /// 初始化动画组件
    /// </summary>
@@ -50,21 +52,24 @@
    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();
        }
@@ -72,6 +77,8 @@
        {
            Debug.LogError("缺少SkeletonGraphic组件!");
        }
    }
    
    public virtual void Release()
@@ -303,14 +310,14 @@
    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
Main/System/Battle/Skill/SkillBase.cs
@@ -135,7 +135,8 @@
            //     DashToTarget(() => BackToOrigin(OnSkillFinished));
            //     break;
            default:
                Debug.LogError("暂时不支持其他的方式释放 有需求请联系策划");
                Debug.LogError("暂时不支持其他的方式释放 有需求请联系策划" + skillConfig.SkillID);
                OnSkillFinished();
                break;
        }
    }
Main/System/Team/TeamHero.cs
@@ -37,6 +37,7 @@
            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
@@ -45,6 +46,7 @@
            var heroConfig = HeroConfig.Get(heroId);
            Country = (HeroCountry)heroConfig.Country;
            SkinID = (int)fightObj.SkinID;
            Debug.LogError("normal hero skin id is " + SkinID);
            modelScale = 1f;
        }