public void ContinueDialogue() { tempNextAvailablePassages.Clear(); currentPassage.GetNextAvailablePassages(ref tempNextAvailablePassages); if (tempNextAvailablePassages.Count != 0) { CheckAllNextAreSameType(); switch (tempNextAvailablePassages[0].type) { case Passage.PassageType.COMPANION_MESSAGE: case Passage.PassageType.COMPANION_IMAGE: if (tempNextAvailablePassages.Count > 1) { Debug.LogError($"ChatScreenWidget: Error: Several t:p next passages possible for passage with id {currentPassage.pid} of companion {currentCompanion.id}"); } else { PrepareNewPassagePresent(); } break; case Passage.PassageType.HERO_MESSAGE: ClearCurrentAnswers(); state = State.WAITING_FOR_ANSWER; for (int i = 0; i < tempNextAvailablePassages.Count; i++) { Answer answer = CreateAnswer(tempNextAvailablePassages[i]); LayoutRebuilder.ForceRebuildLayoutImmediate(answer.rectTransform); } LayoutRebuilder.ForceRebuildLayoutImmediate(answerRoot); LayoutRebuilder.ForceRebuildLayoutImmediate(answerRoot); break; case Passage.PassageType.ADVICE: if (tempNextAvailablePassages.Count > 1) { Debug.LogError($"ChatScreenWidget: Error: Several t:p next passages possible for passage with id {currentPassage.pid} of companion {currentCompanion.id}"); } else { PrepareNewPassagePresent(); // currentPassage = tempNextAvailablePassages[0]; // var adivceW = UIManager.Instance.GetWidget<AdviceWidget>(); // adivceW.ShowWithAdvice(currentPassage.parsedText); // PresentPassage(true); } break; } } else { state = State.DIALOGUE_FINISHED; } }
public override void Show(Action onComplete = null) { base.Show(onComplete); if (firstTimeShown) { StartCoroutine(GradualInit()); firstTimeShown = false; } savePath = true; executeStatements = true; soundEnabled = true; currentStatement = null; currentStatementIndex = -1; var newCompanion = Inventory.Instance.worldState.Value.GetCompanion(Inventory.Instance.currentCompanion.Value); if (currentCompanion == null || newCompanion.Data.id != currentCompanion.Data.id || currentCompanion.lastDialogueTaken != currentCompanion.activeDialogue) { dialogueIsBuilt = false; ResetScreen(); } var lm = LayoutManager.Instance; currentCompanion = newCompanion; companionNameText.fontSize = 1.25f * lm.esw; currentCompanion.lastDialogueTaken = currentCompanion.activeDialogue; currentDialog = currentCompanion.activeDialogue; // screenWidth = UIManager.Instance.canvasRectTransform.rect.size.x; // em = screenWidth / 25f; // margins = new Vector4(em, 0.5f * em, em, 0.5f * em); typingText.fontSize = 0.75f * lm.esw; SFDialogue dialogue = currentCompanion.dialogues[currentCompanion.activeDialogue]; var path = dialogue.path; // we either talked to some companion, went back and entered another companion screen // or this is the first time we enter companion screen if (!dialogueIsBuilt) { time = 0; timeToWait = 0; SetEmotionAndName(currentCompanion, "main"); BuildPastConversation(); // dialogue was undergoing before if (path.Count != 0) { currentPassage = dialogue.root.Find(path[path.Count - 1]); tempNextAvailablePassages.Clear(); currentPassage.GetNextAvailablePassages(ref tempNextAvailablePassages); // if it is the end of the dialogue present last passage and do nothing if (tempNextAvailablePassages.Count == 0) { savePath = false; executeStatements = false; soundEnabled = false; PresentPassage(); savePath = true; executeStatements = true; soundEnabled = true; state = State.DIALOGUE_FINISHED; } // if dialogue is continuing then show last line with sound effect else { savePath = false; executeStatements = false; PresentPassage(); savePath = true; executeStatements = true; ContinueDialogue(); } } // dialogue is undergoing first time else { currentPassage = dialogue.root.startPassage; SFStatement e = currentPassage.GetStatement(SFStatement.Type.CHANGE_IMAGE); if (e != null) { e.Execute(); } e = currentPassage.GetStatement(SFStatement.Type.SET_COMPANION_NAME); if (e != null) { e.Execute(); } StartDialogue(); //blocking } } // else // { // if (path.Count != 0) // { // StartDialogue(); // } // } }