/// <summary>Resizes the level.</summary> /// <param name="amountX">Amount by which to change the width of the level.</param> /// <param name="amountY">Amount by which to change the height of the level.</param> /// <param name="shiftX">Amount by which to shift the contents of the level in X direction.</param> /// <param name="shiftY">Amount by which to shift the contents of the level in Y direction.</param> private void resize(int amountX, int amountY, int shiftX, int shiftY) { if (amountX == 0 && amountY == 0) { return; } int newWidth = _width + amountX; int newHeight = _height + amountY; SokobanCell[] newLevel = new SokobanCell[newWidth * newHeight]; for (int x = 0; x < (amountX < 0 ? newWidth : _width); x++) { for (int y = 0; y < (amountY < 0 ? newHeight : _height); y++) { newLevel[(amountY > 0 ? y + shiftY : y) * newWidth + (amountX > 0 ? x + shiftX : x)] = _cells[(amountY < 0 ? y - shiftY : y) * _width + (amountX < 0 ? x - shiftX : x)]; } } _sokobanPos.Offset(shiftX, shiftY); _cells = newLevel; _width = newWidth; _height = newHeight; }
/// <summary>Changes the contents of the specified cell.</summary> private void setCell(int index, SokobanCell c) { if (index >= 0 && index < _width * _height) { _cells[index] = c; } }
/// <summary>Changes the contents of the specified cell.</summary> public void SetCell(int x, int y, SokobanCell c) { setCell(y * _width + x, c); }
/// <summary>Changes the contents of the specified cell.</summary> public void SetCell(Point pos, SokobanCell c) { setCell(pos.Y * _width + pos.X, c); }