void changeStep() { if (currentStep == steps.question) { currentStep = steps.lag; tickTime = lagTime; } else if (currentStep == steps.lag) { votingOpen = false; answerCount = new int[4]; totalAnswers = 0; foreach (playerObj p in players) { if (p.getAnswer() >= 0) { answerCount[p.getAnswer()] += 1; totalAnswers += 1; } if (p.getAnswer() == qm.getQuestion().correct_answer_id) { p.addScore(1); p.addBouns(); } else if (p.getAnswer() == -2) { //TODO: go with crowd. Debug.LogWarning("TODO: go with crowd."); } else { p.setBonus(0); } } int i = 0; foreach (int per in answerCount) { if (totalAnswers > 0) { perPan[i].anchorMin = new Vector2((float)answerCount[i] / (float)totalAnswers, 0); } else { perPan[i].anchorMin = new Vector2(1, 0); } i++; } currentStep = steps.answer; tickTime = answerTime; ui.showCorrectAnswer(qm.getQuestion()); qm.loadNewQuestion(categoryID.ToString()); } else if (currentStep == steps.answer) { roundNumber -= 1; if (roundNumber < 0) { categoryID = Random.Range(9, 33); qm.loadNewQuestion(); scoreCanvas.enabled = true; gameCanvas.enabled = false; currentStep = steps.scores; tickTime = scoresTime; players.Sort(playerObj.SortByScore); players.Reverse(); Debug.Log(players.Count); int i = 0; scoresLeft.text = ""; while (i < players.Count && i < 20) { scoresLeft.text += players[i].getUsername() + " - " + players[i].getScore() + "\n"; i++; } i = 20; scoresRight.text = ""; while (i < players.Count && i < 40) { scoresLeft.text += players[i].getUsername() + " - " + players[i].getScore() + "\n"; i++; } roundNumber = questionsPerRound; } else { currentStep = steps.question; votingOpen = true; tickTime = questionTime; foreach (playerObj p in players) { p.setAnswer(-1); } ui.setQuestion(qm.getQuestion()); } } else if (currentStep == steps.answer) { currentStep = steps.question; votingOpen = true; tickTime = questionTime; ui.setQuestion(qm.getQuestion()); } else if (currentStep == steps.scores) { gameCanvas.enabled = true; scoreCanvas.enabled = false; currentStep = steps.question; votingOpen = true; tickTime = questionTime; foreach (playerObj p in players) { p.setAnswer(-1); } ui.setQuestion(qm.getQuestion()); } else { Debug.LogWarning("Step Error. Stepping to new question."); currentStep = steps.answer; } }