Inheritance: MonoBehaviour
        private static List <Line> CreateHouse(IMinecraftCommandService commandService, string[] commandArgs,
                                               Position position, List <SavedPosition> savedPositions)
        {
            IHouseOptions house = new Options {
                Fill = false, Thickness = 1, InnerThickness = 3
            };
            var location = position;

            if (commandArgs.Length >= 2)
            {
                commandArgs = commandArgs.Skip(1).ToArray();
                bool evaluate = true;
                while (evaluate)
                {
                    switch (commandArgs[0])
                    {
                    case "floors":
                        var floors = commandArgs.ElementAtOrDefault(1);
                        house.Height = floors.ToInt();
                        commandArgs  = commandArgs.Skip(2).ToArray();
                        break;

                    default:
                        house.Block = commandArgs.Length == 0 ? "stone" : String.Join(" ", commandArgs);
                        evaluate    = false;
                        break;
                    }
                }
            }

            house.Start = location.ToPoint();
            IGenerator generator = new HouseGenerator(commandService);

            return(generator.Run((Options)house));
        }
Ejemplo n.º 2
0
    public override void Generate()
    {
        if (houses == null || houses.Length == 0)
        {
            return;
        }
        int   amountOfHouses = 4;
        float dimX           = dimensions.x / amountOfHouses;
        float dimZ           = dimensions.y / amountOfHouses;

        for (int x = 0; x < amountOfHouses; x++)
        {
            for (int z = 0; z < amountOfHouses; z++)
            {
                Vector3 pos = position;
                pos.x += x * dimX * units.x;
                pos.z += z * dimZ * units.z;
                HouseGenerator generator = Create <HouseGenerator>(pos);               //new Vector3(pos.x * units.x, pos.y * units.y, pos.z * units.z));
                generator.position     = pos;
                generator.scale        = 1;
                generator.dimensions.x = dimX;
                generator.dimensions.y = Random.Range(minHouseDimensions.y, maxHouseDimensions.y);
                generator.dimensions.z = dimZ;
                generator.houseTiles   = houses[Random.Range(0, houses.Length)];
                generator.Generate();
            }
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            backGround = Content.Load <Texture2D>("Backgrounds\\BG");
            HouseGenerator.Load(Content);
            RandomManager.Initialise();
            houses = HouseGenerator.GenerateHouse(mapRect, 1f, GraphicsDevice, Content);
        }
 public void TestDistrictDefinition()
 {
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         Directory.SetCurrentDirectory(wd.WorkingDirectory);
     }
     using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         HouseGenerator.CreateExampleHouseJob(db.ConnectionString);
     }
     // db.Cleanup();
 }
        public void RunMatchingTest()
        {
            PersonCategory        pc10Male = new PersonCategory(10, PermittedGender.Male);
            PersonCategory        pc15Male = new PersonCategory(15, PermittedGender.Male);
            PersonCategory        pc20Male = new PersonCategory(20, PermittedGender.Male);
            PersonCategory        pc30Male = new PersonCategory(30, PermittedGender.Male);
            PersonCategory        pc31Male = new PersonCategory(31, PermittedGender.Male);
            PersonCategory        pc40Male = new PersonCategory(40, PermittedGender.Male);
            PersonCategory        pc41Male = new PersonCategory(41, PermittedGender.Male);
            List <PersonCategory> demand   = new List <PersonCategory>
            {
                pc10Male
            };

            {
                List <PersonCategory> offer = new List <PersonCategory>
                {
                    pc15Male
                };
                var success = HouseGenerator.AreOfferedCategoriesEnough(offer, demand);
                success.Should().BeTrue();
            }
            {
                List <PersonCategory> offer = new List <PersonCategory>
                {
                    pc20Male
                };
                var success = HouseGenerator.AreOfferedCategoriesEnough(offer, demand);
                success.Should().BeFalse();
            }
            demand.Clear();
            demand.Add(pc31Male);
            demand.Add(pc30Male);
            {
                List <PersonCategory> offer = new List <PersonCategory>
                {
                    pc40Male,
                    pc41Male
                };
                var success = HouseGenerator.AreOfferedCategoriesEnough(offer, demand);
                success.Should().BeTrue();
            }
            {
                List <PersonCategory> offer = new List <PersonCategory>
                {
                    pc40Male,
                    pc15Male
                };
                var success = HouseGenerator.AreOfferedCategoriesEnough(offer, demand);
                success.Should().BeFalse();
            }
        }
Ejemplo n.º 6
0
    void Start()
    {
        GameObject clone;

        coordinatePool = new ArrayList();

        generator = GetComponent <HouseGenerator> ();

        GetCoordinate(coordinatePool);

        foreach (Vector3 item in coordinatePool)
        {
            clone = generator.CreateHouse();
            clone.transform.position = item;
            clone.transform.rotation = Quaternion.Euler(new Vector3(0, 90 * Random.Range(0, 5), 0));
        }
    }
        public void RunSinglePredefinedJson()
        {
            Logger.Get().StartCollectingAllMessages();
            Logger.Threshold = Severity.Debug;
            const string srcfile = @"V:\Dropbox\LPGReleases\releases9.4.0\ExampleHouseJob-1.json";

            using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) {
                using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) {
                    FileInfo srcfi      = new FileInfo(srcfile);
                    string   targetfile = wd.Combine(srcfi.Name);
                    string   targetdb   = wd.Combine("profilegenerator.db3");
                    File.Copy(db.FileName, targetdb, true);
                    srcfi.CopyTo(targetfile, true);
                    Directory.SetCurrentDirectory(wd.WorkingDirectory);
                    HouseGenerator houseGenerator = new HouseGenerator();
                    houseGenerator.ProcessSingleHouseJob(targetfile, null);
                }
            }
        }
Ejemplo n.º 8
0
    public void Test()
    {
        map = map ?? GetComponent <Tilemap>() ?? gameObject.AddComponent <Tilemap>();

        HouseGenerator generator = new HouseGenerator(HouseSize.x, HouseSize.y);

        generator.Generate();

        (Queue <Rect> Rooms, Queue <Rect> Halls, Rect House) = generator.Drawables();

        foreach (Rect Hall in Halls)
        {
            for (int x = Hall.l; x <= Hall.r; ++x)
            {
                for (int y = Hall.t; y <= Hall.b; ++y)
                {
                    map.SetTile(new Vector3Int(x, y, 0), hall);
                }
            }
        }

        foreach (Rect Room in Rooms)
        {
            for (int x = Room.l + 1; x <= Room.r - 1; ++x)
            {
                for (int y = Room.t + 1; y <= Room.b - 1; ++y)
                {
                    map.SetTile(new Vector3Int(x, y, 0), room);
                }
            }

            foreach (Vector3Int v in Room.Edge())
            {
                map.SetTile(v, wall);
            }
        }

        foreach (Vector3Int v in House.Edge())
        {
            map.SetTile(v, wall);
        }
    }
Ejemplo n.º 9
0
    public static Building CreateBuilding(GenerationRandom genRan, out BuildingVoxels vox, BuildingGenerationPlan plan)
    {
        Vec2i zero      = new Vec2i(0, 0);
        int   maxWidth  = (plan.DesiredSize == null || plan.DesiredSize == zero) ?Mathf.Min(plan.BuildingPlan.MaxSize, plan.MaxWidth): plan.DesiredSize.x;
        int   maxHeight = (plan.DesiredSize == null || plan.DesiredSize == zero)? Mathf.Min(plan.BuildingPlan.MaxSize, plan.MaxHeight) : plan.DesiredSize.z;
        int   width     = genRan.RandomInt(plan.BuildingPlan.MinSize, maxWidth);
        int   height    = genRan.RandomInt(plan.BuildingPlan.MinSize, maxHeight);

        if (plan.BuildingPlan == Building.BLACKSMITH)
        {
            Blacksmith smith = BlacksmithGenerator.GenerateBlacksmith(genRan, new Blacksmith(width, height), out vox, plan);
            return(smith);
        }
        if (plan.BuildingPlan == Building.BARACKS)
        {
            Barracks barr = BarracksGenerator.GenerateBarracks(genRan, new Barracks(width, height), out vox, plan);
            return(barr);
        }
        if (plan.BuildingPlan == Building.TAVERN)
        {
            return(TavernGenerator.GenerateTavern(genRan, new Tavern(width, height), out vox, plan));
        }
        if (plan.BuildingPlan == Building.VEGFARM)
        {
            Farm farm = FarmGenerator.GenerateVegFarm(genRan, new Farm(width, height), out vox, plan);
            return(farm);
        }
        if (plan.BuildingPlan == Building.WHEATFARM)
        {
            Farm farm = FarmGenerator.GenerateWheatFarm(genRan, new Farm(width, height), out vox, plan);
            return(farm);
        }

        House house = HouseGenerator.GenerateHouse(genRan, new House(width, height), out vox, plan);

        return(house);
        //return GenerateHouse(out vox, width, height);
    }
        public static void RunSingleHouse(Func <Simulator, HouseCreationAndCalculationJob> makeHj,
                                          Action <string> checkResults)
        {
            Logger.Get().StartCollectingAllMessages();
            Logger.Threshold = Severity.Debug;
            using (var wd = new WorkingDir(Utili.GetCallingMethodAndClass())) {
                using (var db = new DatabaseSetup(Utili.GetCallingMethodAndClass())) {
                    wd.SkipCleaning = true;
                    var targetdb = wd.Combine("profilegenerator.db3");
                    File.Copy(db.FileName, targetdb, true);
                    Directory.SetCurrentDirectory(wd.WorkingDirectory);
                    var sim            = new Simulator(db.ConnectionString);
                    var houseGenerator = new HouseGenerator();
                    var hj             = makeHj(sim);
                    houseGenerator.ProcessSingleHouseJob(hj, null, sim);
                    if (hj.CalcSpec == null)
                    {
                        throw new LPGException("calcspec was null");
                    }

                    checkResults(wd.Combine(hj.CalcSpec.OutputDirectory));
                }
            }
        }
        private static void StartHouseJob([JetBrains.Annotations.NotNull] HouseCreationAndCalculationJob houseJob, [JetBrains.Annotations.NotNull] WorkingDir wd,
                                          string fnSuffix)
        {
            string houseJobFile = wd.Combine("houseJob." + fnSuffix + ".json");

            if (File.Exists(houseJobFile))
            {
                File.Delete(houseJobFile);
            }

            using (StreamWriter sw = new StreamWriter(houseJobFile)) {
                sw.WriteLine(JsonConvert.SerializeObject(houseJob, Formatting.Indented));
                sw.Close();
            }

            Logger.Info("======================================================");

            Logger.Info("======================================================");
            Logger.Info("starting house generation");
            Logger.Info("======================================================");
            HouseGenerator houseGenerator = new HouseGenerator();

            houseGenerator.ProcessSingleHouseJob(houseJobFile, null);
        }
 public void ProcessHouseJob([NotNull] HouseJobProcessingOptions args)
 {
     HouseGenerator.ProcessHouseJob(args, Makeallthecharts);
 }
 public void CreateExampleHouseJob()
 {
     HouseGenerator.CreateExampleHouseJob(ConnectionString);
 }