/// <summary> /// Helper function to handle state WaitingText. /// </summary> void HandleWaitingText() { //If we're waiting on text, on the continue key we need to move on to the next correct block. //If there is no next block, exit dialogue. if (Input.GetKeyDown(continue_key)) { //Need to cast the block since we normally store it as TextBlock. DialogueBlock DB = (DialogueBlock)cur_block; //Get the next block. Store in memory as temp. TextBlock tempBlock = DB.GetNext(); //If we there is no next block, exit dialogue. if (tempBlock == null) { cur_block = null; textbox.text = ""; SetState(DM_STATE.Sleeping); } else //If there is a valid next block, set it and init once again. { cur_block = tempBlock; SetState(DM_STATE.Init); } } }
public void SetCurrentDialogueBlock(int id) { if (dialogue == null) { ReadJson jsonReader = GameObject.FindObjectOfType<ReadJson> (); dialogue = jsonReader.GetCharacterDialogue (npcAdapter.NpcName); } DialogueBlock newBlock = null; foreach (DialogueBlock block in dialogue) { if (block.id == id) { newBlock = block; } } currentDialogueBlock = newBlock; npcAdapter.CurrentDialogueBlock = newBlock; if (currentDialogueBlock is BranchDialogueBlock) { currentIsBranch = true; } else { currentIsBranch = false; if (currentDialogueBlock is LinearEffectDialogueBlock) { currentHasEffect = true; } else { currentHasEffect = false; } } currentLine = 0; blockFinished = false; }
public void StartDialogue(Dialogue dialogue) { dialogueUI.transform.GetChild(0).gameObject.SetActive(false); dialogueUI.transform.GetChild(1).gameObject.SetActive(false); dialogueUI.transform.GetChild(2).gameObject.SetActive(false); NameText.text = dialogue.Name; DialogueBlock = dialogue.dialogueBlock; //ele pega o bloco de dialogo que contem todos os dialogos DialogueBlock.index = i; Boss = DialogueBlock.Boss; Festa = DialogueBlock.Festa; Reflexao = DialogueBlock.Reflexão; if (NameText.text == "Alex") { dialogueUI.transform.GetChild(2).gameObject.SetActive(true); } else if (NameText.text != "Alex" && Boss == true) { dialogueUI.transform.GetChild(1).gameObject.SetActive(true); } else { dialogueUI.transform.GetChild(0).gameObject.SetActive(true); } animator.SetBool("IsOpen", true); _sentences.Clear(); foreach (string sentence in dialogue.Sentences) { _sentences.Enqueue(sentence); //organiza em ordem os textos para escreve-los } DisplayNextSentence(); }
/// <summary> /// Helper function that just creates a dialogue block. /// </summary> /// <param name="in_key"></param> /// <param name="in_path"></param> public static DialogueBlock CreateDialogueBlock(string in_key, string in_path) { DialogueBlock db = ScriptableObjectUtility.CreateAsset <DialogueBlock>(in_path, in_key); db.SetKey(in_key); return(db); }
// Use this for initialization void Start() { dManager = FindObjectOfType<DialogueUIManager>(); reader = FindObjectOfType<ReadJson>(); dialogue = reader.GetCharacterDialogue("sortingGameIntro"); currentDialogueBlock = dialogue[0]; Time.timeScale = 0; blockFinished = false; justStarted = true; }
public void StartDialogue(Dialogue dialogue) { NameText.text = dialogue.Name; DialogueBlock = dialogue.dialogueBlock; //ele pega o bloco de dialogo que contem todos os dialogos DialogueBlock.index = i; Boss = DialogueBlock.Boss; _sentences.Clear(); foreach (string sentence in dialogue.Sentences) { _sentences.Enqueue(sentence); //organiza em ordem os textos para escreve-los } DisplayNextSentence(); }
void DialogueStart() { print(currentFish.dateProgress); foreach (GameObject answer in answers) { answer.SetActive(false); } currentDialogueBlock = currentFish.dates.Find(x => x.dateNumber == currentFish.dateProgress).startingDialogue; textField.SetActive(true); SplitAndType(); state = DialogueState.fishTalks; }
/// <summary> /// Helper function that sets a dialogue block given some line data. /// </summary> /// <param name="lineData"></param> static void SetDialogueBlock(string[] lineData) { //Extract the data we need. string key = lineData[0]; string text = lineData[2]; string flagSetListText = lineData[3]; string nextBlockListText = lineData[4]; //Use helper function to parse flag set list. List <FlagSet> flagSetList = ParseFlagSetList(flagSetListText); //Use helper function to parse next block list. List <NextBlock> nextBlockList = ParseNextBlockList(nextBlockListText); DialogueBlock block = (DialogueBlock)SceneBlockDictionary[key]; block.SetDialogueBlock(text, flagSetList, nextBlockList); }
//public void StartDialogue() //{ // if(startDialogue) // { // //currentDialogueBlock = fishFiles.Find(x => x.fish == currentFish) // // .dates.Find(x => x.dateNumber == fishFiles.Find(z => z.fish == currentFish).dateProgress) // // .startingDialogue; // //currentSplittedTextFile = new List<string>(currentDialogueBlock.dialogue.Split('/')); // //textField.GetComponent<Text>().text = currentSplittedTextFile[1]; // //currentDialogueBlock.dialogue = "heyyy"; // startDialogue = false; // } //} public void Answer(int answerNumber) { if (currentDialogueBlock.answers[answerNumber].nextBlockFrom != null && currentDialogueBlock.answers.Count != 0) { switch (currentDialogueBlock.answers[answerNumber].color) { case DialogueBlock.Answer.AnswerColor.red: currentFish.redAnswers++; break; case DialogueBlock.Answer.AnswerColor.blue: currentFish.blueAnswers++; break; case DialogueBlock.Answer.AnswerColor.green: currentFish.greenAnswers++; break; } currentDialogueBlock = currentDialogueBlock.answers[answerNumber].nextBlockFrom; state = DialogueState.fishTalks; SplitAndType(); } else { //Adria specialcase if (currentDialogueBlock.name == "Adria_Intro" || currentDialogueBlock.name != "1Toss" || currentDialogueBlock.name != "2Toss" || currentDialogueBlock.name != "3Toss" || currentDialogueBlock.name != "4Toss") { TossBackAdria(); } else if (currentDialogueBlock.name != "5Toss") { print("Adria gameover??"); } else { EndDate(); } } }
/// <summary> /// Populates our dictionary with all the blocks we need and makes the objects in the folders. /// </summary> /// <param name="lines"></param> static void PopulateDictionaryAndFolders(string[] lines, string path, string sceneName) { //Clear the directory ClearFolder(path); //Refresh the dictionary. SceneBlockDictionary = new Dictionary <string, TextBlock>(); //This ignore bool is for the first line, which are just headers. bool ignore = true; foreach (string line in lines) { //Ignore first line. if (ignore) { ignore = false; } else if (!ignore) { //Separate by commas. (CSV) string[] lineData = (line.Trim()).Split(","[0]); //This is the type of block this is. string key = lineData[0]; string type = lineData[1]; if (type.Equals("DialogueBlock")) { DialogueBlock db = DialogueBlock.CreateDialogueBlock(key, path); SceneBlockDictionary.Add(key, (TextBlock)db); } else if (type.Equals("DecisionBlock")) { DecisionBlock db = DecisionBlock.CreateDecisionBlock(key, path); SceneBlockDictionary.Add(key, (TextBlock)db); } } } //Store this scenes block dictionary into the scene. AllSceneBlockDictionary.Add(sceneName, SceneBlockDictionary); }
public void DisplayDialogue(DialogueBlock dialogueBlock) { StartDialogue(dialogueBlock.Dialogue[i]); //le o proximo dialogo do bloco }
void Start() { block = GetComponent <DialogueBlock>(); block.TriggerDialogue(); }
/// <summary> /// Populates the flag dictinoary with all the flags found in our excel sheet. /// </summary> static void InitFlagFile(List <string> fileNameList) { //Get the flag dict List <string> flagList = new List <string>(); foreach (string FileName in fileNameList) { //Read in all text from the given file (csv) and split by line. string fileData = System.IO.File.ReadAllText(path + FileName + ".csv"); string[] lines = fileData.Split("\n"[0]); //This ignore bool is for the first line, which are just headers. bool ignore = true; foreach (string line in lines) { //Ignore first line. if (ignore) { ignore = false; } else if (!ignore) { //Separate by commas. (CSV) string[] lineData = (line.Trim()).Split(","[0]); //This is the type of block this is. string key = lineData[0]; string type = lineData[1]; if (SceneBlockDictionary.ContainsKey(key)) { //First process the flag set list. List <FlagSet> flagSetList = SceneBlockDictionary[key].GetFlagSetList(); //Loop through all flags in flag set list. foreach (FlagSet fs in flagSetList) { if (!flagList.Contains(fs.flag_key)) { flagList.Add(fs.flag_key); } } //Then check for further flags found in the specific block type. if (type.Equals("DialogueBlock")) { DialogueBlock db = (DialogueBlock)SceneBlockDictionary[key]; foreach (string flag in db.GetDependentFlags()) { //If we don't have this flag in the list yet, add it. if (!flagList.Contains(flag)) { flagList.Add(flag); } } } else if (type.Equals("DecisionBlock")) { DecisionBlock db = (DecisionBlock)SceneBlockDictionary[key]; } } else { throw new System.Exception("Error, given key: " + key + " from file: + " + FileName + " isn't in our dictionary. Reload the csv to populate it."); } } } } //Path that we are going to write to. string file_path = "Assets/Data/FlagData.txt"; //Write some text to the test.txt StreamWriter writer = new StreamWriter(file_path, false); foreach (string flag in flagList) { writer.WriteLine(flag + ", false"); } writer.Close(); Debug.Log("Finished. Flag file initialized at: " + file_path); }