Exemple #1
0
    /// <summary>
    /// Check the input that the user has provided, and determine action based on the current story status
    /// </summary>
    /// <param name="userInput">User input from a text field</param>
    public void OnAnswerSubmit(string userInput)
    {
        //Check if the input has any content
        if (!string.IsNullOrEmpty(userInput) && !string.IsNullOrWhiteSpace(userInput))
        {
            //Chec if the input matches task answers
            if (IsInputCorrectAnswer(userInput))
            {
                _taskView.SetAnswerStatus(true);
                //Set the location completed
                _locationModel.SetCompletionStatus(true);
                //Check if all location within the story have been completed
                if (_storyModel.AllLocationsCompleted())
                {
                    //All locations completed -> set story as completed
                    _storyModel.SetCompletionStatus(true);

                    //Create new model for the StorytellingView
                    new StorytellingModel()
                    {
                        StorySprite        = _activeStory.storytellingSprite,
                        StorytellingStatus = StorytellingStatus.STORYOUTRO,
                        StoryTitle         = _activeStory.GetLocalizedStoryFinishTitle(),
                        StoryText          = _activeStory.GetLocalizedOutroText()
                    };

                    //New navigation interaction with direction to story ending
                    NavigationInteraction(_taskView.gameObject, NavigationDirection.STORYEND);
                }
                else
                {
                    //Not all locations were completed, navigate forward from this view
                    NavigationInteraction(_taskView.gameObject, NavigationDirection.FORWARD);
                }
            }
            else
            {
                //User input did not match any answer
                _taskView.SetAnswerStatus(false);
            }
        }
    }