public FacilityKind GetFacilityKind(int facilityKindID) { FacilityKind kind = null; this.FacilityKinds.TryGetValue(facilityKindID, out kind); return(kind); }
public bool AddFacilityKind(FacilityKind facilityKind) { if (this.FacilityKinds.ContainsKey(facilityKind.ID)) { return false; } this.FacilityKinds.Add(facilityKind.ID, facilityKind); return true; }
public bool AddFacilityKind(FacilityKind facilityKind) { if (this.FacilityKinds.ContainsKey(facilityKind.ID)) { return(false); } this.FacilityKinds.Add(facilityKind.ID, facilityKind); return(true); }
public void LoadFromString(FacilityKindTable allFacilityKinds, string facilityKindIDs) { char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = facilityKindIDs.Split(separator, StringSplitOptions.RemoveEmptyEntries); FacilityKind kind = null; for (int i = 0; i < strArray.Length; i++) { if (allFacilityKinds.FacilityKinds.TryGetValue(int.Parse(strArray[i]), out kind)) { this.AddFacilityKind(kind); } } }
private void AIExtension() { if (this.BuildingFacility < 0) { foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.GetFacilityKindList().GetRandomList()) { bool isExtension = false; foreach (Influence i in kind.Influences.Influences.Values) { if (i.Kind.ID == 1000 || i.Kind.ID == 1001 || i.Kind.ID == 1002 || i.Kind.ID == 1003 || i.Kind.ID == 1020 || i.Kind.ID == 1050) { isExtension = true; break; } } if (isExtension) { if (this.BuildingFacility >= 0) { continue; } if (!(!kind.PopulationRelated || this.Kind.HasPopulation)) { continue; } if (((kind.PointCost > this.BelongedFaction.TotalTechniquePoint) || (kind.TechnologyNeeded > this.Technology))) { continue; } if (kind.UniqueInArchitecture && this.ArchitectureHasFacilityKind(kind.ID)) { continue; } if (this.FacilityPositionLeft < kind.PositionOccupied) { continue; } if (kind.UniqueInFaction && this.FactionHasFacilityKind(kind.ID)) { continue; } bool conditionSatisfied = true; foreach (Conditions.Condition j in kind.GetConditionList()) { if (!j.CheckCondition(this)) { conditionSatisfied = false; break; } } if (!conditionSatisfied) { continue; } if (kind.FundCost <= this.Fund) { FacilityKind facilityKind = kind; this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost); this.BeginToBuildAFacility(facilityKind); return; } else if ((kind.FundCost - (this.Fund - this.EnoughFund)) / this.ExpectedFund + 1 <= kind.Days / 15) { this.PlanFacilityKind = kind; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } return; } } } } }
public void ResetFaction(Faction faction) { Faction oldFaction = this.BelongedFaction; this.ResetAuto(); this.PlanFacilityKind = null; this.PlanFacilityKindID = -1; if ((faction != null) && base.Scenario.IsPlayer(faction)) { this.AutoHiring = true; this.AutoRewarding = true; } if (this.BelongedFaction != null && this.BelongedFaction != faction) { this.ClearFundPacks(); this.ClearRouteways(); this.ReleaseAllCaptive(); this.PurifyFactionInfluences(); if (this.BelongedSection != null) { this.BelongedSection.RemoveArchitecture(this); } this.DefensiveLegion = null; if (this == this.BelongedFaction.Capital) { Person leader = this.BelongedFaction.Leader; while (this.Persons.Count > 0) { Person person2 = this.Persons[0] as Person; person2.Status = PersonStatus.NoFaction; person2.LocationArchitecture = this; } //this.Persons.Clear(); while (this.MovingPersons.Count > 0) { Person person2 = this.MovingPersons[0] as Person; person2.OutsideTask = OutsideTaskKind.无; person2.TaskDays = 0; person2.Status = PersonStatus.NoFaction; person2.LocationArchitecture = this; person2.TargetArchitecture = null; } //if ((leader.LocationTroop == null) || leader.IsCaptive) { TroopList list = new TroopList(); foreach (Troop troop in this.BelongedFaction.Troops) { list.Add(troop); } foreach (Troop troop in list) { troop.FactionDestroy(); } if (faction != null) { faction.CheckLeaderDeath(leader); } this.BelongedFaction.Destroy(); } this.BelongedFaction.Capital = null; } else { while (this.Persons.Count > 0) { if ((this.Persons[0] as Person).LocationArchitecture != null) { (this.Persons[0] as Person).MoveToArchitecture(this.BelongedFaction.Capital); } } while (this.MovingPersons.Count > 0) { if ((this.MovingPersons[0] as Person).LocationArchitecture != null) { (this.MovingPersons[0] as Person).MoveToArchitecture(this.BelongedFaction.Capital); } } } if (this.BelongedFaction != null) { this.BelongedFaction.RemoveArchitectureMilitaries(this); this.BelongedFaction.RemoveArchitectureKnownData(this); this.BelongedFaction.RemoveArchitecture(this); } if (faction != null) { faction.AddArchitecture(this); this.ApplyFactionInfluences(); faction.AddArchitectureMilitaries(this); } else { this.BelongedFaction = null; } } else if (faction != null) { faction.AddArchitecture(this); this.ApplyFactionInfluences(); faction.AddArchitectureMilitaries(this); } if (faction != null) { //this.jianzhuqizi.qizidezi.Text = faction.ToString().Substring(0, 1); } foreach (Architecture architecture in base.Scenario.Architectures) { architecture.RefreshViewArea(); } foreach (Troop troop in base.Scenario.Troops) { troop.RefreshViewArchitectureRelatedArea(); } foreach (LinkNode i in this.AIAllLinkNodes.Values) { i.A.CheckIsFrontLine(); } this.CheckIsFrontLine(); ExtensionInterface.call("ArchitectureResetFaction", new Object[] { this.Scenario, this, oldFaction }); }
public bool FacilityBuildable(FacilityKind facilityKind) { if (this.BuildingFacility >= 0) { return false; } if (!(!facilityKind.PopulationRelated || this.Kind.HasPopulation)) { return false; } if (((facilityKind.PointCost > this.BelongedFaction.TotalTechniquePoint) || (facilityKind.TechnologyNeeded > this.Technology)) || (facilityKind.FundCost > this.Fund)) { return false; } if (facilityKind.UniqueInArchitecture && this.ArchitectureHasFacilityKind(facilityKind.ID)) { return false; } if (this.FacilityPositionLeft < facilityKind.PositionOccupied) { return false; } if (facilityKind.UniqueInFaction && this.FactionHasFacilityKind(facilityKind.ID)) { return false; } foreach (Conditions.Condition i in facilityKind.GetConditionList()) { if (!i.CheckCondition(this)) { return false; } } return true; }
public void BuildFacility(FacilityKind facilityKind) { Facility facility = new Facility(); facility.ID = base.Scenario.Facilities.GetFreeGameObjectID(); facility.Scenario = base.Scenario; facility.KindID = facilityKind.ID; facility.Endurance = facilityKind.Endurance; this.Facilities.AddFacility(facility); base.Scenario.Facilities.AddFacility(facility); if (this.FacilityEnabled) { facility.Influences.ApplyInfluence(this, Applier.Facility, facility.ID); } if (this.OnFacilityCompleted != null) { this.OnFacilityCompleted(this, facility); } ExtensionInterface.call("BuiltFacility", new Object[] { this.Scenario, this, facilityKind }); }
public void BeginToBuildAFacility(FacilityKind facilityKind) { this.BuildingFacility = facilityKind.ID; this.BuildingDaysLeft = (int)(facilityKind.Days * (1 - this.facilityConstructionTimeRateDecrease)); this.DecreaseFund(facilityKind.FundCost); if (this.BelongedFaction.TechniquePoint < facilityKind.PointCost) { this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost - this.BelongedFaction.TechniquePoint); if (this.BelongedFaction.TechniquePoint < facilityKind.PointCost) { this.BelongedFaction.DepositTechniquePointForTechnique(facilityKind.PointCost - this.BelongedFaction.TechniquePoint); } } this.BelongedFaction.DecreaseTechniquePoint(facilityKind.PointCost); if (this.HasSpy) { this.CreateNewFacilitySpyMessage(facilityKind); } this.PlanFacilityKind = null; this.PlanFacilityKindID = -1; ExtensionInterface.call("StartBuildFacility", new Object[] { this.Scenario, this, facilityKind }); }
private SpyMessage CreateNewFacilitySpyMessage(FacilityKind fk) { SpyMessage message = new SpyMessage(); message.Scenario = base.Scenario; message.ID = message.Scenario.SpyMessages.GetFreeGameObjectID(); message.Kind = SpyMessageKind.NewFacility; message.MessageFaction = this.BelongedFaction; message.MessageArchitecture = this; message.Message1 = this.BelongedFaction.Name; message.Message2 = base.Name; message.Message3 = fk.Name; message.Message4 = base.Scenario.Date.ToDateString(); message.Scenario.SpyMessages.AddMessageWithEvent(message); foreach (SpyPack pack in this.SpyPacks) { int singleWayDays = base.Scenario.GetSingleWayDays(pack.SpyPerson.Position, this.ArchitectureArea); message.AddPersonPack(pack.SpyPerson, singleWayDays); } return message; }
public bool LoadFromDatabase(string connectionString) { int num; Animation animation; OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); OleDbDataReader reader = new OleDbCommand("Select * From TerrainDetail", connection).ExecuteReader(); while (reader.Read()) { TerrainDetail terrainDetail = new TerrainDetail(); terrainDetail.ID = (short)reader["ID"]; terrainDetail.Name = reader["Name"].ToString(); terrainDetail.GraphicLayer = (int)reader["GraphicLayer"]; terrainDetail.ViewThrough = (bool)reader["ViewThrough"]; terrainDetail.RoutewayBuildFundCost = (int)reader["RoutewayBuildFundCost"]; terrainDetail.RoutewayActiveFundCost = (int)reader["RoutewayActiveFundCost"]; terrainDetail.RoutewayBuildWorkCost = (int)reader["RoutewayBuildWorkCost"]; terrainDetail.RoutewayConsumptionRate = (float)reader["RoutewayConsumptionRate"]; terrainDetail.FoodDeposit = (int)reader["FoodDeposit"]; terrainDetail.FoodRegainDays = (int)reader["FoodRegainDays"]; terrainDetail.FoodSpringRate = (float)reader["FoodSpringRate"]; terrainDetail.FoodSummerRate = (float)reader["FoodSummerRate"]; terrainDetail.FoodAutumnRate = (float)reader["FoodAutumnRate"]; terrainDetail.FoodWinterRate = (float)reader["FoodWinterRate"]; terrainDetail.FireDamageRate = (float)reader["FireDamageRate"]; this.AllTerrainDetails.AddTerrainDetail(terrainDetail); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Color", connection).ExecuteReader(); while (reader.Read()) { Color item = new Color(); item.PackedValue = uint.Parse(reader["Code"].ToString()); this.AllColors.Add(item); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From IdealTendencyKind", connection).ExecuteReader(); while (reader.Read()) { IdealTendencyKind t = new IdealTendencyKind(); t.ID = (short)reader["ID"]; t.Name = reader["Name"].ToString(); t.Offset = (short)reader["Offset"]; this.AllIdealTendencyKinds.Add(t); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From CharacterKind", connection).ExecuteReader(); while (reader.Read()) { CharacterKind kind2 = new CharacterKind(); kind2.ID = (short)reader["ID"]; kind2.Name = reader["Name"].ToString(); kind2.IntelligenceRate = (float)reader["IntelligenceRate"]; kind2.ChallengeChance = (short)reader["ChallengeChance"]; kind2.ControversyChance = (short)reader["ControversyChance"]; this.AllCharacterKinds.Add(kind2); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From ArchitectureKind", connection).ExecuteReader(); while (reader.Read()) { ArchitectureKind architectureKind = new ArchitectureKind(); architectureKind.ID = (short)reader["ID"]; architectureKind.Name = reader["Name"].ToString(); architectureKind.AgricultureBase = (short)reader["AgricultureBase"]; architectureKind.AgricultureUnit = (short)reader["AgricultureUnit"]; architectureKind.CommerceBase = (short)reader["CommerceBase"]; architectureKind.CommerceUnit = (short)reader["CommerceUnit"]; architectureKind.TechnologyBase = (short)reader["TechnologyBase"]; architectureKind.TechnologyUnit = (short)reader["TechnologyUnit"]; architectureKind.DominationBase = (short)reader["DominationBase"]; architectureKind.DominationUnit = (short)reader["DominationUnit"]; architectureKind.MoraleBase = (short)reader["MoraleBase"]; architectureKind.MoraleUnit = (short)reader["MoraleUnit"]; architectureKind.EnduranceBase = (short)reader["EnduranceBase"]; architectureKind.EnduranceUnit = (short)reader["EnduranceUnit"]; architectureKind.PopulationBase = (int)reader["PopulationBase"]; architectureKind.PopulationUnit = (int)reader["PopulationUnit"]; architectureKind.PopulationBoundary = (int)reader["PopulationBoundary"]; architectureKind.ViewDistance = (short)reader["ViewDistance"]; architectureKind.ViewDistanceIncrementDivisor = (short)reader["VDIncrementDivisor"]; architectureKind.HasObliqueView = (bool)reader["HasObliqueView"]; architectureKind.HasLongView = (bool)reader["HasLongView"]; architectureKind.HasPopulation = (bool)reader["HasPopulation"]; architectureKind.HasAgriculture = (bool)reader["HasAgriculture"]; architectureKind.HasCommerce = (bool)reader["HasCommerce"]; architectureKind.HasTechnology = (bool)reader["HasTechnology"]; architectureKind.HasDomination = (bool)reader["HasDomination"]; architectureKind.HasMorale = (bool)reader["HasMorale"]; architectureKind.HasEndurance = (bool)reader["HasEndurance"]; architectureKind.HasHarbor = (bool)reader["HasHarbor"]; architectureKind.FacilityPositionUnit = (short)reader["FacilityPositionUnit"]; architectureKind.FundMaxUnit = (int)reader["FundMaxUnit"]; architectureKind.FoodMaxUnit = (int)reader["FoodMaxUnit"]; try { architectureKind.CountToMerit = (bool)reader["CountToMerit"]; } catch (Exception) { architectureKind.CountToMerit = architectureKind.ID == 1 ? true : false; } this.AllArchitectureKinds.AddArchitectureKind(architectureKind); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From SectionAIDetail", connection).ExecuteReader(); while (reader.Read()) { SectionAIDetail sectionAIDetail = new SectionAIDetail(); sectionAIDetail.ID = (short)reader["ID"]; sectionAIDetail.Name = reader["Name"].ToString(); sectionAIDetail.Description = reader["Description"].ToString(); sectionAIDetail.OrientationKind = (SectionOrientationKind)((short)reader["OrientationKind"]); sectionAIDetail.AutoRun = (bool)reader["AutoRun"]; sectionAIDetail.ValueAgriculture = (bool)reader["ValueAgriculture"]; sectionAIDetail.ValueCommerce = (bool)reader["ValueCommerce"]; sectionAIDetail.ValueTechnology = (bool)reader["ValueTechnology"]; sectionAIDetail.ValueDomination = (bool)reader["ValueDomination"]; sectionAIDetail.ValueMorale = (bool)reader["ValueMorale"]; sectionAIDetail.ValueEndurance = (bool)reader["ValueEndurance"]; sectionAIDetail.ValueTraining = (bool)reader["ValueTraining"]; sectionAIDetail.ValueRecruitment = (bool)reader["ValueRecruitment"]; sectionAIDetail.ValueNewMilitary = (bool)reader["ValueNewMilitary"]; sectionAIDetail.ValueOffensiveCampaign = (bool)reader["ValueOffensiveCampaign"]; sectionAIDetail.AllowInvestigateTactics = (bool)reader["AllowInvestigateTactics"]; sectionAIDetail.AllowOffensiveTactics = (bool)reader["AllowOffensiveTactics"]; sectionAIDetail.AllowPersonTactics = (bool)reader["AllowPersonTactics"]; sectionAIDetail.AllowOffensiveCampaign = (bool)reader["AllowOffensiveCampaign"]; sectionAIDetail.AllowFundTransfer = (bool)reader["AllowFundTransfer"]; sectionAIDetail.AllowFoodTransfer = (bool)reader["AllowFoodTransfer"]; sectionAIDetail.AllowMilitaryTransfer = (bool)reader["AllowMilitaryTransfer"]; try { sectionAIDetail.AllowFacilityRemoval = (bool)reader["AllowFacilityRemoval"]; } catch { sectionAIDetail.AllowFacilityRemoval = true; } this.AllSectionAIDetails.AddSectionAIDetail(sectionAIDetail); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From InfluenceKind", connection).ExecuteReader(); while (reader.Read()) { num = (short)reader["ID"]; InfluenceKind ik = InfluenceKindFactory.CreateInfluenceKindByID(num); if (ik != null) { ik.ID = num; ik.Type = (InfluenceType)((short)reader["Type"]); ik.Name = reader["Name"].ToString(); try { ik.Combat = (bool)reader["Combat"]; } catch { ik.Combat = true; } this.AllInfluenceKinds.AddInfluenceKind(ik); } } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Influence", connection).ExecuteReader(); while (reader.Read()) { Influence influence = new Influence(); influence.ID = (short)reader["ID"]; influence.Name = reader["Name"].ToString(); influence.Description = reader["Description"].ToString(); influence.Parameter = reader["Parameter"].ToString(); influence.Parameter2 = reader["Parameter2"].ToString(); influence.Kind = this.AllInfluenceKinds.GetInfluenceKind((short)reader["Kind"]); if (influence.Kind != null) { this.AllInfluences.AddInfluence(influence); } } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From ConditionKind", connection).ExecuteReader(); while (reader.Read()) { num = (short)reader["ID"]; ConditionKind ck = ConditionKindFactory.CreateConditionKindByID(num); if (ck != null) { ck.ID = num; ck.Name = reader["Name"].ToString(); this.AllConditionKinds.AddConditionKind(ck); } } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Condition", connection).ExecuteReader(); while (reader.Read()) { Condition condition = new Condition(); condition.ID = (short)reader["ID"]; condition.Name = reader["Name"].ToString(); condition.Parameter = reader["Parameter"].ToString(); condition.Parameter2 = reader["Parameter2"].ToString(); condition.Kind = this.AllConditionKinds.GetConditionKind((short)reader["Kind"]); this.AllConditions.AddCondition(condition); } connection.Close(); /// connection.Open(); reader = new OleDbCommand("Select * From TroopEventEffectKind", connection).ExecuteReader(); while (reader.Read()) { num = (short)reader["ID"]; EventEffectKind e = EventEffectKindFactory.CreateEventEffectKindByID(num); if (e != null) { e.ID = num; e.Name = reader["Name"].ToString(); this.AllTroopEventEffectKinds.AddEventEffectKind(e); } } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From TroopEventEffect", connection).ExecuteReader(); while (reader.Read()) { GameObjects.TroopDetail.EventEffect.EventEffect effect = new GameObjects.TroopDetail.EventEffect.EventEffect(); effect.ID = (short)reader["ID"]; effect.Name = reader["Name"].ToString(); effect.Parameter = reader["Parameter"].ToString(); effect.Kind = this.AllTroopEventEffectKinds.GetEventEffectKind((short)reader["Kind"]); this.AllTroopEventEffects.AddEventEffect(effect); } connection.Close(); ////////////////////////////////////////////////////////// connection.Open(); reader = new OleDbCommand("Select * From EventEffectKind", connection).ExecuteReader(); while (reader.Read()) { num = (short)reader["ID"]; GameObjects.ArchitectureDetail.EventEffect.EventEffectKind e = GameObjects.ArchitectureDetail.EventEffect.EventEffectKindFactory.CreateEventEffectKindByID(num); if (e != null) { e.ID = num; e.Name = reader["Name"].ToString(); this.AllEventEffectKinds.AddEventEffectKind(e); } } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From EventEffect", connection).ExecuteReader(); while (reader.Read()) { GameObjects.ArchitectureDetail.EventEffect.EventEffect effect = new GameObjects.ArchitectureDetail.EventEffect.EventEffect(); effect.ID = (short)reader["ID"]; effect.Name = reader["Name"].ToString(); effect.Parameter = reader["Parameter"].ToString(); effect.Parameter2 = reader["Parameter2"].ToString(); effect.Kind = this.AllEventEffectKinds.GetEventEffectKind((short)reader["Kind"]); this.AllEventEffects.AddEventEffect(effect); } connection.Close(); ////// connection.Open(); reader = new OleDbCommand("Select * From FacilityKind", connection).ExecuteReader(); while (reader.Read()) { FacilityKind facilityKind = new FacilityKind(); facilityKind.ID = (short)reader["ID"]; facilityKind.Name = reader["Name"].ToString(); try { facilityKind.AILevel = (float)reader["AILevel"]; } catch { facilityKind.AILevel = 1; } facilityKind.PositionOccupied = (int)reader["PositionOccupied"]; facilityKind.TechnologyNeeded = (int)reader["TechnologyNeeded"]; facilityKind.FundCost = (int)reader["FundCost"]; facilityKind.PointCost = (int)reader["PointCost"]; facilityKind.MaintenanceCost = (int)reader["MaintenanceCost"]; facilityKind.Days = (short)reader["Days"]; facilityKind.Endurance = (int)reader["Endurance"]; facilityKind.UniqueInArchitecture = (bool)reader["UniqueInArchitecture"]; facilityKind.UniqueInFaction = (bool)reader["UniqueInFaction"]; facilityKind.PopulationRelated = (bool)reader["PopulationRelated"]; facilityKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); facilityKind.rongna = (short)reader["rongna"]; facilityKind.bukechaichu = (bool)reader["bukechaichu"]; facilityKind.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString()); this.AllFacilityKinds.AddFacilityKind(facilityKind); } connection.Close(); /////////////////////////////////////////////////////////////////////// connection.Open(); reader = new OleDbCommand("Select * From DisasterKind", connection).ExecuteReader(); while (reader.Read()) { zainanzhongleilei zainanzhonglei = new zainanzhongleilei(); zainanzhonglei.ID = (short)reader["ID"]; zainanzhonglei.Name = reader["名称"].ToString(); zainanzhonglei.shijianxiaxian = (short)reader["时间下限"]; zainanzhonglei.shijianshangxian = (short)reader["时间上限"]; zainanzhonglei.renkoushanghai = (short)reader["人口伤害"]; zainanzhonglei.tongzhishanghai = (short)reader["统治伤害"]; zainanzhonglei.naijiushanghai = (short)reader["耐久伤害"]; zainanzhonglei.nongyeshanghai = (short)reader["农业伤害"]; zainanzhonglei.shangyeshanghai = (short)reader["商业伤害"]; zainanzhonglei.jishushanghai = (short)reader["技术伤害"]; zainanzhonglei.minxinshanghai = (short)reader["民心伤害"]; this.suoyouzainanzhonglei.Addzainanzhonglei(zainanzhonglei); } connection.Close(); /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// connection.Open(); reader = new OleDbCommand("Select * From guanjuezhonglei", connection).ExecuteReader(); while (reader.Read()) { guanjuezhongleilei guanjuedezhonglei = new guanjuezhongleilei(); guanjuedezhonglei.ID = (short)reader["ID"]; guanjuedezhonglei.Name = reader["名称"].ToString(); guanjuedezhonglei.shengwangshangxian = (int)reader["声望上限"]; guanjuedezhonglei.xuyaogongxiandu = (int)reader["需要贡献度"]; guanjuedezhonglei.xuyaochengchi = (short)reader["需要城池"]; this.suoyouguanjuezhonglei.Addguanjuedezhonglei(guanjuedezhonglei); } connection.Close(); /////////////////////////////////////////////////////////////////////// connection.Open(); reader = new OleDbCommand("Select * From Technique", connection).ExecuteReader(); while (reader.Read()) { Technique technique = new Technique(); technique.ID = (short)reader["ID"]; technique.Kind = (short)reader["Kind"]; technique.DisplayRow = (short)reader["DisplayRow"]; technique.DisplayCol = (short)reader["DisplayCol"]; technique.Name = reader["Name"].ToString(); technique.Description = reader["Description"].ToString(); technique.PreID = (short)reader["PreID"]; technique.PostID = (short)reader["PostID"]; technique.Reputation = (int)reader["Reputation"]; technique.FundCost = (int)reader["FundCost"]; technique.PointCost = (int)reader["PointCost"]; technique.Days = (short)reader["Days"]; technique.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); this.AllTechniques.AddTechnique(technique); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Skill", connection).ExecuteReader(); while (reader.Read()) { Skill skill = new Skill(); skill.ID = (short)reader["ID"]; skill.DisplayRow = (short)reader["DisplayRow"]; skill.DisplayCol = (short)reader["DisplayCol"]; skill.Kind = (short)reader["Kind"]; skill.Level = (short)reader["Level"]; skill.Combat = (bool)reader["Combat"]; skill.Name = reader["Name"].ToString(); skill.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); skill.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString()); this.AllSkills.AddSkill(skill); } connection.Close(); int titleKindShift = 0; connection.Open(); try { reader = new OleDbCommand("Select * From TitleKind", connection).ExecuteReader(); while (reader.Read()) { TitleKind tk = new TitleKind(); tk.ID = (short)reader["ID"]; tk.Name = reader["KName"].ToString(); tk.Combat = (bool)reader["Combat"]; tk.StudyDay = (short)reader["StudyDay"]; tk.SuccessRate = (short)reader["SuccessRate"]; this.AllTitleKinds.AddTitleKind(tk); } } catch { TitleKind tk = new TitleKind(); tk.ID = 1; tk.Name = "个人称号"; tk.Combat = false; tk.StudyDay = 90; this.AllTitleKinds.AddTitleKind(tk); tk = new TitleKind(); tk.ID = 2; tk.Name = "战斗称号"; tk.Combat = true; tk.StudyDay = 90; this.AllTitleKinds.AddTitleKind(tk); titleKindShift = 1; } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Title", connection).ExecuteReader(); while (reader.Read()) { Title title = new Title(); title.ID = (short)reader["ID"]; title.Kind = this.AllTitleKinds.GetTitleKind((short)reader["Kind"] + titleKindShift); title.Level = (short)reader["Level"]; title.Combat = (bool)reader["Combat"]; title.Name = reader["Name"].ToString(); title.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); title.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString()); this.AllTitles.AddTitle(title); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader(); while (reader.Read()) { MilitaryKind militaryKind = new MilitaryKind(); militaryKind.ID = (short)reader["ID"]; militaryKind.Type = (MilitaryType)((short)reader["Type"]); militaryKind.Name = reader["Name"].ToString(); militaryKind.Description = reader["Description"].ToString(); militaryKind.Merit = (short)reader["Merit"]; militaryKind.Speed = (short)reader["Speed"]; militaryKind.TitleInfluence = (short)reader["TitleInfluence"]; militaryKind.CreateCost = (int)reader["CreateCost"]; militaryKind.CreateTechnology = (int)reader["CreateTechnology"]; militaryKind.IsShell = (bool)reader["IsShell"]; militaryKind.CreateBesideWater = (bool)reader["CreateBesideWater"]; militaryKind.Offence = (short)reader["Offence"]; militaryKind.Defence = (short)reader["Defence"]; militaryKind.OffenceRadius = (short)reader["OffenceRadius"]; militaryKind.CounterOffence = (bool)reader["CounterOffence"]; militaryKind.BeCountered = (bool)reader["BeCountered"]; militaryKind.ObliqueOffence = (bool)reader["ObliqueOffence"]; militaryKind.ArrowOffence = (bool)reader["ArrowOffence"]; militaryKind.AirOffence = (bool)reader["AirOffence"]; militaryKind.ContactOffence = (bool)reader["ContactOffence"]; militaryKind.OffenceOnlyBeforeMove = (bool)reader["OffenceOnlyBeforeMove"]; militaryKind.ArchitectureDamageRate = (float)reader["ArchitectureDamageRate"]; militaryKind.ArchitectureCounterDamageRate = (float)reader["ArchitectureCounterDamageRate"]; militaryKind.StratagemRadius = (short)reader["StratagemRadius"]; militaryKind.ObliqueStratagem = (bool)reader["ObliqueStratagem"]; militaryKind.ViewRadius = (short)reader["ViewRadius"]; militaryKind.ObliqueView = (bool)reader["ObliqueView"]; militaryKind.Movability = (short)reader["Movability"]; militaryKind.OneAdaptabilityKind = (short)reader["OneAdaptabilityKind"]; militaryKind.PlainAdaptability = (short)reader["PlainAdaptability"]; militaryKind.GrasslandAdaptability = (short)reader["GrasslandAdaptability"]; militaryKind.ForrestAdaptability = (short)reader["ForrestAdaptability"]; militaryKind.MarshAdaptability = (short)reader["MarshAdaptability"]; militaryKind.MountainAdaptability = (short)reader["MountainAdaptability"]; militaryKind.WaterAdaptability = (short)reader["WaterAdaptability"]; militaryKind.RidgeAdaptability = (short)reader["RidgeAdaptability"]; militaryKind.WastelandAdaptability = (short)reader["WastelandAdaptability"]; militaryKind.DesertAdaptability = (short)reader["DesertAdaptability"]; militaryKind.CliffAdaptability = (short)reader["CliffAdaptability"]; militaryKind.PlainRate = (float)reader["PlainRate"]; militaryKind.GrasslandRate = (float)reader["GrasslandRate"]; militaryKind.ForrestRate = (float)reader["ForrestRate"]; militaryKind.MarshRate = (float)reader["MarshRate"]; militaryKind.MountainRate = (float)reader["MountainRate"]; militaryKind.WaterRate = (float)reader["WaterRate"]; militaryKind.RidgeRate = (float)reader["RidgeRate"]; militaryKind.WastelandRate = (float)reader["WastelandRate"]; militaryKind.DesertRate = (float)reader["DesertRate"]; militaryKind.CliffRate = (float)reader["CliffRate"]; militaryKind.InjuryChance = (short)reader["InjuryRate"]; try { militaryKind.FireDamageRate = (float)reader["FireDamageRate"]; militaryKind.RecruitLimit = (int)reader["RecruitLimit"]; } catch { try { militaryKind.FireDamageRate = (bool)reader["AfraidOfFire"] ? 3.0f : 1.0f; militaryKind.RecruitLimit = (bool)reader["Unique"] ? 1 : 1000; } catch { militaryKind.FireDamageRate = 1.0f; militaryKind.RecruitLimit = 10000; } } militaryKind.FoodPerSoldier = (short)reader["FoodPerSoldier"]; militaryKind.RationDays = (int)reader["RationDays"]; militaryKind.PointsPerSoldier = (int)reader["PointsPerSoldier"]; militaryKind.MinScale = (int)reader["MinScale"]; militaryKind.MaxScale = (int)reader["MaxScale"]; militaryKind.OffencePerScale = (short)reader["OffencePerScale"]; militaryKind.DefencePerScale = (short)reader["DefencePerScale"]; militaryKind.CanLevelUp = (bool)reader["CanLevelUp"]; militaryKind.LevelUpKindID = (short)reader["LevelUpKindID"]; militaryKind.LevelUpExperience = (int)reader["LevelUpExperience"]; militaryKind.OffencePer100Experience = (short)reader["OffencePer100Experience"]; militaryKind.DefencePer100Experience = (short)reader["DefencePer100Experience"]; militaryKind.AttackDefaultKind = (TroopAttackDefaultKind)((short)reader["AttackDefaultKind"]); militaryKind.AttackTargetKind = (TroopAttackTargetKind)((short)reader["AttackTargetKind"]); militaryKind.CastDefaultKind = (TroopCastDefaultKind)((short)reader["CastDefaultKind"]); militaryKind.CastTargetKind = (TroopCastTargetKind)((short)reader["CastTargetKind"]); militaryKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); militaryKind.zijinshangxian = (int)reader["zijinshangxian"]; this.AllMilitaryKinds.AddMilitaryKind(militaryKind); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader(); while (reader.Read()) { MilitaryKind current = this.AllMilitaryKinds.GetMilitaryKindList().GetGameObject((short)reader["ID"]) as MilitaryKind; current.successor = new MilitaryKindTable(); current.successor.LoadFromString(this.AllMilitaryKinds, reader["Successor"].ToString()); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From InformationKind", connection).ExecuteReader(); while (reader.Read()) { InformationKind kind9 = new InformationKind(); kind9.ID = (short)reader["ID"]; kind9.Level = (InformationLevel)((short)reader["iLevel"]); kind9.Oblique = (bool)reader["Oblique"]; kind9.Radius = (short)reader["Radius"]; kind9.CostFund = (int)reader["CostFund"]; this.AllInformationKinds.Add(kind9); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From AttackDefaultKind", connection).ExecuteReader(); while (reader.Read()) { AttackDefaultKind kind10 = new AttackDefaultKind(); kind10.ID = (short)reader["ID"]; kind10.Name = reader["Name"].ToString(); this.AllAttackDefaultKinds.Add(kind10); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From AttackTargetKind", connection).ExecuteReader(); while (reader.Read()) { AttackTargetKind kind11 = new AttackTargetKind(); kind11.ID = (short)reader["ID"]; kind11.Name = reader["Name"].ToString(); this.AllAttackTargetKinds.Add(kind11); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From CombatMethod", connection).ExecuteReader(); while (reader.Read()) { CombatMethod combatMethod = new CombatMethod(); combatMethod.ID = (short)reader["ID"]; combatMethod.Name = reader["Name"].ToString(); combatMethod.Description = reader["Description"].ToString(); combatMethod.Combativity = (short)reader["Combativity"]; combatMethod.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); combatMethod.AttackDefault = this.AllAttackDefaultKinds.GetGameObject((short)reader["AttackDefault"]) as AttackDefaultKind; combatMethod.AttackTarget = this.AllAttackTargetKinds.GetGameObject((short)reader["AttackTarget"]) as AttackTargetKind; combatMethod.ArchitectureTarget = (bool)reader["ArchitectureTarget"]; combatMethod.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString()); combatMethod.ViewingHostile = (bool)reader["ViewingHostile"]; combatMethod.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]); this.AllCombatMethods.AddCombatMethod(combatMethod); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Stunt", connection).ExecuteReader(); while (reader.Read()) { Stunt stunt = new Stunt(); stunt.ID = (short)reader["ID"]; stunt.Name = reader["Name"].ToString(); stunt.Combativity = (short)reader["Combativity"]; stunt.Period = (short)reader["Period"]; stunt.Animation = (short)reader["Animation"]; stunt.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); stunt.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString()); stunt.LearnConditions.LoadFromString(this.AllConditions, reader["LearnConditions"].ToString()); stunt.AIConditions.LoadFromString(this.AllConditions, reader["AIConditions"].ToString()); this.AllStunts.AddStunt(stunt); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From CastDefaultKind", connection).ExecuteReader(); while (reader.Read()) { CastDefaultKind kind12 = new CastDefaultKind(); kind12.ID = (short)reader["ID"]; kind12.Name = reader["Name"].ToString(); this.AllCastDefaultKinds.Add(kind12); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From CastTargetKind", connection).ExecuteReader(); while (reader.Read()) { CastTargetKind kind13 = new CastTargetKind(); kind13.ID = (short)reader["ID"]; kind13.Name = reader["Name"].ToString(); this.AllCastTargetKinds.Add(kind13); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Stratagem", connection).ExecuteReader(); while (reader.Read()) { Stratagem stratagem = new Stratagem(); stratagem.ID = (short)reader["ID"]; stratagem.Name = reader["Name"].ToString(); stratagem.Description = reader["Description"].ToString(); stratagem.Combativity = (short)reader["Combativity"]; stratagem.Chance = (short)reader["Chance"]; stratagem.TechniquePoint = (int)reader["TechniquePoint"]; stratagem.Friendly = (bool)reader["Friendly"]; stratagem.Self = (bool)reader["Self"]; stratagem.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]); stratagem.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); stratagem.CastDefault = this.AllCastDefaultKinds.GetGameObject((short)reader["CastDefault"]) as CastDefaultKind; stratagem.CastTarget = this.AllCastTargetKinds.GetGameObject((short)reader["CastTarget"]) as CastTargetKind; stratagem.ArchitectureTarget = (bool)reader["ArchitectureTarget"]; stratagem.RequireInfluenceToUse = (bool)reader["RequireInfluneceToUse"]; this.AllStratagems.AddStratagem(stratagem); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From TroopAnimation", connection).ExecuteReader(); while (reader.Read()) { animation = new Animation(); animation.ID = (short)reader["ID"]; animation.Name = reader["Name"].ToString(); animation.FrameCount = (short)reader["FrameCount"]; animation.StayCount = (short)reader["StayCount"]; this.AllTroopAnimations.AddAnimation(animation); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From TileAnimation", connection).ExecuteReader(); while (reader.Read()) { animation = new Animation(); animation.ID = (short)reader["ID"]; animation.Name = reader["Name"].ToString(); animation.FrameCount = (short)reader["FrameCount"]; animation.StayCount = (short)reader["StayCount"]; animation.Back = (bool)reader["Back"]; this.AllTileAnimations.AddAnimation(animation); } connection.Close(); connection.Open(); reader = new OleDbCommand("Select * From Biography", connection).ExecuteReader(); while (reader.Read()) { Biography biography = new Biography(); biography.ID = (short)reader["ID"]; biography.Brief = reader["Brief"].ToString(); biography.Romance = reader["Romance"].ToString(); biography.History = reader["History"].ToString(); biography.FactionColor = (short)reader["FactionColor"]; biography.MilitaryKinds.LoadFromString(this.AllMilitaryKinds, reader["MilitaryKinds"].ToString()); this.AllBiographies.AddBiography(biography); } connection.Close(); connection.Open(); try { reader = new OleDbCommand("Select * From TextMessageMap", connection).ExecuteReader(); while (reader.Read()) { int pid = (short)reader["Person"]; TextMessageKind kind = (TextMessageKind) (short) reader["Kind"]; List<string> messages = new List<string>(); StaticMethods.LoadFromString(messages, reader["Messages"].ToString()); this.AllTextMessages.AddTextMessages(pid, kind, messages); } } catch { reader = new OleDbCommand("Select * From TextMessage", connection).ExecuteReader(); while (reader.Read()) { int pid = (short)reader["ID"]; List<string> messages = new List<string>(); StaticMethods.LoadFromString(messages, reader["CriticalStrike"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Critical, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["CriticalStrikeOnArchitecture"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.CriticalArchitecture, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["ReceiveCriticalStrike"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.BeCritical, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["Surround"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Surround, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["Rout"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Rout, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["DualInitiativeWin"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DualActiveWin, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["DualPassiveWin"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DualPassiveWin, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["ControversyInitiativeWin"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ControversyActiveWin, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["ControversyPassiveWin"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ControversyPassiveWin, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["Chaos"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Chaos, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["DeepChaos"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DeepChaos, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["CastDeepChaos"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.CastDeepChaos, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["RecoverFromChaos"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.RecoverChaos, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["TrappedByStratagem"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.TrappedByStratagem, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["HelpedByStratagem"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.HelpedByStratagem, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["ResistHarmfulStratagem"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ResistHarmfulStratagem, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["ResistHelpfulStratagem"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ResistHelpfulStratagem, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["AntiAttack"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.AntiAttack, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["BreakWall"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.BreakWall, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["OutburstAngry"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Angry, messages); messages.Clear(); StaticMethods.LoadFromString(messages, reader["OutburstQuiet"].ToString()); this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Calm, messages); } } connection.Close(); connection.Open(); try { reader = new OleDbCommand("Select * From BiographyAdjectives", connection).ExecuteReader(); while (reader.Read()) { int t; BiographyAdjectives b = new BiographyAdjectives(); b.ID = (short)reader["ID"]; int.TryParse(reader["Strength"].ToString(), out t); b.Strength = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Command"].ToString(), out t); b.Command = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Intelligence"].ToString(), out t); b.Intelligence = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Politics"].ToString(), out t); b.Politics = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Glamour"].ToString(), out t); b.Glamour = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Braveness"].ToString(), out t); b.Braveness = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Calmness"].ToString(), out t); b.Calmness = t; b.ID = (short)reader["ID"]; int.TryParse(reader["PersonalLoyalty"].ToString(), out t); b.PersonalLoyalty = t; b.ID = (short)reader["ID"]; int.TryParse(reader["Ambition"].ToString(), out t); b.Ambition = t; b.Male = (bool)reader["Male"]; b.Female = (bool)reader["Female"]; StaticMethods.LoadFromString(b.Text, reader["BioText"].ToString()); StaticMethods.LoadFromString(b.SuffixText, reader["SuffixText"].ToString()); this.AllBiographyAdjectives.Add(b); } } catch { } connection.Close(); return true; }
public void BuildFacility(FacilityKind facilityKind) { Facility facility = new Facility(); facility.ID = base.Scenario.Facilities.GetFreeGameObjectID(); facility.Scenario = base.Scenario; facility.KindID = facilityKind.ID; facility.Endurance = facilityKind.Endurance; this.Facilities.AddFacility(facility); base.Scenario.Facilities.AddFacility(facility); if (this.FacilityEnabled) { facility.Influences.ApplyInfluence(this); } if (this.OnFacilityCompleted != null) { this.OnFacilityCompleted(this, facility); } }
public void BeginToBuildAFacility(FacilityKind facilityKind) { this.BuildingFacility = facilityKind.ID; this.BuildingDaysLeft = facilityKind.Days; this.DecreaseFund(facilityKind.FundCost); if (this.BelongedFaction.TechniquePoint < facilityKind.PointCost) { this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost - this.BelongedFaction.TechniquePoint); if (this.BelongedFaction.TechniquePoint < facilityKind.PointCost) { this.BelongedFaction.DepositTechniquePointForTechnique(facilityKind.PointCost - this.BelongedFaction.TechniquePoint); } } this.BelongedFaction.DecreaseTechniquePoint(facilityKind.PointCost); if (this.HasSpy) { this.CreateNewFacilitySpyMessage(facilityKind); } }
public List<string> LoadFacilityKind(OleDbConnection connection, GameScenario scen) { List<string> errorMsg = new List<string>(); connection.Open(); OleDbDataReader reader = new OleDbCommand("Select * From FacilityKind", connection).ExecuteReader(); while (reader.Read()) { FacilityKind facilityKind = new FacilityKind(); facilityKind.Scenario = scen; facilityKind.ID = (short)reader["ID"]; facilityKind.Name = reader["Name"].ToString(); try { facilityKind.AILevel = (float)reader["AILevel"]; } catch { facilityKind.AILevel = 1; } facilityKind.PositionOccupied = (int)reader["PositionOccupied"]; facilityKind.TechnologyNeeded = (int)reader["TechnologyNeeded"]; facilityKind.FundCost = (int)reader["FundCost"]; facilityKind.PointCost = (int)reader["PointCost"]; facilityKind.MaintenanceCost = (int)reader["MaintenanceCost"]; facilityKind.Days = (short)reader["Days"]; facilityKind.Endurance = (int)reader["Endurance"]; try { facilityKind.ArchitectureLimit = (int)reader["ArchitectureLimit"]; facilityKind.FactionLimit = (int)reader["FactionLimit"]; } catch { facilityKind.ArchitectureLimit = (bool)reader["UniqueInArchitecture"] ? 1 : 9999; facilityKind.FactionLimit = (bool)reader["UniqueInFaction"] ? 1 : 9999; } facilityKind.PopulationRelated = (bool)reader["PopulationRelated"]; List<string> e = facilityKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()); facilityKind.rongna = (short)reader["rongna"]; facilityKind.bukechaichu = (bool)reader["bukechaichu"]; e.AddRange(facilityKind.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString())); if (e.Count > 0) { errorMsg.Add("设施ID" + facilityKind.ID); errorMsg.AddRange(e); } this.AllFacilityKinds.AddFacilityKind(facilityKind); } connection.Close(); return errorMsg; }
private void AIFacility() { if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (this.BuildingFacility < 0)) { List<FacilityKind> list = new List<FacilityKind>(); List<FacilityKind> list2 = new List<FacilityKind>(); if (this.PlanFacilityKind != null) { if (this.Technology >= this.PlanFacilityKind.TechnologyNeeded) { if ((this.Fund >= this.PlanFacilityKind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= this.PlanFacilityKind.PointCost)) { this.BelongedFaction.DepositTechniquePointForFacility(this.PlanFacilityKind.PointCost); this.BeginToBuildAFacility(this.PlanFacilityKind); this.PlanFacilityKind = null; } else if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } else { this.PlanFacilityKind = null; } } else { List<FacilityKind> list3 = new List<FacilityKind>(); int facilityPositionLeft = this.FacilityPositionLeft; if (facilityPositionLeft <= 0) { foreach (Facility facility in this.Facilities.GetList()) { if (((((this.Technology > facility.TechnologyNeeded) && this.FacilityIsPossibleOverTechnology(facility.TechnologyNeeded)) && (this.Fund > (facility.FundCost * 10))) && (this.BelongedFaction.TechniquePoint > (facility.PointCost * 10))) && (GameObject.Random(facility.Days * facility.PositionOccupied) < 20)) { list3.Add(facility.Kind); if (this.FacilityEnabled) { facility.Influences.PurifyInfluence(this); } this.Facilities.Remove(facility); base.Scenario.Facilities.Remove(facility); } } if (list3.Count == 0) { return; } facilityPositionLeft = this.FacilityPositionLeft; } foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { if (list3.IndexOf(kind) >= 0) { continue; } if (((((!kind.PopulationRelated || this.Kind.HasPopulation) && ((this.Technology >= kind.TechnologyNeeded) && (facilityPositionLeft >= kind.PositionOccupied))) && (!kind.UniqueInArchitecture || !this.ArchitectureHasFacilityKind(kind.ID))) && (!kind.UniqueInFaction || !this.FactionHasFacilityKind(kind.ID))) && ((kind.FrontLine && ((this.HostileLine || (this.FrontLine && GameObject.Chance(50))) || (!this.FrontLine && GameObject.Chance(10)))) || (!kind.FrontLine && ((!this.FrontLine || (!this.HostileLine && GameObject.Chance(50))) || (this.HostileLine && GameObject.Chance(5)))))) { list.Add(kind); if ((this.Fund >= kind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= kind.PointCost)) { list2.Add(kind); } } } if (list2.Count > 0) { FacilityKind facilityKind = list2[GameObject.Random(list2.Count)]; this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost); this.BeginToBuildAFacility(facilityKind); } else if (list.Count > 0) { this.PlanFacilityKind = list[GameObject.Random(list.Count)]; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } } } }
private void AIFacility() { AIExtension(); if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (this.BuildingFacility < 0) && this.FacilityPositionCount > 0) { if (this.PlanFacilityKind != null) { if (this.Technology >= this.PlanFacilityKind.TechnologyNeeded) { if ((this.Fund >= this.PlanFacilityKind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= this.PlanFacilityKind.PointCost)) { this.BelongedFaction.DepositTechniquePointForFacility(this.PlanFacilityKind.PointCost); this.BeginToBuildAFacility(this.PlanFacilityKind); this.PlanFacilityKind = null; } else if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } else { this.PlanFacilityKind = null; } } else { //remove useless facilities if (this.BelongedSection != null && this.BelongedSection.AIDetail.AllowFacilityRemoval) { foreach (Facility i in this.Facilities) { if (i.Kind.AIValue(this) < 0 && !i.Kind.bukechaichu) { if (this.FacilityEnabled || i.MaintenanceCost <= 0) { i.Influences.PurifyInfluence(this, Applier.Facility, i.ID); } this.Facilities.Remove(i); base.Scenario.Facilities.Remove(i); break; } } } //remove facilities if not enough fund to support if (this.FacilityMaintenanceCost * 30 + 1000 > this.ExpectedFund && this.BelongedSection.AIDetail.AllowFacilityRemoval) { GameObjectList f = this.Facilities.GetList(); f.PropertyName = "AIValue"; f.SmallToBig = true; f.IsNumber = true; f.ReSort(); foreach (Facility i in f) { if (!i.Kind.bukechaichu && i.Kind.NetFundIncrease <= 0) { if (this.FacilityEnabled || i.MaintenanceCost <= 0) { i.Influences.PurifyInfluence(this, Applier.Facility, i.ID); } this.Facilities.Remove(i); base.Scenario.Facilities.Remove(i); } if (this.FacilityMaintenanceCost * 30 + 1000 <= this.ExpectedFund) break; } } //choose facilities double maxValue = double.MinValue; FacilityKind toBuild = null; List<Facility> toDestroy = new List<Facility>(); List<Facility> realToDestroy = new List<Facility>(); foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.GetFacilityKindList()) { if (kind.bukechaichu) continue; if (kind.PositionOccupied > 0 && this.FacilityPositionCount == 0) continue; if (!(!kind.PopulationRelated || this.Kind.HasPopulation)) { continue; } if (kind.UniqueInArchitecture && this.ArchitectureHasFacilityKind(kind.ID)) { continue; } if (kind.UniqueInFaction && this.FactionHasFacilityKind(kind.ID)) { continue; } bool conditionSatisfied = true; foreach (Conditions.Condition i in kind.GetConditionList()) { if (!i.CheckCondition(this)) { conditionSatisfied = false; } } if (!conditionSatisfied) continue; if (kind.TechnologyNeeded > this.Technology) { continue; } if ((kind.MaintenanceCost + this.FacilityMaintenanceCost) * 30 + 2000 > this.ExpectedFund && kind.NetFundIncrease <= 0) { continue; } double value = kind.AIValue(this); if (value > 0) { int fundMonthToWait = (kind.FundCost - (this.Fund - this.EnoughFund)) / this.ExpectedFund + 1; if (value > maxValue && GameObject.Chance((int)(100 - fundMonthToWait * Parameters.AIFacilityFundMonthWaitParam)) && this.Fund - kind.FundCost > this.EnoughFund) { if (this.FacilityPositionLeft < kind.PositionOccupied) { if (this.BelongedSection.AIDetail.AllowFacilityRemoval && this.FacilityPositionLeft < base.Scenario.GameCommonData.AllFacilityKinds.GetMaxFacilitySpace()) { int fpl = this.FacilityPositionLeft; toDestroy.Clear(); foreach (Facility f in this.Facilities.GetRandomList()) { if (value > f.Kind.AIValue(this) * Parameters.AIFacilityDestroyValueRate && !f.Kind.bukechaichu) { toDestroy.Add(f); fpl += f.Kind.PositionOccupied; if (fpl >= kind.PositionOccupied) { break; } } } if (fpl >= kind.PositionOccupied) { maxValue = value; toBuild = kind; realToDestroy = toDestroy; } } } else { maxValue = value; toBuild = kind; } } } } if (toBuild != null) { //if no space and the facility is good enough than others, remove others foreach (Facility f in realToDestroy) { if (this.FacilityEnabled || f.MaintenanceCost <= 0) { f.Influences.PurifyInfluence(this, Applier.Facility, f.ID); } this.Facilities.Remove(f); base.Scenario.Facilities.Remove(f); } //actually build it, or put to plan if fund is not enough if ((this.Fund >= toBuild.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= toBuild.PointCost)) { FacilityKind facilityKind = toBuild; this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost); this.BeginToBuildAFacility(facilityKind); } else { this.PlanFacilityKind = toBuild; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } } /*List<FacilityKind> list3 = new List<FacilityKind>(); int facilityPositionLeft = this.FacilityPositionLeft; int iD = 10; int num3 = 0; foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { if (((kind.ID > iD) && ((kind.ID / 10) == 1)) && (kind.TechnologyNeeded < this.Technology)) { iD = kind.ID; } if (((kind.ID > num3) && ((kind.ID / 10) == 0)) && (kind.TechnologyNeeded < this.Technology)) { num3 = kind.ID; } } foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { if (((kind.rongna > 0) || (((kind.ID / 10) == 0) && (kind.ID != num3))) || (((kind.ID / 10) == 1) && (kind.ID != iD))) { continue; } if ((((!kind.PopulationRelated || this.Kind.HasPopulation) && ((this.Technology >= kind.TechnologyNeeded) && (facilityPositionLeft >= kind.PositionOccupied))) && ((!kind.UniqueInArchitecture || !this.ArchitectureHasFacilityKind(kind.ID)) && (!kind.UniqueInFaction || !this.FactionHasFacilityKind(kind.ID)))) && ((kind.FrontLine && ((this.HostileLine || (this.FrontLine && GameObject.Chance(50))) || (!this.FrontLine && GameObject.Chance(10)))) || (!kind.FrontLine && ((!this.FrontLine || (!this.HostileLine && GameObject.Chance(50))) || (this.HostileLine && GameObject.Chance(5)))))) { list.Add(kind); if ((this.Fund >= kind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= kind.PointCost)) { list2.Add(kind); } } } if (facilityPositionLeft <= 0) { foreach (Facility facility in this.Facilities.GetList()) { if ((((this.Technology > facility.TechnologyNeeded) && this.FacilityIsPossibleOverTechnology(facility.TechnologyNeeded)) && ((this.Fund > (facility.FundCost * 10)) && (this.BelongedFaction.TechniquePoint > (facility.PointCost * 10)))) && (GameObject.Random(facility.Days * facility.PositionOccupied) < 20) && !facility.Kind.bukechaichu) { if (list.IndexOf(facility.Kind) >= 0) { continue; } list3.Add(facility.Kind); if (this.FacilityEnabled) { facility.Influences.PurifyInfluence(this); } this.Facilities.Remove(facility); base.Scenario.Facilities.Remove(facility); } } if (list3.Count == 0) { return; } facilityPositionLeft = this.FacilityPositionLeft; } if (list2.Count > 0) { FacilityKind facilityKind = list2[GameObject.Random(list2.Count)]; this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost); this.BeginToBuildAFacility(facilityKind); } else if (list.Count > 0) { this.PlanFacilityKind = list[GameObject.Random(list.Count)]; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } }*/ } } }
private void AIHouGong() { if (base.Scenario.IsPlayer(this.BelongedFaction)) return; if (this.HasHostileTroopsInView()) return; if (GlobalVariables.getChildrenRate <= 0) return; Person leader = this.BelongedFaction.Leader; int uncruelty = leader.Uncruelty; //build hougong int unAmbition = Enum.GetNames(typeof(PersonAmbition)).Length - (int)leader.Ambition; if (this.BelongedFaction.meinvkongjian() - this.BelongedFaction.feiziCount() <= 0 && (this.BuildingFacility < 0) && (this.PlanFacilityKind == null || this.PlanFacilityKind.rongna <= 0) && GameObject.Random((int)(GameObject.Square(unAmbition) * Parameters.AIBuildHougongUnambitionProbWeight + GameObject.Square(this.BelongedFaction.meinvkongjian()) * unAmbition * Parameters.AIBuildHougongSpaceBuiltProbWeight)) == 0) { if (((!this.FrontLine && !this.noFactionFrontline) || GameObject.Chance(Parameters.AILeaveFrontlineForHougongChance)) && (!this.HostileLine || GameObject.Chance(Parameters.AILeaveHostilelineForHougongChance)) && this.Kind.FacilityPositionUnit > 0 && this.Agriculture >= this.AgricultureCeiling * 9 / 10 && this.Commerce >= this.CommerceCeiling * 9 / 10 && this.Technology >= this.TechnologyCeiling * 9 / 10 && this.Endurance >= this.EnduranceCeiling * 9 / 10 && this.Domination >= this.DominationCeiling * 9 / 10 && this.Morale >= this.MoraleCeiling * 9 / 10) { int maxHgSize = (12 - uncruelty) + Math.Max(0, this.FacilityPositionCount / this.Kind.FacilityPositionUnit - 5) + Parameters.AIBuildHougongMaxSizeAdd; FacilityKind hougong = null; foreach (FacilityKind fk in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { if ((((!fk.PopulationRelated || this.Kind.HasPopulation) && ((this.Technology >= fk.TechnologyNeeded))) && ((!fk.UniqueInArchitecture || !this.ArchitectureHasFacilityKind(kind.ID)) && (!fk.UniqueInFaction || !this.FactionHasFacilityKind(kind.ID))))) { if (fk.rongna > 0 && fk.rongna < maxHgSize && GameObject.Chance(Parameters.AIBuildHougongSkipSizeChance)) { if (hougong == null || hougong.rongna < fk.rongna) { hougong = fk; } } } } if (hougong != null) { int facilityPositionLeft = this.FacilityPositionLeft; if (facilityPositionLeft < hougong.PositionOccupied && this.FacilityPositionCount >= hougong.PositionOccupied) { FacilityList fl = new FacilityList(); foreach (Facility f in this.Facilities) { if (!f.Kind.bukechaichu) { fl.Add(f); } } int totalRemovableSpace = 0; foreach (Facility f in fl) { totalRemovableSpace += f.PositionOccupied; } if (totalRemovableSpace >= hougong.PositionOccupied && this.BelongedSection.AIDetail.AllowFacilityRemoval) { fl.PropertyName = "AIValue"; fl.IsNumber = true; fl.SmallToBig = true; fl.ReSort(); while (this.FacilityPositionLeft < hougong.PositionOccupied && fl.Count > 0) { Facility f = fl[0] as Facility; if (this.FacilityEnabled || f.MaintenanceCost <= 0) { f.Influences.PurifyInfluence(this, Applier.Facility, f.ID); } this.Facilities.Remove(f); base.Scenario.Facilities.Remove(f); fl.Remove(f); } } /*foreach (Facility facility in this.Facilities.GetList()) { if ((((this.Technology > facility.TechnologyNeeded) && this.FacilityIsPossibleOverTechnology(facility.TechnologyNeeded)) && ((this.Fund > (facility.FundCost * 10)) && (this.BelongedFaction.TechniquePoint > (facility.PointCost * 10)))) && (GameObject.Random(facility.Days * facility.PositionOccupied) < 20 * hougong.PositionOccupied) && !facility.Kind.bukechaichu) { if (this.FacilityEnabled) { facility.Influences.PurifyInfluence(this); } this.Facilities.Remove(facility); base.Scenario.Facilities.Remove(facility); } }*/ facilityPositionLeft = this.FacilityPositionLeft; } if (facilityPositionLeft >= hougong.PositionOccupied) { if ((this.Fund >= hougong.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= hougong.PointCost)) { this.PlanFacilityKind = null; this.BelongedFaction.DepositTechniquePointForFacility(hougong.PointCost); this.BeginToBuildAFacility(hougong); } else { this.PlanFacilityKind = hougong; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } } } } } //nafei if (leader.WaitForFeiZi != null && leader.Status == PersonStatus.Normal) { if (this.Meinvkongjian - this.Feiziliebiao.Count <= 0 || !this.BelongedFaction.Leader.isLegalFeiZi(leader.WaitForFeiZi)) { leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else if (this.fund >= 50000) { if (leader.LocationArchitecture == this && leader.Status == PersonStatus.Normal && this.nvxingwujiang().GameObjects.Contains(leader.WaitForFeiZi)) { leader.XuanZeMeiNv(leader.WaitForFeiZi); leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else if (leader.WaitForFeiZi.BelongedFaction != this.BelongedFaction) { leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } } else { leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } } else { if (!leader.IsCaptive && this.Meinvkongjian - this.Feiziliebiao.Count > 0 && leader.Status == PersonStatus.Normal && ( GameObject.Random(uncruelty - Parameters.AINafeiUncreultyProbAdd) == 0 || GameObject.Chance((int)Math.Round(Parameters.AIHougongArchitectureCountProbMultiply * Math.Pow(this.BelongedFaction.ArchitectureCount, Parameters.AIHougongArchitectureCountProbPower)))) && this.Fund > 75000 ) { if (leader.LocationArchitecture == this) { PersonList candidate = new PersonList(); foreach (Person p in this.BelongedFaction.Persons) { Person spousePerson = p.Spouse == null ? null : p.Spouse; if (p.Merit > ((unAmbition - 1) * Parameters.AINafeiAbilityThresholdRate) && leader.isLegalFeiZi(p) && p.LocationArchitecture != null && !p.IsCaptive && !p.Hates(this.BelongedFaction.Leader) && (spousePerson == null || spousePerson.ID == leader.ID || !spousePerson.Alive || (leader.PersonalLoyalty < (int)PersonLoyalty.很高 && spousePerson.Merit < p.Merit * ((int)leader.PersonalLoyalty * Parameters.AINafeiStealSpouseThresholdRateMultiply + Parameters.AINafeiStealSpouseThresholdRateAdd))) && (!GlobalVariables.PersonNaturalDeath || (p.Age >= 16 && p.Age <= Parameters.AINafeiMaxAgeThresholdAdd + (int)leader.Ambition * Parameters.AINafeiMaxAgeThresholdMultiply))) { candidate.Add(p); } } candidate.PropertyName = "Merit"; candidate.IsNumber = true; candidate.SmallToBig = false; candidate.ReSort(); Person toTake = null; foreach (Person p in candidate) { if (p.Status == PersonStatus.Normal) { if ((!p.RecruitableBy(this.BelongedFaction, 0) && GameObject.Random((int)unAmbition) == 0) || GameObject.Chance((int)(Parameters.AINafeiSkipChanceAdd + (int)leader.Ambition * Parameters.AINafeiSkipChanceMultiply))) { toTake = p; break; } } } if (toTake != null) { if (leader.LocationArchitecture.Meinvkongjian > this.Meinvkongjian) { if (toTake.LocationArchitecture == leader.LocationArchitecture && toTake.LocationArchitecture.Fund >= 50000) { leader.XuanZeMeiNv(toTake); toTake.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else { toTake.MoveToArchitecture(leader.LocationArchitecture); toTake.WaitForFeiZi = leader; leader.WaitForFeiZi = toTake; } } else { if (leader.LocationArchitecture != this) { leader.MoveToArchitecture(this); leader.WaitForFeiZi = toTake; } if (toTake.LocationArchitecture == this) { if (leader.LocationArchitecture == this && this.Fund >= 50000) { leader.XuanZeMeiNv(toTake); toTake.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else { toTake.WaitForFeiZi = leader; } } else { toTake.MoveToArchitecture(this); toTake.WaitForFeiZi = leader; leader.WaitForFeiZi = toTake; } } } } else if (leader.LocationArchitecture != null && ((!leader.LocationArchitecture.HostileLine || GameObject.Chance(Parameters.AILeaveHostilelineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIHostilelineHougongChance))) && (!leader.LocationArchitecture.FrontLine || GameObject.Chance(Parameters.AILeaveFrontlineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIFrontlineHougongChance)))) ) { if (leader.LocationArchitecture.meifaxianhuaiyundefeiziliebiao().Count <= 0) { leader.MoveToArchitecture(this); } } } } //chongxing if (!leader.IsCaptive && !leader.huaiyun && meifaxianhuaiyundefeiziliebiao().Count > 0 && leader.LocationArchitecture != null && this.BelongedFaction.Leader.WaitForFeiZi == null && leader.Status == PersonStatus.Normal && ( GameObject.Chance((int)((int)leader.Ambition * Parameters.AIChongxingChanceMultiply + Parameters.AIChongxingChanceAdd)) || GameObject.Chance((int)Math.Round(Parameters.AIHougongArchitectureCountProbMultiply * Math.Pow(this.BelongedFaction.ArchitectureCount, Parameters.AIHougongArchitectureCountProbPower))) ) && (((!leader.LocationArchitecture.HostileLine || GameObject.Chance(Parameters.AILeaveHostilelineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIHostilelineHougongChance))) && (!leader.LocationArchitecture.FrontLine || GameObject.Chance(Parameters.AILeaveFrontlineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIFrontlineHougongChance)))) ) ) { if (leader.LocationArchitecture != this) { bool stay = false; PersonList candidate = leader.LocationArchitecture.meifaxianhuaiyundefeiziliebiao(); candidate.PropertyName = "Merit"; candidate.IsNumber = true; candidate.SmallToBig = false; candidate.ReSort(); foreach (Person p in candidate) { if ((GameObject.Random(leader.NumberOfChildren * (GlobalVariables.PersonNaturalDeath ? 1 : 0) + p.NumberOfChildren * 2) == 0 || GameObject.Chance(p.pregnantChance)) && leader.isLegalFeiZi(p)) { stay = true; leader.GoForHouGong(p); break; } } if (!stay) { leader.MoveToArchitecture(this); } } else { PersonList candidate = meifaxianhuaiyundefeiziliebiao(); candidate.PropertyName = "Merit"; candidate.IsNumber = true; candidate.SmallToBig = false; candidate.ReSort(); foreach (Person p in candidate) { if (GameObject.Random(leader.NumberOfChildren * (GlobalVariables.PersonNaturalDeath ? 1 : 0) + p.NumberOfChildren * 2) == 0 && leader.isLegalFeiZi(p)) { leader.GoForHouGong(p); break; } } } } }
private void AIFacility() { if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (this.BuildingFacility < 0)) { List<FacilityKind> list = new List<FacilityKind>(); List<FacilityKind> list2 = new List<FacilityKind>(); if (this.PlanFacilityKind != null) { if (this.Technology >= this.PlanFacilityKind.TechnologyNeeded) { if ((this.Fund >= this.PlanFacilityKind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= this.PlanFacilityKind.PointCost)) { this.BelongedFaction.DepositTechniquePointForFacility(this.PlanFacilityKind.PointCost); this.BeginToBuildAFacility(this.PlanFacilityKind); this.PlanFacilityKind = null; } else if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } else { this.PlanFacilityKind = null; } } else { List<FacilityKind> list3 = new List<FacilityKind>(); int facilityPositionLeft = this.FacilityPositionLeft; //lgs-patch: do not remove building that is wanted to build //lgs-patch: do not build weaker versions of markets/farms and the better ones can be built int bestMarket = 10, bestFarm = 0; foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { if (kind.ID > bestMarket && kind.ID / 10 == 1 && kind.TechnologyNeeded < this.Technology) { bestMarket = kind.ID; } if (kind.ID > bestFarm && kind.ID / 10 == 0 && kind.TechnologyNeeded < this.Technology) { bestFarm = kind.ID; } } foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { //do not build thing just removed /*if (list3.IndexOf(kind) >= 0) { continue; }*/ if (kind.rongna > 0) continue; //不造美女设施 if (kind.ID / 10 == 0 && kind.ID != bestFarm) continue; if (kind.ID / 10 == 1 && kind.ID != bestMarket) continue; //add building that is //1. bound to game rules //2. if facility is for frontline // 100% if arch is on hostile line, or 50% if arch is on front line, or 10% if arch is not on front line //3. otherwise // not front line, or 50% if arch is not on hostile line, or 5% if on hostile line if (((((!kind.PopulationRelated || this.Kind.HasPopulation) && ((this.Technology >= kind.TechnologyNeeded) && (facilityPositionLeft >= kind.PositionOccupied))) && (!kind.UniqueInArchitecture || !this.ArchitectureHasFacilityKind(kind.ID))) && (!kind.UniqueInFaction || !this.FactionHasFacilityKind(kind.ID))) && ((kind.FrontLine && ((this.HostileLine || (this.FrontLine && GameObject.Chance(50))) || (!this.FrontLine && GameObject.Chance(10)))) || (!kind.FrontLine && ((!this.FrontLine || (!this.HostileLine && GameObject.Chance(50))) || (this.HostileLine && GameObject.Chance(5)))))) { list.Add(kind); if ((this.Fund >= kind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= kind.PointCost)) { list2.Add(kind); } } } //if there is no facility position, attempt to remove some facilities if (facilityPositionLeft <= 0) { foreach (Facility facility in this.Facilities.GetList()) { //if //1. this building requires less technology than current arch tech value //2. this building is bound to game rules(?) //3. cost of building (fund and techpoint) is 10 times less than current resource (fund and techpoint) //4. (20/(days * space occupied))% chance //destory this building if (((((this.Technology > facility.TechnologyNeeded) && this.FacilityIsPossibleOverTechnology(facility.TechnologyNeeded)) && (this.Fund > (facility.FundCost * 10))) && (this.BelongedFaction.TechniquePoint > (facility.PointCost * 10))) && (GameObject.Random(facility.Days * facility.PositionOccupied) < 20)) { if (list.IndexOf(facility.Kind) >= 0) { continue; } list3.Add(facility.Kind); if (this.FacilityEnabled) { facility.Influences.PurifyInfluence(this); } this.Facilities.Remove(facility); base.Scenario.Facilities.Remove(facility); } } if (list3.Count == 0) { return; } facilityPositionLeft = this.FacilityPositionLeft; } if (list2.Count > 0) { FacilityKind facilityKind = list2[GameObject.Random(list2.Count)]; this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost); this.BeginToBuildAFacility(facilityKind); } else if (list.Count > 0) { this.PlanFacilityKind = list[GameObject.Random(list.Count)]; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } }// end if (this.PlanFacilityKind != null) } }