Merge remote-tracking branch 'origin/main' into main_ZYT

This commit is contained in:
ZYT
2026-01-15 13:38:21 +08:00
5 changed files with 21 additions and 15 deletions

View File

@@ -125,6 +125,11 @@ public class GameLocal : MonoBehaviour
public Place place = Place.Company1Floor;
public GameKey gameId;
// 总游玩时长
public int vistAllTime = (int)(60 * 10f);
public float curGameTime = 0;
public GameObject Scene;
public GameObject Settle;
@@ -242,6 +247,11 @@ public class GameLocal : MonoBehaviour
{
return (long)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
}
public int GetNowTime()
{
return Mathf.RoundToInt(curGameTime);
}
public string ConvertTimestampToDateTime(long timestamp)
{

View File

@@ -101,10 +101,7 @@ public class GameManager : NetworkBehaviour
[NonSerialized]
[SyncVar]
public long vistEnd = 0;
// 总游玩时长
public int vistAllTime = (int)(60 * 10f);
public float curGameTime = 0;
[SyncVar]
public string settleData = "";
@@ -226,7 +223,7 @@ public class GameManager : NetworkBehaviour
public void GameStart()
{
gameState = GameState.Playing;
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;
ChangeBgmRpc(1);
// CreateTowers();
AstarPath.active.Scan();
@@ -736,13 +733,10 @@ public class GameManager : NetworkBehaviour
{
//服务器计算剩余时间并同步
syncRemainingTime = GetLessTimeSeconds();
curGameTime+=Time.deltaTime;
GameLocal.Ins.curGameTime+=Time.deltaTime;
}
}
public int GetNowTime()
{
return Mathf.RoundToInt(curGameTime);
}
}

View File

@@ -261,12 +261,12 @@ public class HttpServer : MonoBehaviour
private int GetGameTotalTime()
{
return Mathf.FloorToInt(GameManager.Ins.vistAllTime); // 举例1 小时(秒)
return Mathf.FloorToInt(GameLocal.Ins.vistAllTime); // 举例1 小时(秒)
}
private int GetCurrentPlayTime()
{
return GameManager.Ins.GetNowTime();
return GameLocal.Ins.GetNowTime();
}