public void Draw(DrawManager d, fontManager f, Planets p) { int width = 480; int height = 130; f.DrawText("planet ID: ", new Vector3(-230, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText(p.ID.ToString(), new Vector3(-150, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText("| Population: ", new Vector3(-140, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText(p._currentHab.ToString(), new Vector3(-50, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText("Health: ", new Vector3(0, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText(p.health.ToString(), new Vector3(50, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText("Money: ", new Vector3(100, height, 0), 1, Vector3.Zero, Color.White, d, false); f.DrawText(p.CurrentMoney.ToString(), new Vector3(150, height, 0), 1, Vector3.Zero, Color.White, d, false); }
private void GenerateWorld(long seed) { _planets = new Planets[0]; int planetIndex = 0; long[] num = new long[SEEDSIZE]; int j; for (int i = 0; i < SEEDSIZE; i++) { j = i; num[i] = (long)(seed / Math.Pow(10, SEEDSIZE - (i + 1))); while (j > 0) { j--; long power = (long)(Math.Pow(10, i - j)); num[i] -= num[j] * power; } } int sum = 0; for (int i = 0; i < num.Length; i++) { sum += (int)num[i]; } if (sum < 0) { sum *= -1; } center = new Planets(); center.ID = 0; center.Speed = Vector3.Zero; center._position = position; center._mass = 100; center._texCode = 1; center.captured = true; orbits = sum % MAXORBITS + 3; _orbt = new Orbt[orbits]; for (int o = 0; o < orbits; o++) { _orbt[o] = new Orbt(); _orbt[o].planetsNum = (int)((sum + (sum / 2) * (2 * Math.Pow(o, 2))) % MAXPLANETS + 2); _orbt[o].radius = (int)((sum * 597 + sum * (2 * Math.Pow(o, 2))) % 9); R : for (int i = 0; i < o; i++) { if (_orbt[o].radius == ((_orbt[i].radius - 100) / 150)) { _orbt[o].radius++; if (_orbt[o].radius > 9) { _orbt[o].radius = 0; } goto R; } } _orbt[o].radius = (_orbt[o].radius * 150) + 100; Array.Resize(ref _planets, _planets.Length + _orbt[o].planetsNum); for (int p = 0; p < _orbt[o].planetsNum; p++) { int pn = _orbt[o].planetsNum; _planets[planetIndex] = new Planets(); _planets[planetIndex].ID = (o * 10) + p + 1; // v = sqrt(G * M / r) _planets[planetIndex]._mass = .1f;//((sum + o + (pn * p)) % 1 + 5) + 0; double v = Math.Sqrt(gravity * center._mass / _orbt[o].radius); _planets[planetIndex].Speed = new Vector3( (float)(v * Math.Sin((MathHelper.TwoPi / _orbt[o].planetsNum) * p)), (float)(v * Math.Cos((MathHelper.TwoPi / _orbt[o].planetsNum) * p)), 0); _planets[planetIndex]._maxHab = (sum + o + (pn * p)) % 50 + 50; _planets[planetIndex]._temp = (sum + o + (pn * p)) % 50 + 50; // x' = x * cos(theta) - y * sin(theta) // y' = x * sin(theta) + y * cos(theta) _planets[planetIndex]._position = new Vector3( -(float)(_orbt[o].radius * Math.Cos((MathHelper.TwoPi / _orbt[o].planetsNum) * p)) + center._position.X, (float)(_orbt[o].radius * Math.Sin((MathHelper.TwoPi / _orbt[o].planetsNum) * p)) + center._position.Y, 0); _planets[planetIndex]._texCode = 2;// (sum + 2 * p * o) % 2; _planets[planetIndex].orbit = o; _planets[planetIndex].subOrbit = (sum + o + (pn * p)) % 2 - 1; _planets[planetIndex].XP = 0; _planets[planetIndex].Level = 0; // recursos _planets[planetIndex].MaxWater = (sum + o + (pn * p)) % 50 + 50; _planets[planetIndex].CurrentWater = 0; _planets[planetIndex].RestoreWater = (sum + o + (pn * p)) % 5 + 3; _planets[planetIndex].MaxWood = (sum + o + (pn * p)) % 50 + 50; _planets[planetIndex].CurrentWood = 0; _planets[planetIndex].RestoreWood = (sum + o + (pn * p)) % 5 + 3; _planets[planetIndex].MaxIron = (sum + o + (pn * p)) % 50 + 50; _planets[planetIndex].CurrentIron = 0; _planets[planetIndex].RestoreIron = (sum + o + (pn * p)) % 5 + 3; // _planets[planetIndex].MaxPetroill = (sum + o + (pn * p)) % 50 + 50; // _planets[planetIndex].CurrentPetroill = 0; // _planets[planetIndex].RestorePetroil = (sum + o + (pn * p)) % 5 + 3; // _planets[planetIndex].MaxUranium = (sum + o + (pn * p)) % 50 + 50; // _planets[planetIndex].CurrentUrânium = 0; // _planets[planetIndex].RestoreUranium = (sum + o + (pn * p)) % 5 + 3; // _planets[planetIndex].MaxFood = (sum + o + (pn * p)) % 50 + 50; // _planets[planetIndex].CurrentFood = 0; // _planets[planetIndex].ProduceFood = (sum + o + (pn * p)) % 50 + 20; _planets[planetIndex].MaxMoney = 10000; _planets[planetIndex].CurrentMoney = 0; _planets[planetIndex].GetMoney = 1; planetIndex++; } } }