private void evaluateGuess(clientEvent message) { int correctGuesses = 0; foreach (var index in new int[] { 0, 1, 2, 3 }) { if (message.nouns[index] == answer.nouns[index] && message.verbs[index] == answer.verbs[index]) { correctGuesses++; } if (correctGuesses == 4) { clientEvent winner = new clientEvent(); winner.role = message.role; NetworkMessaging.SendJsonViaPOST(winner, "http://35.209.52.72:80/winnerdemo"); } else { clientEvent numCorrect = new clientEvent(); numCorrect.correctGuesses = correctGuesses.ToString(); NetworkMessaging.SendJsonViaPOST(numCorrect, "http://35.209.52.72:80/sendcorrectguessesdemo"); } } }
private void resolveMessage(clientEvent message) { switch (message.msgEvent) { case "connected": playerState.id = message.id; roleRequest roleSend = new roleRequest(); roleSend.role = "Sender"; roleSend.id = message.id; NetworkMessaging.SendJsonViaPOST(roleSend, "http://35.209.52.72:80/roledemo"); break; case "updateGuess": Component[] guessComponents; OutputMessage guessUpdate = new OutputMessage(); guessUpdate.nouns = message.nouns; guessUpdate.verbs = message.verbs; guessUpdate.role = message.role; guessComponents = GetComponents <OutputManager>(); foreach (OutputManager manager in guessComponents) { manager.updateGuessWindow(guessUpdate); } evaluateGuess(message); break; case "correctGuesses": Component[] correctGuessComponents; OutputMessage correctGuessUpdate = new OutputMessage(); correctGuessUpdate.correctGuesses = message.correctGuesses; correctGuessComponents = GetComponents <OutputManager>(); foreach (OutputManager manager in correctGuessComponents) { manager.updateCorrectGuessWindow(correctGuessUpdate); } break; case "gameOver": playerState.gameResult = message.result; sceneManager.changeScene("Result"); break; default: Debug.Log("No matching event found for scene..."); break; } }