public CombatMethod GetCombatMethod(int combatMethodID)
        {
            CombatMethod method = null;

            this.CombatMethods.TryGetValue(combatMethodID, out method);
            return(method);
        }
 public bool RemoveCombatMethod(CombatMethod combatMethod)
 {
     if (this.CombatMethods.ContainsKey(combatMethod.ID))
     {
         return false;
     }
     this.CombatMethods.Remove(combatMethod.ID);
     return true;
 }
 public bool AddCombatMethod(CombatMethod combatMethod)
 {
     if (this.CombatMethods.ContainsKey(combatMethod.ID))
     {
         return false;
     }
     this.CombatMethods.Add(combatMethod.ID, combatMethod);
     return true;
 }
 public bool AddCombatMethod(CombatMethod combatMethod)
 {
     if (this.CombatMethods.ContainsKey(combatMethod.ID))
     {
         return(false);
     }
     this.CombatMethods.Add(combatMethod.ID, combatMethod);
     return(true);
 }
 public bool RemoveCombatMethod(CombatMethod combatMethod)
 {
     if (!this.CombatMethods.ContainsKey(combatMethod.ID))
     {
         return(false);
     }
     this.CombatMethods.Remove(combatMethod.ID);
     return(true);
 }
Esempio n. 6
0
 public virtual void TroopSetCombatMethod(Troop troop, CombatMethod combatMethod)
 {
 }
Esempio n. 7
0
 public virtual void TroopCombatMethodAttack(Troop sending, Troop receiving, CombatMethod combatMethod)
 {
 }
 public override void TroopSetCombatMethod(Troop troop, CombatMethod combatMethod)
 {
     if (((base.Scenario.CurrentPlayer == null) || base.Scenario.CurrentPlayer.IsPositionKnown(troop.Position)) || GlobalVariables.SkyEye)
     {
         troop.Leader.TextDestinationString = combatMethod.Name;
         this.Plugins.PersonBubblePlugin.AddPerson(troop.Leader, troop.Position, TextMessageKind.SetCombatMethod, "SetCombatMethod");
     }
 }
 public override void TroopCombatMethodAttack(Troop sending, Troop receiving, CombatMethod combatMethod)
 {
     if (((base.Scenario.CurrentPlayer == null) || base.Scenario.CurrentPlayer.IsPositionKnown(sending.Position)) || GlobalVariables.SkyEye)
     {
         if (sending.BelongedFaction != null)
         {
             sending.Leader.TextDestinationString = receiving.Leader.Name;
             sending.Leader.TextResultString = receiving.DisplayName;
             this.Plugins.PersonBubblePlugin.AddPerson(sending.Leader, sending.Position, TextMessageKind.UseCombatMethod, "CombatMethod" + combatMethod.ID);
         }
         else
         {
             this.Plugins.PersonBubblePlugin.AddPerson(sending.Leader, sending.Position, TextMessageKind.UseCombatMethod, "CombatMethod");
         }
     }
 }
Esempio n. 10
0
 public void SetCurrentCombatMethod(CombatMethod cm)
 {
     this.currentCombatMethod = cm;
     if (cm != null)
     {
         this.currentCombatMethodID = cm.ID;
         if (cm.AttackDefault != null)
         {
             this.AttackDefaultKind = (TroopAttackDefaultKind) cm.AttackDefault.ID;
         }
         if (cm.AttackTarget != null)
         {
             this.AttackTargetKind = (TroopAttackTargetKind) cm.AttackTarget.ID;
         }
     }
     else
     {
         this.currentCombatMethodID = -1;
     }
 }
Esempio n. 11
0
        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;
        }
Esempio n. 12
0
 private bool AIResetDestination()
 {
     CreditPack moveCreditByPosition;
     double num4;
     double distance;
     if (!this.IsRobber)
     {
         if (GameObject.Chance(80 + (this.Leader.Calmness * 2)) && ((this.InjuryQuantity > this.Quantity) || (this.Morale < 0x2d)))
         {
             this.GoBack();
             if (GameObject.Chance(50))
             {
                 this.AttackTargetKind = TroopAttackTargetKind.无反;
             }
             else
             {
                 this.AttackTargetKind = TroopAttackTargetKind.无反默认;
             }
             this.WillTroop = null;
             this.TargetTroop = null;
             this.TargetArchitecture = null;
             return false;
         }
         if ((((this.WillArchitecture.Endurance >= 30) && (this.WillArchitecture.BelongedFaction != this.BelongedFaction)) && (this.Morale <= 0x4b)) && (((this.BelongedLegion.PreferredRouteway != null) && (this.BelongedLegion.PreferredRouteway.LastActivePointIndex < 0)) || (((this.BelongedLegion.PreferredRouteway != null) && (this.BelongedLegion.PreferredRouteway.LastActivePoint != null)) && !this.BelongedLegion.PreferredRouteway.IsEnough(this.BelongedLegion.PreferredRouteway.LastActivePoint.ConsumptionRate, this.FoodCostPerDay))))
         {
             this.GoBack();
             if (GameObject.Chance(50))
             {
                 this.AttackTargetKind = TroopAttackTargetKind.无反;
             }
             else
             {
                 this.AttackTargetKind = TroopAttackTargetKind.无反默认;
             }
             this.WillTroop = null;
             this.TargetTroop = null;
             this.TargetArchitecture = null;
             return false;
         }
         if (!(this.IsFriendly(this.WillArchitecture.BelongedFaction) || (this.BelongedLegion.Kind != LegionKind.Defensive)))
         {
             this.GoBack();
             this.AttackTargetKind = TroopAttackTargetKind.无反默认;
             this.WillTroop = null;
             this.TargetTroop = null;
             this.TargetArchitecture = null;
             return false;
         }
         if (!(((!GameObject.Chance(10 + this.Leader.Calmness) || !this.HasHostileTroopInView()) || (this.WillArchitecture.BelongedFaction == this.BelongedFaction)) || this.WillArchitecture.ViewTroop(this)))
         {
             this.AttackTargetKind = TroopAttackTargetKind.无反默认;
             this.WillTroop = null;
             this.TargetTroop = null;
             this.TargetArchitecture = null;
             return false;
         }
         if (!(((this.WillArchitecture.BelongedFaction == this.BelongedFaction) || !this.IsFriendly(this.WillArchitecture.BelongedFaction)) || this.WillArchitecture.HasHostileTroopsInView()))
         {
             this.AttackTargetKind = TroopAttackTargetKind.无反默认;
             this.WillTroop = null;
             this.TargetTroop = null;
             this.TargetArchitecture = null;
             this.GoBack();
             return false;
         }
         this.CallTacticsHelp();
         this.CallRoutewayHelp();
     }
     List<CreditPack> list = new List<CreditPack>();
     int credit = 0;
     bool flag = false;
     bool flag2 = false;
     bool hasUnAttackableTroop = false;
     CreditPack pack = null;
     GameArea dayArea = this.GetDayArea(1);
     if (dayArea.Count <= 10)
     {
         if (this.ViewArea.Count > 10)
         {
             dayArea = this.ViewArea;
         }
         else
         {
             dayArea = this.GetDayArea(2);
             dayArea.AddPoint(this.Position);
         }
     }
     else
     {
         dayArea.AddPoint(this.Position);
     }
     if ((((((!this.IsRobber && !this.ViewingWillArchitecture) && ((this.Army.Kind.Type != MilitaryType.水军) || GameObject.Chance(20))) && (((this.Morale > 0x4b) && (this.BelongedLegion.Kind == LegionKind.Offensive)) && (this.WillArchitecture.BelongedFaction != this.BelongedFaction))) && !this.HasHostileTroopInView()) && !this.BelongedLegion.HasTroopViewingWillArchitecture) && (this.WillArchitecture.BelongedFaction != null))
     {
         foreach (Point point in dayArea.Area)
         {
             moveCreditByPosition = this.GetMoveCreditByPosition(point);
             if (moveCreditByPosition != null)
             {
                 list.Add(moveCreditByPosition);
                 if (moveCreditByPosition.Credit > credit)
                 {
                     credit = moveCreditByPosition.Credit;
                     pack = moveCreditByPosition;
                 }
             }
         }
     }
     this.OffenceOnlyBeforeMoveFlag = false;
     foreach (Point point in dayArea.Area)
     {
         if ((this.BelongedLegion == null) || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0))
         {
             moveCreditByPosition = this.GetCreditByPosition(point);
             list.Add(moveCreditByPosition);
             if (!flag2)
             {
                 flag2 = moveCreditByPosition.TargetTroop != null;
             }
             if (!hasUnAttackableTroop)
             {
                 hasUnAttackableTroop = moveCreditByPosition.HasUnAttackableTroop;
             }
             if (moveCreditByPosition.Credit > credit)
             {
                 credit = moveCreditByPosition.Credit;
                 pack = moveCreditByPosition;
             }
         }
     }
     Point? nullable = null;
     Point? nullable2 = null;
     base.Scenario.GetClosestPointsBetweenTwoAreas(dayArea, this.WillArchitecture.ArchitectureArea, out nullable, out nullable2);
     if ((this.CurrentStunt != null) || (GameObject.Random(this.Stunts.Count + 3) < 3))
     {
         if (flag2 && ((credit < 500) || (GameObject.Chance(this.Combativity) && GameObject.Chance(80))))
         {
         //Label_0712:
             foreach (CombatMethod method in this.CombatMethods.CombatMethods.Values)
             {
                 if (!this.HasCombatMethod(method.ID))
                 {
                     continue;
                 }
                 if (method.SimulateApply(this))
                 {
                     this.SimulatingCombatMethod = method;
                     this.RefreshAllData();
                     foreach (Point point in dayArea.Area)
                     {
                         if (((!nullable.HasValue || flag2) || (nullable.Value == point)) && ((this.BelongedLegion == null) || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0)))
                         {
                             moveCreditByPosition = this.GetCreditByPosition(point);
                             moveCreditByPosition.CurrentCombatMethod = method;
                             moveCreditByPosition.Credit -= method.Combativity;
                             list.Add(moveCreditByPosition);
                             if (moveCreditByPosition.Credit > credit)
                             {
                                 credit = moveCreditByPosition.Credit;
                                 pack = moveCreditByPosition;
                             }
                         }
                     }
                     method.SimulatePurify(this);
                     this.RefreshAllData();
                 }
             }
         }
         if ((((this.Morale <= 90) || flag2) || ((hasUnAttackableTroop || GameObject.Chance(10)) || this.HasHostileArchitectureInView())) && ((credit < 500) || (GameObject.Chance(this.Combativity) && GameObject.Chance(30))))
         {
             foreach (Stratagem stratagem in this.Stratagems.Stratagems.Values)
             {
                 if (this.HasStratagem(stratagem.ID))
                 {
                     if (stratagem.Self)
                     {
                         moveCreditByPosition = this.GetSelfStratagemCredit(stratagem);
                         moveCreditByPosition.Credit -= stratagem.Combativity;
                         list.Add(moveCreditByPosition);
                         if (moveCreditByPosition.Credit > credit)
                         {
                             credit = moveCreditByPosition.Credit;
                             pack = moveCreditByPosition;
                             flag = true;
                         }
                     }
                     else
                     {
                         this.SetCurrentStratagem(stratagem);
                         foreach (Point point in dayArea.Area)
                         {
                             if (((!nullable.HasValue || flag2) || (nullable.Value == point)) && (((this.BelongedLegion == null) || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0)) && (!this.OffenceOnlyBeforeMove || !(point != this.Position))))
                             {
                                 moveCreditByPosition = this.GetStratagemCreditByPosition(stratagem, point);
                                 moveCreditByPosition.Credit -= stratagem.Combativity;
                                 list.Add(moveCreditByPosition);
                                 if (moveCreditByPosition.Credit > credit)
                                 {
                                     credit = moveCreditByPosition.Credit;
                                     pack = moveCreditByPosition;
                                     flag = true;
                                 }
                             }
                         }
                         this.SetCurrentStratagem(null);
                     }
                 }
             }
         }
     }
     if (this.OffenceOnlyBeforeMove && ((credit <= 0) || ((credit < 100) && GameObject.Chance(100 - credit))))
     {
         this.OffenceOnlyBeforeMoveFlag = true;
         foreach (Point point in dayArea.Area)
         {
             if ((this.BelongedLegion == null) || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0))
             {
                 moveCreditByPosition = this.GetCreditByPosition(point);
                 list.Add(moveCreditByPosition);
                 flag2 = moveCreditByPosition.TargetTroop != null;
                 hasUnAttackableTroop = moveCreditByPosition.HasUnAttackableTroop;
                 if (moveCreditByPosition.Credit > credit)
                 {
                     credit = moveCreditByPosition.Credit;
                     pack = moveCreditByPosition;
                 }
             }
         }
     }
     if (credit <= 0)
     {
         this.AttackTargetKind = TroopAttackTargetKind.攻防皆弱默认;
         this.TargetTroop = null;
         this.TargetArchitecture = null;
         return false;
     }
     List<CreditPack> list2 = new List<CreditPack>();
     bool flag4 = false;
     foreach (CreditPack pack2 in list)
     {
         if (pack2.Credit == credit)
         {
             list2.Add(pack2);
         }
         if ((!flag4 && (pack2.TargetTroop != null)) && pack2.TargetTroop.AirOffence)
         {
             flag4 = true;
         }
     }
     CreditPack pack3 = null;
     List<CreditPack> list3 = new List<CreditPack>();
     if (this.Army.Kind.AirOffence || flag)
     {
         double minValue = double.MinValue;
         foreach (CreditPack pack2 in list2)
         {
             if (pack2.Distance > minValue)
             {
                 minValue = pack2.Distance;
                 list3.Clear();
                 list3.Add(pack2);
             }
             else if (pack2.Distance == minValue)
             {
                 list3.Add(pack2);
             }
         }
     }
     else
     {
         double maxValue = double.MaxValue;
         foreach (CreditPack pack2 in list2)
         {
             if (pack2.Distance < maxValue)
             {
                 maxValue = pack2.Distance;
                 list3.Clear();
                 list3.Add(pack2);
             }
             else if (pack2.Distance == maxValue)
             {
                 list3.Add(pack2);
             }
         }
     }
     if (flag4 || GameObject.Chance(20))
     {
         num4 = double.MinValue;
         foreach (CreditPack pack2 in list3)
         {
             distance = base.Scenario.GetDistance(this.Position, pack2.Position);
             if ((distance > num4) || (GameObject.Random(list3.Count) == 0))
             {
                 num4 = distance;
                 pack3 = pack2;
             }
         }
     }
     else
     {
         num4 = double.MaxValue;
         foreach (CreditPack pack2 in list3)
         {
             distance = base.Scenario.GetDistance(this.Position, pack2.Position);
             if ((distance < num4) || (GameObject.Random(list3.Count) == 0))
             {
                 num4 = distance;
                 pack3 = pack2;
             }
         }
     }
     this.RealDestination = pack3.Position;
     if (this.BelongedLegion != null)
     {
         this.BelongedLegion.TakenPositions.Add(pack3.Position);
     }
     if (pack3.CurrentCombatMethod != null)
     {
         this.SetCurrentCombatMethod(pack3.CurrentCombatMethod);
     }
     else if (pack3.CurrentStratagem != null)
     {
         this.SetCurrentStratagem(pack3.CurrentStratagem);
         if (pack3.CurrentStratagem.Self)
         {
             this.SelfCastPosition = pack3.SelfCastPosition;
         }
     }
     if (pack3.TargetTroop != null)
     {
         if (this.CurrentCombatMethod == null)
         {
             this.AttackDefaultKind = TroopAttackDefaultKind.防最弱;
             this.AttackTargetKind = TroopAttackTargetKind.目标默认;
         }
         if (this.CurrentStratagem == null)
         {
             this.CastTargetKind = TroopCastTargetKind.特定默认;
         }
         this.TargetTroop = pack3.TargetTroop;
         this.TargetArchitecture = null;
     }
     else if (pack3.TargetArchitecture != null)
     {
         this.AttackDefaultKind = TroopAttackDefaultKind.耐最低;
         this.AttackTargetKind = TroopAttackTargetKind.目标默认;
         this.CastTargetKind = TroopCastTargetKind.智低默认;
         this.TargetTroop = null;
         this.TargetArchitecture = pack3.TargetArchitecture;
     }
     else
     {
         this.AttackDefaultKind = TroopAttackDefaultKind.防最弱;
         this.AttackTargetKind = TroopAttackTargetKind.无反默认;
         this.CastTargetKind = TroopCastTargetKind.智低默认;
         this.TargetTroop = null;
         this.TargetArchitecture = null;
     }
     return true;
 }
Esempio n. 13
0
        private bool AIResetDestination()
        {
            CreditPack moveCreditByPosition;
            double num4;
            double distance;

            if (this.Destroyed) return false;

            if (this.willArchitectureID < 0)
            {
                this.GoBack();
                return false;
            }
            List<Troop> hostileTroopList = new List<Troop>();
            List<Troop> friendlyTroopList = new List<Troop>();
            if (!this.IsRobber)
            {
                //ensure troops won't get stuck forever
                if (stuckPosition == new Point(-1, -1) || (this.HasHostileArchitectureInView() && this.TargetArchitecture != null) ||
                    this.HasHostileTroopInView()
                    || (this.WillArchitecture.BelongedFaction != this.BelongedFaction && this.WillArchitecture.LongViewArea.Area.Contains(this.position)))
                {
                    stuckPosition = this.Position;
                }
                else
                {
                    if (this.Position == stuckPosition)
                    {
                        stuckedFor++;
                        if (stuckedFor >= 5)
                        {
                            this.GoBack();
                            this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                            return false;
                        }
                    }
                    else
                    {
                        stuckPosition = this.Position;
                        stuckedFor = 0;
                    }
                }
                //retreat if the target no longer belong to us and this is a transportation troop.
                if (this.WillArchitecture.BelongedFaction != this.BelongedFaction && this.Army.Kind.IsTransport)
                {
                    this.GoBack();
                    this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                    return false;
                }
                //retreat if target has too much food/fund that further transfer will fill up there, for transport troop
                if ((this.WillArchitecture.Food + this.Food > this.WillArchitecture.FoodCeiling ||
                    this.WillArchitecture.Fund + this.zijin > this.WillArchitecture.FundCeiling) &&
                    this.Army.Kind.IsTransport && !this.StartingArchitecture.HasHostileTroopsInView())
                {
                    this.GoBack();
                    this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                    return false;
                }
                //retreat if morale < 45 or has more injured troop than working troops, with 80 + 2 x calmness chance
                if (GameObject.Chance(80 + (this.Leader.Calmness * 2)) && ((this.InjuryQuantity > this.Quantity) || (this.Morale < 45)
                        || (this.Army.Scales <= 5 && !this.IsTransport && this.BelongedLegion != null && this.BelongedLegion.Kind == LegionKind.Offensive)))
                {
                    this.GoBack();
                    if (GameObject.Chance(50))
                    {
                        this.AttackTargetKind = TroopAttackTargetKind.无反;
                    }
                    else
                    {
                        this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                    }
                    return false;
                }
                //retreat if the enemy base has > 30 endurance, morale <= 75, and routeway not started or don't have enough food
                if (this.BelongedFaction != null)
                {
                    if ((((this.WillArchitecture.Endurance >= 30) && (this.WillArchitecture.BelongedFaction != this.BelongedFaction))
                        && (this.Morale <= 75))
                        && (((this.BelongedLegion.PreferredRouteway != null) && (this.BelongedLegion.PreferredRouteway.LastActivePointIndex < 0)) ||
                            (((this.BelongedLegion.PreferredRouteway != null) && (this.BelongedLegion.PreferredRouteway.LastActivePoint != null)) &&
                                !this.BelongedLegion.PreferredRouteway.IsEnough(this.BelongedLegion.PreferredRouteway.LastActivePoint.ConsumptionRate, this.FoodCostPerDay))))
                    {
                        this.GoBack();
                        if (GameObject.Chance(50))
                        {
                            this.AttackTargetKind = TroopAttackTargetKind.无反;
                        }
                        else
                        {
                            this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                        }
                        return false;
                    }
                }
                //retreat if run out of crop
                if (this.BelongedLegion != null)
                {
                    if (this.Food < this.FoodCostPerDay && !this.StartingArchitecture.IsFoodEnough &&
                        (this.BelongedLegion.Kind == LegionKind.Offensive ||
                        (this.Morale <= 40 && this.BelongedLegion.Kind == LegionKind.Defensive && this.StartingArchitecture.Endurance > 30)))
                    {
                        this.GoBack();
                        this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                        this.WillTroop = null;
                        this.TargetTroop = null;
                        this.TargetArchitecture = null;
                        return false;
                    }
                }
                //earlier retreat if losing this troop is costly
                if (this.Army.IsFewScaleNeedRetreat && (this.BelongedLegion == null || this.BelongedLegion.Kind == LegionKind.Offensive ||
                        (this.BelongedLegion.Kind == LegionKind.Defensive && this.StartingArchitecture.Endurance > 30)))
                {
                    this.GoBack();
                    this.AttackTargetKind = TroopAttackTargetKind.无反默认;

                    return false;
                }
                //retreat if the other base become friendly and this legion is meant to be offensive
                if (this.BelongedLegion != null)
                {
                    if (!(this.IsFriendly(this.WillArchitecture.BelongedFaction) || (this.BelongedLegion.Kind != LegionKind.Defensive)))
                    {
                        this.GoBack();
                        this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                        return false;
                    }
                }
                //if
                //1. 10 + calmness chance, and
                //2. has hostile troop in view, and
                //3. the target arch does not belong to own faction, and
                //4. the target arch cannot see this troop
                //then retreat
                /*if (!(((!GameObject.Chance(10 + this.Leader.Calmness) || !this.HasHostileTroopInView()) 
                    || (this.WillArchitecture.BelongedFaction == this.BelongedFaction)) || this.WillArchitecture.ViewTroop(this)))
                {
                    this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                    return false;
                }*/
                //if
                //the target arch is not belong to own faction, and is friendly, and has hostile troops in view
                //then retreat
                if (!(((this.WillArchitecture.BelongedFaction == this.BelongedFaction) ||
                    !this.IsFriendly(this.WillArchitecture.BelongedFaction)) || this.WillArchitecture.HasHostileTroopsInView()))
                {
                    this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                    this.GoBack();
                    return false;
                }
                //retreat if the starting arch is under attack and cannot resist such attack, and enemy city does not seem to fall
                if (this.BelongedLegion != null)
                {
                    if (this.StartingArchitecture.TotalHostileForce > this.StartingArchitecture.TotalFriendlyForce * 1.2 && this.BelongedLegion.Kind == LegionKind.Offensive &&
                        !this.StartingArchitecture.GetFriendlyTroopsInView().GameObjects.Contains(this) &&
                        (this.WillArchitecture.Endurance >= 30 || this.StartingArchitecture.Endurance <= 30) && !this.IsTransport)
                    {
                        this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                        this.GoBack();
                        return false;
                    }
                }
                // retreat if anyone in the team is too tired
                foreach (Person p in this.Persons)
                {
                    if (p.TooTiredToBattle && GameObject.Chance(20))
                    {
                        this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                        this.GoBack();
                        return false;
                    }
                }
                //retreat if we were outnumbered, in an offensive
                int friendlyFightingForce = 0;
                int hostileFightingForce = 0;
                foreach (Point i in this.ViewArea.Area)
                {
                    Troop t = base.Scenario.GetTroopByPosition(i);
                    if (t != null)
                    {
                        if (!this.BelongedFaction.IsFriendly(t.BelongedFaction))
                        {
                            hostileFightingForce += t.FightingForce;
                            hostileTroopList.Add(t);
                        }
                        else if (t.BelongedFaction == this.BelongedFaction)
                        {
                            friendlyTroopList.Add(t); // 只包括当前视野内的同一势力部队,不包括同一军团但不在视野内的部队
                        }
                    }
                }
                if (this.BelongedLegion != null && this.BelongedLegion.Kind == LegionKind.Offensive && this.Army.KindID != 29)
                {
                    foreach (Troop i in this.BelongedLegion.Troops)
                    {
                        friendlyFightingForce += i.FightingForce;
                    }
                    float hostileToFriendlyRatio = (float)hostileFightingForce / friendlyFightingForce;
                    if (GameObject.Chance((int)((hostileToFriendlyRatio - 1) * 10)) &&
                        (GameObject.Chance((int)((this.Leader.Calmness - this.Leader.Braveness + 10) * 4 * hostileToFriendlyRatio)) &&
                        (GameObject.Chance((int)(((this.Experience + (this.Army.FollowedLeader != null ? 1000 : this.Army.LeaderExperience)) / 2000 + 10) * hostileToFriendlyRatio))) ||
                            !this.BelongedFaction.AvailableMilitaryKinds.GetMilitaryKindList().GameObjects.Contains(this.Army.Kind)))
                    {
                        this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                        this.GoBack();
                        return false;
                    }
                }
                if (this.Army.KindID == 29 || (!this.ViewingWillArchitecture && !this.HasHostileTroopInView()))
                {
                    Point newRealDestination = base.Scenario.GetClosestPoint(this.WillArchitecture.ArchitectureArea, this.Position);
                    int oldDistance = base.Scenario.GetSimpleDistance(this.position, this.RealDestination);
                    int newDistance = base.Scenario.GetSimpleDistance(this.position, newRealDestination);
                    if (oldDistance - newDistance >= 1 || oldDistance == 0)
                        this.RealDestination = newRealDestination;
                    return true; // 运输队或者没看到敌人就不需要计算后面的一大堆东西了
                }
                this.CallTacticsHelp();
                this.CallRoutewayHelp();
            }
            List<CreditPack> list = new List<CreditPack>();
            int credit = 0;
            bool flag = false;
            bool hasTargetTroopFlag = false;
            bool hasUnAttackableTroop = false;
            GameArea dayArea = this.ViewArea;
            if (this.BelongedLegion != null && this.BelongedLegion.Kind == LegionKind.Defensive)
            {
                foreach (Point p in this.StartingArchitecture.LongViewArea.Area)
                {
                    if (!dayArea.Area.Contains(p))
                    {
                        dayArea.AddPoint(p);
                    }
                }
            }
            /*GameArea dayArea = this.GetDayArea(1);
            if (dayArea.Count <= 10)
            {
                if (this.ViewArea.Count > 10)
                {
                    dayArea = this.ViewArea;
                }
                else
                {
                    dayArea = this.GetDayArea(2);
                    dayArea.AddPoint(this.Position);
                }
            }
            else
            {
                dayArea.AddPoint(this.Position);
            }*/

            // legion did not see will arch, do not see an enemy
            /*if (!this.IsRobber && !this.ViewingWillArchitecture && this.Army.Kind.Type != MilitaryType.水军 && this.Morale > 0x4b && this.BelongedLegion.Kind == LegionKind.Offensive && 
                this.WillArchitecture.BelongedFaction != this.BelongedFaction && !this.HasHostileTroopInView() && !this.BelongedLegion.HasTroopViewingWillArchitecture && 
                this.WillArchitecture.BelongedFaction != null)
            {
                foreach (Point point in dayArea.Area)
                {
                    moveCreditByPosition = this.GetMoveCreditByPosition(point);
                    if (moveCreditByPosition != null)
                    {
                        list.Add(moveCreditByPosition);
                        if (moveCreditByPosition.Credit > credit)
                        {
                            credit = moveCreditByPosition.Credit;
                        }
                    }
                }
            }*/
            this.OffenceOnlyBeforeMoveFlag = false;

            Dictionary<Point, CreditPack> positionCredits = new Dictionary<Point, CreditPack>();
            foreach (Point point in dayArea.Area)
            {
                positionCredits.Add(point, this.GetCreditByPosition(point));
            }

            foreach (Point point in dayArea.Area)
            {
                if (this.BelongedLegion == null || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0))
                {
                    moveCreditByPosition = positionCredits[point];
                    if (!hasTargetTroopFlag)
                    {
                        hasTargetTroopFlag = moveCreditByPosition.TargetTroop != null;
                    }
                    if (!hasUnAttackableTroop)
                    {
                        hasUnAttackableTroop = moveCreditByPosition.HasUnAttackableTroop;
                    }
                    if (moveCreditByPosition.Credit >= credit)
                    {
                        list.Add(moveCreditByPosition);
                        credit = moveCreditByPosition.Credit;
                    }
                }
            }
            Point? nullable = null;
            Point? nullable2 = null;
            base.Scenario.GetClosestPointsBetweenTwoAreas(dayArea, this.WillArchitecture.ArchitectureArea, out nullable, out nullable2);
            if ((this.CurrentStunt != null) || (GameObject.Random(this.Stunts.Count + 3) < 3))
            {
                if (hasTargetTroopFlag && ((credit < 500) || (GameObject.Chance(this.Combativity) && GameObject.Chance(80))))
                { //Label_0712:
                    foreach (CombatMethod method in this.CombatMethods.CombatMethods.Values)
                    {
                        if (!this.HasCombatMethod(method.ID))
                        {
                            continue;
                        }
                        if (method.SimulateApply(this))
                        {
                            this.SimulatingCombatMethod = method;
                            this.RefreshAllData();
                            foreach (Point point in dayArea.Area)
                            {
                                if (((!nullable.HasValue || hasTargetTroopFlag) || (nullable.Value == point)) && ((this.BelongedLegion == null) || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0)))
                                {
                                    moveCreditByPosition = positionCredits[point];
                                    moveCreditByPosition.CurrentCombatMethod = method;
                                    moveCreditByPosition.Credit -= method.Combativity;
                                    if (moveCreditByPosition.Credit >= credit)
                                    {
                                        list.Add(moveCreditByPosition);
                                        credit = moveCreditByPosition.Credit;
                                    }
                                }
                            }
                            method.SimulatePurify(this);
                            this.RefreshAllData();
                        }
                    }
                }
                if ((((this.Morale <= 90) || hasTargetTroopFlag) || ((hasUnAttackableTroop || GameObject.Chance(10)) || this.HasHostileArchitectureInView())) && ((credit < 500) || (GameObject.Chance(this.Combativity) && GameObject.Chance(30))))
                {
                    foreach (Stratagem stratagem in this.Stratagems.Stratagems.Values)
                    {
                        if (this.HasStratagem(stratagem.ID))
                        {
                            if (stratagem.Self)
                            {
                                moveCreditByPosition = this.GetSelfStratagemCredit(stratagem);
                                moveCreditByPosition.Credit -= stratagem.Combativity;
                                if (moveCreditByPosition.Credit >= credit)
                                {
                                    list.Add(moveCreditByPosition);
                                    credit = moveCreditByPosition.Credit;
                                    flag = true;
                                }
                            }
                            else
                            {
                                this.SetCurrentStratagem(stratagem);
                                if (stratagem.Friendly)
                                {
                                    foreach (Troop troop in friendlyTroopList)
                                    {
                                        moveCreditByPosition = this.GetStratagemCreditByPosition(stratagem, troop);
                                        moveCreditByPosition.Credit -= stratagem.Combativity;
                                        if (moveCreditByPosition.Credit >= credit)
                                        {
                                            list.Add(moveCreditByPosition);
                                            credit = moveCreditByPosition.Credit;
                                            flag = true;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (Troop troop in hostileTroopList)
                                    {
                                        moveCreditByPosition = this.GetStratagemCreditByPosition(stratagem, troop);
                                        moveCreditByPosition.Credit -= stratagem.Combativity;
                                        if (moveCreditByPosition.Credit >= credit)
                                        {
                                            list.Add(moveCreditByPosition);
                                            credit = moveCreditByPosition.Credit;
                                            flag = true;
                                        }
                                    }
                                }
                                this.SetCurrentStratagem(null);
                            }
                        }
                    }
                }
            }
            if (this.OffenceOnlyBeforeMove && ((credit <= 0) || ((credit < 100) && GameObject.Chance(100 - credit))))
            {
                this.OffenceOnlyBeforeMoveFlag = true;
                foreach (Point point in dayArea.Area)
                {
                    if ((this.BelongedLegion == null) || (this.BelongedLegion.TakenPositions.IndexOf(point) < 0))
                    {
                        moveCreditByPosition = positionCredits[point];
                        list.Add(moveCreditByPosition);
                        hasTargetTroopFlag = moveCreditByPosition.TargetTroop != null;
                        hasUnAttackableTroop = moveCreditByPosition.HasUnAttackableTroop;
                        if (moveCreditByPosition.Credit > credit)
                        {
                            credit = moveCreditByPosition.Credit;
                        }
                    }
                }
            }
            if (credit < 0)
            {
                this.AttackTargetKind = TroopAttackTargetKind.攻防皆弱默认;
                this.TargetTroop = null;
                this.TargetArchitecture = null;
                return false;
            }
            List<CreditPack> list2 = new List<CreditPack>();
            foreach (CreditPack pack2 in list)
            {
                if (pack2.Credit == credit)
                {
                    list2.Add(pack2);
                }
            }
            CreditPack pack3 = null;
            List<CreditPack> list3 = new List<CreditPack>();
            if (this.Army.Kind.AirOffence || flag)
            {
                double maxValue = double.MinValue;
                foreach (CreditPack pack2 in list2)
                {
                    if (pack2.Distance > maxValue)
                    {
                        maxValue = pack2.Distance;
                        list3.Clear();
                        list3.Add(pack2);
                    }
                    else if (pack2.Distance == maxValue)
                    {
                        list3.Add(pack2);
                    }
                }
            }
            else
            {
                double minValue = double.MaxValue;
                foreach (CreditPack pack2 in list2)
                {
                    if (pack2.Distance < minValue)
                    {
                        minValue = pack2.Distance;
                        list3.Clear();
                        list3.Add(pack2);
                    }
                    else if (pack2.Distance == minValue)
                    {
                        list3.Add(pack2);
                    }
                }
            }
            if (this.BelongedLegion == null || this.BelongedLegion.Kind == LegionKind.Offensive) // 当军团为进攻时在价值一样时选择最远的点
            {
                num4 = double.MinValue;
                foreach (CreditPack pack2 in list3)
                {
                    distance = base.Scenario.GetDistance(this.Position, pack2.Position);
                    if ((distance > num4) || (GameObject.Random(list3.Count) == 0))
                    {
                        num4 = distance;
                        pack3 = pack2;
                    }
                }
            }
            else // 当军团为防守时在价值一样时选择最近的点
            {
                num4 = double.MaxValue;
                foreach (CreditPack pack2 in list3)
                {
                    distance = base.Scenario.GetDistance(this.Position, pack2.Position);
                    if ((distance < num4) || (GameObject.Random(list3.Count) == 0))
                    {
                        num4 = distance;
                        pack3 = pack2;
                    }
                }
            }
            if (pack3 == null)
            {
                this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                this.GoBack();
                return false;
            }
            if (this.BelongedLegion != null)
            {
                this.BelongedLegion.TakenPositions.Add(pack3.Position);
            }
            if (pack3.CurrentCombatMethod != null)
            {
                this.SetCurrentCombatMethod(pack3.CurrentCombatMethod);
            }
            else if (pack3.CurrentStratagem != null)
            {
                this.SetCurrentStratagem(pack3.CurrentStratagem);
                if (pack3.CurrentStratagem.Self)
                {
                    this.SelfCastPosition = pack3.SelfCastPosition;
                }
            }
            if (pack3.TargetTroop != null)
            {
                if (this.CurrentCombatMethod == null)
                {
                    this.AttackDefaultKind = TroopAttackDefaultKind.防最弱;
                    this.AttackTargetKind = TroopAttackTargetKind.目标默认;
                }
                if (this.CurrentStratagem == null)
                {
                    this.CastTargetKind = TroopCastTargetKind.特定默认;
                }
                this.TargetTroop = pack3.TargetTroop;
                this.TargetArchitecture = null;
            }
            else if (pack3.TargetArchitecture != null)
            {
                this.AttackDefaultKind = TroopAttackDefaultKind.耐最低;
                this.AttackTargetKind = TroopAttackTargetKind.目标默认;
                this.CastTargetKind = TroopCastTargetKind.智低默认;
                this.TargetTroop = null;
                this.TargetArchitecture = pack3.TargetArchitecture;
            }
            else
            {
                this.AttackDefaultKind = TroopAttackDefaultKind.防最弱;
                this.AttackTargetKind = TroopAttackTargetKind.无反默认;
                this.CastTargetKind = TroopCastTargetKind.智低默认;
                this.TargetTroop = null;
                this.TargetArchitecture = null;
            }
            if (this.TargetTroop == null && this.TargetArchitecture == null)
            {
                Point newRealDestination = base.Scenario.GetClosestPoint(this.WillArchitecture.ArchitectureArea, this.Position);
                int oldDistance = base.Scenario.GetSimpleDistance(this.position, this.RealDestination);
                int newDistance = base.Scenario.GetSimpleDistance(this.position, newRealDestination);
                if (oldDistance - newDistance >= 1 || oldDistance == 0)
                    this.RealDestination = newRealDestination;
            }
            else
            {
                this.RealDestination = pack3.Position;
            }
            return true;
        }
Esempio n. 14
0
 private void troop_OnSetCombatMethod(Troop troop, CombatMethod combatMethod)
 {
     troop.Scenario.GameScreen.TroopSetCombatMethod(troop, combatMethod);
 }
Esempio n. 15
0
 private void troop_OnCombatMethodAttack(Troop sending, Troop receiving, CombatMethod combatMethod)
 {
     sending.Scenario.GameScreen.TroopCombatMethodAttack(sending, receiving, combatMethod);
 }
Esempio n. 16
0
 public List<string> LoadCombatMethodKind(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From CombatMethod", connection).ExecuteReader();
     while (reader.Read())
     {
         CombatMethod combatMethod = new CombatMethod();
         combatMethod.Scenario = scen;
         combatMethod.ID = (short)reader["ID"];
         combatMethod.Name = reader["Name"].ToString();
         combatMethod.Description = reader["Description"].ToString();
         combatMethod.Combativity = (short)reader["Combativity"];
         List<string> e = 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"];
         e.AddRange(combatMethod.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString()));
         if (e.Count > 0)
         {
             errorMsg.Add("战法ID" + combatMethod.ID);
             errorMsg.AddRange(e);
         }
         combatMethod.ViewingHostile = (bool)reader["ViewingHostile"];
         combatMethod.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
         this.AllCombatMethods.AddCombatMethod(combatMethod);
     }
     connection.Close();
     return errorMsg;
 }