Пример #1
0
 //Authors: <Brian and Morgan>
 public GameState()
 {
     this.gameOver          = false;
     this.currentLevel      = 0;
     this.currentScore      = 0;
     this.totalLinesCleared = 0;
     this.activeShape       = ShapeGenerator.GenerateShape(this.currentLevel);
     this.activeShape.MoveShapeToSpawn();
     this.nextShape = ShapeGenerator.GenerateShape(this.currentLevel);
     this.grid      = new BlockGrid(Constants.GAME_MAX_X, Constants.GAME_MAX_Y);
 }
Пример #2
0
        private List <int> GetGameShapeRowIndexes(GameShape gameShape)
        {
            List <int> rowIndexes = new List <int>();

            //for each block of the GameShape-- store row index
            foreach (Block block in gameShape.GetBlocks())
            {
                if (!rowIndexes.Contains(block.GetY()))
                {
                    rowIndexes.Add(block.GetY());
                }
            }

            return(rowIndexes);
        }
Пример #3
0
        // Author: DeAngelo
        public void PlaceShape(GameShape toPlace)
        {
            //TODO:: prevent duplicate placing

            //for each block of the GameShape-- place onto grid + add to list
            foreach (Block block in toPlace.GetBlocks())
            {
                if (grid[block.GetX()][block.GetY()] != null)
                {
                    throw new DuplicateNameException("PlaceShape:: block cannot be placed, position (" + block.GetX() + ", " + block.GetY() + ") already occupied");
                }
                Block blockCopy = block.Copy();
                grid[block.GetX()][block.GetY()] = blockCopy;
                blocks.Add(blockCopy);
            }
            toPlace.GameShapePlaced();
        }
Пример #4
0
 public void activateNext()
 {
     this.activeShape = this.nextShape;
     activeShape.MoveShapeToSpawn();
     this.nextShape = ShapeGenerator.GenerateShape(this.currentLevel);
 }