コード例 #1
0
        public void OnAnswerClicked(LetterBehaviour clicked)
        {
            if (m_oGame.GetCurrentState() != m_oGame.PlayState && m_oGame.GetCurrentState() != m_oGame.TutorialState)
            {
                return;
            }

            m_oGame.SetInIdle(false);

            //refresh the data (for graphics)
            RestoreQuestion(isCorrectAnswer(clicked.LetterData));

            foreach (GameObject _obj in m_aoCurrentAnswerScene)
            {
                _obj.GetComponent <LetterBehaviour>().SetEnabledCollider(false);
            }

            //letter animation wait for ending dancing animation, wait animator fix
            if (isCorrectAnswer(clicked.LetterData))
            {
                clicked.PlayAnimation(LLAnimationStates.LL_still);
                clicked.mLetter.DoHorray();

                PlayParticleSystem(m_aoCurrentQuestionScene[0].transform.position + Vector3.up * 2);

                OnResponse(true);
            }
            else
            {
                clicked.PlayAnimation(LLAnimationStates.LL_still);
                OnResponse(false);
            }
        }
コード例 #2
0
        void NextSentenceQuestion()
        {
            m_oCurrQuestionPack = MissingLetterConfiguration.Instance.Questions.GetNextQuestion();

            List <LL_WordData> questionData = GetWordsFromPhrase((LL_PhraseData)m_oCurrQuestionPack.GetQuestion());

            if (LanguageSwitcher.I.IsLearningLanguageRTL())
            {
                questionData.Reverse();
            }

            var _correctAnswer = (LL_WordData)m_oCurrQuestionPack.GetCorrectAnswers().ToList()[0];
            var _wrongAnswers  = m_oCurrQuestionPack.GetWrongAnswers().ToList();

            foreach (LL_WordData _word in questionData)
            {
                GameObject      oQuestion    = m_oQuestionPool.GetElement();
                LetterBehaviour qstBehaviour = oQuestion.GetComponent <LetterBehaviour>();

                qstBehaviour.Reset();
                qstBehaviour.LetterData = _word;
                qstBehaviour.onLetterBecameInvisible += OnQuestionLetterBecameInvisible;
                qstBehaviour.m_oDefaultIdleAnimation  = LLAnimationStates.LL_idle;
                qstBehaviour.SetInPhrase(m_oCurrQuestionPack.GetQuestion());

                m_aoCurrentQuestionScene.Add(oQuestion);
            }

            //after insert in mCurrentQuestionScene
            m_iRemovedLLDataIndex = RemoveWordfromQuestion(questionData, _correctAnswer);
            m_aoCurrentQuestionScene[m_iRemovedLLDataIndex].GetComponent <LetterBehaviour>().onEnterScene += m_aoCurrentQuestionScene[m_iRemovedLLDataIndex].GetComponent <LetterBehaviour>().Speak;

            GameObject      _correctAnswerObject = m_oAnswerPool.GetElement();
            LetterBehaviour corrAnsBheaviour     = _correctAnswerObject.GetComponent <LetterBehaviour>();

            corrAnsBheaviour.Reset();
            corrAnsBheaviour.LetterData = _correctAnswer;
            corrAnsBheaviour.mLetter.TransformIntoImage();
            corrAnsBheaviour.onLetterBecameInvisible += OnAnswerLetterBecameInvisible;
            corrAnsBheaviour.onLetterClick           += OnAnswerClicked;

            corrAnsBheaviour.m_oDefaultIdleAnimation = m_bTutorialEnabled ? LLAnimationStates.LL_still : LLAnimationStates.LL_idle;

            m_aoCurrentAnswerScene.Add(_correctAnswerObject);
            m_oCorrectAnswer = _correctAnswerObject;

            for (int i = 1; i < m_oGame.m_iNumberOfPossibleAnswers && i < _wrongAnswers.Count() + 1; ++i)
            {
                GameObject      _wrongAnswerObject = m_oAnswerPool.GetElement();
                LetterBehaviour wrongAnsBheaviour  = _wrongAnswerObject.GetComponent <LetterBehaviour>();
                wrongAnsBheaviour.Reset();

                var answer = _wrongAnswers[i - 1];

                wrongAnsBheaviour.LetterData = answer;
                wrongAnsBheaviour.onLetterBecameInvisible += OnAnswerLetterBecameInvisible;
                wrongAnsBheaviour.mLetter.TransformIntoImage();

                if (!m_bTutorialEnabled)
                {
                    wrongAnsBheaviour.onLetterClick += OnAnswerClicked;
                }
                wrongAnsBheaviour.m_oDefaultIdleAnimation = m_bTutorialEnabled ? LLAnimationStates.LL_still : LLAnimationStates.LL_idle;

                m_aoCurrentAnswerScene.Add(_wrongAnswerObject);
            }

            m_aoCurrentAnswerScene.Shuffle();

            m_oEmoticonsController.init(m_aoCurrentQuestionScene[m_iRemovedLLDataIndex].transform);

            m_oCurrentCorrectAnswer = _correctAnswer;
        }
コード例 #3
0
        void NextWordQuestion()
        {
            m_iRemovedLLDataIndex = 0;

            m_oCurrQuestionPack = MissingLetterConfiguration.Instance.Questions.GetNextQuestion();
            ILivingLetterData questionData = m_oCurrQuestionPack.GetQuestion();

            var _wrongAnswers  = m_oCurrQuestionPack.GetWrongAnswers().ToList();
            var _correctAnswer = m_oCurrQuestionPack.GetCorrectAnswers().ToList().GetRandom();

            //Debug.Log("WRONG: " + m_oCurrQuestionPack.GetWrongAnswers().ToList().ToDebugStringNewline());
            //Debug.Log("CORRECT: " + m_oCurrQuestionPack.GetCorrectAnswers().ToList().ToDebugStringNewline());

            GameObject oQuestion = m_oQuestionPool.GetElement();

            LetterBehaviour qstBehaviour = oQuestion.GetComponent <LetterBehaviour>();

            qstBehaviour.Reset();
            qstBehaviour.LetterData = questionData;
            if (MissingLetterConfiguration.Instance.Variation == MissingLetterVariation.Image)
            {
                qstBehaviour.mLetter.LabelRender.SetTextUnfiltered("???");
                //qstBehaviour.LetterData = new LL_ImageData(questionData.Id);
                //qstBehaviour.mLetter.LabelRender.gameObject.SetActive(false);   // Hidden image
            }

            qstBehaviour.onEnterScene            += qstBehaviour.Speak;
            qstBehaviour.onLetterBecameInvisible += OnQuestionLetterBecameInvisible;
            qstBehaviour.m_oDefaultIdleAnimation  = LLAnimationStates.LL_idle;
            m_aoCurrentQuestionScene.Add(oQuestion);

            m_oEmoticonsController.init(qstBehaviour.transform);

            //after insert in mCurrentQuestionScen
            if (MissingLetterConfiguration.Instance.VariationIsMissingLetter)
            {
                m_oRemovedLetter = RemoveLetterFromQuestion(_correctAnswer as LL_LetterData);
            }

            GameObject      _correctAnswerObject = m_oAnswerPool.GetElement();
            LetterBehaviour corrAnsBheaviour     = _correctAnswerObject.GetComponent <LetterBehaviour>();

            corrAnsBheaviour.Reset();

            corrAnsBheaviour.LetterData = _correctAnswer;
            if (MissingLetterConfiguration.Instance.Variation == MissingLetterVariation.Image)
            {
                corrAnsBheaviour.LetterData = new LL_ImageData(_correctAnswer.Id);
            }

            corrAnsBheaviour.onLetterBecameInvisible += OnAnswerLetterBecameInvisible;
            corrAnsBheaviour.onLetterClick           += OnAnswerClicked;

            corrAnsBheaviour.m_oDefaultIdleAnimation = m_bTutorialEnabled ? LLAnimationStates.LL_still : LLAnimationStates.LL_idle;

            m_aoCurrentAnswerScene.Add(_correctAnswerObject);
            m_oCorrectAnswer = _correctAnswerObject;

            for (int i = 1; i < m_oGame.m_iNumberOfPossibleAnswers && i < _wrongAnswers.Count() + 1; ++i)
            {
                GameObject      _wrongAnswerObject = m_oAnswerPool.GetElement();
                LetterBehaviour wrongAnsBheaviour  = _wrongAnswerObject.GetComponent <LetterBehaviour>();
                wrongAnsBheaviour.Reset();

                var answer = _wrongAnswers[i - 1];

                /*
                 * if (answer is LL_LetterData)
                 *  ((LL_LetterData)answer).Position = questionLetterForm;
                 */

                wrongAnsBheaviour.LetterData = answer;
                if (MissingLetterConfiguration.Instance.Variation == MissingLetterVariation.Image)
                {
                    wrongAnsBheaviour.LetterData = new LL_ImageData(answer.Id);
                }

                wrongAnsBheaviour.onLetterBecameInvisible += OnAnswerLetterBecameInvisible;

                if (!m_bTutorialEnabled)
                {
                    wrongAnsBheaviour.onLetterClick += OnAnswerClicked;
                }
                wrongAnsBheaviour.m_oDefaultIdleAnimation = m_bTutorialEnabled ? LLAnimationStates.LL_still : LLAnimationStates.LL_idle;

                m_aoCurrentAnswerScene.Add(_wrongAnswerObject);
            }

            if (MissingLetterGame.VISUAL_DEBUG)
            {
                corrAnsBheaviour.mLetter.MarkData(MissingLetterGame.helpColor);
            }

            switch (MissingLetterConfiguration.Instance.Variation)
            {
            case MissingLetterVariation.LetterForm:
            case MissingLetterVariation.LetterInWord:
                m_aoCurrentAnswerScene.Sort((a, b) =>
                {
                    var first  = (LL_LetterData)a.GetComponent <LetterBehaviour>().LetterData;
                    var second = (LL_LetterData)b.GetComponent <LetterBehaviour>().LetterData;

                    return(Comparer <int> .Default.Compare(
                               (int)second.Form,
                               (int)first.Form));
                });
                break;

            case MissingLetterVariation.Phrase:
            case MissingLetterVariation.Image:
                m_aoCurrentAnswerScene.Shuffle();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            m_oCurrentCorrectAnswer = _correctAnswer;
        }
コード例 #4
0
ファイル: RoundManager.cs プロジェクト: vgwb/Antura_arabic
        void NextWordQuestion()
        {
            m_iRemovedLLDataIndex = 0;

            m_oCurrQuestionPack = MissingLetterConfiguration.Instance.Questions.GetNextQuestion();
            ILivingLetterData questionData = m_oCurrQuestionPack.GetQuestion();

            var _wrongAnswers  = m_oCurrQuestionPack.GetWrongAnswers().ToList();
            var _correctAnswer = m_oCurrQuestionPack.GetCorrectAnswers().ToList().GetRandom() as LL_LetterData;

            Debug.Log("WRONG: " + m_oCurrQuestionPack.GetWrongAnswers().ToList().ConvertAll(x => (x as LL_LetterData).Data).ToDebugStringNewline());
            Debug.Log("CORRECT: " + m_oCurrQuestionPack.GetCorrectAnswers().ToList().ConvertAll(x => (x as LL_LetterData).Data).ToDebugStringNewline());

            GameObject oQuestion = m_oQuestionPool.GetElement();

            LetterBehaviour qstBehaviour = oQuestion.GetComponent <LetterBehaviour>();

            qstBehaviour.Reset();
            qstBehaviour.LetterData               = questionData;
            qstBehaviour.onEnterScene            += qstBehaviour.Speak;
            qstBehaviour.onLetterBecameInvisible += OnQuestionLetterBecameInvisible;
            qstBehaviour.m_oDefaultIdleAnimation  = LLAnimationStates.LL_idle;
            m_aoCurrentQuestionScene.Add(oQuestion);

            m_oEmoticonsController.init(qstBehaviour.transform);

            //after insert in mCurrentQuestionScen
            m_oRemovedLetter = RemoveLetterFromQuestion(_correctAnswer);

            GameObject      _correctAnswerObject = m_oAnswerPool.GetElement();
            LetterBehaviour corrAnsBheaviour     = _correctAnswerObject.GetComponent <LetterBehaviour>();

            corrAnsBheaviour.Reset();

            corrAnsBheaviour.LetterData = _correctAnswer;

            corrAnsBheaviour.onLetterBecameInvisible += OnAnswerLetterBecameInvisible;
            corrAnsBheaviour.onLetterClick           += OnAnswerClicked;

            corrAnsBheaviour.m_oDefaultIdleAnimation = m_bTutorialEnabled ? LLAnimationStates.LL_still : LLAnimationStates.LL_idle;

            m_aoCurrentAnswerScene.Add(_correctAnswerObject);
            m_oCorrectAnswer = _correctAnswerObject;

            for (int i = 1; i < m_oGame.m_iNumberOfPossibleAnswers && i < _wrongAnswers.Count() + 1; ++i)
            {
                GameObject      _wrongAnswerObject = m_oAnswerPool.GetElement();
                LetterBehaviour wrongAnsBheaviour  = _wrongAnswerObject.GetComponent <LetterBehaviour>();
                wrongAnsBheaviour.Reset();

                var answer = _wrongAnswers[i - 1];

                /*
                 * if (answer is LL_LetterData)
                 *  ((LL_LetterData)answer).Position = questionLetterForm;
                 */

                wrongAnsBheaviour.LetterData = answer;
                wrongAnsBheaviour.onLetterBecameInvisible += OnAnswerLetterBecameInvisible;

                if (!m_bTutorialEnabled)
                {
                    wrongAnsBheaviour.onLetterClick += OnAnswerClicked;
                }
                wrongAnsBheaviour.m_oDefaultIdleAnimation = m_bTutorialEnabled ? LLAnimationStates.LL_still : LLAnimationStates.LL_idle;

                m_aoCurrentAnswerScene.Add(_wrongAnswerObject);
            }

            if (MissingLetterConfiguration.Instance.Variation == MissingLetterVariation.LetterInWord ||
                MissingLetterConfiguration.Instance.Variation == MissingLetterVariation.LetterForm)
            {
                m_aoCurrentAnswerScene.Sort((a, b) => {
                    var first  = (LL_LetterData)a.GetComponent <LetterBehaviour>().LetterData;
                    var second = (LL_LetterData)b.GetComponent <LetterBehaviour>().LetterData;

                    return(Comparer <int> .Default.Compare(
                               (int)second.Form,
                               (int)first.Form));
                });
            }
            else
            {
                m_aoCurrentAnswerScene.Shuffle();
            }

            m_oCurrentCorrectAnswer = _correctAnswer;
        }