From 8fdc47d31413620d3427adb16d93cc4218cbf77b Mon Sep 17 00:00:00 2001
From: liuyu <272912176@qq.com>
Date: Wed, 4 Sep 2024 16:52:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=9C=BA=E6=99=AF=E7=BC=93?=
=?UTF-8?q?=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Assets/Scripts/CXX/Score/ScoreBase.cs | 7 +++-
Assets/Scripts/CXX/Score/Score_1002.cs | 34 +++++++++++++++++++
.../Scripts/Project/Manager/ReconnectMgr.cs | 13 +++++++
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/Assets/Scripts/CXX/Score/ScoreBase.cs b/Assets/Scripts/CXX/Score/ScoreBase.cs
index 404e12d..87eb5c6 100644
--- a/Assets/Scripts/CXX/Score/ScoreBase.cs
+++ b/Assets/Scripts/CXX/Score/ScoreBase.cs
@@ -72,10 +72,15 @@ public abstract class ScoreBase : MonoBehaviour
}
///
- /// 设置科目得分,用于断线重连恢复
+ /// 设置科目得分,用于断线重连恢复 HQB
///
public void setCurrentScore(float _score)
{
this.currentScore = _score;
}
+
+ ///
+ /// 记录现场环境中scoreBase的各项List缓存
+ ///
+ public abstract void SaveSceneBufferList();
}
diff --git a/Assets/Scripts/CXX/Score/Score_1002.cs b/Assets/Scripts/CXX/Score/Score_1002.cs
index 0b99f60..8cfec02 100644
--- a/Assets/Scripts/CXX/Score/Score_1002.cs
+++ b/Assets/Scripts/CXX/Score/Score_1002.cs
@@ -3,6 +3,21 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
+using LitJson;
+
+///
+/// 转存场景buffer
+///
+public class BufferTemp_1002
+{
+ public List TestPen3list;
+ public List InSwitchCloseYDList;
+ public List InSwitchOpenYDList;
+ public List currentunInstallJieXian;
+ public List currentInstallJieXian;
+ public List installCover;
+ public List currentInstallTestJieXian;
+}
public class Score_1002 : ScoreBase
{
@@ -445,4 +460,23 @@ public class Score_1002 : ScoreBase
return false;
}
+
+ ///
+ /// 保存场景中List缓存,用于断线重连
+ ///
+ ///
+ public override void SaveSceneBufferList()
+ {
+ BufferTemp_1002 tmp = new BufferTemp_1002();
+ tmp.TestPen3list = TestPen3list;
+ tmp.InSwitchCloseYDList = InSwitchCloseYDList;
+ tmp.InSwitchOpenYDList = InSwitchOpenYDList;
+ tmp.currentunInstallJieXian = currentunInstallJieXian;
+ tmp.currentInstallJieXian = currentInstallJieXian;
+ tmp.installCover = installCover;
+ tmp.currentInstallTestJieXian = currentInstallTestJieXian;
+ string sceneInfo = JsonConvert.SerializeObject(tmp, Formatting.Indented);
+ Debug.Log("==场景信息:" + sceneInfo);
+ //throw new System.NotImplementedException();
+ }
}
diff --git a/Assets/Scripts/Project/Manager/ReconnectMgr.cs b/Assets/Scripts/Project/Manager/ReconnectMgr.cs
index 668eb98..e757b2a 100644
--- a/Assets/Scripts/Project/Manager/ReconnectMgr.cs
+++ b/Assets/Scripts/Project/Manager/ReconnectMgr.cs
@@ -123,6 +123,15 @@ public class ReconnectMgr : SingletonMono
File.WriteAllText(localStatPath, UserJson);
}
+ ///
+ /// 记录场景中的信息
+ ///
+ public void RealtimeSceneWriter()
+ {
+ ScoreBase scoreBase = FindAnyObjectByType();
+ scoreBase.SaveSceneBufferList();
+ }
+
///
/// 读取用户状态(先使用同步,后用异步)
///
@@ -271,6 +280,10 @@ public class ReconnectMgr : SingletonMono
// Update is called once per frame
void Update()
{
+ if (Input.GetKeyDown(KeyCode.U))
+ {
+ RealtimeSceneWriter();
+ }
if (Input.GetKeyDown(KeyCode.T))//测试用,按T读取状态保存
{
RealtimeStatWriter();