示例#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;
		}
示例#2
0
		public void SwapBlocks(LinkedList<Block> leftBlockList, Block leftBlock, LinkedList<Block> rightBlockList, Block rightBlock)
		{
			leftBlockList.AddBefore(leftBlockList.Find(leftBlock), rightBlock);
			leftBlockList.Remove(leftBlockList.Find(leftBlock));
			blocksFall(leftBlockList);

			rightBlockList.AddBefore(rightBlockList.Find(rightBlock), leftBlock);
			rightBlockList.Remove(rightBlock);
			blocksFall(rightBlockList);
		}