/// <summary> /// Starts new game. /// </summary> private void StartGame() { this.MessageText.Text = Properties.Resources.SelectImageText; this.StartButton.Text = Properties.Resources.MoveButtonText; this.HumanChoise.Cursor = Cursors.Hand; this.HumanChoise.Image = Properties.Resources.Unknown; this.HumanMove = MoveVariation.Unknown; this.ComputerChoice.Image = Properties.Resources.Unknown; this.Stage = GameStage.HumanMove; }
private bool IsHumanVictory(MoveVariation computerMove) { if (this.HumanMove == MoveVariation.Rock && computerMove == MoveVariation.Scissors) { return(true); } else if (this.HumanMove == MoveVariation.Scissors && computerMove == MoveVariation.Rock) { return(false); } else { return((int)this.HumanMove > (int)computerMove); } }
/// <summary> /// Draws computer move. /// </summary> /// <param name="computerMove"></param> private void DrawComputerMove(MoveVariation computerMove) { switch (computerMove) { case MoveVariation.Rock: this.ComputerChoice.Image = Properties.Resources.RightRock; break; case MoveVariation.Paper: this.ComputerChoice.Image = Properties.Resources.RightPaper; break; case MoveVariation.Scissors: this.ComputerChoice.Image = Properties.Resources.RightScissors; break; default: throw new Exception(Properties.Resources.InvalidComputerMove); } }
/// <summary> /// This object calls this method when user clicks /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HumanChoise_Click(object sender, EventArgs e) { switch (this.Stage) { case GameStage.HumanMove: { int currentMove = (int)this.HumanMove; ++currentMove; if (currentMove >= (int)MoveVariation.Unknown) { currentMove = (int)MoveVariation.Rock; } this.HumanMove = (MoveVariation)currentMove; this.DrawHumanMove(); } break; case GameStage.BeforeStart: case GameStage.Finished: case GameStage.ComputerMove: default: break; } }