188 lines
5.3 KiB
C#
188 lines
5.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
//using System.Diagnostics;
|
|
using AibisDream;
|
|
using MeadowGames.UINodeConnect4;
|
|
using UnityEngine;
|
|
using Yarn.Unity;
|
|
using RainbowArt.CleanFlatUI;
|
|
using UnityEditor.Localization.Plugins.XLIFF.V20;
|
|
|
|
public class ClueBaordNew : MonoBehaviour
|
|
{
|
|
|
|
private GraphManager gm;
|
|
public List<Node> nodeLists;
|
|
|
|
public List<Node> Day1InitnodeLists;
|
|
|
|
public List<Node> Day2InitnodeLists;
|
|
|
|
public List<Node> Day1AllnodeLists;
|
|
|
|
public List<Node> Day2AllnodeLists;
|
|
|
|
public Notification ClueBoardNotification;
|
|
//private Dictionary<string, Vector3> nodePositions = new Dictionary<string, Vector3>();
|
|
|
|
private Connection currentConnection;
|
|
|
|
private bool isTriggerDialogue=true;
|
|
void Start()
|
|
{
|
|
gm=GetComponent<GraphManager>();
|
|
gm.OnConnectionAdded += CheckConnection;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
[YarnCommand("SetNodeState")]
|
|
public void ActiveNodeToBoard(string nodeID,bool isactive)
|
|
{
|
|
gm.localNodes.Find(node => node.ID == nodeID).gameObject.SetActive(isactive);
|
|
}
|
|
[YarnCommand("NodeInit")]
|
|
public void NodeInit(int day)
|
|
{
|
|
gm.localConnections.Clear();
|
|
gm.localNodes.Clear();
|
|
if(day==1)
|
|
{
|
|
|
|
foreach(Node node in Day2AllnodeLists)
|
|
{
|
|
node.gameObject.SetActive(false);
|
|
}
|
|
foreach(Node node in Day1InitnodeLists)
|
|
{
|
|
node.gameObject.SetActive(true);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
if(day==2)
|
|
{
|
|
gm.localConnections.Clear();
|
|
foreach(Node node in Day1AllnodeLists)
|
|
{
|
|
node.gameObject.SetActive(false);
|
|
}
|
|
foreach(Node node in Day2InitnodeLists)
|
|
{
|
|
node.gameObject.SetActive(true);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public Node GetNode(string nodeID)
|
|
{
|
|
return gm.localNodes.Find(node => node.ID == nodeID);
|
|
}
|
|
|
|
[YarnCommand("SetIsTriggerDialogueWhenConnect")]
|
|
public void SetIsTriggerDialogueWhenConnect(bool isTrigger)
|
|
{
|
|
isTriggerDialogue=isTrigger;
|
|
}
|
|
|
|
|
|
//[YarnCommand("CheckClueBoard")]
|
|
public void CheckConnection(Connection connection)
|
|
{
|
|
currentConnection=connection;
|
|
DialogController.Instance.SetVariable("$StartNode",connection.port0.node.ID);
|
|
DialogController.Instance.SetVariable("$EndNode",connection.port1.node.ID);
|
|
if(isTriggerDialogue)
|
|
{
|
|
DialogController.Instance.StartDialogNode("检查ClueBoard");
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (connection.port0.node.ID == "UFImage" && connection.port1.node.ID == "MemoryGrass")
|
|
// {
|
|
// connection.DisableClick=false;
|
|
// connection.EnableDrag=false;
|
|
// DialogController.Instance.StartDialogNode("UF图像问题回答正确");
|
|
// // GetNode("MemoryGrass").transform.GetChild(1).gameObject.SetActive(true);
|
|
|
|
// }
|
|
// if (connection.port0.node.ID == "MemoryGrass" && connection.port1.node.ID == "EyePlant")
|
|
// {
|
|
// connection.DisableClick=false;
|
|
// connection.EnableDrag=false;
|
|
// DialogController.Instance.StartDialogNode("记忆问题回答正确");
|
|
// }
|
|
// if (connection.port0.node.ID == "手术" && connection.port1.node.ID == "solution")
|
|
// {
|
|
// connection.DisableClick=false;
|
|
// connection.EnableDrag=false;
|
|
// DialogController.Instance.StartDialogNode("执行手术");
|
|
// }
|
|
}
|
|
[YarnCommand("ConnectionCantBreak")]
|
|
public void SetConnectionProperties()
|
|
{
|
|
if (currentConnection == null)
|
|
{
|
|
Debug.LogWarning("Connection not found.");
|
|
return;
|
|
}
|
|
|
|
currentConnection.DisableClick=false;
|
|
currentConnection.EnableDrag=false;
|
|
currentConnection.EnableHover=false;
|
|
currentConnection.line.color=Color.green;
|
|
//currentConnection.port0.node.
|
|
//currentConnection=null;
|
|
|
|
}
|
|
[YarnCommand("AddNodeConnection")]
|
|
public void CreateConnection(string starNode,int startPort,string endNode,int endPort)
|
|
{
|
|
Node start= GetNode(starNode);
|
|
Node end= GetNode(endNode);
|
|
Connection newConnection=start.ports[startPort].ConnectTo(end.ports[endPort]);
|
|
newConnection.DisableClick=false;
|
|
newConnection.EnableDrag=false;
|
|
gm.UnselectAllElements();
|
|
newConnection.DisableClick=false;
|
|
newConnection.EnableDrag=false;
|
|
newConnection.EnableHover=false;
|
|
newConnection.line.color=Color.green;
|
|
//currentConnection=null;
|
|
}
|
|
|
|
[YarnCommand("AddNode")]
|
|
public void CreateNode(string NodeID)
|
|
{
|
|
Node targetNode = nodeLists.Find(node => node.ID == NodeID);
|
|
if (targetNode == null)
|
|
{
|
|
Debug.LogWarning($"Node with ID {NodeID} not found.");
|
|
return;
|
|
}
|
|
targetNode.gameObject.SetActive(true);
|
|
}
|
|
[YarnCommand("EnableQuestion")]
|
|
public void EnableQuestion(string nodeID)
|
|
{
|
|
GetNode(nodeID).transform.GetChild(1).gameObject.SetActive(true);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|