コード例 #1
0
        void OnPointerUp()
        {
            if (playerInputPointerUp != null)
            {
                playerInputPointerUp(true);
            }

            draggingLetter = null;

            if (questionLivingLetter != null)
            {
                questionLivingLetter.OnPointerUp();
            }
        }
コード例 #2
0
        void UpdateQuestion(IQuestionPack questionPack)
        {
            hidePipesTimer      = 0;
            currentQuestionPack = questionPack;
            ResetLetters();

            questionLivingLetter = livingLetters[questionLetterIndex];
            ILivingLetterData correctAnswer = null;

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

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

            if (ToboganConfiguration.Instance.Variation == ToboganVariation.SunMoon)
            {
                LL_WordData question = questionPack.GetQuestion() as LL_WordData;

                questionLivingLetter.SetQuestionText(question, 2, ToboganGame.LETTER_MARK_COLOR);
            }
            else
            {
                if (ToboganConfiguration.Instance.Difficulty <= 0.3f)
                {
                    questionLivingLetter.SetQuestionText(questionPack.GetQuestion() as LL_WordData, correctAnswer as LL_LetterData, ToboganGame.LETTER_MARK_COLOR);
                }
                else
                {
                    questionLivingLetter.SetQuestionText(questionPack.GetQuestion());
                }
            }

            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);
        }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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);
                }
            }
        }