private void LoadNode(SpeakEasyFile_NodeData data) { Vector2 dataPosition = data.nodePosition; NodeType dataType = data.nodeType; SpeakEasyNode node = new SpeakEasyNode { nodeID = data.nodeID, nodeType = dataType, stringReference = data.stringReference, isEntryPoint = data.isEntryPoint, priority = data.nodePriority, scriptEvent = data.scriptEventRef, scriptTest = data.scriptTestRef, }; AddElement(InitializeNode(node, dataPosition, dataType)); }
// Conversation Parser Logic private void JumpToSpeechNode(SpeakEasyFile_NodeData node) { //We are assuming that the conditional fired and returned TRUE. if (node.nodeType != NodeType.speech) { Debug.Log("Trying to access a non speech node."); DeactivateScreen(); } //This is how we traverse conversation //Clear the previous node data ClearScreen(); //Set the Speech Text to this: speechText.text = Locale.Lookup(locale, node.stringReference); //Execute any OnFire here //We need to populate our responses (if any). PopulateResponseList(node.connectionData); }
private void InstantiateResponseButton(SpeakEasyFile_NodeData data, float x, float y) { //We are assuming that the button has returned true on it's onConditional GameObject buttonInstance = Instantiate(responseButtonPrefab, new Vector3(x, y, 0), Quaternion.identity); buttonInstance.transform.SetParent(responseButtonContainer.transform, false); responseButtonInstance.Add(buttonInstance); //Now we populate the data and behaviour of the button itself UIConversationResponseButton logic = buttonInstance.GetComponent <UIConversationResponseButton>(); if (logic == null) { Debug.Log("Something has gone terribly wrong and we are unable to find the logic for the button."); return; } logic.label.text = Locale.Lookup(locale, data.stringReference); //Localise our response text. logic.connectionData = data.connectionData; //Assign the connection data reference to the button itself. }
IEnumerator MoveToNextSpeechNode(SpeakEasyFile_NodeData node) { yield return(new WaitForSeconds(3f)); JumpToSpeechNode(node); }