Esempio n. 1
0
    void OnInputPointerDrag(LessonInputField inp)
    {
        bool active = inp.curCard != null && dockArea.Contains(inp.curPos);

        if (mAvailableAnchors.Count > 0)
        {
            var anchor = mAvailableAnchors.Peek();
            anchor.Highlight(active);
        }
    }
Esempio n. 2
0
    void OnInputPointerUp(LessonInputField inp)
    {
        if (mIsAnswerPicked)
        {
            return;
        }

        var card = inp.curCard;

        if (card == null)
        {
            if (mAvailableAnchors.Count > 0)  //edge case
            {
                var toAnchor = mAvailableAnchors.Peek();
                toAnchor.Highlight(false);
            }

            return;
        }

        //check if there's available
        if (mAvailableAnchors.Count > 0)
        {
            var toAnchor = mAvailableAnchors.Peek();
            toAnchor.Highlight(false);

            //check if we are in valid dock area
            if (!dockArea.Contains(inp.curPos))
            {
                return;
            }

            //check to see if correct
            var question = curQuestion;
            if (question != null && question.ContainsAnswer(card.type))
            {
                //dock card
                mAvailableAnchors.Dequeue();

                mDeckCards.Remove(card);
                mDockedCards.Add(card);

                card.Dock(toAnchor.position);

                //score
                int prevScore = mCurScore;
                int score     = Mathf.RoundToInt(question.score * Mathf.Clamp((1.0f - (mIncorrectCounter / 4.0f)), 0.1f, 1.0f));

                mCurScore += score;

                HUD.instance.UpdateScore(mCurScore, prevScore);

                //save score
                M8.SceneState.instance.global.SetValue(SceneStateVars.curScore, mCurScore, false);

                //progress
                Progress.UpdateLessonProgress(mCurQuestionIndex + 1);

                LoLManager.instance.PlaySound(soundCorrectPath, false, false);
            }
            else   //return as incorrect
            {
                card.ReturnIncorrect();
                mIncorrectCounter++;

                LoLManager.instance.PlaySound(soundWrongPath, false, false);
            }

            mIsAnswerPicked = true;
            input.isLocked  = true;
        }
        else
        {
            card.Return();
        }

        inp.ClearCurrent();
    }