public void UpdateNode(VD.NodeData choice) { // Feedback eventStartChoice.Invoke(); /*moveCharacter.MoveToNewParent(transformStart); * * for (int i = 0; i < feedbacks.Length; i++) * { * feedbacks[i].SetBool("Appear", true); * }*/ // ============ for (int i = 0; i < choice.comments.Length; i++) { if (buttonList.Count <= i) { buttonList.Add(Instantiate(buttonPrefab, buttonListParent)); } buttonList[i].gameObject.SetActive(true); buttonList[i].DrawButton(choice.comments[i], choiceInterval * i); buttonList[i].AssignID(i); } for (int i = choice.comments.Length; i < buttonList.Count; i++) { buttonList[i].gameObject.SetActive(false); } }
//Will start and end the assigned dialogue public void Interact() { if (!questChartContainer.activeSelf) { questChartContainer.SetActive(true); VD.NodeData nd = VD.BeginDialogue(assigned); LoadChart(nd); } else { for (int i = 0; i < peGameObject.transform.parent.childCount; i++) { if (i != 0) { Destroy(peGameObject.transform.parent.GetChild(i).gameObject); } } for (int i = 0; i < ovGameObject.transform.parent.childCount; i++) { if (i != 0) { Destroy(ovGameObject.transform.parent.GetChild(i).gameObject); } } questChartContainer.SetActive(false); VD.EndDialogue(); } }
void UpdateChoices(VD.NodeData data) { //Color the Player options. Yellow for the selected one for (int i = 0; i < currentChoices.Count; i++) { currentChoices[i].color = Color.white; //currentChoices[i].rectTransform.localPosition = new Vector3(0, 0, 0); //currentChoices[i].GetComponent<LayoutElement>().preferredHeight = 46; if (currentChoices[i].rectTransform.localPosition.x > 0) { //currentChoices[i].rectTransform.DOLocalMoveX(0, 0.1f); //currentChoices[i].rectTransform.localPosition = new Vector3(0,0,0); } if (i == data.commentIndex) { currentChoices[i].color = Color.yellow; //currentChoices[i].GetComponent<LayoutElement>().preferredHeight = 56; //currentChoices[i].rectTransform.DOLocalMoveX(5, 0.1f); //currentChoices[i].rectTransform.localPosition = new Vector3(5, 0, 0); } } //Debug.Log(currentChoices[0].text + " " + currentChoices[0].rectTransform.localPosition.x); }
void UpdateUI(VD.NodeData data) { container_Text.SetActive(false); container_Choices.SetActive(false); nextQuestionGameObject.SetActive(false); if (data.isPlayer) { container_Choices.SetActive(true); nextQuestionGameObject.SetActive(true); nextButton.SetActive(false); for (int i = 0; i < choices.Length; i++) { if (i < data.comments.Length) { choices[i].transform.parent.gameObject.SetActive(true); choices[i].text = data.comments[i]; } else { choices[i].transform.parent.gameObject.SetActive(false); } } } else { container_Text.SetActive(true); nextButton.SetActive(true); text.text = data.comments[data.commentIndex]; } }
private void UpdateUI(VD.NodeData data) { //What happens when we change node; //First, we check whether the node is player or NPC npcUi.SetActive(false); playerUI.SetActive(false); if (data.isPlayer) { playerUI.SetActive(true); for (int i = 0; i < playerTextChoices.Length; i++) { if (i < data.comments.Length) { playerTextChoices[i].text = data.comments[i]; playerTextChoices[i].transform.parent.gameObject.SetActive(true); } else { playerTextChoices[i].transform.parent.gameObject.SetActive(false); } } playerTextChoices[0].transform.parent.GetComponent <Button>().Select(); } else { npcUi.SetActive(true); npcText.text = data.comments[data.commentIndex]; //=> Setting the UI text to the current text from the node //"it will continue to do so until we reach the last one and move on to the next node." } }
//Conditions we check after VD.Next was called but before we update the UI void PostConditions(VD.NodeData data) { //Don't conduct extra variable actions if we are waiting on a paused action if (data.pausedAction) { return; } if (!data.isPlayer) //For player nodes { //Replace [WORDS] ReplaceWord(data); //Checks for extraData that concerns font size(CrazyCap node 2) //if (data.extraData[data.commentIndex].Contains("fs")) // { // int fSize = 36; // string[] fontSize = data.extraData[data.commentIndex].Split(","[0]); // int.TryParse(fontSize[1], out fSize); // NPC_Text.fontSize = fSize; // } // else // { // NPC_Text.fontSize = 36; // } } }
void NodeChangeAction(VD.NodeData data) { talkText.text = ""; talkText.transform.parent.gameObject.SetActive(false); if (data.isPlayer) { } else { if (data.sprite != null) { if (data.extraVars.ContainsKey("side")) { int side = (int)data.extraVars["side"]; } } else { } npcTextAnimator = AnimateText(data); StartCoroutine(npcTextAnimator); talkText.transform.parent.gameObject.SetActive(true); } }
void UpdateUI(VD.NodeData data) { container_PLAYER.SetActive(false); if (data.isPlayer) { container_PLAYER.SetActive(true); pushDialogNext.gameObject.SetActive(false); for (int i = 0; i < text_Choices.Length; i++) { if (i < data.comments.Length) { text_Choices[i].transform.parent.gameObject.SetActive(true); text_Choices[i].text = data.comments[i]; } else { text_Choices[i].transform.parent.gameObject.SetActive(false); } } text_Choices[0].transform.parent.GetComponent <Button>().Select(); } else { pushDialogNext.gameObject.SetActive(true); container_NPC.SetActive(true); text_NPC.text = data.comments[data.commentIndex]; if (VD.GetNext(true, false).isPlayer) { VD.Next(); } } }
//Every time VD.nodeData is updated, this method will be called. (Because we subscribed it to OnNodeChange event) void UpdateUI(VD.NodeData data) { WipeAll(); //Turn stuff off first if (!data.isPlayer) //For NPC. Activate text gameobject and set its text { NPC_text.gameObject.SetActive(true); NPC_text.text = data.comments[data.commentIndex]; } else //For Player. It will activate the required Buttons and set their text { for (int i = 0; i < PLAYER_text.Length; i++) { if (i < data.comments.Length) { PLAYER_text[i].transform.parent.gameObject.SetActive(true); PLAYER_text[i].text = data.comments[i]; } else { PLAYER_text[i].transform.parent.gameObject.SetActive(false); } PLAYER_text[0].transform.parent.GetComponent <Button>().Select(); } } }
void End(VD.NodeData data) { DisableContainers(); VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); }
private void UpdateUI(VD.NodeData data) { if (data.isPlayer) { ResetPlayerChoiceTxt(); nextBtn.enabled = false; for (int i = 0; i < txtPlayerChoices.Length; i++) { if (i < data.comments.Length) { txtPlayerChoices[i].transform.parent.gameObject.SetActive(true); txtPlayerChoices[i].text = data.comments[i]; } else { txtPlayerChoices[i].transform.parent.gameObject.SetActive(false); } } } else { ResetPlayerChoiceTxt(); nextBtn.enabled = true; txtNPC.text = data.comments[data.commentIndex]; npcNameTxt.text = VD.assigned.alias; } }
//Check some of the Quests completion public static void CheckTaskCompletion(VD.NodeData data) { if (VD.assigned == null) { return; } if (!interactedWith.Contains(VD.assigned.gameObject.name)) { interactedWith.Add(VD.assigned.gameObject.name); } //Check // 0 Talk to Everyone // 1 Listen to CylinderGuy // 2 Get all items from Crazy Cap // 3 Threaten Charlie if (interactedWith.Count == totalInteractions) { SetQuest(0, false); } if (cylinderGuyInteractions.Count == cylinderGuyTotal) { SetQuest(1, false); } }
void ReplaceWord(VD.NodeData data) { //if (data.comments[data.commentIndex].Contains("[NAME]")) // data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[NAME]", VD.assigned.gameObject.name); if (data.comments[data.commentIndex].Contains("[WEAPON]")) { data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[WEAPON]", "sword"); } if (data.extraVars.ContainsKey("ReplaceItem")) { string itemName = CookingMain.GetIngredientName(textReplaceIngredient, (int)data.extraVars["ReplaceItem"] == 1); data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[ITEM]", itemName); } if (data.extraVars.ContainsKey("ReplaceItems")) { string items = CookingMain.Instance.GetNamesOfIngredientsInStew(); data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[ITEMS]", items); } if (data.extraVars.ContainsKey("ReplaceScore")) { data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[SCORE]", stewScore.ToString()); } }
void UpdateUI(VD.NodeData data) { container_NPC.SetActive(false); container_PLAYER.SetActive(false); if (data.isPlayer) { container_PLAYER.SetActive(true); //loop through player node comments to enable varying amounts of buttons (1 to 3) for (int i = 0; i < text_Choices.Length; i++) { if (i < data.comments.Length) { text_Choices[i].transform.parent.gameObject.SetActive(true); text_Choices[i].text = data.comments[i]; } else { text_Choices[i].transform.parent.gameObject.SetActive(false); } } } else { container_NPC.SetActive(true); text_NPC.text = data.comments[data.commentIndex]; } }
// End handles deactivation of dialogue private void End(VD.NodeData data) { // unpause player control if (DialogueInPause != null) { DialogueInPause.enabled = true; } VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); // disable UI containers & dialogue escape button @ conclusion of dialogue HideEscapeButton(); if (npc_container != null && player_container != null) { npc_container.SetActive(false); player_container.SetActive(false); } } // handles ending dialogue in case of errors private void OnDisable() { // unpause player control if (DialogueInPause != null)
void ParseAndSetModeFromNode(VD.NodeData node) { if (node.extraVars.ContainsKey("mode")) { object obj = node.extraVars["mode"]; string s = (string)obj; try { DialogueMode prevmode = mode; mode = (DialogueMode)System.Enum.Parse(typeof(DialogueMode), s); if (prevmode == DialogueMode.Ambient && mode == DialogueMode.Dialogue) { nextButton.gameObject.SetActive(false); } } catch { Debug.LogError("Dialogue Mode couldn't be parsed. Spelling error? " + s + " in node " + node.nodeID); } } else { return; //no change. keep as is. } }
private void UpdateUI(VD.NodeData data) { containerNPC.SetActive(false); containerPlayer.SetActive(false); if (data.isPlayer) { Debug.Log("data is player"); containerPlayer.SetActive(true); for (int i = 0; i < textChoices.Length; i++) { if (i < data.comments.Length) { textChoices[i].transform.parent.gameObject.SetActive(true); textChoices[i].text = data.comments[i]; } else { textChoices[i].transform.parent.gameObject.SetActive(false); } } textChoices[0].transform.parent.GetComponent <Button>().Select(); } else { Debug.Log("Data is NPC"); containerNPC.SetActive(true); textNPC.text = data.comments[data.commentIndex]; } }
//Check to see if there's Extra Variables and if so, we do stuff void PostCheckExtraVariables(VD.NodeData data) { //Don't conduct extra variable actions if we are waiting on a paused action if (data.pausedAction) { return; } if (!data.isPlayer) //For player nodes { //Replaces [NAME] if (data.extraVars.ContainsKey("nameLookUp")) { nameLookUp(data); } //Checks for extraData that concerns font size (CrazyCap node 2) if (data.extraData[data.commentIndex].Contains("fs")) { string[] fontSize = data.extraData[data.commentIndex].Split(","[0]); int fSize = 14; int.TryParse(fontSize[1], out fSize); npcText.fontSize = fSize; } else { npcText.fontSize = 14; } } return; }
//This will be called when we reach the end of the dialogue. //Very important that this gets called before we call BeginDialogue again! void End(VD.NodeData data) { VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); //Third most important method when using VIDE WipeAll(); }
private void OnNodeChange(VD.NodeData data) { container_NPC.SetActive(false); container_PLAYER.SetActive(false); if (data.isPlayer) { container_PLAYER.SetActive(true); for (int i = 0; i < text_Choices.Length; i++) { if (i < data.comments.Length) { text_Choices[i].transform.parent.gameObject.SetActive(true); text_Choices[i].text = data.comments[i]; } else { text_Choices[i].transform.parent.gameObject.SetActive(false); } } } else { container_NPC.SetActive(true); text_NPC.text = data.comments[data.commentIndex]; image_NPC.sprite = data.sprite; } }
//This will replace any "[NAME]" with the name of the gameobject holding the VIDE_Assign //Will also replace [WEAPON] with a different variable void ReplaceWord(VD.NodeData data) { if (data.comments[data.commentIndex].Contains("[NAME]")) { data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[NAME]", VD.assigned.gameObject.name); } }
//This will be called when we reach the end of the dialogue. //Very important that this gets called before we call BeginDialogue again! void End(VD.NodeData data) { canvas.GetComponent <CanvasGroup>().alpha = 0.0f; VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); //Third most important method when using VIDE WipeAll(); }
private void End(VD.NodeData data) { containerNPC.SetActive(false); containerPlayer.SetActive(false); VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); }
void End(VD.NodeData data) { container_Choices.SetActive(false); container_Text.SetActive(false); VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); }
void End(VD.NodeData data) { left.gameObject.SetActive(false); right.gameObject.SetActive(false); VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); }
//This will replace any "[NAME]" with the name of the gameobject holding the VIDE_Assign //Will also replace [WEAPON] with a different variable void ReplaceWord(VD.NodeData data) { //if (data.comments[data.commentIndex].Contains("[NAME]")) // data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[NAME]", VD.assigned.gameObject.name); //if (data.comments[data.commentIndex].Contains("[WEAPON]")) // data.comments[data.commentIndex] = data.comments[data.commentIndex].Replace("[WEAPON]", player.demo_ItemInventory[0].ToLower()); }
void End(VD.NodeData data) { container_NPC.SetActive(false); container_PLAYER.SetActive(false); VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); }
private void End(VD.NodeData data) { cursorManager.showDialogBox = false; containerDialogue.SetActive(false); VD.OnActionNode -= ActionUI; VD.OnNodeChange -= UpdateUI; VD.OnEnd -= End; VD.EndDialogue(); }
//Unsuscribe from everything, disable UI, and end dialogue void EndDialogue(VD.NodeData data) { CheckTasks(); VD.OnActionNode -= ActionHandler; VD.OnNodeChange -= NodeChangeAction; VD.OnEnd -= EndDialogue; uiContainer.SetActive(false); VD.EndDialogue(); }
private void OnEnd(VD.NodeData data) { container_NPC.SetActive(false); container_PLAYER.SetActive(false); dialogue_Background.SetActive(false); VD.OnNodeChange -= OnNodeChange; VD.OnEnd -= OnEnd; VD.EndDialogue(); }