public IEnumerator ReadGroup(string groupToRead) { yield return(true); BREAK_LOOP = false; sentenceVal = ObtainSentenceGroupValue(groupToRead); if (sentenceVal == -1) { yield break; } //When a group must a new number is selected, and the foreach is evaluated again. //Bite me. This is a great use for goto ...you snob. READ_FROM_GROUP: curSentenceValue = -1; //Use this to set the starting sentences. fro save/load system if you save in the middle of dialogue. int intialLine = 0; if (startReadingFromLine > -1) { intialLine = startReadingFromLine; //reset the start of line reading to -1 so that goto' don't break. startReadingFromLine = -1; } if (autoSaveData) { IniGameMemory.instance.WriteData(group, key, groupToRead); //this gets updated during goto's IniGameMemory.instance.WriteData(group, lineKey, 0); //if you ever add a way of specifying a line, then save it here. } //--------------------------------------------------------------------------------------------------- for (int i = intialLine; i < Sentences[sentenceVal].sentences.Count; i++) { SentenceUnit s = Sentences[sentenceVal].sentences[i]; curSentenceUnit = s; curSentenceValue++; next = false; if (autoSaveData) { IniGameMemory.instance.WriteData(group, lineKey, i); } while (pauseTime > 0) { HideDialogueBox(); pauseTime -= Time.deltaTime; yield return(null); } ShowDialogueBox(); Write(s.dialogue); SetNameToWrite(s.speakerName); yield return(true); while (IsPrinting()) { if (BREAK_LOOP) { BREAK_LOOP = false; isReading = false; yield break; } if (PlayerInput.instance != null) { next = PlayerInput.instance.GetFire1_B(); } if (next) { //Make text typeout all at once. SentenceDisplay.EndTypewriterEffect(); next = false; } if (GetFastforwardButton()) { // Time.timeScale = 50f; SentenceDisplay.EndTypewriterEffect(); } yield return(true); } //...now look for skip button input. yield return(true); while (!next && GetFastforwardButton() == false) { if (BREAK_LOOP) { BREAK_LOOP = false; isReading = false; yield break; } if (PlayerInput.instance != null) { next = PlayerInput.instance.GetFire1_B(); } if (autoNextAtEndIfPromptIsRequested) { if (SentenceDisplay.IsPrinting() == false) { if (s.dealWithSpecialCommands == SentenceUnit.DealWithSpecailCommands.UseInPromptMenu) { yield return(new WaitForSeconds(0.5f)); next = true; } } } yield return(true); } next = false; //The multichoice prompt is evaluated before each specail command is requested. //all special commands become a choice in the prompt if (s.dealWithSpecialCommands == SentenceUnit.DealWithSpecailCommands.UseInPromptMenu) { menuPrompt.ClearChoicesList(); List <SpecialCommand> modifiedChoiceList = new List <SpecialCommand>(); int checkCommandNumber = 0; foreach (SpecialCommand command in s.specialCommands) { //Remove choice if memory says to remove it. if (IniGameMemory.instance.GetDataValue(menuGroupName, choiceKeyRootName + checkCommandNumber, -1) == 1) { //skip this command choice. this works, but I need to find a way to have menu choice link to new index number... checkCommandNumber++; continue; } menuPrompt.AddChoice(command.requestName); //The choice list can be modfied, so make a copy of it and build it up from valid options. modifiedChoiceList.Add(command); checkCommandNumber++; } yield return(true); menuPrompt.OpenPrompt(); while (menuPrompt.isPromptOpen()) { if (BREAK_LOOP) { BREAK_LOOP = false; isReading = false; menuPrompt.ClearChoicesList(); menuPrompt.HidePromptDisplay(); yield break; } yield return(true); } sentenceVal = ObtainSentenceGroupValue(modifiedChoiceList[menuPrompt.GetChoice()].commandLine); if (autoSaveData) { groupToRead = s.specialCommands[menuPrompt.GetChoice()].commandLine; } if (sentenceVal == -1) { Debug.LogError("ScreenplayReader Error 01: Group '" + s.specialCommands[menuPrompt.GetChoice()].commandLine + "' does not exist!"); } goto READ_FROM_GROUP; //Bite me. This is a great use for goto ...you snob. } //Parse special commands..................... foreach (SpecialCommand command in s.specialCommands) { switch (s.dealWithSpecialCommands) { case SentenceUnit.DealWithSpecailCommands.Ignore: break; case SentenceUnit.DealWithSpecailCommands.NotifySystem: break; case SentenceUnit.DealWithSpecailCommands.UseInPromptMenu: //... not evaluated here... was delt with by the if statement above. on line starting @ if(s.dealWithSpecialCommands==SentenceUnit.DealWithSpecailCommands.UseInPromptMenu) break; case SentenceUnit.DealWithSpecailCommands.AutoGoto: print("GOTO:" + command.commandLine); //pick a new sentence group and goto that group... sentenceVal = ObtainSentenceGroupValue(command.commandLine); if (autoSaveData) { groupToRead = command.commandLine; } if (sentenceVal == -1) { Debug.LogError("ScreenplayReader Error 01: Group '" + command.commandLine + "' does not exist!"); } goto READ_FROM_GROUP; //Bite me. This is a great use for goto ...you snob. #pragma warning disable CS0162 // Unreachable code detected break; #pragma warning restore CS0162 // Unreachable code detected } } //......................................................................................... } sentenceVal = -1; print("End of conversation"); HideDialogueBox(); yield break; }