Exemplo n.º 1
0
    /* When the player drops a card on an answer, all cards are moved left and the number of nodes is decreased.
     * However, when this happens, the card on the leftmost node (which is on the node that is getting moved away from the hand and deactivated)
     * is still attatched to that soon to be removed node. This causes the card to for a very small amount of time move towards the removed node.
     * This causes that card to move from offscreen to the new leftmost node, which does not look good. This coroutine adds a small delay between moving
     * the cards to the left and moving the leftmost node offscreen, allowing for any card on the leftmost node to move close enough to what will
     * soon be the leftmost node.
     * And I hate it.
     */
    IEnumerator CoroutineFix()
    {
        yield return(new WaitForSeconds(.05f));

        HandPhysicsManager.moveNodes(HandPhysicsManager.currentPresentNodeCount - 1);
        Destroy(gameObject);
    }
Exemplo n.º 2
0
    void OnMouseDrag()
    {
        Ray   camRay = myMainCamera.ScreenPointToRay(Input.mousePosition);
        float planeDist;

        dragPlane.Raycast(camRay, out planeDist);
        transform.position = camRay.GetPoint(planeDist) + offset;
        movingCards        = true;

        // alreadyRan is to make sure that if a card causes other cards to move, it only causes the movement once.
        if (!alreadyRan1 && distanceFromCurrentNode() > 4 && distanceFromClosestNode() < 20)
        {
            openNode        = currentHandNode;
            currentHandNode = closestNode();

            if (openNode <= currentHandNode)
            {
                HandPhysicsManager.moveAllCardsLeftBetween(openNode, currentHandNode);
                currentHandNode++;
            }
            else if (openNode > currentHandNode)
            {
                HandPhysicsManager.moveAllCardsRightBetween(currentHandNode, openNode);
                currentHandNode--;
            }
            alreadyRan1 = true;
        }
    }
Exemplo n.º 3
0
    void OnMouseUp()
    {
        if (distanceFromClosestQuestionDropArea() < 4)
        {
            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
                nodeNav        = "question";                                                                        // 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()
                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
                StartCoroutine(CoroutineFix());                                                                     // Move the hand nodes as there is now one more node than cards. See note.
                HandPhysicsManager.drawBool = true;
            }
            else
            {
                QnAManager.attemptedAnswers.Add(new attemptedAnswer(false, questionOnNode, answerOnCard));
            }
        }
        closestQuestionDropArea();
        setPosition(currentHandNode);
        movingCards = false;
    }
Exemplo n.º 4
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);
    }