private void resetPlanet() { planet = new Planet(); planet.generate(noise, (int)DateTime.Now.Ticks); planetGfx.Clear(panel1.BackColor); planetGfx.DrawImage(planet.circle, new Rectangle(20, 20, planet.circle.Width, planet.circle.Height), 0, 0, planet.circle.Width, planet.circle.Height, GraphicsUnit.Pixel, imageAttributes); textBox1.Text = "Mass: " + planet.mass + "x10^" + planet.massRadix + " tons\r\n"; textBox1.Text += "Mean Radius: " + planet.planetRadius + "km\r\n"; textBox1.Text += "Temperature: " + planet.minTemp + "ºC min. - " + (planet.minTemp + planet.maxTemp) / 2 + "ºC mean - " + planet.maxTemp + "ºC max.\r\n"; textBox1.Text += "Atmosphere Percentage: " + planet.atmosphere + "%\r\n"; textBox1.Text += "Organic Resources Percentage: " + planet.orgRes + "%\r\n"; textBox1.Text += "Industrial Resources Percentage: " + planet.indRes + "%\r\n"; textBox1.Text += "Civilization Level: " + planet.technology + "\r\n\r\n"; textBox1.Text += " PERLIN NOISE STUFF \r\n\r\n"; textBox1.Text += "Frequency: " + planet.frequency + "\r\n"; textBox1.Text += "Persistence: " + planet.persistence + "\r\n"; textBox1.Text += "Octaves: " + planet.octaves + "\r\n"; textBox1.Text += "Amplitude: " + planet.amplitude + "\r\n"; drawSurface(); }
void loadStuff() { Readable r = new Readable("Loading planets for\r\nthis star system.\r\nYou can scroll around and\r\nMove this window.\r\n", 30, 30, 140, 80, 10f, Color.White); Popup p = new Popup("Loading", 20, this.Width / 2 - 100, this.Height / 2 - 50, 200, 120, 12f, Color.White, new SolidBrush(Color.SteelBlue), Color.DarkSlateBlue, Color.Black); p.readables = new List<Readable>(); //home planet on the home star system p.readables.Add(r); p.isMovable = true; popups.Add(p); starSystem = new StarSystem(); starSystem.width = STARSYSTEM_SIZE; starSystem.height = STARSYSTEM_SIZE; starSystem.numPlanets = noise.random.Next(10, 21); starSystem.planets = new List<Planet>(); Planet planet = new Planet(); planet.generate(noise, seed); planet.x = noise.random.Next(planet.width, gfx.totalAreaWidth - planet.width); planet.y = noise.random.Next(planet.height, gfx.totalAreaHeight - planet.height); starSystem.planets.Add(planet); gfx.targetViewAreaX = (planet.x + (planet.width / 2)) - (gfx.viewAreaWidth / 2); gfx.targetViewAreaY = (planet.y + (planet.height / 2)) - (gfx.viewAreaHeight / 2); gfx.centerViewAreaImediately(); for (int j = 0; j < starSystem.numPlanets; j++) { Planet pl = new Planet(); pl.generate(noise, seed); pl.x = noise.random.Next(pl.width, gfx.totalAreaWidth - pl.width); pl.y = noise.random.Next(pl.height, gfx.totalAreaHeight - pl.height); starSystem.planets.Add(pl); } gfx.drawMap = true; }
void MasterItemSelected(object sender, Planet e) { Detail = new NavigationPage(new PlanetsDetailPage(e)); IsPresented = false; }
void loadInBackground() { if (main.loading) { main.loading1 = ""; main.loading2 = ""; int i; for (i = 0; i < main.totalPlanets; i++) { main.loading1 = "Generating planets (" + (i + 1) + "/" + (main.totalPlanets) + ")"; Planet planet = new Planet(); planet.generate(main.noise, main.device, main.seed); planet.x = main.noise.random.Next(0, main.quadrantWidth); planet.y = main.noise.random.Next(0, main.quadrantHeight); main.planets[i] = planet; } main.loading1 = i + " planets loaded"; for (i = 0; i < main.totalShips; i++) { main.loading2 = "Generating ships (" + (i + 1) + "/" + (main.totalShips + 1) + ")"; Ship ship = new Ship(); ship.x = main.noise.random.Next(0, main.quadrantWidth); ship.y = main.noise.random.Next(0, main.quadrantHeight); int planet = main.noise.random.Next(0, main.totalPlanets); ship.targetX = main.planets[planet].x; ship.targetY = main.planets[planet].y; ship.targetWidth = main.planets[planet].width; ship.targetHeight = main.planets[planet].height; ship.smoke = new ParticleSmoke(); ship.smoke.newSmokeParticles(main.noise, ship.x, ship.y, 20, 20f, 0.8f); ship.maxSpeed = main.noise.random.Next(2, 4); ship.moving = true; main.ships[i] = ship; } main.loading2 = i + " ships loaded"; main.loading = false; loadingThread.Abort(); } }
void loadInBackground() { if (loading) { loading1 = ""; loading2 = ""; shipImage = Content.Load<Texture2D>("dummyShip"); //generateBackground(); background = Content.Load<Texture2D>("dummyBackground"); int i; for (i = 0; i < totalPlanets; i++) { loading1 = "Generating planets (" + (i + 1) + "/" + (totalPlanets) + ")"; Planet planet = new Planet(); planet.generate(noise, device, seed); planet.x = noise.random.Next(0, quadrantWidth); planet.y = noise.random.Next(0, quadrantHeight); planets[i] = planet; } loading1 = i + " planets loaded"; for (i = 0; i < totalShips; i++) { loading2 = "Generating ships (" + (i + 1) + "/" + (totalShips + 1) + ")"; Ship ship = new Ship(); ship.x = noise.random.Next(0, quadrantWidth); ship.y = noise.random.Next(0, quadrantHeight); ship.targetX = noise.random.Next(0, quadrantWidth); ship.targetY = noise.random.Next(0, quadrantHeight); ships[i] = ship; } loading2 = i + " ships loaded"; loading = false; loadingThread.Abort(); } //if (!loading) //{ // while (true) // { // for (int i = 0; i < totalShips; i++) // { // if (ships[i] != null) // { // Ship ship = ships[i]; // for (int j = 0; j < totalShips; j++) // { // if (i != j && ships[j] != null) // { // Ship ship2 = ships[j]; // if (rectanglesCollide(ship.x, ship.y, 20, 20, ship2.x, ship2.y, 20, 20)) // { // ships[i] = null; // ships[j] = null; // } // } // } // } // } // } //} }