Exemple #1
0
        //Initialize
        public override void Initialize(int row, int column, int mine, Window window)
        {
            //assign values to variables
            base.Initialize(row, column, mine, window);

            //Create rows
            for (int i = 0; i < row; i++)
            {
                RowDefinition rowDef = new RowDefinition();
                rowDef.Height = new GridLength(blockSize);
                gameBoard.RowDefinitions.Add(rowDef);
                // Create Columns
                for (int j = 0; j < column; j++)
                {
                    ColumnDefinition columnDef = new ColumnDefinition();
                    columnDef.Width = new GridLength(blockSize);
                    gameBoard.ColumnDefinitions.Add(columnDef);
                    Tile tile = new MP_Tile(i, j, this);
                    tiles.Add(tile);
                }
            }
            //Randomly place mine to the gameboard
            SetMine(RandomNumber(mine), tiles);

            //Create the top banner to show the players information
            topBannerHUD = new TopBanner(this.gameCanvas.Width, topPadding, this.gameCanvas);
            //Update the win condition
            topBannerHUD.WinCondition.Content = mine / 2 + 1;
            //Create two players
            for (int i = 0; i < 2; i++)
            {
                players.Add(new Player(i, this));
            }
            //Add the gameboard(grid) to canvas
            gameCanvas.Children.Add(this.gameBoard);
            //Display the canvas
            gameWindow.Content = this.gameCanvas;
            //Window size to content
            gameWindow.SizeToContent = SizeToContent.WidthAndHeight;
            //Switch player turn - Start from 0
            SwitchPlayerTurn();
        }
Exemple #2
0
 public GhostRoleRulesWindow(string rules, Action <BaseButton.ButtonEventArgs> requestAction)
 {
     RobustXamlLoader.Load(this);
     TopBanner.SetMessage(FormattedMessage.FromMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer")));
     RequestButton.OnPressed += requestAction;
 }