Example #1
0
        /// <summary>
        /// Call it before use any other method
        /// </summary>
        public static void Init()
        {
            config = new RuntimeConfigRepository().Get();

            if (config == null)
            {
                throw new NullReferenceException(nameof(LocalizationConfig));
            }

            translationDatabase = new TranslationDatabase(
                new TranslationRepository(
                    new TranslationStorageProvider()));

            defaultCulture = CultureMap.Get(config.DefaultCulture);
            translations   = new RuntimeTranslationInfoRepository().GetAll();

            if (translations.Length == 0)
            {
                Debug.LogWarning("No cultures found.");
            }

            isInit = true;

            SetDefaultCulture();
        }
Example #2
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();
            }
        }