public void loginAttempt()
 {
     if (username.text != "" && password.text != "")
     {
         StartCoroutine(BackendHook.login(username.text, passwordInputfield.text));
     }
 }
    IEnumerator Start()
    {
        // saves the images to the questoins and answers
        // Move to moduleselect
        // have stack that incriments whenever a new corutine is called and decrements when one is complete, wait til it is at 0


        if (pictureMode)
        {
            foreach (KeyValuePair <int, answer> entry in CollectionManager.answerCollection)
            {
                StartCoroutine(BackendHook.downloadImg(entry.Value.getImageLocation(), false, entry.Key));
            }
        }

        CollectionManager.createCardCollection();

        // Creates the answer and question decks from the collection
        DeckManager.createAnswerDeckFromCollection();
        DeckManager.createQuestionDeckFromCollection();
        DeckManager.shuffle("answer");

        // Spawn the question nodes. Having trouble moving that from its own start function to here

        // Spawn the hand nodes. Same as above.
        //HandPhysicsManager.init();
        //HandPhysicsManager.createNodes(HandPhysicsManager.maxNodes);

        questionCount = CollectionManager.questionCollection.Count;
        answerCount   = CollectionManager.answerCollection.Count;



        return(null);
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (fields.Count <= _fieldIndexer)
            {
                _fieldIndexer = 0;
            }
            fields[_fieldIndexer].Select();
            _fieldIndexer++;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            loginAttempt();
        }

        if (BackendHook.loginTokenString != null)
        {
            if (BackendHook.loginTokenString.Contains("User Not Found") || BackendHook.loginTokenString.Contains("Incorrect"))
            {
                badLoginShown = true;
            }
            else if (!pingModulesOnce)
            {
                Debug.Log("*hacker voice* I'm in");
                StartCoroutine(BackendHook.avalibleModules());
                pingModulesOnce = true;
            }
        }

        if (badLoginShown == true)
        {
            badLoginText.SetActive(true);
        }

        if (!getModLengths && BackendHook.modulesFound)
        {
            foreach (KeyValuePair <string, int> m in BackendHook.avalibleModulesDic)
            {
                StartCoroutine(BackendHook.getModuleQuestionCount(m.Value));
                StartCoroutine(BackendHook.getModuleHighScore(m.Value));
            }

            getModLengths = true;
        }

        // Don't hate me please
        if (getModLengths)
        {
            if (runninggetModuleInfo.Count == 0)
            {
                SceneManager.LoadScene("ModuleSelect");
            }
        }
    }
 public void startGame()
 {
     if (currentModuleID != -1)
     {
         GameManager.timeBwtweenQuestions = float.Parse(questionTimerArea.text);
         StartCoroutine(BackendHook.startSession(currentModuleID));
         Debug.Log("STARTING GAME");
         BackendHook.modulesFound  = false;
         GameManager.endlessMode   = endless;
         GameManager.pictureMode   = pictureMode;
         GameManager.currentModule = CollectionManager.moduleCollection[currentModuleID];
         StartCoroutine(BackendHook.getModule(currentModuleID));
     }
 }
    void Start()
    {
        questionTimerArea.text = "5";

        currentModuleID = -1;
        BackendHook.highScores.Clear();

        endless     = false;
        pictureMode = false;

        foreach (KeyValuePair <string, int> m in BackendHook.avalibleModulesDic)
        {
            StartCoroutine(BackendHook.getModuleHighScore(m.Value));
        }
    }
예제 #6
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);
    }
 void OnEnable()
 {
     StartCoroutine(BackendHook.endSession(QnAManager.points));
 }
 public void exitGame()
 {
     StartCoroutine(BackendHook.endSession(QnAManager.points));
     Application.Quit();
 }
 public void returnMenu()
 {
     StartCoroutine(BackendHook.endSession(QnAManager.points));
     GameManager.resetStats();
     SceneManager.LoadScene("ModuleSelect");
 }