void Loop() { int nbLoop = 0; int blockToRemove = 0; BoardModel board = new BoardModel(); board.loopCompleted += (sender, ev) => { nbLoop++; }; board.removeBlock += (sender, ev) => { blockToRemove += ev.Blocks.Count; }; List <BlockModel> blocks = new List <BlockModel>(); blocks.Add(new BlockModel(4, 5, HexDirection.SW, HexDirection.E)); blocks.Add(new BlockModel(5, 5, HexDirection.W, HexDirection.SE)); blocks.Add(new BlockModel(4, 4, HexDirection.SE, HexDirection.NE)); blocks.Add(new BlockModel(6, 4, HexDirection.SW, HexDirection.NW)); blocks.Add(new BlockModel(4, 3, HexDirection.NW, HexDirection.E)); board.Add(blocks); blocks = new List <BlockModel>(); blocks.Add(new BlockModel(5, 3, HexDirection.NE, HexDirection.W)); board.Add(blocks); blocks.Add(new BlockModel(4, 5, HexDirection.SW, HexDirection.E)); // should not crash here Debug.Assert(nbLoop == 1, "should detect one loop"); Debug.Assert(blockToRemove == 6, "should delete 6 blocks"); }
public void CreateBlocks(List <BlockModel> blocks, bool init = false) { foreach (BlockModel block in blocks) { transforms.Add(block.x, block.z, CreateBlock(block)); } if (init) { board.Add(blocks); } else { board.Push(blocks); } }