From c90cdd78c2bf8bcfa25cec7432a5876f6085ecfb Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期五, 01 二月 2019 11:18:37 +0800
Subject: [PATCH] 3335 切换地图逻辑重构。
---
Utility/StageLoadTimeOutCatcher.cs | 54 ++++++++++++++++++++++++++++++------------------------
1 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/Utility/StageLoadTimeOutCatcher.cs b/Utility/StageLoadTimeOutCatcher.cs
index 95c3eaa..73ca8ea 100644
--- a/Utility/StageLoadTimeOutCatcher.cs
+++ b/Utility/StageLoadTimeOutCatcher.cs
@@ -5,9 +5,6 @@
public class StageLoadTimeOutCatcher : MonoBehaviour
{
-
- const int timeOut = 20;//绉�
-
public static ProtocolRecorder got0102Time;
public static ProtocolRecorder gotA126Time;
public static ProtocolRecorder gotA127Time;
@@ -15,39 +12,47 @@
public static ProtocolRecorder got0403Time;
public static ProtocolRecorder send0107Time;
- public static StageLoadTimeOutCatcher Begin(int stageId)
- {
- var go = new GameObject("StageLoadTimeOutCatcher");
- var catcher = go.AddMissingComponent<StageLoadTimeOutCatcher>();
- catcher.stageId = stageId;
-
- DontDestroyOnLoad(go);
- return catcher;
- }
+ static StageLoadTimeOutCatcher timeOutCatcher;
public int stageId = 0;
- DateTime startTime;
+ public DateTime startTime;
private void Awake()
{
startTime = DateTime.Now;
}
- public void Stop()
+ public static void Begin(int stageId)
{
- if (this.gameObject != null)
+ if (timeOutCatcher != null)
{
- Destroy(this.gameObject);
+ DestroyImmediate(timeOutCatcher.gameObject);
+ timeOutCatcher = null;
+ }
+
+ var go = new GameObject("StageLoadTimeOutCatcher");
+ var catcher = go.AddMissingComponent<StageLoadTimeOutCatcher>();
+ catcher.stageId = stageId;
+ timeOutCatcher = catcher;
+ DontDestroyOnLoad(go);
+ }
+
+ public static void Stop()
+ {
+ if (timeOutCatcher != null)
+ {
+ DestroyImmediate(timeOutCatcher.gameObject);
+ timeOutCatcher = null;
}
}
- void Update()
+ public static void ReportLoadingOverTime()
{
- if (DateTime.Now > startTime + new TimeSpan(timeOut * TimeSpan.TicksPerSecond))
+ if (timeOutCatcher != null)
{
- var title = StringUtility.Contact(stageId, "鍦板浘鍔犺浇瓒呮椂");
+ var title = StringUtility.Contact(timeOutCatcher.stageId, "鍦板浘鍔犺浇瓒呮椂");
var description = StringUtility.Contact(
- "寮�濮嬫椂闂�:", startTime.ToString("HH:mm:ss"), "$$",
+ "寮�濮嬫椂闂�:", timeOutCatcher.startTime.ToString("HH:mm:ss"), "$$",
"瓒呮椂鏃堕棿:", DateTime.Now.ToString("HH:mm:ss"), "$$",
got0102Time.ToString(), "$$",
gotA126Time.ToString(), "$$",
@@ -57,11 +62,12 @@
got0403Time.ToString());
ExceptionCatcher.ReportException(title, description);
- Stop();
+ DestroyImmediate(timeOutCatcher.gameObject);
+ timeOutCatcher = null;
}
}
- public static void RecordProtocol(GameNetSystem.SocketType socketType, string number, DateTime time)
+ public static void RecordProtocol(ServerType socketType, string number, DateTime time)
{
var recorder = new ProtocolRecorder(number, time, socketType);
switch (number)
@@ -93,9 +99,9 @@
{
public string number;
public DateTime time;
- public GameNetSystem.SocketType socketType;
+ public ServerType socketType;
- public ProtocolRecorder(string number, DateTime time, GameNetSystem.SocketType socketType)
+ public ProtocolRecorder(string number, DateTime time, ServerType socketType)
{
this.number = number;
this.time = time;
--
Gitblit v1.8.0