public static Image GetImageFromTile(Tile tile, int x, int y) { Image img = new Image() { Width = 16, Height = 16, Margin = new Thickness(x * 16, y * 16, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; if (tile != null) { img.Source = tile.Source; } return img; }
public void SetTile(int column, int row, Tile tile, int front_ness) { Tile[] layer = back; if (front_ness == 0) layer = front; if (front_ness == 1) layer = middle; if (row >= 0 && row < this.height && column >= 0 && column < this.width) { layer[row * this.width + column] = tile; } }
public void ResizeTo(int newWidth, int newHeight) { Tile[] newFront = new Tile[newWidth * newHeight]; Tile[] newMiddle = new Tile[newWidth * newHeight]; Tile[] newBack = new Tile[newWidth * newHeight]; for (int y = 0; y < newHeight; ++y) { if (y < this.height) { for (int x = 0; x < newWidth; ++x) { if (x < this.width) { int index = y * newWidth + x; int oldIndex = y * this.width + x; newFront[index] = this.front[oldIndex]; newMiddle[index] = this.middle[oldIndex]; newBack[index] = this.back[oldIndex]; } } } } this.front = newFront; this.middle = newMiddle; this.back = newBack; this.width = newWidth; this.height = newHeight; }