示例#1
0
        public void Button(string userAnswer)
        {
            string lastItem    = _randomizer.GetItem(_randomizer.Index - 1);
            string currentItem = _randomizer.GetCurrentItem();
            string answer      = lastItem == currentItem ? "true" : "false";

            if (userAnswer.Equals(answer))
            {
                _timerManager.StartTimerAt(0, 10f);

                _baseScoreHandler.AddScore(1);
            }
            else
            {
                _mistake++;
                if (_mistake > 3)
                {
                    EndGame();

                    return;
                }

                _mistakeText.SetText($"Mistakes: {_mistake}/3");
            }

            StartCoroutine(ChangeWord());
        }
示例#2
0
        public override void EndGame()
        {
            _gameDone = !_gameDone;

            BaseScoreHandler baseScoreHandler = new BaseScoreHandler(0, 100);

            baseScoreHandler.AddScore(_score);
            baseScoreHandler.SaveScore(UserStat.GameCategory.ProblemSolving);

            ShowGraph(
                UserStat.GameCategory.ProblemSolving,
                baseScoreHandler.Score,
                baseScoreHandler.ScoreLimit);

            base.EndGame();
        }
示例#3
0
        public void IncreasePoint()
        {
            _score++;
            if (_score > 14)
            {
                EndGame();

                return;
            }

            _scoreText.SetText($"{(int)_score}/{_maxScore}");

            _baseScoreHandler.AddScore(1);

            IncreaseDifficulty();
        }
示例#4
0
        private void Progress()
        {
            _selectedIdx++;

            if (_selectedIdx > _seqOfClips.Count - 1)
            {
                // Just add point every complete sequence
                if (!_hasError)
                {
                    // Add points
                    _baseScoreHandler.AddScore(1);
                }

                _selectedIdx = 0;
                _repetition++;

                _currentSequenceText.SetText($"#{_repetition + 1}");

                if (_repetition > 10)
                {
                    _baseScoreHandler.SaveScore(UserStat.GameCategory.Memory);

                    ShowGraph(
                        UserStat.GameCategory.Memory,
                        _baseScoreHandler.Score,
                        _baseScoreHandler.ScoreLimit);

                    base.EndGame();

                    return;
                }

                // Show result
                StartCoroutine(SequenceNotif(_hasError));

                // Ready new set of sequence
                RandomPopulate();

                // Disable while waiting
                SetEnableInstrument(false);

                StartCoroutine(PlaySequence());
            }
        }
示例#5
0
        public void CheckAnswer()
        {
            _answerField = (TMP_InputField)_uiManager.GetUI(UIType.InputField, "answer");

            _scoreAddAnimator =
                (Animator)_uiManager.GetUI(UIType.AnimatedMultipleState, "score add anim");

            if (_answerField.text.ToLower().Equals(_randomizer.GetCurrentItem().name.ToLower()))
            {
                FindObjectOfType <AudioManager>().PlayClip("sfx_correct");

                _scoreAddAnimator.GetComponent <TextMeshProUGUI>().SetText("CORRECT!");
                _scoreAddAnimator.SetTrigger("correct");

                _baseScoreHandler.AddScore(1);

                _answerField.text = string.Empty;
            }
            else
            {
                FindObjectOfType <AudioManager>().PlayClip("sfx_incorrect");

                _scoreAddAnimator.GetComponent <TextMeshProUGUI>().SetText("WRONG!");
                _scoreAddAnimator.SetTrigger("wrong");
            }

            if (_randomizer.IsEmpty)
            {
                _currentLevel++;

                // We only have 3 levels
                if (_currentLevel > 2)
                {
                    EndGame();

                    return;
                }

                SetDifficulty(Difficulty.ParseLevel(_currentLevel));
            }

            _puzzlePictureContainer.sprite = _randomizer.GetRandomItem();
        }
示例#6
0
        public void Submit()
        {
            if (_src.clip.name == _answerField.text)
            {
                GetAttachedAudioComponents().FirstOrDefault(i => i.clip.name == "CorrectSFX")?.Play();

                _baseScoreHandler.AddScore(1);

                _scoreText.SetText($"Words: {_baseScoreHandler.Score}/{_words.Length}");

                _timerManager.Seconds += 5f;
            }
            else
            {
                GetAttachedAudioComponents().FirstOrDefault(i => i.clip.name == "IncorrectSFX")?.Play();
            }

            _answerField.GetComponent <TMP_InputField>().text = string.Empty;

            PrepareWord();
        }
示例#7
0
        private void CheckAnswer(bool isCorrect)
        {
            Debug.Log(isCorrect ? "Correct" : "Incorrect");

            if (isCorrect)
            {
                GetAttachedAudioComponents().FirstOrDefault(i => i.clip.name == "CorrectSFX")?.Play();

                _baseScoreHandler.AddScore(_point);
                _scoreText.SetText($"Score:{_baseScoreHandler.Score}");
            }
            else
            {
                GetAttachedAudioComponents().FirstOrDefault(i => i.clip.name == "IncorrectSFX")?.Play();
            }

            ClearAnswersContainer();

            // Every 10 questions increase difficulty
            if (_randomizer.IsEmpty)
            {
                _level++;

                // Upon finishing the Hard part end the game
                if (_level > 2)
                {
                    EndGame();

                    return;
                }

                SetDifficulty(Difficulty.ParseLevel(_level));
            }

            DisplayAnswerOption();
        }
示例#8
0
        private void Update()
        {
            // Forcefully destroys the Animation component to prevent "select" animation to still occur when locked
            if (GameObject.FindGameObjectsWithTag("PuzzlePiece") != null)
            {
                foreach (GameObject piece in GameObject.FindGameObjectsWithTag("PuzzlePiece"))
                {
                    if (piece.GetComponent <TouchManager>().Locked&& piece.GetComponent <Animation>() != null)
                    {
                        Destroy(piece.GetComponent <Animation>());
                    }
                }
            }

            // There is only 4 levels any more increment should result game completion
            if (_currentLevel > 4 && !GameDone)
            {
                GameDone = true;

                EndGame();

                return;
            }

            if (_proceedToNextLevel && !GameDone)
            {
                _proceedToNextLevel = false;

                // Clear current puzzle image shape
                Destroy(_puzzleImage.transform.GetChild(0).gameObject);

                // Then  update level image
                Instantiate(_puzzleImagesPerLevel[_currentLevel - 1], _puzzleImage.transform);

                // Add time as score
                _baseScoreHandler.AddScore(_timerManager.Minutes, _timerManager.Seconds);

                TextMeshProUGUI levelText = (TextMeshProUGUI)_uiManager.GetUI(UIManager.UIType.Text, "level");
                levelText.SetText($"Level: {_currentLevel}");

                // For every level load, timer will reset and start at specified time
                switch (_currentLevel)
                {
                case 2:
                    _timerManager.StartTimerAt(1, 30f);
                    break;

                case 3:
                    _timerManager.StartTimerAt(1, 45f);
                    break;

                case 4:
                    _timerManager.StartTimerAt(2, 00f);
                    break;
                }

                Populate();
            }

            // Timer's up
            if (Mathf.RoundToInt(_timerManager.Seconds) == 0 && Mathf.RoundToInt(_timerManager.Minutes) < 0)
            {
                Transform gameFinishPanel = (Transform)_uiManager.GetUI(UIManager.UIType.Panel, "game finish panel");
                gameFinishPanel.gameObject.SetActive(true);

                TextMeshProUGUI gameResult = (TextMeshProUGUI)_uiManager.GetUI(UIManager.UIType.Text, "game result");
                gameResult.SetText("FAILED!");

                EndGame();
            }
        }