public static void join(PopUnit pop) { if (pop.getMovement() == null) { var goal = pop.getMostImportantIssue(); if (!goal.Equals(default(KeyValuePair <AbstractReform, AbstractReformValue>))) { //find reasonable goal and join var found = pop.Country.movements.Find(x => x.getGoal() == goal.Value); if (found == null) { pop.setMovement(new Movement(goal.Key, goal.Value, pop, pop.Country)); } else { found.add(pop); pop.setMovement(found); } } } else // change movement if (Game.Random.Next(Options.PopChangeMovementRate) == 1) { leave(pop); join(pop); } }
public override Procent howIsItGoodForPop(PopUnit pop) { Procent result; //positive - higher subsidies int change = GetRelativeConservatism(pop.Country.UBI.typedValue); if (pop.Type.isPoorStrata(pop)) { if (change > 0) { result = new Procent(1f); } else { result = new Procent(0f); } } else { if (change > 0) { result = new Procent(0f); } else { result = new Procent(1f); } } return(result); }
public override Procent howIsItGoodForPop(PopUnit pop) { Procent result; if (pop.Type == PopType.Workers) { //positive - reform will be better for worker, [-5..+5] int change = GetRelativeConservatism(pop.Country.FamilyPlanning.typedValue); // ID - pop.Country.minimalWage.value.ID; //result = new Procent((change + PossibleStatuses.Count - 1) * 0.1f); if (change > 0) { if (this == OneKid) { result = new Procent(0f); } else { result = new Procent(0.6f); } } else { //result = new Procent((change + PossibleStatuses.Count - 1) * 0.1f /2f); result = new Procent(0f); } } else // rich strata { result = new Procent(0f); } return(result); }
//public override bool isAvailable(Country country) //{ // SerfValue requested = this; // if ((requested.ID == 4) && country.Science.IsInvented(Invention.Collectivism) && (country.serfdom.status.ID == 0 || country.serfdom.status.ID == 1 || country.serfdom.status.ID == 4)) // return true; // else // if ((requested.ID == 3) && country.Science.IsInvented(Invention.Banking) && (country.serfdom.status.ID == 0 || country.serfdom.status.ID == 1 || country.serfdom.status.ID == 3)) // return true; // else // if ((requested.ID == 2) && (country.serfdom.status.ID == 0 || country.serfdom.status.ID == 1 || country.serfdom.status.ID == 2)) // return true; // else // if ((requested.ID == 1) && (country.serfdom.status.ID == 0 || country.serfdom.status.ID == 1)) // return true; // else // if ((requested.ID == 0)) // return true; // else // return false; //} //public Procent getTax() //{ // if (this == Brutal) // return brutalTax; // else // if (this == SerfdomAllowed) // return allowedTax; // else // return nullTax; //} public override Procent howIsItGoodForPop(PopUnit pop) { Procent result; int change = GetRelativeConservatism(pop.Country.serfdom.typedValue); //positive - more liberal if (pop.Type == PopType.Aristocrats) { if (change > 0) { result = new Procent(0f); } else { result = new Procent(1f); } } else { if (change > 0) { result = new Procent(1f); } else { result = new Procent(0f); } } return(result); }
//public override bool isAvailable(Country country) //{ // MinPOlValue requested = this; // if ((requested.ID == 4) && country.Science.IsInvented(Invention.Collectivism) && (country.serfdom == Serfdom.Brutal || country.serfdom == Serfdom.Allowed || country.serfdom == Serfdom.AbolishedAndNationalized)) // return true; // else // if ((requested.ID == 3) && country.Science.IsInvented(Invention.Banking) && (country.serfdom == Serfdom.Brutal || country.serfdom == Serfdom.Allowed || country.serfdom == Serfdom.AbolishedWithLandPayment)) // return true; // else // if ((requested.ID == 2) && (country.serfdom == Serfdom.Brutal || country.serfdom == Serfdom.Allowed || country.serfdom == Serfdom.Abolished)) // return true; // else // if ((requested.ID == 1) && (country.serfdom == Serfdom.Brutal || country.serfdom == Serfdom.Allowed)) // return true; // else // if ((requested.ID == 0)) // return true; // else // return false; //} public override Procent howIsItGoodForPop(PopUnit pop) { Procent result; if (pop.isStateCulture()) { result = new Procent(0f);//0.5f); } else { //positive - more rights for minorities int change = GetRelativeConservatism(pop.Country.minorityPolicy.typedValue); //result = new Procent((change + PossibleStatuses.Count - 1) * 0.1f); if (change > 0) { result = new Procent(0.3f);// 1f); } else { //result = new Procent((change + PossibleStatuses.Count - 1) * 0.1f /2f); result = new Procent(0f); } } return(result); }
protected CattleGetter(PopUnit source, int sizeOfNewPop, PopType newPopType, Province where, Culture culture, IWayOfLifeChange oldLife) : base(source, sizeOfNewPop, newPopType, where, culture, oldLife) { //storage = new Storage(Product.Cattle); //gainGoodsThisTurn = new Storage(Product.Cattle); //sentToMarket = new Storage(Product.Cattle); changeProductionType(Product.Cattle); }
internal void initialize(PopUnit origin, int size) { this.origin = origin; this.size = size; this.morale.Set(0f); consumption.setZero(); }
public override Procent howIsItGoodForPop(PopUnit pop) { Procent result; if (pop.getVotingPower(this) > pop.getVotingPower(pop.Country.government.typedValue)) { //if (this == Tribal) // result = new Procent(0.8f); //else result = new Procent(1f); } else if (this == ProletarianDictatorship) { result = new Procent(0.5f); } else if (this == Despotism && pop.needsFulfilled.get() < 0.1f) { result = new Procent(1f); } else if (this == Tribal) { result = new Procent(0.3f); } else { result = new Procent(0f); } return(result); }
public static void join(PopUnit pop) { if (pop.getMovement() == null) { var goal = pop.getMostImportantIssue();// getIssues().MaxByRandom(x => x.Value); //todo if it's null it should throw exception early //if (!goal.Equals(default(KeyValuePair<AbstractReform, IReformValue>))) //if (!ReferenceEquals(goal, null)) { //find reasonable goal and join var found = pop.Country.Politics.AllMovements.FirstOrDefault(x => x.getGoal() == goal.Value); if (found == null) { pop.setMovement(new Movement(goal.Key, goal.Value, pop, pop.Country)); } else { found.add(pop); pop.setMovement(found); } } } else // change movement if (Rand.Get.Next(Options.PopChangeMovementRate) == 1) { leave(pop); join(pop); } }
//private Movement(PopUnit firstPop, Country place) : base(place) //{ // members.Add(firstPop); // Country.movements.Add(this); //} private Movement(AbstractReform reform, AbstractReformValue goal, PopUnit firstPop, Country place) : base(place)// : this(firstPop, place) { members.Add(firstPop); Country.movements.Add(this); targetReform = reform; targetReformValue = goal; Flag = Nashet.Flag.Rebels; }
//public Corps(Corps corps):this(corps.getPopUnit(), corps.getSize()) //{ //} internal void deleteData() { size = 0; origin = null; morale.Set(0); consumption.setZero(); //here - delete all links on that object }
//private Movement(PopUnit firstPop, Country place) : base(place) //{ // members.Add(firstPop); // Country.movements.Add(this); //} private Movement(AbstractReform reform, IReformValue goal, PopUnit firstPop, Country place) : base(place)// : this(firstPop, place) { members.Add(firstPop); Country.Politics.RegisterMovement(this); targetReformType = reform; targetReformValue = goal; Flag = Nashet.Flag.Rebels; }
public static void CreateRandomPopulation() { foreach (Province province in allLandProvinces) { if (province.Country == UncolonizedLand) { //1500-2000 //new Tribesmen(PopUnit.getRandomPopulationAmount(300, 400), province.Country.Culture, province); //new Aristocrats(PopUnit.getRandomPopulationAmount(300, 400), province.Country.Culture, province); new Tribesmen(PopUnit.getRandomPopulationAmount(1500, 2000), province.Country.Culture, province); //new Tribesmen(PopUnit.getRandomPopulationAmount(2000, 2500), province.Country.Culture, province); } else { PopUnit pop; //if (Game.devMode) // pop = new Tribesmen(2000, province.Country.Culture, province); //else //new Tribesmen(PopUnit.getRandomPopulationAmount(11000, 12000), province.Country.Culture, province); //new Tribesmen(PopUnit.getRandomPopulationAmount(3100, 3200), province.Country.Culture, province); new Tribesmen(PopUnit.getRandomPopulationAmount(200, 300), province.Country.Culture, province); //if (Game.devMode) // pop = new Aristocrats(1000, province.Country.Culture, province); //else pop = new Aristocrats(PopUnit.getRandomPopulationAmount(500, 1000), province.Country.Culture, province); pop.GiveMoneyFromNoWhere(900m); pop.storage.add(new Storage(Product.Grain, 60f)); //if (!Game.devMode) //{ //pop = new Capitalists(PopUnit.getRandomPopulationAmount(500, 800), Country.Culture, province); //pop.Cash.set(9000); pop = new Artisans(PopUnit.getRandomPopulationAmount(400, 500), province.Country.Culture, province); pop.GiveMoneyFromNoWhere(900m); pop = new Farmers(PopUnit.getRandomPopulationAmount(8200, 9000), province.Country.Culture, province); pop.GiveMoneyFromNoWhere(20m); if (Game.IndustrialStart) { new Workers(PopUnit.getRandomPopulationAmount(4500, 5000), province.Country.Culture, province); pop = new Capitalists(PopUnit.getRandomPopulationAmount(500, 800), province.Country.Culture, province); pop.GiveMoneyFromNoWhere(9000); } else { new Workers(PopUnit.getRandomPopulationAmount(500, 800), province.Country.Culture, province); } //} //province.allPopUnits.Add(new Workers(600, PopType.workers, Game.player.culture, province)); //break; } } }
internal int HowManyEmployed(PopUnit pop) { int result = 0; //foreach (var link in hiredWorkForce) // if (link.Key == pop) // result += link.Value; hiredWorkForce.TryGetValue(pop, out result); return(result); }
///<summary> Similar by popType & culture</summary> public PopUnit getSimilarPopUnit(PopUnit target) { foreach (PopUnit pop in allPopUnits) { if (pop.popType == target.popType && pop.culture == target.culture && pop.isAlive()) { return(pop); } } return(null); }
public string getWayOfLifeString(PopUnit pop) { if (pop.Country == Country) { return("migrated"); } else { return("immigrated"); } }
public void RegisterPop(PopUnit pop) { if (AllPops.Any(x => x.Type == pop.Type && x.culture == pop.culture)) //temporally { throw new Exception("Can't have 2 same popunits"); } else { allPopUnits.Add(pop); } }
protected void AddButton(string text, PopUnit record) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); //newButton.transform.SetParent(contentPanel); //newButton.transform.localScale = Vector3.one; SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(text, this, record); }
///<summary> Simular by popType & culture</summary> public PopUnit FindSimularPopUnit(PopUnit target) { //PopUnit result = null; foreach (PopUnit pop in allPopUnits) { if (pop.type == target.type && pop.culture == target.culture) { return(pop); } } return(null); }
public static Corps mobilize(Staff staff, PopUnit origin) { int howMuch = origin.mobilize(staff); if (howMuch > 0) { return(CorpsPool.GetObject(origin, howMuch)); } else { return(null); } }
internal int howManyEmployed(PopUnit pop) { int result = 0; foreach (var link in hiredWorkForce) { if (link.Key == pop) { result += link.Value; } } return(result); }
internal uint HowManyEmployed(PopUnit pop) { uint result = 0; foreach (PopLinkage link in workForce) { if (link.pop == pop) { result += link.amount; } } return(result); }
protected float loyaltyBoostFor(PopUnit popUnit) { float result; if (howIsItGoodForPop(popUnit).get() > 0.5f) { result = popUnit.loyalty.get() / 4f; } else { result = popUnit.loyalty.get50Centre() / 4f; } return(result); }
protected void AddButton(string text, PopUnit record, Func <string> dynamicTooltip) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); //newButton.transform.SetParent(contentPanel); //newButton.transform.localScale = Vector3.one; SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(text, this, record); newButton.GetComponentInChildren <ToolTipHandler>().dynamicString = dynamicTooltip; newButton.GetComponentInChildren <ToolTipHandler>().tip = MainTooltip.thatObj; }
public static void leave(PopUnit pop) { if (pop.getMovement() != null) { pop.getMovement().demobilize(x => x.getPopUnit() == pop); pop.getMovement().members.Remove(pop); if (pop.getMovement().members.Count == 0) { pop.getMovement().demobilize(); pop.Country.movements.Remove(pop.getMovement()); } pop.setMovement(null); } }
/// <summary> /// Adjusted to use in modifiers /// </summary> internal float getOverpopulationAdjusted(PopUnit pop) { if (pop.popType == PopType.Tribesmen || pop.popType == PopType.Farmers) { float res = getOverpopulation(); res -= 1f; if (res <= 0f) { res = 0f; } return(res); } else { return(0f); } }
static void сreateRandomPopulation() { foreach (Province province in Province.allProvinces) { if (province.GetCountry() == Country.NullCountry) { Tribesmen f = new Tribesmen(PopUnit.getRandomPopulationAmount(500, 1000), province.GetCountry().getCulture(), province); } else { PopUnit pop; //if (Game.devMode) // pop = new Tribesmen(2000, province.getCountry().getCulture(), province); //else pop = new Tribesmen(PopUnit.getRandomPopulationAmount(1800, 2000), province.GetCountry().getCulture(), province); if (province.GetCountry() == Game.Player) { //pop = new Tribesmen(20900, PopType.tribeMen, province.getOwner().culture, province); //province.allPopUnits.Add(pop); } //if (Game.devMode) // pop = new Aristocrats(1000, province.getCountry().getCulture(), province); //else pop = new Aristocrats(PopUnit.getRandomPopulationAmount(800, 1000), province.GetCountry().getCulture(), province); pop.cash.set(9000); pop.storage.add(new Storage(Product.Grain, 60f)); //if (!Game.devMode) //{ //pop = new Capitalists(PopUnit.getRandomPopulationAmount(500, 800), getCountry().getCulture(), province); //pop.cash.set(9000); pop = new Artisans(PopUnit.getRandomPopulationAmount(500, 800), province.GetCountry().getCulture(), province); pop.cash.set(900); pop = new Farmers(PopUnit.getRandomPopulationAmount(10000, 12000), province.GetCountry().getCulture(), province); pop.cash.set(20); //} //province.allPopUnits.Add(new Workers(600, PopType.workers, Game.player.culture, province)); } } }
public void consolidatePops() { if (allPopUnits.Count > 14) //get some small pop and merge it into bigger { PopUnit popToMerge = getRandomPop((x) => x.getPopulation() < Options.PopSizeConsolidationLimit); //PopUnit popToMerge = getSmallerPop((x) => x.getPopulation() < Options.PopSizeConsolidationLimit); if (popToMerge != null) { PopUnit targetPop = this.getBiggerPop(x => x.isStateCulture() == popToMerge.isStateCulture() && x.popType == popToMerge.popType && x != popToMerge); if (targetPop != null) { targetPop.mergeIn(popToMerge); } } } }
public static Corps GetObject(PopUnit origin, int size) { lock (_available) { if (_available.Count == 0) { Corps po = new Corps(origin, size); _inUse.Add(po); return(po); } else { Corps po = _available[0]; po.initialize(origin, size); _inUse.Add(po); _available.RemoveAt(0); return(po); } } }
public override Procent howIsItGoodForPop(PopUnit pop) { Procent result; //if (pop.Type == PopType.Capitalists) if (pop.Type.isRichStrata(pop)) { //positive - more liberal int relation = GetRelativeConservatism(pop.Country.economy.typedValue); // ID - pop.Country.economy.value.ID; //result = new Procent((change + PossibleStatuses.Count - 1) * 0.1f); if (relation > 0) { result = new Procent(1f + relation / 10f); } else { //result = new Procent((change + PossibleStatuses.Count - 1) * 0.1f /2f); result = new Procent(0f); } } else { if (this == PlannedEconomy) { result = new Procent(0f); // that can be achieved only by government reform } else if (this == LaissezFaire) { result = new Procent(0.6f); } else if (this == Interventionism) { result = new Procent(0.7f); } else { result = new Procent(0.5f); } } return(result); }