Ejemplo n.º 1
0
    public static Bounds3Int[] GenerateAddon(AddonParameters addonParameters)
    {
        using (ListPool <Bounds3Int> .Get(out List <Bounds3Int> addons))
        {
            Bounds3Int addonBounds;
            using (ListPool <Bounds3Int> .Get(out List <Bounds3Int> stub))
            {
                stub.Add(new Bounds3Int(0, 0, 0, 1, 1, 1));
                Vector3Int sizeMin = new Vector3Int((int)addonParameters.primarySizeMin, (int)addonParameters.primarySizeMin, (int)addonParameters.primarySizeMin);
                Vector3Int sizeMax = new Vector3Int((int)addonParameters.primarySizeMax, (int)addonParameters.primarySizeMax, (int)addonParameters.primarySizeMax);
                addonBounds = IterateAddonBounds(stub, sizeMin, sizeMax, addons);
            }

            int area = addonBounds.area;
            addons.Add(addonBounds);

            while (area < addonParameters.minArea)
            {
                Vector3Int sizeMin  = new Vector3Int((int)addonParameters.secondarySizeMin, (int)addonParameters.secondarySizeMin, (int)addonParameters.secondarySizeMin);
                Vector3Int sizeMax  = new Vector3Int((int)addonParameters.secondarySizeMax, (int)addonParameters.secondarySizeMax, (int)addonParameters.secondarySizeMax);
                Bounds3Int subAddon = IterateAddonBounds(addons, sizeMin, sizeMax, addons);
                area += subAddon.area;
                addons.Add(subAddon);
            }

            return(addons.ToArray());
        }
    }
Ejemplo n.º 2
0
 static void InitializeRooms()
 {
     for (int i = 1; i <= 50; ++i)
     {
         Color           floorColor = new Color(Random.Range(128f, 255f), Random.Range(128f, 255f), Random.Range(128f, 255f));
         AddonParameters parameters = new AddonParameters
         {
             minArea          = GameVars.GetPlatformArea(i),
             primarySizeMin   = GameVars.GetSpacePlatformMinSize(i) + 2,
             primarySizeMax   = GameVars.GetSpacePlatformMaxSize(i) + 2,
             secondarySizeMin = GameVars.GetSpacePlatformMinSize(i),
             secondarySizeMax = GameVars.GetSpacePlatformMaxSize(i)
         };
         Bounds3Int[] bounds = AddonGen.GenerateAddon(parameters);
         SpacePlatform.Create(bounds, floorColor);
     }
 }
Ejemplo n.º 3
0
 public static Bounds3Int[] Addon(AddonParameters addonParameters)
 {
     Bounds3Int[] addon       = GenerateAddon(addonParameters);
     Bounds3Int[] placedAddon = PlaceAddon(addon, LandSystem.instance.landParcelHash);
     return(placedAddon);
 }