private OSTTools.Vector3 GetRandomSystemPosition() { OSTTools.Vector3 result = new OSTTools.Vector3((_random.NextDouble() * 250.0) - 125.0, 0.0, (_random.NextDouble() * 250.0) - 125.0f); return(result); }
private OSTTools.Vector3 GetRandomStationPosition() { OSTTools.Vector3 result = new OSTTools.Vector3((_random.NextDouble() * 100.0) - 50.0, 0.0, (_random.NextDouble() * 100.0) - 50.0); return(result); }
/// <summary> Constructeur par type </summary> public StarSystem(int id, Universe universe, OSTTools.Vector3 position) { ID = id; Position = position; Stations = new List <Station>(); Universe = universe; }
public void PortalPositions() { Universe u = new Universe(0); Portal p = u.Portals[0]; OSTTools.Vector3 pos = p.Position(p.Station1); OSTTools.Vector3 pos2 = p.Position(p.Station2); }
/// <summary> Constructeur par type </summary> /// <param name="type">le type de la station</param> /// <param name="starSystem">Le systeme solair qui contient cette station</param> /// <param name="position">La position de la station dans son syteme, en AU</param> /// <param name="iID">Un identifiant pour cette station</param> public Station(StationType type, StarSystem starSystem, OSTTools.Vector3 position, int iID) { Type = type; Position = position; _gates = new List <Portal>(); Name = "StationName"; System = starSystem; ID = iID; Hangar h = new Hangar(this, starSystem.Universe.GetCorporation(-1)); _hangars.Add(-1, h); }
private void HardCordedBuildUniverse() { _stations = new Dictionary <int, Station>(); _corporations = new Dictionary <int, Corporation>(); Systems = new Dictionary <int, StarSystem>(); Portals = new List <Portal>(); Ships = new List <Ship>(); //creaction de la corp NPC Corporation npcCorp = new Corporation(-1); _corporations.Add(-1, npcCorp); //creation des systemes for (int i = 0; i < _nbSystemPerMap; i++) { StarSystem sys = new StarSystem(i, this, GetRandomSystemPosition()); sys.Name = "System " + (i + 1); Systems.Add(i, sys); //creation d'une cite OSTTools.Vector3 stationPos = new OSTTools.Vector3(1.0, 1.0, 1.0); Station s = new Station(Station.StationType.City, Systems[i], stationPos, _stations.Count + 1); s.Name = "city " + i; _stations.Add(s.ID, s); Systems[i].Stations.Add(s); } //creation des stations mines for (int i = 0; i < _nbMine; i++) { StarSystem sys = Systems[_random.Next(_nbSystemPerMap)]; Station s = new Station(Station.StationType.Mine, sys, GetRandomStationPosition(), _stations.Count + 1); s.Name = "mine " + i; _stations.Add(s.ID, s); sys.Stations.Add(s); } for (int i = 0; i < _nbIceField; i++) { StarSystem sys = Systems[_random.Next(_nbSystemPerMap)]; Station s = new Station(Station.StationType.IceField, sys, GetRandomStationPosition(), _stations.Count + 1); s.Name = "ice field " + i; _stations.Add(s.ID, s); sys.Stations.Add(s); } Array allTypes = Enum.GetValues(typeof(Station.StationType)); while (_stations.Count < _nbStation) { StarSystem sys = Systems[_random.Next(_nbSystemPerMap)]; Station.StationType type = (Station.StationType)allTypes.GetValue(_random.Next(allTypes.Length - 3) + 3); Station s = new Station(type, sys, GetRandomStationPosition(), _stations.Count + 1); s.Name = type.ToString() + " " + (_stations.Count + 1); _stations.Add(s.ID, s); sys.Stations.Add(s); } //creation des links entre systeme for (int i = 0; i < _nbSystemPerMap; i++) { for (int j = i + 1; j < _nbSystemPerMap; j++) { Station from = Systems[i].Stations[_random.Next(Systems[i].Stations.Count)]; Station to = Systems[j].Stations[_random.Next(Systems[j].Stations.Count)]; Portal p = new Portal(from, to, Portal.PortalType.StarToStar); from.AddGate(p); to.AddGate(p); Portals.Add(p); } //creer les liens internes List <Station> connected = new List <Station>(); foreach (Station s in Systems[i].Stations) { Station closest = null; double bestDist = 0.0; foreach (Station s2 in connected) { if (s2 != s) { double dist = (s2.Position.X - s.Position.X) * (s2.Position.X - s.Position.X) + (s2.Position.Y - s.Position.Y) * (s2.Position.Y - s.Position.Y) + (s2.Position.Z - s.Position.Z) * (s2.Position.Z - s.Position.Z); if (closest == null || dist < bestDist) { bestDist = dist; closest = s2; } } } if (closest != null) { Portal p = new Portal(s, closest, Portal.PortalType.StationToStation); s.AddGate(p); closest.AddGate(p); Portals.Add(p); } connected.Add(s); } } }