Example #1
0
		public static Board BuildNewBoard()
		{
			var blockLists = new System.Collections.Generic.List<System.Collections.Generic.LinkedList<Block>>();

			for (int counter = 0; counter < maxNumberOfLists; counter++)
			{
				var linkedList = new System.Collections.Generic.LinkedList<Block>();

				int numberOfBlocksInTheList = randomNumberGenerator.Next(3, 6);

				for (int listCounter = 0; listCounter < numberOfBlocksInTheList; listCounter++)
				{
					var block = GetNewRandomBlock();
					linkedList.AddFirst(block);
				}

				for (int listCounter = numberOfBlocksInTheList; listCounter < 9; listCounter++)
				{
					var block = new Block();
					linkedList.AddLast(block);
				}

					blockLists.Add(linkedList);
			}

			Board board = new Board()
			{
				BlockLists = blockLists,
				inDanger = false,
				active = true
			};

			return board;
		}
		public BlockComponent(Game game, Board b)
			: base(game)
		{
			board = b;
			for (int i = 0; i < 6; i++)
			{
				blocks[i] = new Sprite[9];
			}
		}
Example #3
0
		public TetrisAttack()
		{
			graphics = new GraphicsDeviceManager(this);
			graphics.PreferredBackBufferHeight = 405;
			graphics.PreferredBackBufferWidth = 459;
			Content.RootDirectory = "Content";
			board = Board.BuildNewBoard();
			Components.Add(backgroundComponent = new BackgroundComponent(this, themeName));
			Components.Add(frameComponent = new FrameComponent(this, themeName));
			Components.Add(blockComponent = new BlockComponent(this, board));
			Components.Add(cursorComponent = new CursorComponent(this, board));
			Components.Add(textComponent = new TextComponent(this, board));
		}
		public CursorComponent(Game game, Board b)
			: base(game)
		{
			board = b;
			cursor = board.cursor;
		}
		public TextComponent(Game game, Board b)
			: base(game)
		{
			board = b;
		}