修改了插头的功能,增加了插头触发对话,保险起见只触发一次

This commit is contained in:
2024-11-15 01:20:32 +08:00
parent 40bd8a7475
commit c01b55806f
4 changed files with 169 additions and 68 deletions
+2 -2
View File
@@ -183,7 +183,7 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
{
currentSocket = closestSocket;
currentSocket.InsertPlug(this);
initialSocket.InsertPlug(this);
//initialSocket.InsertPlug(this);
OnPlugInserted?.Invoke(this); // 触发插入事件
transform.position = currentSocket.GetPosition();
plugSprite.enabled = false;
@@ -196,7 +196,7 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
{
//transform.rotation = startRotation;
initialSocket.InsertPlug(this);
OnPlugInserted?.Invoke(this); // 触发插入事件
//OnPlugInserted?.Invoke(this); // 触发插入事件
plugSprite.enabled =false; // Make the plug sprite disappear when it is inserted into the initial socket.
});
}
@@ -123,7 +123,9 @@ public class OscilloscopeController : MonoBehaviour
}
private void HandlePlugInserted(Plug plug)
{
DialogController.Instance.SetVariable("$currentSocket",plug.currentSocket.name);
string originalString = plug.currentSocket.name;
string trimmedString = originalString.Replace("Socket", "");
DialogController.Instance.SetVariable("$currentSocket",trimmedString);
DialogController.Instance.StartDialogNode("PlugInsert");
// 这里可以处理插入后的波形显示逻辑
Debug.Log("Plug inserted into the socket, starting waveform display.");
@@ -341,10 +343,23 @@ private IEnumerator ScanForError(string trimmedString)
if(targetData.HasExternalError())
{
screenText.text="外部错误已关联,可以直接入";
screenText.text="记忆模块,允许直接入";
//waveformVisualizer.gameObject.SetActive(false);
return;
}
else if(currentSocket.targetData.isCorrect)
{
string originalString = currentSocket.name;
string trimmedString = originalString.Replace("Socket", "");
screenText.text=trimmedString+ ":未检测到错误";
return;
}
else if(!currentSocket.targetData.isCorrect)
{
string originalString = currentSocket.name;
string trimmedString = originalString.Replace("Socket", "");
screenText.text=trimmedString+ ":检测到异常,请寻找错误深入";
}
if(!setInitSliderValue)
{