예제 #1
0
 public void resetBoard()
 {
     //Clear board
     //Game remains as it is
     game.resetGameBoard();
     pic00.Image = null;
     pic01.Image = null;
     pic02.Image = null;
     pic10.Image = null;
     pic11.Image = null;
     pic12.Image = null;
     pic20.Image = null;
     pic21.Image = null;
     pic22.Image = null;
     if (game.game_mode == GameMode.SINGLE_PLAYER && game.playerB.moveAllowed)
     {
         game.current_player = game.playerB;
         AI ai = new AI(ref game);
         ai.makeMove();
     }
     else if (game.game_mode == GameMode.SINGLE_PLAYER && game.playerA.moveAllowed)
     {
         game.current_player = game.playerA;
     }
     update();
 }
예제 #2
0
        private void makeMove(int x, int y)
        {
            if (game.game_mode == GameMode.SINGLE_PLAYER)
            {
                if (game.playerA.moveAllowed)
                {
                    game.playerA.move(x, y);
                    update();
                    if (game.isGameFinished())
                    {
                        MessageBox.Show(game.getGameStat().ToString());
                        update();
                        resetBoard();
                    }
                    else
                    {
                        AI ai = new AI(ref game);
                        ai.makeMove();
                        update();
                        if (game.isGameFinished())
                        {
                            MessageBox.Show(game.getGameStat().ToString());
                            update();
                            resetBoard();
                        }
                    }
                }
            }
            else if(game.game_mode == GameMode.MULTI_PLAYER)
            {
                //Multiplayer game movements
                if (game.moveAllowed && game.connected)
                {
                    String str;
                    if (server != null && game.playerA.move(x, y))
                    {
                        str = generateStringCommand(PlayerType.BALL, x, y);
                        sendCommand(str);
                    }
                    else if (client != null && game.playerB.move(x, y))
                    {
                        str = generateStringCommand(PlayerType.CROSS, x, y);
                        sendCommand(str);
                    }

                    update();
                    game.moveAllowed = false;

                    if (game.isGameFinished())
                    {
                        MessageBox.Show(game.getGameStat().ToString());
                        updateGameDescription();
                        resetBoard();
                        update();
                        if (game.playerA.moveAllowed == false && client != null)
                        {
                            game.playerA.moveAllowed = true;
                            game.moveAllowed = true;
                        }
                        else if (game.playerA.moveAllowed == false && server != null)
                        {
                            game.playerA.moveAllowed = true;
                            game.moveAllowed = false;
                        }
                        else if (game.playerA.moveAllowed == true && server != null)
                        {
                            game.playerA.moveAllowed = false;
                            game.moveAllowed = false;
                        }
                        else if (game.playerA.moveAllowed == true && server != null)
                        {
                            game.playerA.moveAllowed = true;
                            game.moveAllowed = true;
                        }
                    }
                }
            }else if(game.game_mode == GameMode.MULTI_PLAYER_STANDALONE){
                if(game.playerA.moveAllowed)
                {
                    game.playerA.move(x, y);
                    update();
                }
                else if (game.playerB.moveAllowed)
                {
                    game.playerB.move(x, y);
                    update();
                }
                if (game.isGameFinished())
                {
                    MessageBox.Show(game.getGameStat().ToString());
                    update();
                    resetBoard();
                }
            }
        }