/// <summary>
    /// Decides the placement and type of each structure
    /// </summary>
    public void GenerateAllShells()
    {
        StructureShells = new List <ChunkStructureShell>();
        //Generate the lairs first, so that the grid points aren't free
        GenerateDragonLairShells();

        WeightedGridPoints = FindFreeGridPoints();
        GenerateMainDungeonShells();
        GenerateAncientTempleShells();
        GenerateBanditCampShells();
        GenerateVampireNestShells();
    }
Example #2
0
 /// <summary>
 /// Iterates each grid point in the world, calculating its settlement desirability
 /// We add each to a WeightRandomList <see cref="DesireWeightedGridpoints"/>.
 /// We add each grid point with a weight of its desirability
 /// </summary>
 private void FindGridPointsSettlementDesirability()
 {
     DesireWeightedGridpoints = new WeightedRandomList <GridPoint>(GameGen.Seed);
     for (int x = 0; x < GridPlacement.GridSize; x++)
     {
         for (int z = 0; z < GridPlacement.GridSize; z++)
         {
             //Get grid point
             GridPoint gp  = GameGen.GridPlacement.GridPoints[x, z];
             float     des = CalculateGridPointSettlementDesirability(gp);
             gp.Desirability = des;
             if (des > 0)
             {
                 DesireWeightedGridpoints.AddElement(gp, des);
             }
         }
     }
 }
    /// <summary>
    /// Iterates through all grid points and checks for valid ones (on land, no settlement or tactloc).
    /// We then add them to a weighted random list, with locations surrounded by settlements having a lower weighting
    /// we then return this list for use
    /// </summary>
    /// <returns></returns>
    private WeightedRandomList <GridPoint> FindFreeGridPoints()
    {
        WeightedRandomList <GridPoint> gridPoints = new WeightedRandomList <GridPoint>();

        int radius = 2;

        for (int x = 0; x < GridPlacement.GridSize; x++)
        {
            for (int z = 0; z < GridPlacement.GridSize; z++)
            {
                GridPoint gp = GameGen.GridPlacement.GridPoints[x, z];
                if (!gp.IsValid)
                {
                    continue;
                }

                if (gp.ChunkPos.QuickDistance(GameGen.TerGen.EvilDragonMountainPeak) < 100 * 100)
                {
                    continue;
                }

                if (gp.ChunkPos.QuickDistance(GameGen.TerGen.GoodDragonMountainPeak) < 60 * 60)
                {
                    continue;
                }

                float weight = 10;

                //If there is something here, then we ignore this point
                if (gp.Shell != null)
                {
                    continue;
                }
                Debug.Log("No shell");
                for (int rx = -radius; rx <= radius; rx++)
                {
                    if (weight <= 0)
                    {
                        break;
                    }
                    for (int rz = -radius; rz <= radius; rz++)
                    {
                        Vec2i testPos = new Vec2i(x + rx, z + rz);
                        //Distance from gridpoint to this point
                        float dist = Mathf.Sqrt(rx * rx + rz * rz);
                        if (GridPlacement.InGridBounds(testPos))
                        {
                            //Get near point
                            GridPoint gp2 = GameGen.GridPlacement.GridPoints[testPos.x, testPos.z];
                            if (gp2.Shell != null)
                            {
                                //If too close, then point not valid
                                if (dist <= 1)
                                {
                                    weight -= 5;
                                }
                                else
                                {
                                    weight -= 3f / dist;
                                }
                            }
                        }
                    }
                }
                if (weight > 0)
                {
                    gridPoints.AddElement(gp, weight);
                }
            }
        }

        return(gridPoints);
    }