//End dialogue void EndDialogue(IDialogueLine dialogue, CharacterSO actorSo) { // depending on the dialogue that ended, do something. The dialogue type can be different from the current dialogue type switch (dialogue.DialogueType) { case DialogueType.StartDialogue: // Check the validity of the step CheckTaskValidity(); break; case DialogueType.WinDialogue: // After playing the win dialogue close Dialogue and end step break; case DialogueType.LoseDialogue: // closeDialogue // replay start Dialogue if the lose Dialogue ended if (_currentTask.StoryBeforeTask != null) { _currentStory = _currentTask.StoryBeforeTask; } break; case DialogueType.DefaultDialogue: // close Dialogue // nothing happens if it's the default dialogue break; } }
/// <summary> /// Prepare DialogueManager when first time displaying DialogueData. /// <param name="storyDataSo"></param> /// </summary> private void BeginDialogueStory(SimpleStorySO storyDataSo) { inputReader.EnableDialogueInput(); inputReader.advanceDialogueEvent += OnAdvance; m_CurrentStory = storyDataSo; _isInputEnabled = false; StopAllCoroutines(); }
// play dialogue of the story void PlayStoryDialogue() { if (defaultStory != null) { _currentStory = defaultStory; StartDialogue(); } }
// register a step void RegisterTask(TaskSO task) { _currentTask = task; // Find me a story where the task belongs to. _currentStory = stories.FirstOrDefault((s) => s.ID == task.ParentId) ?? defaultStory; revisionId = stories.FindIndex(s => s == _currentStory); Debug.Log(revisionId); _hasActiveTask = true; }
void PlayWinDialogue() { if (_currentTask != null) { if (_currentTask.WinStory != null) { _currentStory = _currentTask.WinStory; StartDialogue(); } } }
void PlayLoseDialogue() { if (_currentTask != null) { if (_currentTask.LoseStory != null) { _currentStory = _currentTask.LoseStory; StartDialogue(); } } }
// void EndTask() // { // UnregisterTask(); // } //unregister a step when it ends. private void UnregisterTask() { UpdateRevisionId(); _currentTask = null; _hasActiveTask = false; _hasActiveStory = false; if (stories != null) { if (stories.Count > revisionId) { _currentStory = stories.FirstOrDefault(s => !s.IsDone); } } }
// play default dialogue if no step void PlayDefaultDialogue() { if (defaultStory != null) { _currentStory = defaultStory; StartDialogue(); } else { // if we have nothing to show go back to normal input if (onInteractionEnded != null) { onInteractionEnded.RaiseEvent(); } } }
/// <summary> /// St /// </summary> void PlayTaskDialogue() { if (_currentTask != null) { // if we have a task check the validation if (_hasActiveTask) { CheckTaskValidity(); } // The player is going to get a tasks handed over else if (_currentTask.StoryBeforeTask != null) { _currentStory = _currentTask.StoryBeforeTask; StartDialogue(); } else { Debug.LogError("Task without dialogue registering not implemented."); } } }
/// <summary> /// Displays DialogueData in the UI, one by one. /// Start interaction with the NPC /// </summary> /// <param name="storyDataSo"></param> public void Interact(SimpleStorySO storyDataSo) { BeginDialogueStory(storyDataSo); DisplayDialogueLine(storyDataSo.StartDialogue, storyDataSo.Character); ToggleCameras(true); }