public partial class MainWindow : Window
{
private int Seed;
double WorldHeight { get; set; }
double WorldWidth { get; set; }
public MainWindow()
{
InitializeComponent();
Seed = new Random().Next(1,1000);
GenerateWorld();
}
private void GenerateWorld()
{
WorldHeight = Math.Round(Height / Tile.Size);
WorldWidth = Math.Round(Width / Tile.Size);
Random random = new Random(Seed);
for(int i = 0; i < WorldHeight; i++)
{
for(int j = 0; j < WorldWidth; j++)
{
TileType type = new TileType[] { TileType.Stone, TileType.Grass }[random.Next(0, 2)];
Tile tile = new Tile(Convert.ToDouble(j),Convert.ToDouble(i),type);
Display.Children.Add(tile);
}
}
}
private void OnWindowResize(object sender, EventArgs e)
{
Display.Children.Clear();
GenerateWorld();
}
}