Exemplo n.º 1
0
 private void BlockWhite()
 {
     foreach (WhiteChecker checker in GameField.WhiteCheckers)
     {
         CheckerUI checkUI = checker.checkerUI as CheckerUI;
         checkUI.druggingIsPermitted = false;
     }
     foreach (BlackChecker checker in GameField.BlackCheckers)
     {
         CheckerUI checkUI = checker.checkerUI as CheckerUI;
         checkUI.druggingIsPermitted = true;
     }
 }
Exemplo n.º 2
0
 private void InitializePlayersForCheckers()
 {
     foreach (IChecker checker in GameField.BlackCheckers)
     {
         CheckerUI checkerUI = checker.checkerUI as CheckerUI;
         checkerUI.Player = BlackPlayer;
     }
     foreach (IChecker checker in GameField.WhiteCheckers)
     {
         CheckerUI checkerUI = checker.checkerUI as CheckerUI;
         checkerUI.Player = WhitePlayer;
     }
 }
Exemplo n.º 3
0
        public BlackChecker CreateBlack(Coord coord, IGameField gameField)
        {
            BlackChecker black = new BlackChecker(new BlackNormalCheckerState(), new CheckerUI());

            black.CurrentCoord = coord;
            (black.checkerUI as CheckerUI).AssignConnectedChecker(black);

            CheckerUI checkerUI = black.checkerUI as CheckerUI;

            checkerUI.CoordChangedFromForm         += black.CoordChangedFromForm;
            black.CoordChanged                     += gameField.CheckCheckersMovement;
            gameField.Grid[coord.Row][coord.Column] = black;
            Grid.SetColumn(black.checkerUI, coord.Column - 1);
            Grid.SetRow(black.checkerUI, coord.Row - 1);
            gameField.FormGrid.Children.Add(black.checkerUI);
            checkerUI.TryingToMoveToAnotherCell += gameField.MainWindow.TryToMoveCheckerToAnotherCell;
            checkerUI.MovingToAnotherCell       += gameField.MainWindow.MoveCheckerToAnotherCell;
            checkerUI.ConnectedChecker           = black;
            checkerUI.GetVictim += gameField.GetVictim;
            return(black);
        }
Exemplo n.º 4
0
        public WhiteChecker CreateWhite(Coord coord, IGameField gameField)
        {
            WhiteChecker white = new WhiteChecker(new WhiteNormalCheckerState(), new CheckerUI());

            white.CurrentCoord = coord;
            (white.checkerUI as CheckerUI).AssignConnectedChecker(white);

            CheckerUI checkerUI = white.checkerUI as CheckerUI;

            checkerUI.CoordChangedFromForm += white.CoordChangedFromForm;
            white.CoordChanged             += gameField.CheckCheckersMovement;

            gameField.Grid[coord.Row][coord.Column] = white;
            Grid.SetColumn(white.checkerUI, coord.Column - 1);
            Grid.SetRow(white.checkerUI, coord.Row - 1);
            gameField.FormGrid.Children.Add(white.checkerUI);
            checkerUI.TryingToMoveToAnotherCell += gameField.MainWindow.TryToMoveCheckerToAnotherCell;
            checkerUI.MovingToAnotherCell       += gameField.MainWindow.MoveCheckerToAnotherCell;
            checkerUI.ConnectedChecker           = white;
            checkerUI.GetVictim += gameField.GetVictim;
            return(white);
        }