예제 #1
0
        private Game(GameData data, GameField field, Player playerWhite, Player playerBlack)
        {
            this.data        = data;
            this.field       = field;
            this.playerWhite = playerWhite;
            this.playerBlack = playerBlack;
            gameHistory      = new List <Command>();

            this.playerWhite.setMoveFunc(WhitePlayerMoved); //привязываем функции к событиям
            this.playerBlack.setMoveFunc(BlackPlayerMoved);
            emitWhiteMove = this.playerWhite.getMoveComand;
            emitBlackMove = this.playerBlack.getMoveComand;

            if (this.playerWhite is FormControl)                        //если БЕЛЫЙ это formControl
            {
                playerWhiteFormControl = (FormControl)this.playerWhite; //приводя их к такому виду, мы избавляемся от множества проверок
            }
            if (this.playerBlack is FormControl)                        //если ЧЕРНЫЙ это formControl
            {
                playerBlackFormControl = (FormControl)this.playerBlack;
            }

            isWhitTurn = true;
            emitWhiteMove();
        }
예제 #2
0
 public GameMemento(GameData data, GameField field, Player playerWhite, Player playerBlack, FormControl playerWhiteFormControl, FormControl playerBlackFormControl)
 {
     this.Data                   = data;
     this.Field                  = field;
     this.PlayerWhite            = playerWhite;
     this.PlayerBlack            = playerBlack;
     this.PlayerWhiteFormControl = playerWhiteFormControl;
     this.PlayerBlackFormControl = playerBlackFormControl;
 }
예제 #3
0
        public static Game TwoPlayersGame(int width, int height) //создает игру с двумя реальными игроками
        {
            GameData  data  = new GameData();
            GameField field = new GameField(data, width, height);
            Player    white = new FormControl(data, true);
            Player    black = new FormControl(data, false);
            Game      game  = Game.getInstance(data, field, white, black); //надеюсь тут более менее понятно

            return(game);
        }