public void GetNodeFunction(List <NodePort> _ports) { //cannot find a way to use a switch, so we'll have to stick with a bunch of if statements :notlikethis: foreach (NodePort _nodePort in _ports) { XNode.Node _node = _nodePort.node; if (_node.GetType() == typeof(DialogueNode)) { dialoguePanel.SetActive(true); currentDialogue = _node as DialogueNode; ShowDialogue(currentDialogue); return; //do NOT grab the node after this, and wait for the player to advance the dialogue } if (_node.GetType() == typeof(VoiceClipNode)) { VoiceClipNode voiceClipNode = _node as VoiceClipNode; voiceClipNode.OnUse(); return; } if (_node.GetType() == typeof(EndSceneNode)) { EndCutscene(); return; } else if (_node.GetType() == typeof(EndBattleSceneNode)) { EndCutscene(); BattleManager BM = GameObject.Find("BattleManager").GetComponent <BattleManager>(); BM.EnableUI(); BM.StartActor(); //Move Battle UI Back In? return; } if (_node is MovementNode movementNode) { movementNode.CharacterMovement(); } if (_node.GetType() == typeof(CloseDialogue)) { dialoguePanel.SetActive(false); speakerPanel.SetActive(false); } if (_node.GetType() == typeof(CG)) { CG scopedCGNode = _node as CG; showCG(_node as CG); if (scopedCGNode.waitForInput) { currentCGNode = scopedCGNode; dialoguePanel.gameObject.SetActive(false); _charactersInScene.SetActive(false); CGWaitingForInput = true; return; } } if (_node.GetType() == typeof(SetSpriteNode)) { SetImage(_node as SetSpriteNode); } if (_node.GetType() == typeof(CGHide)) { _cgGraphic.enabled = false; } if (_node.GetType() == typeof(WaitFor)) { WaitFor _waitForNode = _node as WaitFor; StartCoroutine(WaitToAdvance(_waitForNode)); //do not get next node automatically return; } if (_node.GetType() == typeof(Choices)) { ChoicePanel.SetActive(true); nodeOptions = new List <Node>(); int listIndex = 0; Choices _choiceNode = _node as Choices; NodePort _choicePort = _choiceNode.GetOutputPort("output"); List <NodePort> _nodePorts = _choicePort.GetConnections(); foreach (NodePort _NP in _nodePorts) { nodeOptions.Add(_NP.node); Button _newOption = Instantiate(choiceButton) as Button; _newOption.transform.SetParent(ChoicePanel.transform); listIndex++;//on this button it where on the list it is, using this //ChoiceOptionHolder _holder = _newOption.GetComponent<ChoiceOptionHolder>(); OptionNode optionNode = _NP.node as OptionNode; _newOption.GetComponentInChildren <Text>().text = optionNode.optionText; _newOption.GetComponent <ChoiceOptionHolder>().node = _NP.node; // _holder.node = _NP.node; // _holder.indexOfOptions = listIndex; } return; //do not load next node, since we want the player input to decide the branch to go down } if (_node.GetType() == typeof(TimelineNode)) { TimelineNode timelineNode = _node as TimelineNode; timelineNode.PlayTimeLine(); } //get next node(s) NodePort _port = _node.GetOutputPort("output"); if (_port.IsConnected) { GetNodeFunction(_port.GetConnections()); } } }