Exemple #1
0
 public bool CheckWinner(Game game)
 {
     switch (game.Winner)
     {
         case 1:
             lbl_player.Content = "RED WINS!";
             lbl_player.Background = Brushes.Red;
             return true;
         case 2:
             lbl_player.Content = "BLUE WINS!";
             lbl_player.Background = Brushes.RoyalBlue;
             return true;
         default:
             return false;
     }
 }
Exemple #2
0
        public void CreateBoard(Game game)
        {
            _btnList = new List<SquareButton>();
            _dynamicGrid = new Grid();

            _dynamicGrid.HorizontalAlignment = HorizontalAlignment.Left;
            _dynamicGrid.VerticalAlignment = VerticalAlignment.Top;

            ColumnDefinition gridCol;
            RowDefinition gridRow;
            SquareButton squareBtn;

            int counter = 0;
            int padding = _squareSize + 2;

            for (int i = 0; i < game.Vsize; i++)
            {
                gridCol = new ColumnDefinition();
                gridCol.Width = new GridLength(padding);
                _dynamicGrid.ColumnDefinitions.Add(gridCol);

                for (int j = 0; j < game.Hsize; j++)
                {
                    gridRow = new RowDefinition();
                    gridRow.Height = new GridLength(padding);
                    _dynamicGrid.RowDefinitions.Add(gridRow);
                    squareBtn = CreateButton("", game.Board[counter++], j, i);

                    Grid.SetRow(squareBtn, i);
                    Grid.SetColumn(squareBtn, j);
                    _dynamicGrid.Children.Add(squareBtn);
                    _btnList.Add(squareBtn);
                }
            }

            this.grid.Children.Add(_dynamicGrid);
        }
Exemple #3
0
 public bool SetGame()
 {
     try
     {
         _game = _api.GetGame(GameId);
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }