少年修仙传客户端代码仓库
client_Zxw
2018-08-30 861522f900702bf928f4ee4857bfef90e1939711
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
5个文件已修改
2个文件已添加
368 ■■■■■ 已修改文件
Core/NetworkPackage/DTCFile/ServerPack/HA1_Sys/DTCA127_tagMCStartChangeMap.cs 113 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Stage/StageManager.cs 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Debug/DebugLogRecorder.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/ExceptionCatcher.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/StageLoadTimeOutCatcher.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/StageLoadTimeOutCatcher.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/TransformExtension.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/NetworkPackage/DTCFile/ServerPack/HA1_Sys/DTCA127_tagMCStartChangeMap.cs
@@ -23,10 +23,10 @@
        int _realMapDataID = PlayerDatas.Instance.baseData.MapID;
        var _mapConfig = Config.Instance.Get<MapConfig>(_realMapDataID);
        if (_mapConfig.MapFBType != 0)
        {
            DungeonModel _model = ModelCenter.Instance.GetModel<DungeonModel>();
            _realMapDataID = _model.GetDungeonDataIdByMapId(_realMapDataID);
        if (_mapConfig.MapFBType != 0)
        {
            DungeonModel _model = ModelCenter.Instance.GetModel<DungeonModel>();
            _realMapDataID = _model.GetDungeonDataIdByMapId(_realMapDataID);
        }
        var _key = _realMapDataID * 1000 + LineID;
@@ -44,16 +44,8 @@
    public override void Done(GameNetPackBasic vNetPack)
    {
        base.Done(vNetPack);
        DEBUG_A127 = true;
        if (DTC0403_tagPlayerLoginLoadOK.neverLoginOk)
        {
#if !UNITY_EDITOR
            // OperationLogCollect.Instance.BugReport("A127错误", "在首次登录未完成时客户端收到A127 ");
#endif
            Debug.LogError("在首次登录未完成时客户端收到A127!请通知蔡瀚");
        }
        DEBUG_A127 = true;
        var package = vNetPack as HA127_tagMCStartChangeMap;
        DEBUG_STEP = 0;
@@ -70,23 +62,23 @@
        if (_mapConfig.MapFBType != 0)
        {
            DungeonModel _model = ModelCenter.Instance.GetModel<DungeonModel>();
            DungeonModel _model = ModelCenter.Instance.GetModel<DungeonModel>();
            _realMapDataID = _model.GetDungeonDataIdByMapId(_realMapDataID);
            if (package.MapID != 52020 && package.MapID != 52010)
            {
            if (package.MapID != 52020 && package.MapID != 52010)
            {
                LineID = package.FuncLineID;
            }
        }
        var _mapResConfig = GetMapResourcesConfig(_realMapDataID, LineID);
        if (_mapResConfig == null)
        {
            LineID = 0;
            _mapResConfig = GetMapResourcesConfig(_realMapDataID, LineID);
        }
        }
        var _mapResConfig = GetMapResourcesConfig(_realMapDataID, LineID);
        if (_mapResConfig == null)
        {
            LineID = 0;
            _mapResConfig = GetMapResourcesConfig(_realMapDataID, LineID);
        }
        if (_mapResConfig != null)
        {
            GA_Hero.MapOffset.x = _mapResConfig.MapOffset.x;
@@ -96,8 +88,8 @@
        {
            GA_Hero.MapOffset.x = 0;
            GA_Hero.MapOffset.z = 0;
        }
        DEBUG_STEP = 1;
        }
        DEBUG_STEP = 1;
        BossShowModel.Instance.reqDungeonLineId = package.FuncLineID;
        GA_Hero _hero = PlayerDatas.Instance.hero;
@@ -106,14 +98,14 @@
        {
            _hero.ShowArrow(false);
            _hero.SwitchGrayName(false);
            if (StatusMgr.Instance.IsExist(PlayerDatas.Instance.PlayerId, StatusMgr.Instance.redNameBuffID))
            {
                _hero.SwitchRedName(true);
            if (StatusMgr.Instance.IsExist(PlayerDatas.Instance.PlayerId, StatusMgr.Instance.redNameBuffID))
            {
                _hero.SwitchRedName(true);
            }
        }
        GAMgr.Instance.UnInit();
        DTCA713_tagMCDynamicBarrierState.Clear();
        GAMgr.Instance.UnInit();
        DTCA713_tagMCDynamicBarrierState.Clear();
        DEBUG_STEP = 2;
        GameObjectPoolManager.Instance.UnLoadAll();
@@ -121,10 +113,10 @@
        if (PlayerDatas.Instance.baseData.MapID == package.MapID)
        {
            WindowCenter.Instance.Close<LoadingWin>();
        }
        LocalSave.SetInt(RECORDPREMAPID_KEY, PlayerDatas.Instance.baseData.MapID);
        }
        LocalSave.SetInt(RECORDPREMAPID_KEY, PlayerDatas.Instance.baseData.MapID);
        DEBUG_STEP = 3;
        PlayerDatas.Instance.baseData.MapID = (ushort)package.MapID;
@@ -134,21 +126,20 @@
        {
            PlayerDatas.Instance.hero.LockTarget = null;
            PlayerDatas.Instance.hero.SelectTarget = null;
        }
        }
        DungeonStage.CurrentMapType = (MapType)_mapConfig.MapFBType;
        if (StageManager.Instance.currentMapResId == _mapResConfig.ID)
        {
            // OperationLogCollect.Instance.BugReport("Warning", "A127 Load Same MapID:" + _mapResConfig.ID);
#if UNITY_EDITOR
            Debug.LogFormat("DTCA127_tagMCStartChangeMap出现加载相同地图行为:" + _mapResConfig.ID);
#endif
            return;
        }
        StageManager.Instance.isServerPreparing = true;
        DEBUG_STEP = 4;
        }
        StageManager.Instance.isServerPreparing = true;
        DEBUG_STEP = 4;
        switch (_mapConfig.MapFBType)
        {
            case 0:
@@ -156,8 +147,8 @@
            default:
                ModelCenter.Instance.GetModel<DungeonModel>().ResetDungeonBufData();
                break;
        }
        }
        DEBUG_STEP = 5;
        switch (package.MapID)
        {
@@ -173,22 +164,22 @@
            default:
                StageManager.Instance.Load<DungeonStage>(_mapConfig.MapID);
                break;
        }
        DEBUG_STEP = 6;
        }
        DEBUG_STEP = 6;
    }
    public static MapResourcesConfig GetMapResourcesConfig(int mapID, int lineID)
    {
    public static MapResourcesConfig GetMapResourcesConfig(int mapID, int lineID)
    {
        int _key = mapID * 1000 + lineID;
        int _mapResourceID = -1;
        MapResourcesConfig _mapResConfig = null;
        if (mapIdDict.TryGetValue(_key, out _mapResourceID))
        {
            _mapResConfig = Config.Instance.Get<MapResourcesConfig>(_mapResourceID);
        }
        else
        {
        }
        else
        {
            foreach (var _config in Config.Instance.GetAllValues<MapResourcesConfig>())
            {
                if (mapID == _config.DataID
@@ -199,10 +190,10 @@
                    mapIdDict[_key] = _mapResourceID;
                    break;
                }
            }
        }
        return _mapResConfig;
            }
        }
        return _mapResConfig;
    }
}
Fight/Stage/StageManager.cs
@@ -76,6 +76,8 @@
    public bool isLoading { get; private set; }
    StageLoadTimeOutCatcher loadTimeOutCatcher;
    public StageManager()
    {
        DebugEx.LogFormat("初始化StageManager");
@@ -83,6 +85,9 @@
    public void Load<T>(int stageId) where T : Stage
    {
        loadTimeOutCatcher = StageLoadTimeOutCatcher.Begin(stageId);
        // 读取配置的方式创建场景
        var mapResConfig = DTCA127_tagMCStartChangeMap.GetMapResourcesConfig();
@@ -129,10 +134,10 @@
    {
        if (currentMapResId != 0 && currentMapResId == mapResConfigID)
        {
            //OperationLogCollect.Instance.BugReport("Warning", "StageManager Load Same MapID:" + mapResConfigID);
#if UNITY_EDITOR
            Debug.LogFormat("StageManager出现加载相同地图行为:" + mapResConfigID);
#endif
            ExceptionCatcher.ReportException("场景加载 Step1", StringUtility.Contact("StageManager出现加载相同地图行为:", mapResConfigID));
            yield break;
        }
@@ -148,6 +153,7 @@
        catch (Exception ex)
        {
            Debug.LogError("场景加载开始事件发生异常:" + ex);
            ExceptionCatcher.ReportException("场景加载 Step2", ex);
        }
        var progressBuf = loadingProgress = 0f;
@@ -162,42 +168,49 @@
        SystemSetting.Instance.LetFPSUnLimit();
        WindowCenter.Instance.asyncLoad.StopAllTasks();
        //为什么在这个地方要调用两次关闭其他窗口的接口呢,这个水就深了。
        //因为有些界面被关闭的时候,会去打开主界面,所以,还得再关闭一次关闭其他窗口的界面,防止主界面被意外开启。
        switch (_stageId)
        try
        {
            case 2:
                WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.Login);
                WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                if (!WindowCenter.Instance.CheckOpen<LaunchBackGroundWin>())
                {
                    WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
                }
            WindowCenter.Instance.asyncLoad.StopAllTasks();
            //为什么在这个地方要调用两次关闭其他窗口的接口呢,这个水就深了。
            //因为有些界面被关闭的时候,会去打开主界面,所以,还得再关闭一次关闭其他窗口的界面,防止主界面被意外开启。
            switch (_stageId)
            {
                case 2:
                    WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.Login);
                    WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                    if (!WindowCenter.Instance.CheckOpen<LaunchBackGroundWin>())
                    {
                        WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
                    }
                WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                break;
            case 1:
                WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.Launch);
                WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                if (!WindowCenter.Instance.CheckOpen<LaunchBackGroundWin>())
                {
                    WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
                }
                    WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                    break;
                case 1:
                    WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.Launch);
                    WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                    if (!WindowCenter.Instance.CheckOpen<LaunchBackGroundWin>())
                    {
                        WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
                    }
                WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                break;
            default:
                WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.SelectRole);
                WindowCenter.Instance.CloseOthers<LoadingWin>();
                if (!WindowCenter.Instance.CheckOpen<LoadingWin>())
                {
                    LoadingWin.targetMapResId = currentMapResId;
                    WindowCenter.Instance.Open<LoadingWin>(true);
                }
                    WindowCenter.Instance.CloseOthers<LaunchBackGroundWin>();
                    break;
                default:
                    WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.SelectRole);
                    WindowCenter.Instance.CloseOthers<LoadingWin>();
                    if (!WindowCenter.Instance.CheckOpen<LoadingWin>())
                    {
                        LoadingWin.targetMapResId = currentMapResId;
                        WindowCenter.Instance.Open<LoadingWin>(true);
                    }
                WindowCenter.Instance.CloseOthers<LoadingWin>();
                break;
                    WindowCenter.Instance.CloseOthers<LoadingWin>();
                    break;
            }
        }
        catch (System.Exception ex)
        {
            ExceptionCatcher.ReportException("场景加载 Step3", ex);
        }
        loadingProgress += 0.05f;
@@ -225,15 +238,21 @@
        GC.Collect();
        loadingProgress += 0.1f;
        if (!AssetSource.sceneFromEditor)
        try
        {
            AssetBundleUtility.Instance.UnloadAssetBundle("maps/map000_xsdt", true, false);
            AssetBundleUtility.Instance.UnloadAssetBundle(GetAssetBundleNameByStageId(lastMapId, lastCurrentMapResId), true, false);
            AssetBundleUtility.Instance.Sync_LoadAll(GetAssetBundleNameByStageId(currentMapId, currentMapResId));
            if (!AssetSource.sceneFromEditor)
            {
                AssetBundleUtility.Instance.UnloadAssetBundle("maps/map000_xsdt", true, false);
                AssetBundleUtility.Instance.UnloadAssetBundle(GetAssetBundleNameByStageId(lastMapId, lastCurrentMapResId), true, false);
                AssetBundleUtility.Instance.Sync_LoadAll(GetAssetBundleNameByStageId(currentMapId, currentMapResId));
            }
        }
        catch (System.Exception ex)
        {
            ExceptionCatcher.ReportException("场景加载 Step4", ex);
        }
        var sceneLoadOperation = SceneManager.LoadSceneAsync(_resources);
        progressBuf = loadingProgress;
        timer = 0f;
        duration = 1f;
@@ -251,14 +270,21 @@
                yield return null;
            }
            // 如果用户尚未完成前期战斗部分
            if (!PreFightMission.Instance.IsFinished())
            try
            {
                if (!AssetSource.sceneFromEditor)
                // 如果用户尚未完成前期战斗部分
                if (!PreFightMission.Instance.IsFinished())
                {
                    AssetBundleUtility.Instance.Sync_LoadAll("maps/map000_xsdt");
                    if (!AssetSource.sceneFromEditor)
                    {
                        AssetBundleUtility.Instance.Sync_LoadAll("maps/map000_xsdt");
                    }
                    SceneManager.LoadScene("Map000_Xsdt", LoadSceneMode.Additive);
                }
                SceneManager.LoadScene("Map000_Xsdt", LoadSceneMode.Additive);
            }
            catch (System.Exception ex)
            {
                ExceptionCatcher.ReportException("场景加载 Step5", ex);
            }
        }
@@ -268,13 +294,27 @@
        // 场景加载完就可以确定玩家位置了, 不需要等待具体场景的逻辑初始化
        if (_stageId > 2)
        {
            InitHero();
            try
            {
                InitHero();
            }
            catch (System.Exception ex)
            {
                ExceptionCatcher.ReportException("场景加载 Step6", ex);
            }
        }
        GameObject _gameObject = new GameObject(string.Format("__Stage_{0}_", _resources));
        m_CurrentStage = _gameObject.AddComponent<T>();
        m_StageType = m_CurrentStage is DungeonStage ? Stage.E_StageType.Dungeon : Stage.E_StageType.MainCity;
        m_CurrentStage.mapId = _stageId;
        try
        {
            GameObject _gameObject = new GameObject(string.Format("__Stage_{0}_", _resources));
            m_CurrentStage = _gameObject.AddComponent<T>();
            m_StageType = m_CurrentStage is DungeonStage ? Stage.E_StageType.Dungeon : Stage.E_StageType.MainCity;
            m_CurrentStage.mapId = _stageId;
        }
        catch (System.Exception ex)
        {
            ExceptionCatcher.ReportException("场景加载 Step7", ex);
        }
        yield return null;
@@ -325,13 +365,22 @@
        catch (Exception ex)
        {
            Debug.LogError("场景加载完成事件发生异常:" + ex);
            ExceptionCatcher.ReportException("场景加载 Step8", ex);
        }
        if (loadTimeOutCatcher != null)
        {
            loadTimeOutCatcher.Stop();
        }
        loadTimeOutCatcher = null;
        Application.backgroundLoadingPriority = ThreadPriority.BelowNormal;
        isLoading = false;
        DebugEx.LogFormat("StageManager => Load Scene : {0} Finished.", _resources);
        WindowCenter.Instance.Close<LoadingWin>();
        SystemSetting.Instance.SetFPSLimit(SystemSetting.Instance.GetFPSLimit());
    }
    IEnumerator BackToNoviceVillageWhileMapResourceLacked(int _mapResId)
System/Debug/DebugLogRecorder.cs
@@ -18,11 +18,6 @@
        private void Awake()
        {
            if (DebugUtility.Instance.debugAccount)
            {
                Application.logMessageReceived += AddLogRenderer;
                Application.logMessageReceivedThreaded += AddLogRenderer;
            }
        }
        private void OnEnable()
@@ -55,11 +50,6 @@
        private void OnDestroy()
        {
            if (DebugUtility.Instance.debugAccount)
            {
                Application.logMessageReceived -= AddLogRenderer;
                Application.logMessageReceivedThreaded -= AddLogRenderer;
            }
        }
        public void SetLogVisible()
Utility/ExceptionCatcher.cs
@@ -7,30 +7,25 @@
{
    public static void Init()
    {
        if (VersionConfig.Get().versionAuthority == VersionAuthority.Release)
        {
#if !UNITY_EDITOR
            BuglyAgent.ConfigDebugMode(false);
            BuglyAgent.ConfigAutoReportLogLevel(VersionConfig.Get().versionAuthority == VersionAuthority.Release ? LogSeverity.LogException : LogSeverity.LogError);
            BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogException);
            BuglyAgent.ConfigDefault(VersionConfig.Get().appId, VersionConfig.Get().version, SystemInfo.deviceName, 0);
#if UNITY_ANDROID
            BuglyAgent.InitWithAppId("bff7374864");
#elif UNITY_IPHONE || UNITY_IOS
            BuglyAgent.InitWithAppId("553c67c376");
#endif
#endif
        }
#endif
    }
    public static void Catch()
    {
        if (VersionConfig.Get().versionAuthority == VersionAuthority.Release)
        {
#if !UNITY_EDITOR
            BuglyAgent.EnableExceptionHandler();
        BuglyAgent.EnableExceptionHandler();
#endif
        }
    }
    public static void Abort()
@@ -38,4 +33,19 @@
    }
    public static void ReportException(string name, System.Exception ex)
    {
#if !UNITY_EDITOR
        BuglyAgent.ReportException(name, ex.Message, ex.StackTrace);
#endif
    }
    public static void ReportException(string name, string message)
    {
#if !UNITY_EDITOR
        BuglyAgent.ReportException(name, message, "");
#endif
    }
}
Utility/StageLoadTimeOutCatcher.cs
New file
@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class StageLoadTimeOutCatcher : MonoBehaviour
{
    const int timeOut = 20;//秒
    public static DateTime got0109Time = DateTime.MinValue;
    public static StageLoadTimeOutCatcher Begin(int stageId)
    {
        var go = new GameObject("StageLoadTimeOutCatcher");
        var catcher = go.AddMissingComponent<StageLoadTimeOutCatcher>();
        catcher.stageId = stageId;
        DontDestroyOnLoad(go);
        return catcher;
    }
    public int stageId = 0;
    DateTime startTime;
    private void Awake()
    {
        startTime = DateTime.Now;
    }
    public void Stop()
    {
        if (this.gameObject != null)
        {
            Destroy(this.gameObject);
        }
    }
    void Update()
    {
        if (DateTime.Now > startTime + new TimeSpan(timeOut * TimeSpan.TicksPerSecond))
        {
            var title = "地图加载超时";
            var description = StringUtility.Contact(
                                        "加载地图:", stageId, ";",
                                        "开始时间:", startTime.ToString("HH:mm:ss"), ";",
                                        "超时时间:", DateTime.Now.ToString("HH:mm:ss"),
                                        "服务器是否准备完毕:", StageManager.Instance.isServerPreparing,
                                        "上一次接收到0109的时间:", got0109Time);
            ExceptionCatcher.ReportException(title, description);
            Stop();
        }
    }
}
Utility/StageLoadTimeOutCatcher.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c94dd2ad545844d41ae32b38c84f5370
timeCreated: 1535611323
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Utility/TransformExtension.cs
@@ -143,4 +143,9 @@
    }
    public static Transform GetRoot(this Transform transform)
    {
        return transform && transform.parent ? GetRoot(transform.parent) : transform;
    }
}