Exemple #1
0
        private void Maze3ButtonClicked(object sender, RoutedEventArgs e)
        {
            Menu.Visibility = Visibility.Collapsed;
            var mazeViewModel      = new MazeViewModel(GetMazeSettings(MazeExamples.Example_3()));
            var gameBoardViewModel = new GameBoardViewModel(mazeViewModel, Width);

            GameBoard            = new GameBoardView(gameBoardViewModel);
            GameBoard.Visibility = Visibility.Visible;
            Content.Children.Add(GameBoard);
            BackButton.Visibility = Visibility.Visible;
        }
Exemple #2
0
        private void SetDifficultyAndRestart(Difficulty difficulty)
        {
            _dispatcherTimer.Stop();
            IsGameBoardInteractable = true;

            SecondsFromGameStarted = 0;
            CurrentDifficulty      = difficulty;
            MinesRemaining         = CurrentDifficulty.Mines;

            GameBoard.SetDifficultyAndRestart(CurrentDifficulty);
            GameBoardView.Refresh();
        }
Exemple #3
0
    public GameBoard(int rows, int columns)
    {
        _rows    = rows;
        _columns = columns;
        _view    = new GameBoardView(_rows, _columns);
        _tiles   = new Tile[_columns, _rows];
        _tilesSo = Resources.Load <TilesSo>("Tiles");

        _view.OnTileTurnOff           = OnTileTurnOff;
        _view.OnBlastCompleted        = OnBlastCompleted;
        _view.OnShuffleTilesCompleted = OnShuffleTilesCompleted;
        _view.OnTileFallCompleted     = OnTileFallCompleted;
        _view.OnCreateTileCompleted   = OnCreateTileCompleted;
    }
Exemple #4
0
        public void GameControl_FinishGame()
        {
            int    rowWidth    = 3;
            int    rowCount    = 3;
            int    playerPosX  = 1;
            int    playerPosY  = 1;
            string levelDesign = "#$,# ####";

            Game           level = new Game(rowWidth, rowCount, playerPosX, playerPosY, levelDesign);
            GameBoardView  view  = new GameBoardView();
            GameController game  = new GameController(view, level);

            Assert.IsTrue(game.FinishGame(), "Failed to finish game");
        }
        // instance method to create our Game Board & Game Tiles
        public void CreateGameBoard()
        {
            // Specify our tile width and tile centre values
            float tileWidth   = this.gameViewWidth / this.boardGridSize;
            float tileCenterX = tileWidth / 2;
            float tileCenterY = tileWidth / 2;

            //initialise our image counter position
            int imageIndex = 0;

            // Build our game board with images from our array
            for (int row = 0; row < this.boardGridSize; row++)
            {
                for (int column = 0; column < this.boardGridSize; column++)
                {
                    // create a new instance of our image tile
                    GameTile tile = new GameTile(row, column);
                    tile.Image  = GameTile.GameBoardObjects[imageIndex].Image;
                    tile.Center = new CGPoint(tileCenterX, tileCenterY);

                    // convert the image tile into a circle
                    var theTileImageView = tile.CreateCircle(tileWidth - 5, tileWidth - 5);
                    theTileImageView.UserInteractionEnabled = true;

                    // Store our Tile Coordinates within our ArrayList object
                    GameTileCoords.Add(new CGPoint(tileCenterX, tileCenterY));

                    // Add the tile to our Tile Images
                    TilesImageArray.Add(theTileImageView);
                    GameBoardView.AddSubview(theTileImageView);

                    // Increment to the next tile position and image within array
                    tileCenterX = tileCenterX + tileWidth;
                    imageIndex++;

                    // if we have reached the end of our row, reset out index
                    if (imageIndex == this.boardGridSize)
                    {
                        imageIndex = 0;
                    }
                }
                tileCenterX = tileWidth / 2;
                tileCenterY = tileCenterY + tileWidth;
            }
        }
Exemple #6
0
 private void InitGameBoard()
 {
     gameBoard = Instantiate(_gameBoardViewPref).GetComponent <GameBoardView>();
 }