//=========== EDITING ============ #region Editing /** <summary> Resizes the maze to the new specified size. </summary> */ public void ResizeMaze(Size newSize) { MazeBlock[,] newBlocks = new MazeBlock[Math.Max(1, newSize.Width), Math.Max(1, newSize.Height)]; for (int x = 0; x < newBlocks.GetLength(0); x++) { for (int y = 0; y < newBlocks.GetLength(1); y++) { if (x < this.blocks.GetLength(0) && y < this.blocks.GetLength(1)) { newBlocks[x, y] = this.blocks[x, y]; } else { newBlocks[x, y] = new MazeBlock(); } } } this.blocks = newBlocks; this.Invalidate(); }
/** <summary> Translates the maze by the specified distance. </summary> */ public void TranslateMaze(Point distance) { MazeBlock[,] newBlocks = new MazeBlock[this.blocks.GetLength(0), this.blocks.GetLength(1)]; for (int x = 0; x < newBlocks.GetLength(0); x++) { for (int y = 0; y < newBlocks.GetLength(1); y++) { if (x - distance.X < this.blocks.GetLength(0) && y - distance.Y < this.blocks.GetLength(1)) { newBlocks[x, y] = this.blocks[x - distance.X, y - distance.Y]; } else { newBlocks[x, y] = new MazeBlock(); } } } this.blocks = newBlocks; this.Invalidate(); }