Пример #1
0
    private void CreateDiscoveryPrompt()
    {
        GameObject newDiscoveryPrompt = Instantiate(discoveryPromptPrefab, background);

        newDiscoveryPrompt.transform.Find("SecondLine").GetComponent <Text>().text = _targetedPlace.engName;

        String gameType   = _targetedPlace.gameType;
        String difficulty = _targetedPlace.gameDifficulty;

        newDiscoveryPrompt.transform.Find("FourthLine").GetComponent <Text>().text =
            "Game type: " + gameType + "\nDifficulty: " + difficulty;
        newDiscoveryPrompt.transform.Find("Buttons/BTN_NO").GetComponent <Button>().onClick.AddListener(delegate
        {
            var pb = new Save.PlaceBlock {
                placeId = _targetedPlace.id, blockUntil = DateTime.Now.AddSeconds(300)
            };
            _playerController.BlockedPlaces.Add(pb);
            _playerController.Settings.SelectedPlace = null;
            _promptExists = false;
            SetTargetToNearestPlace();
            Destroy(newDiscoveryPrompt);
        });
        newDiscoveryPrompt.transform.Find("Buttons/BTN_YES").GetComponent <Button>().onClick.AddListener(delegate
        {
            _playerController.CurrentPlayedPlaceId   = _targetedPlace.id;
            _playerController.Settings.SelectedPlace = null;

            if (gameType.Equals("Quiz"))
            {
                _sceneController.GoToScene(SceneController.SCN_QUIZ_LEARNING);
            }
            else if (gameType.Equals("Puzzle"))
            {
                _sceneController.GoToScene(SceneController.SCN_PUZZLE_GAME);
            }
            else
            {
                _sceneController.GoToScene(SceneController.SCN_ACTION_GAME);
            }
        });
    }
Пример #2
0
    private IEnumerator PrepareForNextQuestion()
    {
        ChangeButtonState(false);
        _currentQuestionNumber++;
        if (_currentQuestionNumber < _currentQuiz.questions.Count)
        {
            yield return(new WaitForSeconds(5));

            LoadNextQuestion();
            ResetColorOfButtons();
            ChangeButtonState(true);
        }
        else
        {
            yield return(new WaitForSeconds(2));

            if (_correctlyAnsweredQuestionsNumber == _currentQuiz.questions.Count)
            {
                _playerController.AddPoints(_currentQuiz.points);
                _playerController.DiscoveredPlaces.Add(_currentQuiz.id);
                questionText.text = "Quiz was passed successfully!";
                yield return(new WaitForSeconds(3));

                _sceneController.GoToScene(SceneController.SCN_INSPIRATIONAL_LEARNING);
            }
            else
            {
                var pb = new Save.PlaceBlock {
                    placeId = _playerController.CurrentPlayedPlaceId, blockUntil = DateTime.Now.AddSeconds(300)
                };
                _playerController.BlockedPlaces.Add(pb);
                questionText.text = $"Unfortunately you have not passed the quiz successfully. Number of correct answers: {_correctlyAnsweredQuestionsNumber}/{_currentQuiz.questions.Count}";
                yield return(new WaitForSeconds(5));

                _sceneController.GoBackFromGame();
            }
        }
    }