/// <summary> /// Puts a new block in the level. /// </summary> /// <returns>Returns a value indicating if switching to the new block was succesful.</returns> /// <remarks>TODO: Separate the check for the possibility of adding a block from the actual adding.</remarks> public void ActivateNextBlock() { activeBlockPosition = spawnPoint; //Get next block from the queue. activeBlock = nextBlocks.Dequeue(); nextBlocks.Enqueue(blockFactory.GetNewBlock()); }
/// <summary> /// Create a new level. /// </summary> /// <param name="width">Width of the level in number of blocks.</param> /// <param name="height">Height of the level in number of blocks.</param> public GamePlayManager(int width, int height) { //Set up the starting matrix and set it to all zeroes. levelGrid = new int[width, height]; Array.Clear(levelGrid, 0, levelGrid.Length); //Generate the first block, and set up rotation subsystem. blockFactory = new BlockFactory(); wallKickData = new WallKickData(); activeBlock = blockFactory.GetNewBlock(); activeBlockPosition = spawnPoint; //Generate the next 3 blocks. nextBlocks = new Queue <Block>(); for (int i = 0; i < 3; i++) { nextBlocks.Enqueue(blockFactory.GetNewBlock()); } }