public void OnButtonPressed(int buttonID) { if (currentNode.getNextNode() == -1) { if (currentNode.getEvent() != null) { currentNode.triggerEvent(); } if (currentNode.getNumButtons() != 0) { currentNode = currentNode.getChildAt(buttonID); displayText(currentNode.getLine()); } else { endDialogue(); } } else { if (currentNode.getEvent() != null) { currentNode.triggerEvent(); } currentNode = currentNode.getChildAt(currentNode.getNextNode()); displayText(currentNode.getLine()); } }
///<summary>Start a dialogue with the existing tree and without disabling anything. ///This is mostly used for colliders, where we still want them to have collision but we don't want it to stop interacting entirely ///</summary> public void startDialogue() { gameObject.GetComponent <Canvas>().enabled = true; gameObject.GetComponent <GraphicRaycaster>().enabled = true; //Prevent the player from moving while they're in dialogue player.GetComponent <CustomPlatformer2DUserControl>().canControl = false; player.GetComponentInChildren <Animator>().SetFloat("Speed", 0f); player.GetComponent <Rigidbody2D>().velocity = Vector3.zero; currentNode = dialogueTree.getNodeAtIndex(1); currentButtonLayout = null; displayText(currentNode.getLine()); }
public void startDialogue(TextAsset dialogue, Collider2D triggerToDisable, Sprite NPCSprite) { triggeredThis = triggerToDisable; triggeredThis.enabled = false; gameObject.GetComponent <Canvas>().enabled = true; gameObject.GetComponent <GraphicRaycaster>().enabled = true; //Prevent the player from moving while they're in dialogue player.GetComponent <CustomPlatformer2DUserControl>().canControl = false; player.GetComponentInChildren <Animator>().SetFloat("Speed", 0f); player.GetComponent <Rigidbody2D>().velocity = Vector3.zero; dialogueTextAsset = dialogue; dialogueTree = new dialogueTree(dialogue.text, dialogueEvent, NPCSprite); currentNode = dialogueTree.getNodeAtIndex(1); currentButtonLayout = null; displayText(currentNode.getLine()); }