添加Trigger状态记录函数

This commit is contained in:
liuyu 2024-09-05 11:14:16 +08:00
parent 3c9b1c9a8a
commit b0d1ac0edd
16 changed files with 216 additions and 6 deletions

View File

@ -3,7 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Device_Base : PermanentTriggerBase
public abstract class Device_Base : PermanentTriggerBase
{
/// <summary>
/// 设备类型

View File

@ -39,4 +39,19 @@ public class Device_Seal : Device_Base
isCut = false;
gameObject.SetActive(true);
}
/// <summary>
/// ¶ÏÏßÖØÁ¬
/// </summary>
/// <param name="triggerInfo"></param>
/// <exception cref="NotImplementedException"></exception>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
if (triggerInfo != "")
isCut = bool.Parse(triggerInfo);
}
public override string SaveCurrentTriggerStat()
{
return isCut.ToString();
}
}

View File

@ -6,6 +6,18 @@ using UnityEngine;
/// 低压电流互感器
/// </summary>
public class Device_LowVoltageCurrentTransformer : Device_Base
{
/// <summary>
/// 不需要
/// </summary>
/// <param name="triggerInfo"></param>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
}
public override string SaveCurrentTriggerStat()
{
return "";
}
}

View File

@ -218,4 +218,19 @@ public class Device_3Phase4WireMeter : Device_Base
CallScoreAction(true);
});
}
/// <summary>
/// ²»ÐèÒª
/// </summary>
/// <returns></returns>
public override string SaveCurrentTriggerStat()
{
return "";
//throw new System.NotImplementedException();
}
public override void LoadCurrentTriggerStat(string triggerInfo)
{
//throw new System.NotImplementedException();
}
}

View File

@ -54,4 +54,21 @@ public class Device_NamePlate : Device_Base
}
}
}
/// <summary>
/// ¶ÏÏßÖØÁ¬
/// </summary>
/// <param name="triggerInfo"></param>
/// <exception cref="System.NotImplementedException"></exception>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
if (triggerInfo != "")
isChecked = bool.Parse(triggerInfo);
//throw new System.NotImplementedException();
}
public override string SaveCurrentTriggerStat()
{
return isChecked.ToString();
//throw new System.NotImplementedException();
}
}

View File

@ -63,5 +63,30 @@ public class Device_Switch : Device_Base
transform.localEulerAngles = new Vector3(0, 45, 0);
}
/// <summary>
/// ¶ÏÏßÖØÁ¬
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public override string SaveCurrentTriggerStat()
{
return isOpen.ToString();
//throw new NotImplementedException();
}
public override void LoadCurrentTriggerStat(string triggerInfo)
{
if (triggerInfo != "")
{
if (bool.Parse(triggerInfo))
{
OpenState();
}
else
{
CloseState();
}
}
//throw new NotImplementedException();
}
}

View File

@ -1,4 +1,6 @@
using DG.Tweening;
using LitJson;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -89,4 +91,35 @@ public class Device_CabinetDoor : Device_Base
transform.Find("¼ÆÁ¿¹ñËø2/¼ÆÁ¿¹ñËø3").localEulerAngles = Vector3.zero;
}
/// <summary>
/// ¶ÏÏßÖØÁ¬
/// </summary>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
class tempCabin {
public bool isOpen;
public bool hasElectricity;
}
public override string SaveCurrentTriggerStat()
{
tempCabin tmp = new tempCabin();
tmp.hasElectricity = hasElectricity;
tmp.isOpen = isOpen;
return JsonConvert.SerializeObject(tmp);
//throw new System.NotImplementedException();
}
public override void LoadCurrentTriggerStat(string triggerInfo)
{
tempCabin tmp = JsonMapper.ToObject<tempCabin>(triggerInfo);
tmp.hasElectricity= hasElectricity;
if (tmp.isOpen)
{
OpenState();
}else
{
CloseState();
}
//throw new System.NotImplementedException();
}
}

View File

@ -16,4 +16,20 @@ public class Device_Socket : Device_Base
/// </summary>
public bool hasElectricity;
/// <summary>
/// ¶ÏÏßÖØÁ¬±£´æ
/// </summary>
/// <param name="triggerInfo"></param>
/// <exception cref="System.NotImplementedException"></exception>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
if (triggerInfo != "")
hasElectricity = bool.Parse(triggerInfo);
}
public override string SaveCurrentTriggerStat()
{
return hasElectricity.ToString();
}
}

View File

@ -16,4 +16,19 @@ public class Device_Sundries : Device_Base
}
}
/// <summary>
/// ²»ÐèÒª
/// </summary>
/// <param name="triggerInfo"></param>
/// <exception cref="System.NotImplementedException"></exception>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
throw new System.NotImplementedException();
}
public override string SaveCurrentTriggerStat()
{
return "";
}
}

View File

@ -24,6 +24,7 @@ public class ReconnectTriggerInfo
public string triggerName;
public Vector3 selfPosInScene;
public Vector3 selfRotInScene;
public string triggerInfo;
}

View File

@ -116,6 +116,7 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
ret.triggerID = item.triggerID;
ret.selfPosInScene = item.transform.localPosition;
ret.selfRotInScene = item.transform.localEulerAngles;
ret.triggerInfo = item.SaveCurrentTriggerStat();
UserExamStat.currentSceneTriggers.Add(ret);
}
@ -219,6 +220,7 @@ public class ReconnectMgr : SingletonMono<ReconnectMgr>
item.gameObject.SetActive(true);
item.transform.localPosition = ret.selfPosInScene;
item.transform.localEulerAngles = ret.selfRotInScene;
item.LoadCurrentTriggerStat(ret.triggerInfo);
break;
}
}

View File

@ -17,5 +17,15 @@ public class MirrorController : PermanentTriggerBase
}
}
/// <summary>
/// 不需要断线重连恢复
/// </summary>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override string SaveCurrentTriggerStat()
{
return "";
}
public override void LoadCurrentTriggerStat(string triggerInfo){ }
}

View File

@ -3,6 +3,8 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using LitJson;
using Newtonsoft.Json;
public class MobileController : PermanentTriggerBase
{
@ -49,4 +51,22 @@ public class MobileController : PermanentTriggerBase
});
}
}
/// <summary>
/// 断线重连的状态保存与读取
/// </summary>
/// <param name="triggerInfo"></param>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
if (triggerInfo != "")
{
this.downIndex = int.Parse(triggerInfo);
}
}
public override string SaveCurrentTriggerStat()
{
return downIndex.ToString();
//throw new NotImplementedException();
}
}

View File

@ -7,6 +7,7 @@ public class NPCController : PermanentTriggerBase
public List<string> npcSpeack;
public int speackIndex = 0;
public SpriteRenderer spriteRenderer;
protected override void OnMDown()
{
base.OnMDown();
@ -42,4 +43,22 @@ public class NPCController : PermanentTriggerBase
speackIndex = 0;
}
}
/// <summary>
/// ¶ÏÏßÖØÁ¬±£´æ
/// </summary>
/// <param name="triggerInfo"></param>
/// <exception cref="System.NotImplementedException"></exception>
public override void LoadCurrentTriggerStat(string triggerInfo)
{
if (triggerInfo != "")
{
speackIndex = int.Parse(triggerInfo);
}
}
public override string SaveCurrentTriggerStat()
{
return speackIndex.ToString() ;
}
}

View File

@ -9,7 +9,7 @@ using Unity.VisualScripting;
/// <summary>
/// ³£×¤½»»¥
/// </summary>
public class PermanentTriggerBase : MonoBehaviour
public abstract class PermanentTriggerBase : MonoBehaviour
{
public int triggerID;
public string triggerName;
@ -130,4 +130,13 @@ public class PermanentTriggerBase : MonoBehaviour
{
scoreAction?.Invoke(triggerName==null?this.triggerName:triggerName, para, systemcid, shchmeid);
}
/// <summary>
/// 保存Trigger的自身具体信息,参考scoreBase
/// </summary>
public abstract string SaveCurrentTriggerStat();
/// <summary>
/// 加载Trigger的自身具体信息,参考scoreBase
/// </summary>
public abstract void LoadCurrentTriggerStat(string triggerInfo);
}

View File

@ -7,13 +7,13 @@
"index": 1,
"subProcessId": 1,
"currentScore": 0.0,
"isDone": false
"isDone": true
},
{
"index": 2,
"subProcessId": 2,
"currentScore": 0.0,
"isDone": false
"isDone": true
},
{
"index": 3,
@ -129,7 +129,8 @@
"x": 0.0,
"y": 0.0,
"z": 0.0
}
},
"triggerInfo": "2"
}
],
"currentSceneOtherInfo": "{\r\n \"TestPen3list\": [],\r\n \"InSwitchCloseYDList\": [],\r\n \"InSwitchOpenYDList\": [],\r\n \"currentunInstallJieXian\": [],\r\n \"currentInstallJieXian\": [],\r\n \"installCover\": [],\r\n \"currentInstallTestJieXian\": []\r\n}"