예제 #1
0
        public Town(TownOptions options)
        {
            Options = options;
            Random  = new Random(options.Seed);

            var ok = false;

            while (!ok)
            {
                NumPatches  = options.Patches;
                Roads       = new List <List <Vector2> > ();
                Streets     = new List <List <Vector2> > ();
                Gates       = new List <Vector2> ();
                Center      = new Vector2(Width / 2f * (1f + 0.1f * Random.value - 0.1f * Random.value), Height / 2f * (1f + 0.1f * Random.value - 0.1f * Random.value));
                Patches     = new List <Patch> ();
                WaterBorder = new List <Vector2> ();

                try
                {
                    BuildPatches();
                    OptimizePatches();
                    BuildWalls();
                    BuildRoads();
                    PopulateTown();

                    ok = Roads.Count > 1;
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }
예제 #2
0
        public Town(TownOptions options)
        {
            Options = options;
            //  Random = new Random (options.Seed);

            SplinesToRender = new List <Dictionary <Den.Tools.Coord, List <UnityEngine.Vector3> > >();

            Random = new Random(options.Seed + RandomGen.Next());

            mapOffset  = options.mapOffset;
            townOffset = options.townOffset;

            var ok = false;

            while (!ok)
            {
                NumPatches = options.Patches;

                name = TownGlobalObjectService.NamesQueue.Dequeue();

                //var addendum =
                //    ((Options.coord.z > 0) ? "N" : "S")
                //    +
                //    ((Options.coord.x > 0) ? "E" : "W");

                //name += "_" + addendum;

                //name = TownGlobalObjectService.namegenref.GeneratePlace();
                //  name = "cityWith"+ NumPatches+"Patches"; // TownGlobalObjectService.namegenref.GeneratePlace();

                Roads       = new List <List <Vector2> > ();
                Streets     = new List <List <Vector2> > ();
                Gates       = new List <Vector2> ();
                Center      = new Vector2(Width / 2f * (1f + 0.1f * Random.value - 0.1f * Random.value), Height / 2f * (1f + 0.1f * Random.value - 0.1f * Random.value));
                Patches     = new List <Patch> ();
                WaterBorder = new List <Vector2> ();

                try
                {
                    BuildPatches();
                    OptimizePatches();
                    BuildWalls();
                    BuildRoads();
                    PopulateTown();

                    ok = Roads.Count > 1;
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }
예제 #3
0
 protected Area(Patch patch)
 {
     Patch  = patch;
     random = patch.Town.Random;
 }