Esempio n. 1
0
        public CultureParser BranchCulture(string Culture)
        {
            var rel = CultureMap[Culture];

            var group = rel.Group;

            var cultureName = rel.dna.GetPlaceName();

            while (GroupMap.ContainsKey(StarNames.SafeName(cultureName)))
            {
                cultureName = rel.dna.GetPlaceName();
            }

            CultureParser rel2 = null;

            if (allowMultiCultureGroups)
            {
                rel2 = group.AddCulture(cultureName);
                rel2.Init();
                rel2.dna = rel.dna.MutateSmall(4);
            }

            else
            {
                // need to make a new group for the culture

                var newGroupName = rel.dna.GetPlaceName();

                while (GroupMap.ContainsKey(StarNames.SafeName(newGroupName)))
                {
                    newGroupName = rel.dna.GetPlaceName();
                }

                LanguageManager.instance.Add(StarNames.SafeName(newGroupName), newGroupName);

                var newCultureGroup = AddCultureGroup(StarNames.SafeName(newGroupName), group);

                newCultureGroup.Name = StarNames.SafeName(newGroupName);
                rel2 = newCultureGroup.AddCulture(cultureName);
                newCultureGroup.AddCulture(rel2);

                rel2.Init();
                rel2.dna = rel.dna.Mutate(16, rel);
                rel2.dna.DoRandom();

                CultureGroupMap[newCultureGroup.Name] = newCultureGroup;
            }

            rel2.DoDetailsForCulture();

            return(rel2);
        }
Esempio n. 2
0
        public CultureParser BranchCulture(string Culture)
        {
            var rel   = this.CultureMap[Culture];
            var group = rel.Group;

            var naa = rel.dna.GetPlaceName();

            while (GroupMap.ContainsKey(StarNames.SafeName(naa)))
            {
                naa = rel.dna.GetPlaceName();
            }

            CultureParser rel2 = null;

            if (!allowMultiCultureGroups)
            {
                var na = rel.dna.GetPlaceName();
                while (GroupMap.ContainsKey(StarNames.SafeName(na)))
                {
                    na = rel.dna.GetPlaceName();
                }

                LanguageManager.instance.Add(StarNames.SafeName(na), na);

                var group2 = AddCultureGroup(StarNames.SafeName(na), group);
                group2.Name = StarNames.SafeName(na);
                rel2        = group2.AddCulture(naa);
                group2.AddCulture(rel2);

                rel2.Init();
                rel2.dna = rel.dna.Mutate(16, rel);
                rel2.dna.DoRandom();
                CultureGroupMap[group2.Name] = group2;
            }
            else
            {
                rel2 = group.AddCulture(naa);
                rel2.Init();
                rel2.dna = rel.dna.MutateSmall(4);
            }

            rel2.DoDetailsForCulture();

            return(rel2);
        }
Esempio n. 3
0
        private void DoRandomChange()
        {
            switch (Rand.Next(4))
            {
            case 0:
                // replace 1/3 of the Start words and replace with random dna culture....
            {
                int count = CommonStartNames.Count / 2;
                WordFormats.Clear();
                ReplaceStartNames(count);
                {
                    wordsForLand.Clear();
                    int c      = wordsForLand.Count / 2;
                    int create = 3;

                    for (int n = 0; n < create; n++)
                    {
                        String a = "";
                        a = ConstructWord(2 * wordLengthBias, 4 * wordLengthBias);

                        if (!wordsForLand.Contains(a))
                        {
                            wordsForLand.Add(a);
                            continue;
                        }
                    }
                }
            }
            break;

            case 1:
            {
                int count = CommonEndNames.Count / 2;
                ReplaceEndNames(count);
                WordFormats.Clear();
                {
                    wordsForLand.Clear();
                    int c      = wordsForLand.Count / 2;
                    int create = 3;

                    for (int n = 0; n < create; n++)
                    {
                        String a = "";
                        a = ConstructWord(2 * wordLengthBias, 4 * wordLengthBias);

                        if (!wordsForLand.Contains(a))
                        {
                            wordsForLand.Add(a);
                            continue;
                        }
                    }
                }
            }
            break;

            case 2:

                // replace 1/3 of the words for land
            {
                WordFormats.Clear();
                if (portraitPool.Count == 0)
                {
                    return;
                }

                int x = Rand.Next(portraitPool.Count);

                var por = portraitPool[x];
                portraitPool.RemoveAt(x);
                portraitPool.Add(culture.GetRelatedCultureGfx(por));

                if (Rand.Next(6) == 0)
                {
                    if (portraitPool.Count == 1)
                    {
                        portraitPool.Add(culture.GetRelatedCultureGfx(por));
                    }
                    else if (portraitPool.Count == 2)
                    {
                        portraitPool.RemoveAt(Rand.Next(2));
                    }
                }

                if (Rand.Next(6) == 0)
                {
                    portraitPool.RemoveAt(0);
                    portraitPool.Add(CultureParser.GetRandomCultureGraphics());
                }
            }

            break;

            case 3:

                //   for(int n=0;n<3;n++)
            {
                // switch (Rand.Next(6))
                {
                    //    case 0:
                    empTitle = ConstructWord(2, 5);
                    empTitle = LanguageManager.instance.AddSafe(empTitle);

                    //       break;
                    //    case 1:
                    kingTitle = ConstructWord(2, 5);
                    kingTitle = LanguageManager.instance.AddSafe(kingTitle);

                    //      break;
                    //  case 2:
                    dukeTitle = ConstructWord(2, 5);
                    dukeTitle = LanguageManager.instance.AddSafe(dukeTitle);

                    //       break;
                    //   case 3:
                    countTitle = ConstructWord(2, 5);
                    countTitle = LanguageManager.instance.AddSafe(countTitle);

                    //     break;
                    //    case 4:
                    baronTitle = ConstructWord(2, 5);
                    baronTitle = LanguageManager.instance.AddSafe(baronTitle);

                    //        break;
                    //    case 5:
                    mayorTitle = ConstructWord(2, 5);
                    mayorTitle = LanguageManager.instance.AddSafe(mayorTitle);

                    //       break;
                }
            }

            break;
            }

            if (culture != null)
            {
                culture.DoDetailsForCulture();
            }
        }