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()); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { if (firstEncoutner) { gameObject.GetComponent <BoxCollider2D>().enabled = false; dialogueManager.makeDialogueTree(questIntro, wizardSprite); nodeTextLine branchingNode = dialogueManager.dialogueTree.getNodeAtIndex(3); //We hide the third option because we only want to access it through external variables branchingNode.setNumButtons(2); //These are those external variables that affect the if (currentAppleStatus == appleStatus.eaten) { branchingNode.setNextNode(2); branchingNode.setLine("So I helped you, will you help me?|Oh, Um..."); } else if (currentAppleStatus == appleStatus.gotten) { branchingNode.setNextNode(3); branchingNode.setLine("So I helped you, will you help me?|Oh, actually...!"); } dialogueManager.startDialogue(GetComponent <Collider2D>()); firstEncoutner = false; //Shrink the box back down after the player has ran into him the first time. GetComponent <BoxCollider2D>().size = new Vector2(5.5f, 6.5f); GetComponent <BoxCollider2D>().offset = new Vector2(0f, 0f); } } }
///<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()); }
//Accessors and mutators public void addChild(nodeTextLine child) { children.Add(child); }