void CreateRaces() { raceDropdown.ClearOptions(); var newOptions = new List <TMP_Dropdown.OptionData>(); foreach (var id in Library.races.Keys) { var data = new TMP_Dropdown.OptionData(Library.races[id].name); newOptions.Add(data); } raceDropdown.AddOptions(newOptions); raceDropdown.onValueChanged.AddListener((x) => { var raceName = raceDropdown.options[x].text; foreach (var id in Library.races.Keys) { var libRace = Library.races[id]; if (libRace.name == raceName) { var newRuler = Ruler.CreateRuler(); newRuler.name = ruler.name; ruler = newRuler; UpdateDisplay(); return; } } }); }
public void PopulateWithKingdoms(int amount, int maxSize = 1) { kingdoms.Clear(); for (int i = 0; i < amount; i++) { List <Region> territory = new List <Region>(); int size = 1 + KMaths.FloorToInt((1 - KMaths.Clamp01(Math.Abs((float)Game.state.random.NextGaussian()))) * maxSize); Region startingRegion = map.regions[KMaths.FloorToInt(Game.state.random.NextFloat() * map.regions.Count)]; var race = Library.races[Game.state.random.Range(0, Library.races.Count)]; Kingdom kingdom = new Kingdom(i, race.GetRandomKingdomName(), new List <Region>() { startingRegion }, race, Ruler.CreateRuler()); for (int j = 0; j < size; j++) { List <Region> blobCandidates = kingdom.GetNeighborRegions(); blobCandidates.RemoveAll(o => o.IsOwned()); if (blobCandidates.Count <= 0) { break; } kingdom.TakeOwnership(blobCandidates[KMaths.FloorToInt(blobCandidates.Count * Game.state.random.NextFloat())]); } kingdoms.Add(kingdom); } }
// Start is called before the first frame update void Start() { ruler = Ruler.CreateRuler(); stock = ruler.race.rulerCreationRules.stock; CreateCharacteristics(); CreateRaces(); increaseAgeButton.onClick.AddListener(delegate { IncreaseAge(); }); decreaseAgeButton.onClick.AddListener(delegate { DecreaseAge(); }); }