///////////////////////////////////////////////////////////// PICK THE NEXT STATE /// This is the big one - it takes the state the game was in last time, and chooses the next state. /// Order of operations is important here, since it defines how the game rules work. public void PickNextState() { //Most importantly, if you're in the GameWin state, you can't be knocked out of it when the balls stop if (previousState == GameState.Win) { if (currentTeam == Team.Red) { mainUITextScript.DisplayMessage("Red Wins Forever!", 30); } else { mainUITextScript.DisplayMessage("Blue Wins Forever!", 30); } } //if a foul has been triggered, start a new turn. else if (previousState == GameState.Foul) { if (currentTeam == Team.Red) { NewBlueTurn(); mainUITextScript.DisplayMessage("Red Foul! Blue's Turn", 3); } else { NewRedTurn(); mainUITextScript.DisplayMessage("Blue Foul! Red's Turn", 3); } } //when continuation ends, start a new turn for the other team //no matter what you do in a continuation, its the end of your turn. else if (previousState == GameState.Continuation) { if (currentTeam == Team.Blue) { NewRedTurn(); } else { NewBlueTurn(); } } //if it's not a continuation and the ball has been hit, then go to placing a ball //placing the ball then moves on to roquet else if (ballBeenHit) { mainUITextScript.DisplayMessage("ROQUET!!!", 3); ballBeenHit = false; currentState = GameState.PlaceBall; } //if the ball has gone through a hoop but not been hit, get a continuation else if (ballThroughHoop) { mainUITextScript.DisplayMessage("CONTINUATION!!!", 3); ballThroughHoop = false; currentState = GameState.Continuation; } //otherwise, if you've had an uneventful roquet, go to continuation //(this means that a roquet leads to a continuation any time it doesn't lead to a collision) else if (previousState == GameState.Roquet) { mainUITextScript.DisplayMessage("CONTINUATION!!!", 3); currentState = GameState.Continuation; } //if none of the options above have happened, go to a new turn for the other player else { if (currentTeam == Team.Blue) { NewRedTurn(); } else { NewBlueTurn(); } } }