Ejemplo n.º 1
0
 protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
 {
     if (canMove() && MessageBox.Show("The current game will end.", "Exit to main menu?", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
     {
         if (e != null)
         {
             e.Cancel = true;
         }
         return;
     }
     else
     {
         TURN_TIMER.Stop();
         COMPUTER_DELAY.Stop();
         wait_for_computer = false;
         wait_for_timer    = false;
         player_turn       = true;
         NavigationService.GoBack();
         MainPage.game_state = GameState.MENU;
     }
 }
Ejemplo n.º 2
0
 private void Computer_Delay_Tick(object o, EventArgs e)
 {
     COMPUTER_DELAY.Stop();
     Make_Educated_Move(o, e);
 }
Ejemplo n.º 3
0
        private void timerTick(object o, EventArgs e)
        {
            TURN_TIMER.Stop();
            if (checkEndGame())
            {
                MainPage.game_state = GameState.END_GAME;
                return;
            }
            PieceColor last = logic.getWhoMovedLast();

            // if there is a double jump available and it isn't forced
            if (multi_jump)
            {
                // if black is making the jump
                if (!last.Equals(PieceColor.RED) || (MainPage.game_state != GameState.SINGLE_PLAYER))
                {
                    if (used_make_move)
                    {
                        Make_Educated_Move(o, e);
                    }
                    else
                    {
                        if (!MainPage.FORCE_JUMP)
                        {
                            if (MessageBox.Show("Double Jump Available!", "Take the double jump?", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                            {
                                logic.skipMultiJump();
                                multi_jump = false;
                            }
                            else
                            {
                                int x = checkerX;
                                int y = checkerY;
                                checkerX = checkerY = -1;
                                handleHighlighting(x, y);
                            }
                        }
                    }
                }
                else
                {
                    if (MainPage.game_state == GameState.SINGLE_PLAYER)
                    {
                        COMPUTER_DELAY.Start();
                    }
                }
            }
            else
            {
                used_make_move = false;
                checkerX       = checkerY = -1;
            }
            multi_jump     = false;
            WhoseTurn.Text = (logic.whoseMove().Equals(PieceColor.RED) ? "Red" : "Black") + " to move next.";
            Moves.Text     = "Moves: " + logic.getMoveNumber();
            wait_for_timer = false;
            player_turn    = true;
            if (MainPage.game_state == GameState.SINGLE_PLAYER)
            {
                //MessageBox.Show("Computer's turn.");
                wait_for_computer = !wait_for_computer;
                if (wait_for_computer && logic.whoseMove().Equals(PieceColor.RED))
                {
                    COMPUTER_DELAY.Start();
                }
                else
                {
                    wait_for_computer = false;
                }
            }
        }