最新修改提交

This commit is contained in:
高铎 2026-04-12 16:04:20 +08:00
parent 417f471a6e
commit 7062897d2c
27 changed files with 445 additions and 48 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: f8a5914dbef2a7e44a1db76b21ef671b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,88 @@
using NAudio.Wave;
using System;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using UnityEngine;
using UnityThreadingUtils;
/// <summary>
/// 语音工具
/// </summary>
public class ZXKWakeup : MonoBehaviour
{
//唤醒词:小智小智
#region ,
[Header("串口名")]
public string portName = "COM10";
[Header("波特率")]
public int baudRate = 115200;
[Header("奇偶校验")]
private Parity parity = Parity.None;
[Header("数据位")]
private int dataBits = 8;
[Header("停止位")]
private StopBits stopBits = StopBits.One;
SerialPort sp = null;
Thread dataReceiveThread;
#endregion
StringBuilder sb = new StringBuilder();
public Action callBack;//唤醒回调
private void Start()
{
//sp = new SerialPort(portName, baudRate, parity, dataBits, stopBits);
//dataReceiveThread = new Thread(new ThreadStart(DataReceiveStrThread));
//try
//{
// if (!sp.IsOpen)
// {
// sp.Open();
// dataReceiveThread.Start();
// Debug.Log("串口打开成功");
// }
//}
//catch (Exception e)
//{
// Debug.Log("串口打开失败" + e.ToString());
//}
}
/// <summary>
/// 接收字符串
/// </summary>
private void DataReceiveStrThread()
{
while (true)
{
if (sp != null && sp.IsOpen)
{
try
{
if (sp.BytesToRead > 0)
{
sb.Append(sp.ReadExisting());
UnityMainThreadDispatcher.Instance().Enqueue(() =>
{
Debug.Log("before="+sb.ToString().TrimEnd('\n', '\r'));
if (sb.ToString().TrimEnd('\n', '\r') == "hello")
{
callBack?.Invoke();
}
sb.Clear();
Debug.Log("after="+sb.ToString());
});
}
}
catch (Exception)
{
Debug.Log("消息接收失败");
}
}
Thread.Sleep(20);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 548c8f6de64fa65478fa07b11da59528
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -21,11 +21,18 @@ public class QiGuanChaGuan_Sensor : Sensor
public Text huiYan_Txt;
public Text qiGuanDeep_Txt;
[HideInInspector]
public bool isOpen;
float time;
float lastTime;
public override void ReceiveData(string datas, SerialPort sp = null)
{
base.ReceiveData(datas);
data = datas.Split("#")[1].Split("%")[0];
if (!data.Contains("DWYX1")) return;
lastTime = time;
if (data.Contains("DATA"))
{
isHuiYan = true;
@ -36,7 +43,21 @@ public class QiGuanChaGuan_Sensor : Sensor
}
if (data.Contains("QGDeep"))
{
qiGuanDeep = float.Parse(data.Split(",")[3].Split(":")[1].Split("mm")[0]);
qiGuanDeep = float.Parse(data.Split(",")[4].Split(":")[1].Split("mm")[0]);
}
}
private void Update()
{
time += Time.deltaTime;
if (time - lastTime < 1.0f)
{
isOpen = true;
}
else
{
isOpen = false;
//progressValue = 0;
}
}

View File

@ -1130,6 +1130,7 @@ MonoBehaviour:
isHuiYan: 0
huiYan_Txt: {fileID: 420083956}
qiGuanDeep_Txt: {fileID: 749465377}
isOpen: 0
--- !u!114 &34381059
MonoBehaviour:
m_ObjectHideFlags: 0
@ -19846,6 +19847,11 @@ PrefabInstance:
propertyPath: m_Layer
value: 8
objectReference: {fileID: 0}
- target: {fileID: 8538378742566826990, guid: 7aed8de88ca84a84ea99f939edf39e8a,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8933697090741927507, guid: 7aed8de88ca84a84ea99f939edf39e8a,
type: 3}
propertyPath: m_Layer
@ -19972,6 +19978,12 @@ GameObject:
type: 3}
m_PrefabInstance: {fileID: 429858861}
m_PrefabAsset: {fileID: 0}
--- !u!4 &429858863 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7775683361156134320, guid: 7aed8de88ca84a84ea99f939edf39e8a,
type: 3}
m_PrefabInstance: {fileID: 429858861}
m_PrefabAsset: {fileID: 0}
--- !u!114 &430463142
MonoBehaviour:
m_ObjectHideFlags: 0
@ -70876,6 +70888,52 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
serializedGuid: fdfa23547c2c804d8a40cb5012e13556
--- !u!1 &1205967526
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1205967527}
- component: {fileID: 1205967528}
m_Layer: 8
m_Name: ZXKWakeup
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1205967527
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1205967526}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 429858863}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1205967528
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1205967526}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 548c8f6de64fa65478fa07b11da59528, type: 3}
m_Name:
m_EditorClassIdentifier:
portName: COM10
baudRate: 115200
--- !u!114 &1206192758
MonoBehaviour:
m_ObjectHideFlags: 0
@ -112350,7 +112408,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 48dd5e49debeead44a7105f01b94cfd5, type: 3}
m_Name:
m_EditorClassIdentifier:
defaultStateName: BingLiXinXiState
defaultStateName: ShuZheZhunBeiState
nextState: 0
--- !u!4 &44452961559943390
Transform:

View File

@ -192,6 +192,15 @@ namespace DongWuYiXue.QiGuanChaGuan
//²¥·ÅTimeline
Coroutine coroutine;
public void StopClip(string value)
{
if (Game.Instance)
{
Game.Instance.IEnumeratorManager.Stop(coroutine);
GameManager.Instance.timelineManager.StopNormalCilp(value);
}
}
public void PlayClip(string value, Action callBack = null)
{
float t = GetClipLength(value);

View File

@ -19,7 +19,7 @@ namespace DongWuYiXue.QiGuanChaGuan
fsm.PlayBgm(1);
//cor = Game.Instance.IEnumeratorManager.Run(3.0f, () =>
//{
isChaRu = true;
isChaRu = true;
//});
}
public override void OnStateStay()
@ -35,6 +35,8 @@ namespace DongWuYiXue.QiGuanChaGuan
{
chaRuValue = 1;
}
fsm.PlayClip("±©Â¶»áÑá_TimeLine", null, chaRuValue);
if (chaRuValue >= 1.0f)
{
@ -51,6 +53,16 @@ namespace DongWuYiXue.QiGuanChaGuan
fsm.nextState = true;
}
}
if (isChaRu && Input.GetKeyDown(KeyCode.L))
{
isChaRu = false;
fsm.PlayClip("ąŠÂśťáŃá_TimeLine", () =>
{
chaRuValue = 0;
fsm.nextState = true;
});
}
}
public override void OnStateExit()
{

View File

@ -25,25 +25,47 @@ namespace DongWuYiXue.QiGuanChaGuan
public override void OnStateStay()
{
base.OnStateStay();
if (isChaRu)
{
//if (isChaRu)
//{
//if (Input.GetKeyDown(KeyCode.L))
//{
// chaRuValue = 1;
//}
if (GameManager.Instance.senSor.GetSensor<QiGuanChaGuan_Sensor>().qiGuanDeep > 60)
// //if (Input.GetKeyDown(KeyCode.L))
// //{
// // chaRuValue = 1;
// //}
// if (GameManager.Instance.senSor.GetSensor<QiGuanChaGuan_Sensor>().qiGuanDeep > 60)
// {
// chaRuValue = 1;
// }
// fsm.PlayClip("²åÈëÆø¹Üµ¼¹Ü_TimeLine", null, chaRuValue);
// if (chaRuValue >= 1.0f)
// {
// isChaRu = false;
// chaRuValue = 0;
// if (fsm.main_gameModel.modeType == ModeType.KaoHe)
// {
// fsm.AddScore(6, 0);
// fsm.ShowTxtQuestion("²å¹Ü²Ù×÷¡·²åÈëÆø¹Üµ¼¹Ü¡·²½Öè2", 3, 1, 3, () =>
// {
// fsm.nextState = true;
// });
// }
// if (fsm.main_gameModel.modeType == ModeType.ShiXun)
// {
// fsm.AddScore(8, 0);
// fsm.nextState = true;
// }
// }
//}
if (isChaRu && Input.GetKeyDown(KeyCode.L))
{
isChaRu = false;
fsm.PlayClip("²åÈëÆø¹Üµ¼¹Ü_TimeLine", () =>
{
chaRuValue = 1;
}
fsm.PlayClip("²åÈëÆø¹Üµ¼¹Ü_TimeLine", null, chaRuValue);
if (chaRuValue >= 1.0f)
{
isChaRu = false;
chaRuValue = 0;
if (fsm.main_gameModel.modeType == ModeType.KaoHe)
{
fsm.AddScore(6, 0);
//fsm.AddScore(6, 0);
fsm.ShowTxtQuestion("²å¹Ü²Ù×÷¡·²åÈëÆø¹Üµ¼¹Ü¡·²½Öè2", 3, 1, 3, () =>
{
fsm.nextState = true;
@ -51,11 +73,39 @@ namespace DongWuYiXue.QiGuanChaGuan
}
if (fsm.main_gameModel.modeType == ModeType.ShiXun)
{
fsm.AddScore(8, 0);
//fsm.AddScore(8, 0);
fsm.nextState = true;
}
});
}
if (isChaRu && GameManager.Instance.senSor.GetSensor<QiGuanChaGuan_Sensor>().isOpen)
{
chaRuValue = GameManager.Instance.senSor.GetSensor<QiGuanChaGuan_Sensor>().qiGuanDeep / 12;
fsm.PlayClip("²åÈëÆø¹Üµ¼¹Ü_TimeLine", null, chaRuValue);
}
if (chaRuValue >= 1.0f && isChaRu)
{
isChaRu = false;
if (fsm.main_gameModel.modeType == ModeType.KaoHe)
{
fsm.AddScore(6, 0);
fsm.ShowTxtQuestion("²å¹Ü²Ù×÷¡·²åÈëÆø¹Üµ¼¹Ü¡·²½Öè2", 3, 1, 3, () =>
{
fsm.nextState = true;
});
}
if (fsm.main_gameModel.modeType == ModeType.ShiXun)
{
fsm.AddScore(8, 0);
fsm.nextState = true;
}
if (!GameManager.Instance.senSor.GetSensor<QiGuanChaGuan_Sensor>().isOpen && isChaRu)
{
fsm.StopClip("²åÈëÆø¹Üµ¼¹Ü_TimeLine");
}
}
}
public override void OnStateExit()
{

View File

@ -32,13 +32,30 @@ namespace DongWuYiXue.QiGuanChaGuan
{
base.OnStateStay();
if (isOpen)
{
{
isOpen = false;
//if (Input.GetKeyDown(KeyCode.L))
//{
openValue = 1;
//openValue = 1;
//}
fsm.PlayClip("´ò¿ª¿ÚÇ»1_TimeLine", null, openValue);
if (openValue >= 1.0f)
//fsm.PlayClip("´ňżŞżÚÇť1_TimeLine", null, openValue);
//if (openValue >= 1.0f)
//{
// if (fsm.main_gameModel.modeType == ModeType.ShiXun)
// {
// fsm.AddScore(6, 0);
// }
// if (fsm.main_gameModel.modeType == ModeType.KaoHe)
// {
// fsm.AddScore(6, 0);
// }
// isOpen = false;
// openValue = 0;
// fsm.nextState = true;
//}
fsm.PlayClip("´ňżŞżÚÇť1_TimeLine", () =>
{
if (fsm.main_gameModel.modeType == ModeType.ShiXun)
{
@ -48,10 +65,9 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.AddScore(6, 0);
}
isOpen = false;
openValue = 0;
fsm.nextState = true;
}
});
}
}
public override void OnStateExit()

View File

@ -193,6 +193,34 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.PlayClip("检查套囊气密性1_TimeLine", null, (1.0f - tuiValue) / 2);
}
if (Input.GetKeyDown(KeyCode.L))
{
fsm.PlayClip("检查套囊气密性1_TimeLine", () =>
{
isJianChaOne = false;
isZhuSheQiLa = false;
isOpen = false;
cor = Game.Instance.IEnumeratorManager.Run(1.0f, () =>
{
if (null != cor)
{
Game.Instance.IEnumeratorManager.Stop(cor);
}
fsm.Show("5ml注射器");
fsm.Light_EnableInteraction("5ml注射器");
fsm.Light("12mm气管导管");
fsm.EnableInteraction("12气管导管检查气密性");
fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器");
fsm.ShowTipBtn(() =>
{
this.Error("2222222222222222222");
fsm.Light("12mm气管导管", true);
fsm.Light_EnableInteraction("5ml注射器", true);
fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器", 0, 0, 5, true);
}, 2);
});
});
}
}
if (isJianChaOne && isZhuSheQiLa)
{
@ -245,6 +273,31 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.PlayClip("检查套囊气密性1_TimeLine", null, .5f + (tuiValue / 2));
}
//if (!GameManager.Instance.senSor.GetSensor<ZhuSheQi_10SenSor>().isOpen && Input.GetKeyDown(KeyCode.L))
//{
// isJianChaOne = false;
// isZhuSheQiLa = false;
// isOpen = false;
// cor = Game.Instance.IEnumeratorManager.Run(1.0f, () =>
// {
// if (null != cor)
// {
// Game.Instance.IEnumeratorManager.Stop(cor);
// }
// fsm.Show("5ml注射器");
// fsm.Light_EnableInteraction("5ml注射器");
// fsm.Light("12mm气管导管");
// fsm.EnableInteraction("12气管导管检查气密性");
// fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器");
// fsm.ShowTipBtn(() =>
// {
// this.Error("2222222222222222222");
// fsm.Light("12mm气管导管", true);
// fsm.Light_EnableInteraction("5ml注射器", true);
// fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器", 0, 0, 5, true);
// }, 2);
// });
//}
}
if (isJianChaTwo && isZhuSheQiTui)
@ -268,6 +321,34 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.PlayClip("检查套囊气密性2_TimeLine", null, (1.0f - tuiValue) / 2);
}
if (Input.GetKeyDown(KeyCode.L))
{
fsm.PlayClip("检查套囊气密性2_TimeLine", () =>
{
isJianChaTwo = false;
isZhuSheQiLa = false;
isOpen = false;
cor = Game.Instance.IEnumeratorManager.Run(1.0f, () =>
{
if (null != cor)
{
Game.Instance.IEnumeratorManager.Stop(cor);
}
fsm.Show("5ml注射器");
fsm.Light_EnableInteraction("5ml注射器");
fsm.Light("14mm气管导管");
fsm.EnableInteraction("14气管导管检查气密性");
fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器");
fsm.ShowTipBtn(() =>
{
this.Error("33333333333333333");
fsm.Light("14mm气管导管", true);
fsm.Light_EnableInteraction("5ml注射器", true);
fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器", 0, 0, 5, true);
}, 2);
});
});
}
}
if (isJianChaTwo && isZhuSheQiLa)
{
@ -320,6 +401,31 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.PlayClip("检查套囊气密性2_TimeLine", null, .5f + (tuiValue / 2));
}
//if (!GameManager.Instance.senSor.GetSensor<ZhuSheQi_10SenSor>().isOpen &&Input.GetKeyDown(KeyCode.L))
//{
// fsm.PlayClip("检查套囊气密性2_TimeLine", () =>
// {
// cor = Game.Instance.IEnumeratorManager.Run(1.0f, () =>
// {
// if (null != cor)
// {
// Game.Instance.IEnumeratorManager.Stop(cor);
// }
// fsm.Show("5ml注射器");
// fsm.Light_EnableInteraction("5ml注射器");
// fsm.Light("14mm气管导管");
// fsm.EnableInteraction("14气管导管检查气密性");
// fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器");
// fsm.ShowTipBtn(() =>
// {
// this.Error("33333333333333333");
// fsm.Light("14mm气管导管", true);
// fsm.Light_EnableInteraction("5ml注射器", true);
// fsm.ShowArrow("请拖拽10ml注射器", "5ml注射器", 0, 0, 5, true);
// }, 2);
// });
// });
//}
}
if (isJianChaThree && isZhuSheQiTui)
@ -343,6 +449,23 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.PlayClip("检查套囊气密性3_TimeLine", null, (1.0f - tuiValue) / 2);
}
if (!GameManager.Instance.senSor.GetSensor<ZhuSheQi_10SenSor>().isOpen &&Input.GetKeyDown(KeyCode.L)&& isJianChaThree)
{
fsm.PlayClip("检查套囊气密性3_TimeLine", () =>
{
isJianChaThree = false;
isZhuSheQiLa = false;
isOpen = false;
cor = Game.Instance.IEnumeratorManager.Run(1.0f, () =>
{
if (null != cor)
{
Game.Instance.IEnumeratorManager.Stop(cor);
}
fsm.nextState = true;
});
});
}
}
if (isJianChaThree && isZhuSheQiLa)
{
@ -383,6 +506,23 @@ namespace DongWuYiXue.QiGuanChaGuan
{
fsm.PlayClip("检查套囊气密性3_TimeLine", null, .5f + (tuiValue / 2));
}
//if (!GameManager.Instance.senSor.GetSensor<ZhuSheQi_10SenSor>().isOpen && Input.GetKeyDown(KeyCode.L))
//{
// fsm.PlayClip("检查套囊气密性3_TimeLine", () =>
// {
// isJianChaThree = false;
// isZhuSheQiLa = false;
// isOpen = false;
// cor = Game.Instance.IEnumeratorManager.Run(1.0f, () =>
// {
// if (null != cor)
// {
// Game.Instance.IEnumeratorManager.Stop(cor);
// }
// fsm.nextState = true;
// });
// });
//}
}
}
public override void OnStateExit()