// wait for the players to choose their move, display results from battle IEnumerator WaitForChoices() { state = RPSNGameState.CHOOSE_WEAPON; // wait for players to choose their move float choiceCounter = RPSNChoiceWaitTime; while (!BothPlayersReady() && choiceCounter > 1) { choiceCounter -= 0.01f; // update the counter RPSNcountdownTimer.SetText(Mathf.FloorToInt(choiceCounter).ToString()); ChoiceListen(); yield return(new WaitForSeconds(0.01f)); } // purchase the choices PurchaseChoice(1); PurchaseChoice(2); battleOutcome result = Battle(); // display the results of their choices DisplayBattleOutcome(result); float displayOutcomeCounter = winnerChoiceDisplayTime; while (displayOutcomeCounter > 1) { displayOutcomeCounter -= 0.1f; yield return(new WaitForSeconds(0.1f)); } // have the player who won the battle select the next stage StartCoroutine(ChooseMinigame()); // SIMULATE PLAYING A GAME /* * if (result == battleOutcome.P1WIN) * { * SimulatePlayerWinningMinigame(1); * } * else if (result == battleOutcome.P2WIN) * { * SimulatePlayerWinningMinigame(2); * } * else * { * SimulatePlayerWinningMinigame(Random.Range(1, 2)); * } */ }
void DisplayBattleOutcome(battleOutcome outcome) { Debug.Log("Displaying the battle outcome"); p1ChoiceGUI.SetText(p1Choice.ToString()); p2ChoiceGUI.SetText(p2Choice.ToString()); // update the score p1Score.SetText(GameState.Instance.ScorePlayer1.ToString() + " POINTS"); p2Score.SetText(GameState.Instance.ScorePlayer2.ToString() + " POINTS"); battleResultUI.SetActive(true); playBattleUI.SetActive(false); // display art assets corresponding to each player's choice Sprite p1Sprite = rock; // default image is rock Sprite p2Sprite = rock; switch (p1Choice) { case choice.ROCK: p1Sprite = rock; break; case choice.PAPER: p1Sprite = paper; break; case choice.SCISSORS: p1Sprite = scissors; break; case choice.NUKE: p1Sprite = nuke; break; case choice.ANTINUKE: p1Sprite = antinuke; break; } switch (p2Choice) { case choice.ROCK: p2Sprite = rock; break; case choice.PAPER: p2Sprite = paper; break; case choice.SCISSORS: p2Sprite = scissors; break; case choice.NUKE: p2Sprite = nuke; break; case choice.ANTINUKE: p2Sprite = antinuke; break; } p1ChoiceImage.sprite = p1Sprite; p2ChoiceImage.sprite = p2Sprite; switch (outcome) { case battleOutcome.INVALID: Debug.Log("Oh no! You've created an invalid battle outcome!"); winText.SetText("##INVALID BATTLE OUTCOME##"); break; case battleOutcome.P1WIN: winText.SetText("Player 1 Wins!"); break; case battleOutcome.P2WIN: winText.SetText("Player 2 Wins!"); break; case battleOutcome.TIE: winText.SetText("It's a tie!"); break; } }