//遍歷所有node,如果有選項,則印出選項 //因為當前node如果有下一個,就沒有選項 //如果有選項,就沒有下一個,因此選項都會在最後一個DATA裡面 //所以也就是說,一個選項,會有目標節點,一個節點,必包含一段文字,而選項則不依定 //那開始對話的話,就是獲得當前節點,和 //option需要點擊後進行某件事還有開啟某個對話的事件 //所以就是結束目前對話,但文字不消失 //然後如果沒選項,則再點一次消失。 //如果有選項,則是點選項,點選項則會調用一個委派,檢查目前按到的按鈕OID //然後開始執行StartConveration(data) IEnumerator StartConvestaion(List <DialougeNode> Data) { DestoryButton(); for (int i = 0; i < Data.Count; i++) { currentNode = Data[i]; currentText = currentNode.Text; currentSpeaker = currentNode.Speaker; if (OnStart != null) { OnStart(); } //第一種方案 //if (Data[i].Options != null) //{ // SetOptionButtons(Data[i].Options); //} yield return(null); //movenext之後會得到這個 } //這樣就不用每次都判斷了 if (Data[Data.Count - 1].Options != null) { SetOptionButtons(Data[Data.Count - 1].Options); } else { OnEnd(); } }
/// <summary> /// Reads the current node number's information /// </summary> void readDialouge() { DialougeNode currentNode = currentSet.nodes[currentNodeNumber]; characterNameText.text = currentNode.character.characterName; characterPortrait.sprite = currentNode.character.characterPortrait; StartCoroutine(characterByCharacterDialouge(currentNode)); }
private void AddChoicePort(DialougeNode dialogNode) { var generatedPort = GeneratePort(dialogNode, Direction.Output); var outputPortCount = dialogNode.outputContainer.Query("connector").ToList().Count; generatedPort.portName = $"Choice {outputPortCount}"; dialogNode.outputContainer.Add(generatedPort); dialogNode.RefreshExpandedState(); dialogNode.RefreshPorts(); }
//Ends the dialouge public void EndDialouge(DialougeNode CurrentNode) { //Showing the node text,the only first reply and clearing the other button DialougeText.text = CurrentNode.SentenceText; ReplyOne.text = CurrentNode.replies[0].SentenceText; ReplyTwo.text = ""; //Assigning data to the first button ButtonData ButtonOne = (ButtonData)ActionOne.GetComponent("ButtonData"); ButtonOne.NodeIndex = CurrentNode.replies[0].Nodelink; }
/* This function defines a next node reference, current node index, * and current reply index for each button. */ public void AssignButtonData(DialougeNode CurrentNode, int NodeIndex) { ButtonData ButtonOne = (ButtonData)ActionOne.GetComponent("ButtonData"); ButtonOne.NodeIndex = CurrentNode.replies[0].Nodelink; // ButtonOne.setCurrentNodeIndex(NodeIndex); // ButtonOne.setCurrentReplyIndex(0); ButtonData ButtonTwo = (ButtonData)ActionTwo.GetComponent("ButtonData"); ButtonTwo.NodeIndex = CurrentNode.replies[1].Nodelink; // ButtonOne.setCurrentNodeIndex(NodeIndex); // ButtonOne.setCurrentReplyIndex(1); }
public void ShowNode(DialougeNode node, int index) { //Showing the node's sentence and it's replies DialougeText.text = node.SentenceText; ReplyOne.text = node.replies[0].SentenceText; // if(node.replies[0].getIsSelected()) ActionOne.interactable = false; // else ActionOne.interactable = true; ReplyTwo.text = node.replies[1].SentenceText; // if(node.replies[0].getIsSelected()) ActionTwo.interactable = false; // else ActionTwo.interactable = true; /* Assigning data to buttons */ AssignButtonData(node, index); }
/// <summary> /// Types out the text onto the screen, if it sees a rich text it will store it to display /// </summary> /// <param name="node">The current node to display</param> IEnumerator characterByCharacterDialouge(DialougeNode node) { dialougeText.text = ""; isReading = true; foreach (char c in node.text) { if (c == '<') { richTextModifer += c; isTypingRichText = true; } else if (c == '>') { richTextModifer += c; dialougeText.text += richTextModifer; richTextModifer = ""; isTypingRichText = false; } else { if (isTypingRichText) { richTextModifer += c; } else { dialougeText.text += c; //Dividing by 10 to make sure we have finner controls over how fast text is read yield return(new WaitForSeconds(readSpeed / 10f)); } } } isReading = false; if (currentSet.autoRead) { yield return(new WaitForSeconds(node.timeToWait)); gotoNextNode(); } }
private DialougeNode GenerateEntryPointNode() { var node = new DialougeNode { title = "START", GUID = Guid.NewGuid().ToString(), DialogueText = "ENTRYPOINT", entryPoint = true }; var generatedPort = GeneratePort(node, Direction.Output); generatedPort.name = "Next"; node.outputContainer.Add(generatedPort); node.RefreshExpandedState(); node.RefreshPorts(); node.SetPosition(new Rect(100, 200, 100, 150)); return(node); }
public DialougeNode CreateDialogueNode(string nodeName) { var dialogNode = new DialougeNode { title = nodeName, DialogueText = nodeName, GUID = Guid.NewGuid().ToString() }; var inputPort = GeneratePort(dialogNode, Direction.Input, Port.Capacity.Multi); inputPort.name = "Input"; dialogNode.inputContainer.Add(inputPort); var button = new Button(() => { AddChoicePort(dialogNode); }); button.text = "New choice"; dialogNode.titleContainer.Add(button); dialogNode.RefreshExpandedState(); dialogNode.RefreshPorts(); dialogNode.SetPosition(new Rect(Vector2.zero, defaultNodeSize)); return(dialogNode); }
private Port GeneratePort(DialougeNode node, Direction portDirection, Port.Capacity capacity = Port.Capacity.Single) { return(node.InstantiatePort(Orientation.Horizontal, portDirection, capacity, typeof(float))); }