From 214d5fdeb691085f86498a923d5aa9fe7d001b4e Mon Sep 17 00:00:00 2001 From: bzx <496597135@qq.com> Date: Thu, 15 Jan 2026 11:38:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E9=9D=99=E6=80=81=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=BE=E5=88=B0gamelocal=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/_DefendNJ/Scripts/GameLocal.cs | 10 ++++++++++ Assets/_DefendNJ/Scripts/HttpServer.cs | 5 ++--- Assets/_DefendNJ/Scripts/Manager/GameManager.cs | 16 +++++----------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Assets/_DefendNJ/Scripts/GameLocal.cs b/Assets/_DefendNJ/Scripts/GameLocal.cs index 122d9aa7..7fe749b9 100644 --- a/Assets/_DefendNJ/Scripts/GameLocal.cs +++ b/Assets/_DefendNJ/Scripts/GameLocal.cs @@ -119,6 +119,11 @@ public class GameLocal : MonoBehaviour public GameKey gameId; + // 总游玩时长 + public int vistAllTime = (int)(60*12);//开启最后拼刺刀模式 + + public float curGameTime; + [NonSerialized] public int GameMode = 0; @@ -273,4 +278,9 @@ public class GameLocal : MonoBehaviour { endBulletPos.gameObject.SetActive(false); } + + public int GetNowTime() + { + return Mathf.RoundToInt(curGameTime); + } } diff --git a/Assets/_DefendNJ/Scripts/HttpServer.cs b/Assets/_DefendNJ/Scripts/HttpServer.cs index 1c4c3bd3..c2f0ab6f 100644 --- a/Assets/_DefendNJ/Scripts/HttpServer.cs +++ b/Assets/_DefendNJ/Scripts/HttpServer.cs @@ -262,15 +262,14 @@ public class HttpServer : MonoBehaviour private int GetGameTotalTime() { - return Mathf.FloorToInt(GameManager.Ins.vistAllTime+60*3); // 举例:1 小时(秒) + return Mathf.FloorToInt(GameLocal.Ins.vistAllTime+60*3); // 举例:1 小时(秒) } private int GetCurrentPlayTime() { - return GameManager.Ins.GetNowTime(); + return GameLocal.Ins.GetNowTime(); } - #endregion #region Shutdown diff --git a/Assets/_DefendNJ/Scripts/Manager/GameManager.cs b/Assets/_DefendNJ/Scripts/Manager/GameManager.cs index 2750652f..d6b1251f 100644 --- a/Assets/_DefendNJ/Scripts/Manager/GameManager.cs +++ b/Assets/_DefendNJ/Scripts/Manager/GameManager.cs @@ -172,10 +172,7 @@ public class GameManager : NetworkBehaviour [NonSerialized] [SyncVar] public long vistEnd = 0; - // 总游玩时长 - public int vistAllTime = (int)(60*12);//开启最后拼刺刀模式 - - public float curGameTime; + [SyncVar] public string settleData = ""; @@ -351,7 +348,7 @@ public class GameManager : NetworkBehaviour { gameState = GameState.Playing; gameMode=players.Count<=1 ? GameMode.OnePlayer : GameMode.TwoPlayers; - vistEnd = (long)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + vistAllTime; + vistEnd = (long)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + GameLocal.Ins.vistAllTime; isStart = true; ChangeBgmRpc(0); AstarPath.active.Scan(); @@ -365,7 +362,7 @@ public class GameManager : NetworkBehaviour { //GameOver(GameState.Settle); StartSpecialEvent(GameEnemyEventType.CleanUp); - }, vistAllTime); + }, GameLocal.Ins.vistAllTime); } [ClientRpc] @@ -1011,14 +1008,11 @@ public class GameManager : NetworkBehaviour // } if (isStart) { - curGameTime+=Time.deltaTime; + GameLocal.Ins.curGameTime+=Time.deltaTime; } } - public int GetNowTime() - { - return Mathf.RoundToInt(curGameTime); - } + IEnumerator CreateMortarBullet() {