Beispiel #1
0
        public World(Random Random, MapGeneratorSettings Settings)
        {
            _Settings      = Settings;
            _Noise         = new LatticeNoiseGenerator(Random, Settings.Terrain);
            _MoistureNoise = new LatticeNoiseGenerator(Random, Settings.Moisture);
            _WaterLevel    = Settings.WaterLevel;

            _MicroRegions = new MicroRegion[Settings.Width, Settings.Height];
            _HeightMap    = new float[Settings.Width, Settings.Height];
            _MoistureMap  = new float[Settings.Width, Settings.Height];
            for (int i = 0; i < Settings.Width; ++i)
            {
                for (int j = 0; j < Settings.Height; ++j)
                {
                    float n = (float)_Noise.Generate(i, j);
                    float h = n > _WaterLevel ? (n - _WaterLevel) / (1 - _WaterLevel) : n / _WaterLevel - 1;
                    float m = (float)_MoistureNoise.Generate(i, j);
                    _HeightMap[i, j]   = h;
                    _MoistureMap[i, j] = m;
                    Biome B = Settings.BiomeMap.Closest(HeightAt(i, j), TemperatureAt(i, j), Moisture(i, j));
                    _MicroRegions[i, j] = new MicroRegion(i, j, B, this, h <= 0);
                }
            }
            _Shade = new FloatingImage(_HeightMap, Channel.RED)
                     .Filter(new Cence.Filters.Emboss()).GetChannel(Channel.RED);

            CreateRegions(Random, Settings.Regions, Settings.Language);
            CreateResources(Random, Settings.Population, Settings.Resource, Settings.Resources);
            InitializeEconomy();
        }
Beispiel #2
0
        //End

        public Region(string Name, MicroRegion Center, Culture Culture, Economy Economy)
            : base(Culture.CalculateLabor(), Economy)
        {
            _Name           = Name;
            _Center         = Center;
            _Culture        = Culture;
            _Administration = new RegionAdministration(this);
        }
Beispiel #3
0
 public void Add(MicroRegion Region)
 {
     _Regions.Add(Region);
     Region.Region = this;
     if (!Region.Oceanic)
     {
         _Area += 10000;
     }
     if (Region.Coastal)
     {
         _Coast++;
     }
 }
Beispiel #4
0
        void CreateRegions(Random Random, int Number, Language Language)
        {
            MicroRegion[] Arr = new MicroRegion[_Settings.Height * _Settings.Width];
            for (int i = 0; i < _Settings.Width; ++i)
            {
                for (int j = 0; j < _Settings.Height; ++j)
                {
                    Arr[i * _Settings.Height + j] = _MicroRegions[i, j];
                }
            }

            for (int i = 0; i < Arr.Length; ++i)
            {
                MicroRegion T     = Arr[i];
                int         index = Random.Next(0, Arr.Length);
                Arr[i]     = Arr[index];
                Arr[index] = T;
            }

            DijkstraPool <MicroRegion> pool = new DijkstraPool <MicroRegion>();
            CultureMap cultureMap           = new CultureMap(Random, _Settings.Culture);

            _Regions = new Region[Number];
            int c = 0;

            for (int i = 0; i < Arr.Length && c < Number; ++i)
            {
                if (!Arr[i].Oceanic && Random.NextDouble() < Math.Sqrt(Arr[i].Biome.RegionSlow))
                {
                    string Name = Language.Generate(Random).Orthography;
                    Region R    = new Region(
                        char.ToUpper(Name[0]) + Name.Substring(1),
                        Arr[i],
                        cultureMap.Generate(Arr[i].X, Arr[i].Y),
                        _Settings.Economy);
                    pool.Drop(R);
                    _Regions[c] = R;
                    ++c;
                    R.Culture.Colors                = _Settings.FlagColorMap.Closest(R.Culture, 3);
                    R.Administration.Flag           = Settings.FlagData.CreateFlag(R.Culture, Settings.FlagColorMap, Random);
                    R.Administration.GovernmentForm = GovernmentForm.AllValidGovernmentForms(
                        g => !g.Integrated && g.Devolved && g.Tributary).ArgMax(R.Culture.Favorability);
                }
            }
            pool.Resolve();
            foreach (Region R in _Regions)
            {
                R.DiscoverBorder();
            }
        }
Beispiel #5
0
 public float Distribute(float Noise, MicroRegion Region)
 {
     return(_Distributor.Invoke(Noise, Region));
 }