public void ParseUnlockCompanion(string t, Passage p) { // unlockPerson:1 try { int colon1 = t.IndexOf(':'); string companionId = t.Substring(colon1 + 1); CompanionData.ItemID eCompanionId; if (!CompanionData.ItemID.TryParse(companionId, out eCompanionId)) { Debug.LogError($"DialogueManager: failed to parse companionId in unlockPerson tag: {t}"); return; } var unlockStatement = (UnlockCompanionSfStatement)p.GetStatement(SFStatement.Type.UNLOCK_COMPANION); if (unlockStatement == null) { unlockStatement = new UnlockCompanionSfStatement(); p.effects.Add(unlockStatement); } unlockStatement.companionIds.Add(eCompanionId); } catch { Debug.LogError($"DialogueManager: Failed to parse tag {t}"); throw; } }
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(); // } // } }