private void AddFactionCultures() { foreach (Faction faction in Polity.GetFactions()) { Profiler.BeginSample("AddFactionCulture"); AddFactionCulture(faction); Profiler.EndSample(); } FinalizeUpdateFromFactions(); }
private void SetFactionButtons() { ChosenFaction = null; Territory selectedTerritory = Manager.CurrentWorld.SelectedTerritory; Polity polity = null; if ((polity == null) && (Manager.CurrentWorld.SelectedTerritory != null) && (Manager.CurrentWorld.SelectedTerritory.Polity.StillPresent)) { polity = selectedTerritory.Polity; } if (polity == null) { throw new System.Exception("SetFactionButtons: Both focused polity and selected polity are null..."); } _factionButtons.Add(FactionButtonPrefab); List <Faction> factions = new List <Faction>(polity.GetFactions()); factions.Sort((a, b) => { if (a.Influence > b.Influence) { return(-1); } if (a.Influence < b.Influence) { return(1); } return(0); }); int i = 0; foreach (Faction faction in factions) { SetFactionButton(faction, i); i++; } }
protected override void GenerateName(Faction parentFaction) { int rngOffset = RngOffsets.CLAN_GENERATE_NAME + unchecked ((int)Polity.Id); if (parentFaction != null) { rngOffset += unchecked ((int)parentFaction.Id); } GetRandomIntDelegate getRandomInt = (int maxValue) => Polity.GetNextLocalRandomInt(rngOffset++, maxValue); GetRandomFloatDelegate getRandomFloat = () => Polity.GetNextLocalRandomFloat(rngOffset++); Language language = Polity.Culture.Language; Region region = CoreGroup.Cell.Region; string untranslatedName = ""; if (region.Elements.Count <= 0) { throw new System.Exception("No elements to choose name from"); } List <string> possibleAdjectives = null; List <Element.Instance> remainingElements = new List <Element.Instance>(region.Elements); bool addMoreWords = true; bool isPrimaryNoun = true; float extraWordChance = 0.2f; List <Element.Instance> usedElements = new List <Element.Instance>(); while (addMoreWords) { addMoreWords = false; bool hasRemainingElements = remainingElements.Count > 0; if ((!hasRemainingElements) && (usedElements.Count <= 0)) { throw new System.Exception("No elements to use for name"); } Element.Instance element = null; if (hasRemainingElements) { element = remainingElements.RandomSelectAndRemove(getRandomInt); usedElements.Add(element); } else { element = usedElements.RandomSelect(getRandomInt); } if (isPrimaryNoun) { untranslatedName = element.SingularName; isPrimaryNoun = false; possibleAdjectives = element.Adjectives; } else { bool first = true; foreach (Element.Instance usedElement in usedElements) { if (first) { untranslatedName = usedElement.SingularName; first = false; } else { untranslatedName = usedElement.SingularName + ":" + untranslatedName; } } } string adjective = possibleAdjectives.RandomSelect(getRandomInt, 2 * usedElements.Count); if (!string.IsNullOrEmpty(adjective)) { untranslatedName = "[adj]" + adjective + " " + untranslatedName; } addMoreWords = extraWordChance > getRandomFloat(); if (!addMoreWords) { foreach (Faction faction in Polity.GetFactions()) { if (Language.ClearConstructCharacters(untranslatedName) == faction.Name.Meaning) { addMoreWords = true; break; } } } extraWordChance /= 2f; } untranslatedName = "[Proper][NP](" + untranslatedName + ")"; Info.Name = new Name(untranslatedName, language, World); // #if DEBUG // Debug.Log ("Clan #" + Id + " name: " + Name); // #endif }
private void AddCellDataToInfoPanel_PolityTerritory(TerrainCell cell) { InfoText.text += "\n"; InfoText.text += "\n -- Polity Territory Data -- "; InfoText.text += "\n"; if (cell.Group == null) { InfoText.text += "\n\tNo population at location"; return; } int population = cell.Group.Population; if (population <= 0) { InfoText.text += "\n\tNo population at location"; return; } Territory territory = cell.EncompassingTerritory; if (territory == null) { InfoText.text += "\n\tGroup not part of a polity's territory"; return; } Polity polity = territory.Polity; PolityProminence pi = cell.Group.GetPolityProminence(polity); InfoText.text += "\nTerritory of the " + polity.Name.Text + " " + polity.Type.ToLower(); InfoText.text += "\nTranslates to: " + polity.Name.Meaning; InfoText.text += "\nFormation Date: " + Manager.GetDateString(polity.FormationDate); InfoText.text += "\n"; int totalPopulation = (int)Mathf.Floor(polity.TotalPopulation); InfoText.text += "\n\tPolity population: " + totalPopulation; InfoText.text += "\n"; float administrativeCost = polity.TotalAdministrativeCost; InfoText.text += "\n\tAdministrative Cost: " + administrativeCost; Agent leader = polity.CurrentLeader; InfoText.text += "\nLeader: " + leader.Name.Text; InfoText.text += "\nTranslates to: " + leader.Name.Meaning; InfoText.text += "\nBirth Date: " + Manager.GetDateString(leader.BirthDate); InfoText.text += "\nGender: " + ((leader.IsFemale) ? "Female" : "Male"); InfoText.text += "\nCharisma: " + leader.Charisma; InfoText.text += "\nWisdom: " + leader.Wisdom; InfoText.text += "\n"; InfoText.text += "\n"; InfoText.text += "\n -- Polity Factions -- "; InfoText.text += "\n"; List <Faction> factions = new List <Faction>(polity.GetFactions()); factions.Sort((a, b) => { if (a.Influence > b.Influence) { return(-1); } if (a.Influence < b.Influence) { return(1); } return(0); }); foreach (Faction faction in factions) { InfoText.text += "\n\t" + faction.Type + " " + faction.Name; InfoText.text += "\n\t\tCore: " + faction.CoreGroup.Position; InfoText.text += "\n\t\tFormation Date: " + Manager.GetDateString(faction.FormationDate); InfoText.text += "\n\t\tInfluence: " + faction.Influence.ToString("P"); Agent factionLeader = faction.CurrentLeader; InfoText.text += "\n\t\tLeader: " + factionLeader.Name.Text; InfoText.text += "\n\t\tTranslates to: " + factionLeader.Name.Meaning; InfoText.text += "\n\t\tBirth Date: " + Manager.GetDateString(factionLeader.BirthDate); InfoText.text += "\n\t\tGender: " + ((factionLeader.IsFemale) ? "Female" : "Male"); InfoText.text += "\n\t\tCharisma: " + factionLeader.Charisma; InfoText.text += "\n\t\tWisdom: " + factionLeader.Wisdom; InfoText.text += "\n"; } InfoText.text += "\n"; InfoText.text += "\n -- Selected Group's Polity Data -- "; InfoText.text += "\n"; float percentageOfPopulation = cell.Group.GetPolityProminenceValue(polity); int prominencedPopulation = (int)Mathf.Floor(population * percentageOfPopulation); float percentageOfPolity = 1; if (totalPopulation > 0) { percentageOfPolity = prominencedPopulation / (float)totalPopulation; } InfoText.text += "\n\tProminenced population: " + prominencedPopulation; InfoText.text += "\n\tPercentage of polity population: " + percentageOfPolity.ToString("P"); InfoText.text += "\n\tDistance to polity core: " + pi.PolityCoreDistance.ToString("0.000"); InfoText.text += "\n\tDistance to faction core: " + pi.FactionCoreDistance.ToString("0.000"); }