Пример #1
0
        public void ChooseOponentMove()
        {
            int randomChoice = new Random(DateTime.Now.Millisecond).Next(0, 4);

            switch (randomChoice)
            {
            case 0:
                opponent_move_choice = GameComponents.Rock;
                OpponentMove.Source  = new BitmapImage(new Uri(this.Resources["RockImg"].ToString()));
                break;

            case 1:
                opponent_move_choice = GameComponents.Paper;
                OpponentMove.Source  = new BitmapImage(new Uri(this.Resources["PaperImg"].ToString()));
                break;

            case 2:
                opponent_move_choice = GameComponents.Scissor;
                OpponentMove.Source  = new BitmapImage(new Uri(this.Resources["ScissorImg"].ToString()));
                break;

            case 3:
                opponent_move_choice = GameComponents.Lizard;
                OpponentMove.Source  = new BitmapImage(new Uri(this.Resources["LizardImg"].ToString()));
                break;

            case 4:
                opponent_move_choice = GameComponents.Spock;
                OpponentMove.Source  = new BitmapImage(new Uri(this.Resources["SpockImg"].ToString()));
                break;
            }
        }
Пример #2
0
 private void Scissor_Click(object sender, RoutedEventArgs e)
 {
     if (hasMoved)
     {
         return;
     }
     player_move_choice = GameComponents.Scissor;
     PlayerMove.Source  = new BitmapImage(new Uri(this.Resources["ScissorImg"].ToString()));
 }
Пример #3
0
        private void GoButton_Click(object sender, RoutedEventArgs e)
        {
            if (player_move_choice == null)
            {
                return;                             // If player didnot coose a move what can I do.
            }
            if (hasMoved)
            {
                // After a move player must restart the process of choosing a move.
                // This restarts the whole move, both opponents and players.
                GoButton.Content     = "Go";
                PlayerMove.Source    = new BitmapImage(new Uri(this.Resources["ChooseImg"].ToString()));
                player_move_choice   = null;
                OpponentMove.Source  = new BitmapImage(new Uri(this.Resources["ChooseImg"].ToString()));
                opponent_move_choice = null;
                hasMoved             = false;
                return;
            }

            ChooseOponentMove();
            GameResult move_result = GameComponents.Eval(player_move_choice, opponent_move_choice); // Player's move stored here.

            Result_lbl.Content = move_result.ToString();

            if (move_result.Equals(GameComponents.Win))
            {
                player_score++;
            }
            else if (move_result.Equals(GameComponents.Loose))
            {
                opponent_score++;
            }
            UpdatePlayerScores();
            hasMoved         = true;
            GoButton.Content = "Again";
        }