// Go to the next step in the conversation e.g. Show options, go to the next dialogue in conversation, or go to the next sentence public void Next() { if (!_inConversation) { return; } if (_currentSentence >= _currentDialogue.Sentences.Count - 1) { // Check if there's options to display if (_currentDialogue.Options.Count != 0) { _uiController.ShowOptions(_currentDialogue.Options); } // Check if we need to go to another dialogue else if (_currentDialogue.NextId != -1) { goToDialogue(_currentDialogue.NextId); } // We've finished. else { // Perform any OnFinished actions foreach (var actionName in _currentDialogue.OnFinishedActionNames) { ActionController.PerformAction(_currentConversation, actionName); } StopCurrentConversation(); } } else { // There's more sentences to show _currentSentence++; // Last speaker var sameSpeaker = _lastSpeaker == _currentDialogue.SpeakersName; _lastSpeaker = _currentDialogue.SpeakersName; if (needToChangeTheme()) { ChangeTheme(_currentDialogue.Theme); } _uiController.ShowSentence(_currentDialogue.SpeakersName, parseSentenceForCustomTags(_currentDialogue.Sentences[_currentSentence]), (!sameSpeaker) ? SpriteRepo.Instance.RetrieveSprite(_currentDialogue.CharacterSpritesName, string.IsNullOrEmpty(_currentDialogue.StartingSprite) ? "Default" : _currentDialogue.StartingSprite) : null, //null, // After the conversation has started the sprite should be changed using the changeSprite tag sameSpeaker, _currentDialogue.AutoProceed); } }
// An option was selected public void OptionSelected(int index) { // Perform any selected action foreach (var actionName in _currentDialogue.Options[index].SelectedActionNames) { ActionController.PerformAction(_currentConversation, actionName); } if (_currentDialogue.Options[index].NextId != -1) { goToDialogue(_currentDialogue.Options[index].NextId); } }
// Pass actions to the action controller private void performAction(string actionName) => ActionController.PerformAction(_conversation, actionName);
// Called from the UIController, used by the action custom tag public void PerformAction(string actionName) => ActionController.PerformAction(_currentConversation, actionName);