Beispiel #1
0
        void UpdateQuestion(IQuestionPack questionPack)
        {
            ResetLetters();

            questionLivingLetter = livingLetters[questionLetterIndex];

            questionLivingLetter.SetQuestionText(questionPack.GetQuestion());

            ILivingLetterData correctAnswer = null;

            var correctAnswers = questionPack.GetCorrectAnswers();
            var correctList    = correctAnswers.ToList();

            correctAnswer = correctList[UnityEngine.Random.Range(0, correctList.Count)];

            var wrongAnswers = questionPack.GetWrongAnswers().ToList();

            // Shuffle wrong answers
            int n = wrongAnswers.Count;

            while (n > 1)
            {
                n--;
                int k     = UnityEngine.Random.Range(0, n + 1);
                var value = wrongAnswers[k];
                wrongAnswers[k] = wrongAnswers[n];
                wrongAnswers[n] = value;
            }

            game.pipesAnswerController.SetPipeAnswers(wrongAnswers, correctAnswer, sunMoonGameVariation);
        }
Beispiel #2
0
        void OnPointerUp()
        {
            if (playerInputPointerUp != null)
            {
                playerInputPointerUp(true);
            }

            draggingLetter = null;

            if (questionLivingLetter != null)
            {
                questionLivingLetter.OnPointerUp();
            }
        }
Beispiel #3
0
        void CreateQuestionLivingLetters()
        {
            livingLetters.Clear();

            for (int i = 0; i < game.questionLivingLetterBox.lettersPosition.Length - 1; i++)
            {
                QuestionLivingLetter questionLetter = CreateQuestionLivingLetter();

                questionLetter.ClearQuestionText();
                questionLetter.PlayStillAnimation();
                questionLetter.EnableCollider(false);

                questionLetter.GoToPosition(i);
                questionLetter.playWhenDragged = playWhenDragged;

                livingLetters.Add(questionLetter);
            }
        }
Beispiel #4
0
        QuestionLivingLetter CreateQuestionLivingLetter()
        {
            QuestionLivingLetter newQuestionLivingLetter = GameObject.Instantiate(game.questionLivingLetterPrefab).GetComponent <QuestionLivingLetter>();

            newQuestionLivingLetter.gameObject.SetActive(true);

            newQuestionLivingLetter.Initialize(game.tubesCamera, game.questionLivingLetterBox.upRightMaxPosition.position,
                                               game.questionLivingLetterBox.downLeftMaxPosition.position, game.questionLivingLetterBox.lettersPosition);
            newQuestionLivingLetter.transform.SetParent(game.questionLivingLetterBox.transform);
            newQuestionLivingLetter.onMouseUpLetter += CheckAnswer;

            var shadow = GameObject.Instantiate(game.shadowPrefab);

            shadow.transform.SetParent(newQuestionLivingLetter.transform);
            shadow.gameObject.SetActive(true);
            shadow.Initialize(newQuestionLivingLetter.transform, game.pipesAnswerController.basePosition.position.y);

            return(newQuestionLivingLetter);
        }
Beispiel #5
0
        void OnPointerDown()
        {
            if (Enabled && questionLivingLetter != null)
            {
                var pointerPosition = game.Context.GetInputManager().LastPointerPosition;
                var screenRay       = game.tubesCamera.ScreenPointToRay(pointerPosition);

                RaycastHit hitInfo;
                if (questionLivingLetter.GetComponent <Collider>().Raycast(screenRay, out hitInfo, game.tubesCamera.farClipPlane))
                {
                    if (playerInputPointerUp != null)
                    {
                        playerInputPointerUp(false);
                    }

                    draggingLetter = questionLivingLetter;
                    questionLivingLetter.OnPointerDown(pointerPosition);
                }
            }
        }