Esempio n. 1
0
 void CalibrateRects(GameBoardConfig _config)
 {
     tilesRectArr = new Rectangle[board.GetLength(0), board.GetLength(1)];
     for (int i = 0; i < board.GetLength(0); i++)
     {
         for (int j = 0; j < board.GetLength(1); j++)
         {
             tilesRectArr[i, j] = new Rectangle((int)((i * (boardConfig.tileWidth * scale)) + position.X), (int)((j * (boardConfig.tileHeight * scale)) + position.Y), boardConfig.tileWidth, boardConfig.tileHeight);
         }
     }
 }
Esempio n. 2
0
 public void NewGame(GameBoardMode _mode)
 {
     /*New game stuff goes here*/
     //GameBoard Initalization
     //First we will check to see if the board config we were given is different than the one we have
     if (!_mode.boardConfig.Equals(boardConfig))
     {
         //If it is different, then let's create a new board
         boardConfig = _mode.boardConfig;
         board       = new int[boardConfig.gridWidth, boardConfig.gridHeight];
         scale       = 1.0f;
         CalibrateRects(_mode.boardConfig);
     }
     else
     {
         //If they are the same, then nothing needs to be recreated. Let's just wipe the board clean
         WipeBoard();
     }
     highscore   = _mode.highScore;
     score       = 0;
     isGameOver  = false;
     reached2048 = reached3072 = false;
     isMoved     = false;
     //Run the RunOnce event if it's set
     if (initEvent != null)
     {
         initEvent();
     }
     //SPAWNING FIRST BLOCK
     SpawnNewBlock();
     SpawnNewBlock();
     if (boardConfig.gameMode == GameModeState.Threes)
     {
         SpawnNewBlock();
     }
 }
Esempio n. 3
0
 void CalibrateRects(GameBoardConfig _config)
 {
     tilesRectArr = new Rectangle[board.GetLength(0), board.GetLength(1)];
     for (int i = 0; i < board.GetLength(0); i++) {
         for (int j = 0; j < board.GetLength(1); j++) {
             tilesRectArr[i, j] = new Rectangle((int)((i * (boardConfig.tileWidth * scale)) + position.X), (int)((j * (boardConfig.tileHeight * scale)) + position.Y), boardConfig.tileWidth, boardConfig.tileHeight);
         }
     }
 }
Esempio n. 4
0
 public void NewGame(GameBoardMode _mode)
 {
     /*New game stuff goes here*/
     //GameBoard Initalization
     //First we will check to see if the board config we were given is different than the one we have
     if (!_mode.boardConfig.Equals(boardConfig)) {
         //If it is different, then let's create a new board
         boardConfig = _mode.boardConfig;
         board = new int[boardConfig.gridWidth, boardConfig.gridHeight];
         scale = 1.0f;
         CalibrateRects(_mode.boardConfig);
     } else {
         //If they are the same, then nothing needs to be recreated. Let's just wipe the board clean
         WipeBoard();
     }
     highscore = _mode.highScore;
     score = 0;
     isGameOver = false;
     reached2048 = reached3072 = false;
     isMoved = false;
     //Run the RunOnce event if it's set
     if (initEvent != null) {
         initEvent();
     }
     //SPAWNING FIRST BLOCK
     SpawnNewBlock();
     SpawnNewBlock();
     if (boardConfig.gameMode == GameModeState.Threes) {
         SpawnNewBlock();
     }
 }