Example #1
0
    private void CreateMap(MapGenerator.Containers.Container map, List <CelestialBodyIdentifier[]> warpJumps)
    {
        if (MapSize == CelestialBodyType.Universe)
        {
            Map = new CelestialBodies.Universe((MapGenerator.Containers.Universe)map);
        }
        else if (MapSize == CelestialBodyType.Expanse)
        {
            Map = new CelestialBodies.Expanse((MapGenerator.Containers.Expanse)map);
        }
        else if (MapSize == CelestialBodyType.Galaxy)
        {
            Map = new CelestialBodies.Galaxy((MapGenerator.Containers.Galaxy)map);
        }
        else if (MapSize == CelestialBodyType.Sector)
        {
            Map = new CelestialBodies.Sector((MapGenerator.Containers.Sector)map);
        }
        else if (MapSize == CelestialBodyType.SolarSystem)
        {
            Map = new CelestialBodies.SolarSystem((MapGenerator.Containers.SolarSystem)map);
        }

        Network = new Network(warpJumps, Map);
    }
Example #2
0
    private void LoadMap()
    {
        byte[]            bytes = System.IO.File.ReadAllBytes("MapInfo.dat");
        CelestialBodyType type  = (CelestialBodyType)System.BitConverter.ToInt32(bytes, 4);

        if (type == CelestialBodyType.Universe)
        {
            Map = new CelestialBodies.Universe(bytes, 0);
        }
        else if (type == CelestialBodyType.Expanse)
        {
            Map = new CelestialBodies.Expanse(bytes, 0);
        }
        else if (type == CelestialBodyType.Galaxy)
        {
            Map = new CelestialBodies.Galaxy(bytes, 0);
        }
        else if (type == CelestialBodyType.Sector)
        {
            Map = new CelestialBodies.Sector(bytes, 0);
        }
        else
        {
            Map = new CelestialBodies.SolarSystem(bytes, 0);
        }

        int offset = System.BitConverter.ToInt32(bytes, 0);

        Network = new Network(bytes, offset, Map);
    }
Example #3
0
 public Network(List <CelestialBodyIdentifier[]> edges, CelestialBodies.CelestialBody Map)
 {
     Edges = new List <CelestialBodies.CelestialBody[]>();
     foreach (CelestialBodyIdentifier[] edge in edges)
     {
         CelestialBodies.CelestialBody body1 = Map.GetCelestialBody(edge[0]);
         CelestialBodies.CelestialBody body2 = Map.GetCelestialBody(edge[1]);
         Edges.Add(new CelestialBodies.CelestialBody[] { body1, body2 });
     }
 }
Example #4
0
    public Network(byte[] bytes, int startIndex, CelestialBodies.CelestialBody Map)
    {
        Edges = new List <CelestialBodies.CelestialBody[]>();
        int offset        = 4;
        int numberOfEdges = BitConverter.ToInt32(bytes, startIndex + offset);

        offset += 4;
        for (int i = 0; i < numberOfEdges; i++)
        {
            CelestialBodyIdentifier id1 = new CelestialBodyIdentifier(bytes, startIndex + offset);
            offset += BitConverter.ToInt32(bytes, startIndex + offset);
            CelestialBodyIdentifier id2 = new CelestialBodyIdentifier(bytes, startIndex + offset);
            offset += BitConverter.ToInt32(bytes, startIndex + offset);

            CelestialBodies.CelestialBody body1 = Map.GetCelestialBody(id1);
            CelestialBodies.CelestialBody body2 = Map.GetCelestialBody(id2);
            Edges.Add(new CelestialBodies.CelestialBody[] { body1, body2 });
        }
    }