public LayoutInstance(LayoutDescription desc, Point loc) { Layout = desc; Location = loc; }
public void AddLayout(LayoutDescription desc) { layouts.Add(desc); }
protected bool MatchLayout(PuzzleBoard board, LayoutDescription desc, int startX, int startY) { int layoutWidth = desc.Bottom.Length; int layoutHeight = (string.IsNullOrEmpty(desc.Top) ? 1 : 2); string pattern = desc.Top + desc.Bottom; int i = 0; for (int y = startY; y < startY + layoutHeight; y++) for (int x = startX; x < startX + layoutWidth; x++) { if (board.Blocks[x, y] != CharToBlock(pattern[i++])) return false; } return true; }
private void ClearLayout(PuzzleBoard board, LayoutDescription desc, int startX, int startY) { int layoutWidth = desc.Bottom.Length; int layoutHeight = (string.IsNullOrEmpty(desc.Top) ? 1 : 2); for (int y = startY; y < startY + layoutHeight; y++) for (int x = startX; x < startX + layoutWidth; x++) { board.Blocks[x, y] = BlockType.Empty; } }