少年修仙传客户端代码仓库
client_Zxw
2018-08-30 861522f900702bf928f4ee4857bfef90e1939711
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
5个文件已修改
2个文件已添加
170 ■■■■ 已修改文件
Core/NetworkPackage/DTCFile/ServerPack/HA1_Sys/DTCA127_tagMCStartChangeMap.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Stage/StageManager.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Debug/DebugLogRecorder.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/ExceptionCatcher.cs 26 ●●●●● 补丁 | 查看 | 原始文档 | 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
@@ -46,14 +46,6 @@
        base.Done(vNetPack);
        DEBUG_A127 = true;
        if (DTC0403_tagPlayerLoginLoadOK.neverLoginOk)
        {
#if !UNITY_EDITOR
            // OperationLogCollect.Instance.BugReport("A127错误", "在首次登录未完成时客户端收到A127 ");
#endif
            Debug.LogError("在首次登录未完成时客户端收到A127!请通知蔡瀚");
        }
        var package = vNetPack as HA127_tagMCStartChangeMap;
        DEBUG_STEP = 0;
@@ -139,7 +131,6 @@
        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
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,6 +168,8 @@
        SystemSetting.Instance.LetFPSUnLimit();
        try
        {
        WindowCenter.Instance.asyncLoad.StopAllTasks();
        //为什么在这个地方要调用两次关闭其他窗口的接口呢,这个水就深了。
        //因为有些界面被关闭的时候,会去打开主界面,所以,还得再关闭一次关闭其他窗口的界面,防止主界面被意外开启。
@@ -199,6 +207,11 @@
                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;
        try
        {
        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,6 +270,8 @@
                yield return null;
            }
            try
            {
            // 如果用户尚未完成前期战斗部分
            if (!PreFightMission.Instance.IsFinished())
            {
@@ -261,6 +282,11 @@
                SceneManager.LoadScene("Map000_Xsdt", LoadSceneMode.Additive);
            }
        }
            catch (System.Exception ex)
            {
                ExceptionCatcher.ReportException("场景加载 Step5", ex);
            }
        }
        yield return null;
        loadingProgress = loadingProgress + 0.1f;
@@ -268,13 +294,27 @@
        // 场景加载完就可以确定玩家位置了, 不需要等待具体场景的逻辑初始化
        if (_stageId > 2)
        {
            try
            {
            InitHero();
        }
            catch (System.Exception ex)
            {
                ExceptionCatcher.ReportException("场景加载 Step6", ex);
            }
        }
        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();
#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;
    }
}