private void toolStripButton1_Click(object sender, EventArgs e) { var sizeRequest = new Form() { Size = new Size(220, 130),ControlBox = false, Text = Manager.Opts.Get<string>("loc_mapProperties"), FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow}; sizeRequest.Controls.Add(new NumericUpDown() { Maximum = 100000, Minimum = 1, Location = new Point(70, 10), Value = 102.4m, Size = new Size(70,25),TextAlign = HorizontalAlignment.Right, DecimalPlaces = 1}); sizeRequest.Controls.Add(new NumericUpDown() { Maximum = 100000, Minimum = 1, Location = new Point(70, 40), Value = 102.4m, Size = new Size(70, 25), TextAlign = HorizontalAlignment.Right, DecimalPlaces = 1 }); sizeRequest.Controls.Add(new Button() { Text = Manager.Opts.Get<string>("loc_ok"), Location = new Point(10, 70)}); sizeRequest.Controls.Add(new Label() { Text = Manager.Opts.Get<string>("loc_mapWidth")+@":", Location = new Point(10, 12) }); sizeRequest.Controls.Add(new Label() { Text = Manager.Opts.Get<string>("loc_mapDepth")+@":", Location = new Point(10, 42) }); sizeRequest.Controls.Add(new Label() { Text = Manager.Opts.Get<string>("loc_meter"), Location = new Point(150, 12) }); sizeRequest.Controls.Add(new Label() { Text = Manager.Opts.Get<string>("loc_meter"), Location = new Point(150, 42) }); sizeRequest.Controls[2].Click += delegate { sizeRequest.Close(); }; sizeRequest.ShowDialog(this); var oldTerrains = View.Render.Content.Where(renderable => renderable is TerrainSubrender).Select(rendereable => View.Render.Content.IndexOf(rendereable)).Reverse(); foreach (var oldTerrain in oldTerrains) { View.Render.Content[oldTerrain].Dispose(); View.Render.Content.RemoveAt(oldTerrain); } if(currentTerrain != null) currentTerrain.Dispose(); currentTerrain = new Terrain((float)((NumericUpDown)sizeRequest.Controls[0]).Value, (float)((NumericUpDown)sizeRequest.Controls[1]).Value,Manager); View.Render.Content.Add(new TerrainSubrender(currentTerrain, View.Render, Manager)); }
private void toolStripButton4_Click(object sender, EventArgs e) { var oldTerrains = View.Render.Content.Where(renderable => renderable is TerrainSubrender).Select(rendereable => View.Render.Content.IndexOf(rendereable)).Reverse(); foreach (var oldTerrain in oldTerrains) View.Render.Content.RemoveAt(oldTerrain); if (currentTerrain != null) currentTerrain.Dispose(); currentTerrain = Terrain.GetRandomTerrain(Manager); View.Render.Content.Add(new TerrainSubrender(currentTerrain, View.Render, Manager)); }
public static Terrain GetRandomTerrain(IRunManager manager) { var ter = new Terrain(500, 500, manager); var r = new Random(); for (int i = 0; i < ter.Height.Length; i++) { ter.Height[i] = (float)r.NextDouble(); } return ter; }