コード例 #1
0
    void OnMouseUp()
    {
        priorityView = false;
        HandPhysicsManager.cardIsGrabbed = false;

        if (distanceFromClosestQuestionDropArea() < 5)
        {
            nodeNav = "question";
            answer   answerOnCard   = this.GetComponent <AnswerObject>().answer;
            question questionOnNode = closestQuestionDropAreaObject().GetComponent <QuestionObject>().question;

            // If the card dropped corectly answers the question:
            if (QnAManager.answerQuestion(closestQuestionDropArea(), this.GetComponent <AnswerObject>().answerID))
            {
                QnAManager.attemptedAnswers.Add(new attemptedAnswer(true, questionOnNode, answerOnCard));                       // Adds the correct answer to the list of attempted answers
                //HandPhysicsManager.moveAllCardsLeftBetween(currentHandNode, HandPhysicsManager.handNodeGOs.Length); // Fix the card positions, removed since it auto draws after a ques is answerd                                                                             // Set the nav of tjhis card so it moves towards the center of the quesiton node
                gameObject.tag = "Untagged";                                                                                    // Change the tag of this card so it is not picked up by findCards()
                DeckManager.answerGraveyard.Add(this.GetComponent <AnswerObject>().answer);
                QuestionDropsManager.deleteQuestionDropArea(closestQuestionDropArea());                                         // Delete the quesiton node and move question nodes under the deleted node up 1
                QuestionDropsManager.findQuestionDropAreas();                                                                   // Refind QDAs
                HandPhysicsManager.findCards();                                                                                 // Refind cards
                HandPhysicsManager.drawBool = true;
                HandPhysicsManager.moveAllCardsLeftBetween(currentHandNode, HandPhysicsManager.currentPresentNodeCount);        // Moves correct cards to the left as there will soon be one lest card and node
                GameManager.currentModule.addCorrect();                                                                         // Increments the player data for number of correct answers answered
                StartCoroutine(BackendHook.sendQuestionInfo(questionOnNode.getQuestionID(), answerOnCard.getAnswerID(), true)); // Reports to the backend that a question was answered right
                QnAManager.currentAnswers.Remove(answerOnCard);
                QnAManager.currentQuestions.Remove(questionOnNode);

                Destroy(gameObject);
            }
            else
            {
                closestQuestionDropAreaObject().GetComponent <QuestionObject>().redTimer = .5f;
                QnAManager.attemptedAnswers.Add(new attemptedAnswer(false, questionOnNode, answerOnCard));
                StartCoroutine(BackendHook.sendQuestionInfo(questionOnNode.getQuestionID(), answerOnCard.getAnswerID(), false));
                GameManager.currentModule.addWrong();
                nodeNav = "hand";
            }
        }

        movingCards = false;
        setPosition(currentHandNode);
    }