Ejemplo n.º 1
0
        public RegionCell(GalaxyGenerator generator, int cellX, int cellY)
        {
            this.generator = generator;
            this.cellX     = cellX;
            this.cellY     = cellY;

            Rand64 random = new Rand64((ulong)(cellY * GalaxyGenerator.galaxySize + cellX + GalaxyGenerator.galaxySeed + GalaxyGenerator.galaxySize * GalaxyGenerator.galaxySize));

            int numRegions = random.Range(5, 10);

            for (int n = 0; n < numRegions; n++)
            {
                RegionId id     = new RegionId(cellX, cellY, n);
                Region   region = new Region(id, random);
                regions.Add(region);
            }

            ConstrainPositions();

            NameRegions(random);
        }
Ejemplo n.º 2
0
 public GalaxyRenderer()
 {
     galaxyGenerator = new GalaxyGenerator();
 }
Ejemplo n.º 3
0
        public GalaxyCell(GalaxyGenerator generator, int cellX, int cellY, bool fullGeneration = true)
        {
            this.generator = generator;
            this.cellX     = cellX;
            this.cellY     = cellY;

            Rand64 random = new Rand64((ulong)(cellY * GalaxyGenerator.galaxySize + cellX + GalaxyGenerator.galaxySeed));

            int numStars = random.Range(1, 10);

            for (int n = 0; n < numStars; n++)
            {
                StarSystemId id   = new StarSystemId(cellX, cellY, n);
                StarSystem   star = new StarSystem(id, random);
                starSystems.Add(star);
            }

            if (cellY > 0)
            {
                PickConnector(random, StarSystem.Attributes.NorthConnector);
            }
            if (cellX < GalaxyGenerator.galaxySize - 1)
            {
                PickConnector(random, StarSystem.Attributes.EastConnector);
            }
            if (cellY < GalaxyGenerator.galaxySize - 1)
            {
                PickConnector(random, StarSystem.Attributes.SouthConnector);
            }
            if (cellX > 0)
            {
                PickConnector(random, StarSystem.Attributes.WestConnector);
            }

            ConstrainPositions();

            if (fullGeneration)
            {
                if (cellY > 0)
                {
                    jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.NorthConnector).id,
                                                   GetCell(cellX, cellY - 1).GetSystemWithAttribute(StarSystem.Attributes.SouthConnector).id));
                }
                if (cellX < GalaxyGenerator.galaxySize - 1)
                {
                    jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.EastConnector).id,
                                                   GetCell(cellX + 1, cellY).GetSystemWithAttribute(StarSystem.Attributes.WestConnector).id));
                }
                if (cellY < GalaxyGenerator.galaxySize - 1)
                {
                    jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.SouthConnector).id,
                                                   GetCell(cellX, cellY + 1).GetSystemWithAttribute(StarSystem.Attributes.NorthConnector).id));
                }
                if (cellX > 0)
                {
                    jumpGates.Add(new JumpGateLink(GetSystemWithAttribute(StarSystem.Attributes.WestConnector).id,
                                                   GetCell(cellX - 1, cellY).GetSystemWithAttribute(StarSystem.Attributes.EastConnector).id));
                }

                if (!IsFullyConnected())
                {
                    TryConnectClosest();
                }

                int itCount = 0;
                while (!IsFullyConnected())
                {
                    bool avoidIntersections = itCount < 100;
                    TryAddJumpGate(starSystems[random.Range(0, starSystems.Count)].id, starSystems[random.Range(0, starSystems.Count)].id, avoidIntersections);
                    itCount++;
                }

                AssignRegions();

                for (int n = 0; n < starSystems.Count; n++)
                {
                    Region region = generator.GetRegion(starSystems[n].regionId);

                    if ((starSystems[n].attributes & StarSystem.Attributes.Capital) != 0)
                    {
                        starSystems[n].name = generator.GenerateCapitalName(region, random);
                    }
                    else
                    {
                        starSystems[n].name = generator.GenerateName(region.languageIndex, random);
                    }
                }
            }
        }