Exemple #1
0
        public bool GetSecondTierPath(Point start, Point end, MilitaryKind kind)
        {
            this.troop.ClearSecondTierPath();
            if (end == this.troop.Destination)
            {
                this.troop.ClearThirdTierPath();
            }
            if (troop.BelongedFaction == null)
            {
                return(false);
            }
            Point point  = new Point(start.X / GameObjectConsts.SecondTierSquareSize, start.Y / GameObjectConsts.SecondTierSquareSize);
            Point point2 = new Point(end.X / GameObjectConsts.SecondTierSquareSize, end.Y / GameObjectConsts.SecondTierSquareSize);

            this.troop.SecondTierPath = this.troop.BelongedFaction.GetSecondTierKnownPath(point, point2);
            if (this.troop.SecondTierPath == null)
            {
                if (this.secondTierPathFinder.GetPath(point, point2, kind))
                {
                    this.troop.SecondTierPath = new List <Point>();
                    this.secondTierPathFinder.SetPath(this.troop.SecondTierPath);
                    this.troop.BelongedFaction.AddSecondTierKnownPath(this.troop.SecondTierPath);
                    return(true);
                }
                this.troop.Destination = this.troop.Position;
                this.troop.ClearThirdTierPath();
            }
            return(false);
        }
        public MilitaryKind GetMilitaryKind(int militaryKindID)
        {
            MilitaryKind kind = null;

            this.MilitaryKinds.TryGetValue(militaryKindID, out kind);
            return(kind);
        }
 public static Military Create(GameScenario scenario, Architecture architecture, MilitaryKind kind)
 {
     Military military = new Military();
     military.Scenario = scenario;
     military.KindID = kind.ID;
     military.ID = scenario.Militaries.GetFreeGameObjectID();
     if (kind.RecruitLimit == 1)
     {
         military.Name = kind.Name;
     }
     else
     {
         military.Name = kind.Name + "队";
     }
     architecture.AddMilitary(military);
     architecture.BelongedFaction.AddMilitary(military);
     scenario.Militaries.AddMilitary(military);
     architecture.DecreaseFund((int) (kind.CreateCost * kind.GetRateOfNewMilitary(architecture)));
     if (kind.IsTransport)
     {
         military.Quantity = kind.MaxScale;
         military.Morale = military.MoraleCeiling;
         military.Combativity = military.CombativityCeiling;
     }
     return military;
 }
Exemple #4
0
 public void FindFirstTierPath(Point start, Point end, List <Point> list, MilitaryKind kind)
 {
     this.Start = start;
     this.End   = end;
     this.troop.MovabilityLeft = this.troop.Movability;
     if (this.troop.GetPossibleMoveByPosition(end, kind) >= 0xdac)
     {
         if (this.movableAreaSearcher.Search(end, start, GameObjectConsts.FindMovableDestinationMaxCheckCount, kind))
         {
             if (this.CurrentDestination == this.End)
             {
                 this.troop.MovabilityLeft = -1;
                 return;
             }
             if (this.firstTierPathFinder.GetPath(this.Start, this.CurrentDestination, kind))
             {
                 this.firstTierPathFinder.SetPath(list);
             }
         }
         this.troop.MovabilityLeft = -1;
     }
     else
     {
         if (this.firstTierPathFinder.GetPath(this.Start, this.End, kind))
         {
             this.firstTierPathFinder.SetPath(list);
         }
         this.troop.MovabilityLeft = -1;
     }
 }
        public List <string> LoadFromString(MilitaryKindTable allMilitaryKinds, string militaryKindIDs)
        {
            List <string> errorMsg = new List <string>();

            char[]       separator = new char[] { ' ', '\n', '\r', '\t' };
            string[]     strArray  = militaryKindIDs.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            MilitaryKind kind      = null;

            try
            {
                for (int i = 0; i < strArray.Length; i++)
                {
                    if (allMilitaryKinds.MilitaryKinds.TryGetValue(int.Parse(strArray[i]), out kind))
                    {
                        this.AddMilitaryKind(kind);
                    }
                    else
                    {
                        errorMsg.Add("兵种ID" + int.Parse(strArray[i]) + "不存在");
                    }
                }
            }
            catch
            {
                errorMsg.Add("兵种一栏应为半型空格分隔的影响ID");
            }

            return(errorMsg);
        }
Exemple #6
0
 private int GetPenalizedCostByPosition(Point position, MilitaryKind kind)
 {
     if (this.OnGetPenalizedCost != null)
     {
         return(this.OnGetPenalizedCost(position, kind));
     }
     return(0);
 }
Exemple #7
0
 private int firstTierPathFinder_OnGetPenalizedCost(Point position, MilitaryKind kind)
 {
     if (Session.Current.Scenario.PositionOutOfRange(position))
     {
         return(0);
     }
     return(Session.Current.Scenario.PenalizedMapData[position.X, position.Y]);
 }
Exemple #8
0
 private int GetCostByPosition(Point position, bool oblique, MilitaryKind kind)
 {
     if (this.OnGetCost != null)
     {
         return(this.OnGetCost(position, oblique, kind));
     }
     return(0xdac);
 }
 private int GetCostByPosition(Point position, bool oblique, int DirectionCost, MilitaryKind kind)
 {
     if (this.OnGetCost != null)
     {
         return this.OnGetCost(position, oblique, DirectionCost, kind);
     }
     return 0xdac;
 }
 public bool AddMilitaryKind(MilitaryKind militaryKind)
 {
     if (this.MilitaryKinds.ContainsKey(militaryKind.ID))
     {
         return false;
     }
     this.MilitaryKinds.Add(militaryKind.ID, militaryKind);
     return true;
 }
 public bool AddMilitaryKind(MilitaryKind militaryKind)
 {
     if (this.MilitaryKinds.ContainsKey(militaryKind.ID))
     {
         return(false);
     }
     this.MilitaryKinds.Add(militaryKind.ID, militaryKind);
     return(true);
 }
 private List<Point> BuildFirstTierSimulatePath(Point start, Point end, MilitaryKind kind)
 {
     if (this.firstTierPathFinder.GetPath(start, end, kind))
     {
         List<Point> path = new List<Point>();
         this.firstTierPathFinder.SetPath(path);
         return path;
     }
     return null;
 }
 private bool BuildModifyFirstTierPath(Point start, Point end, List<Point> middlePath, MilitaryKind kind)
 {
     if (this.firstTierPathFinder.GetPath(start, end, kind))
     {
         this.firstTierPathFinder.SetPath(middlePath);
         return true;
     }
     middlePath = null;
     return false;
 }
Exemple #14
0
 private List <Point> BuildFirstTierSimulatePath(Point start, Point end, MilitaryKind kind)
 {
     if (this.firstTierPathFinder.GetPath(start, end, kind))
     {
         List <Point> path = new List <Point>();
         this.firstTierPathFinder.SetPath(path);
         return(path);
     }
     return(null);
 }
Exemple #15
0
        public GameArea GetDayArea(Troop troop, int Days)
        {
            GameArea area = new GameArea();

            openDictionary.Clear();
            openList.Clear();
            closeDictionary.Clear();
            closeList.Clear();
            GameSquare square = new GameSquare();

            square.Position = troop.Position;
            this.AddToCloseList(square);
            int num            = troop.Movability * Days;
            int movabilityLeft = troop.MovabilityLeft;

            //int num3 = troop.RealMovability * Days;
            troop.MovabilityLeft = num;
            MilitaryKind kind = troop.Army.Kind;

            do
            {
                CheckAdjacentSquares(square, troop.Position, false, kind);
                if (this.openList.Count == 0)
                {
                    break;
                }
                square = this.AddToCloseList();
                if (square == null)
                {
                    break;
                }
                if (num >= square.G)
                {
                    if (!troop.Scenario.PositionIsTroop(square.Position))
                    {
                        area.AddPoint(square.Position);
                    }
                }
                else
                {
                    break;
                }
                if (closeList.Count > 2500 || closeDictionary.Count > 2500)
                {
                    break;
                }
            } while (true);
            troop.MovabilityLeft = movabilityLeft;
            saveLastPath();
            openDictionary.Clear();
            openList.Clear();
            closeDictionary.Clear();
            closeList.Clear();
            return(area);
        }
 private void CheckAdjacentSquares(GameSquare currentSquare, Point end, bool useAStar, MilitaryKind kind)
 {
     int leftSquareCost = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X - 1, currentSquare.Position.Y), end, -1, useAStar, kind);
     int topSquareCost = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X, currentSquare.Position.Y - 1), end, -1, useAStar, kind);
     int rightSquareCost = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X + 1, currentSquare.Position.Y), end, -1, useAStar, kind);
     int bottomSquareCost = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X, currentSquare.Position.Y + 1), end, -1, useAStar, kind);
     this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X - 1, currentSquare.Position.Y - 1), end, (topSquareCost > leftSquareCost) ? topSquareCost : leftSquareCost, useAStar, kind);
     this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X - 1, currentSquare.Position.Y + 1), end, (bottomSquareCost > leftSquareCost) ? bottomSquareCost : leftSquareCost, useAStar, kind);
     this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X + 1, currentSquare.Position.Y - 1), end, (topSquareCost > rightSquareCost) ? topSquareCost : rightSquareCost, useAStar, kind);
     this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X + 1, currentSquare.Position.Y + 1), end, (bottomSquareCost > rightSquareCost) ? bottomSquareCost : rightSquareCost, useAStar, kind);
 }
Exemple #17
0
        public List <Point> GetSimplePath(Point start, Point end, MilitaryKind kind)
        {
            List <Point> path = new List <Point>();

            if (this.simplePathFinder.GetPath(start, end, kind))
            {
                path = new List <Point>();
                this.simplePathFinder.SetPath(path);
                return(path);
            }
            return(path);
        }
Exemple #18
0
 public bool GetPath(Point start, Point end, MilitaryKind kind)
 {
     if (Troop.LaunchThirdPathFinder(start, end, kind))
     {
         return(this.GetThirdTierPath(start, end, kind));
     }
     if (Troop.LaunchSecondPathFinder(start, end, kind))
     {
         return(this.GetSecondTierPath(start, end, kind));
     }
     return(this.GetFirstTierPath(start, end, kind));
 }
Exemple #19
0
 private bool movableAreaSearcher_OnCompare(Point position, MilitaryKind kind)
 {
     if (this.troop.GetPossibleMoveByPosition(position, kind) >= 0xdac)
     {
         return(false);
     }
     if (this.End == this.troop.Destination)
     {
         this.troop.Destination = position;
     }
     this.CurrentDestination = position;
     return(true);
 }
Exemple #20
0
 private void BtDelMiliKind_Click(object sender, RoutedEventArgs e)
 {
     for (int i = lbMiliKind.Items.Count - 1; i >= 0; i--)
     {
         CheckBox checkBox = lbMiliKind.Items[i] as CheckBox;
         if (checkBox.IsChecked == true)
         {
             GameObjects.TroopDetail.MilitaryKind militaryKind = checkBox.Content as GameObjects.TroopDetail.MilitaryKind;
             baseMilitaryKindstemp.RemoveMilitaryKind(militaryKind.ID);
             lbMiliKind.Items.Remove(lbMiliKind.Items[i]);
         }
     }
 }
        public void LoadFromString(MilitaryKindTable allMilitaryKinds, string militaryKindIDs)
        {
            char[]       separator = new char[] { ' ', '\n', '\r', '\t' };
            string[]     strArray  = militaryKindIDs.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            MilitaryKind kind      = null;

            for (int i = 0; i < strArray.Length; i++)
            {
                if (allMilitaryKinds.MilitaryKinds.TryGetValue(int.Parse(strArray[i]), out kind))
                {
                    this.AddMilitaryKind(kind);
                }
            }
        }
        public bool RemoveMilitaryKind(GameScenario scenario, int kind)
        {
            if (!this.MilitaryKinds.ContainsKey(kind))
            {
                return(false);
            }
            MilitaryKind militaryKind = scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(kind);

            if (militaryKind != null)
            {
                this.MilitaryKinds.Remove(militaryKind.ID);
            }
            return(true);
        }
Exemple #23
0
        public bool AddMilitaryKind(int kind)
        {
            if (this.MilitaryKinds.ContainsKey(kind))
            {
                return(false);
            }
            MilitaryKind militaryKind = Session.Current.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(kind);

            if (militaryKind != null)
            {
                this.MilitaryKinds.Add(kind, militaryKind);
            }
            return(true);
        }
Exemple #24
0
 public List <Point> GetFirstTierSimulatePath(Point start, Point end, MilitaryKind kind)
 {
     this.Start = start;
     this.End   = end;
     if (this.troop.GetPossibleMoveByPosition(end, kind) >= 0xdac)
     {
         if (this.movableAreaSearcher.Search(end, start, GameObjectConsts.FindMovableDestinationMaxCheckCount, kind))
         {
             return(this.BuildFirstTierSimulatePath(start, this.CurrentDestination, kind));
         }
         return(null);
     }
     return(this.BuildFirstTierSimulatePath(start, end, kind));
 }
Exemple #25
0
 private bool BuildFirstTierPath(Point start, Point end, MilitaryKind kind)
 {
     this.troop.ClearFirstTierPath();
     if (end == this.troop.Destination)
     {
         this.troop.ClearSecondTierPath();
     }
     if (this.firstTierPathFinder.GetPath(start, end, kind))
     {
         this.troop.FirstTierPath = new List <Point>();
         this.firstTierPathFinder.SetPath(this.troop.FirstTierPath);
     }
     else
     {
         this.troop.Destination = this.troop.Position;
     }
     return(true);
 }
 private bool BuildFirstTierPath(Point start, Point end, MilitaryKind kind)
 {
     this.troop.ClearFirstTierPath();
     if (end == this.troop.Destination)
     {
         this.troop.ClearSecondTierPath();
     }
     if (this.firstTierPathFinder.GetPath(start, end, kind))
     {
         this.troop.FirstTierPath = new List<Point>();
         this.firstTierPathFinder.SetPath(this.troop.FirstTierPath);
     }
     else
     {
         this.troop.Destination = this.troop.Position;
     }
     return true;
 }
Exemple #27
0
        public bool GetPath(Point start, Point end, MilitaryKind kind)
        {
            bool flag = false;

            openDictionary.Clear();
            openList.Clear();
            closeDictionary.Clear();
            closeList.Clear();
            GameSquare square = new GameSquare();

            square.Position = start;
            this.AddToCloseList(square);
            if (start == end)
            {
                lastPath = new List <Point>();
                lastPath.Add(start);
                return(true);
            }
            do
            {
                CheckAdjacentSquares(square, end, true, kind);
                if (this.openList.Count == 0)
                {
                    break;
                }
                square = this.AddToCloseList();
                if (square == null)
                {
                    break;
                }
                flag = square.Position == end;
                if (closeList.Count > 2500 || closeDictionary.Count > 2500)
                {
                    break;
                }
            }while (!flag && (square.RealG < 0xdac));
            saveLastPath();
            openDictionary.Clear();
            openList.Clear();
            closeDictionary.Clear();
            closeList.Clear();
            return(flag);
        }
Exemple #28
0
        public bool Search(Point start, Point direction, int MaxCheckCount, MilitaryKind kind)
        {
            this.startPosition     = start;
            this.directionPosition = direction;
            this.EnableDirection   = start != direction;
            bool flag = false;

            this.openDictionary.Clear();
            this.closeDictionary.Clear();
            this.openList.Clear();
            this.closeList.Clear();
            AreaSquare square = new AreaSquare();

            square.Position = start;
            this.AddToCloseList(square);
            int num = 0;

            do
            {
                this.CheckAdjacentSquares(square, kind);
                if (this.openList.Count == 0)
                {
                    break;
                }
                square = this.AddToCloseList();
                if (square == null)
                {
                    break;
                }
                if (this.OnCompare != null)
                {
                    flag = this.OnCompare(square.Position, kind);
                }
                else
                {
                    return(false);
                }
                num++;
            }while (!flag && (num < MaxCheckCount));
            return(flag);
        }
Exemple #29
0
 private void BtDelchrhi_Click(object sender, RoutedEventArgs e)
 {
     for (int i = lbMiliKind.Items.Count - 1; i >= 0; i--)
     {
         CheckBox checkBox = lbMiliKind.Items[i] as CheckBox;
         if (checkBox.IsChecked == true)
         {
             GameObjects.TroopDetail.MilitaryKind militaryKind = checkBox.Content as GameObjects.TroopDetail.MilitaryKind;
             baseMilitaryKindstemp.RemoveMilitaryKind(militaryKind.ID);
             lbMiliKind.Items.Remove(lbMiliKind.Items[i]);
         }
     }
     for (int i = lbArchis.Items.Count - 1; i >= 0; i--)
     {
         CheckBox checkBox = lbArchis.Items[i] as CheckBox;
         if (checkBox.IsChecked == true)
         {
             Architecture architecture = checkBox.Content as Architecture;
             if (architecture.Persons.HasGameObject(leadertemp))
             {
                 MessageBox.Show("无法删除" + architecture.Name + "," + faction.Name + "的君主" + leadertemp.Name + "在此城池中");
                 checkBox.IsChecked = false;
             }
             else
             {
                 architectureListtemp.Remove(architecture);
                 if (capitaltemp == architecture)
                 {
                     capitaltemp       = null;
                     btCapital.Content = capitaltemp;
                 }
                 lbArchis.Items.Remove(lbArchis.Items[i]);
             }
         }
     }
 }
Exemple #30
0
 private bool ModifyFirstTierPath(Point start, Point end, List <Point> middlePath, MilitaryKind kind)
 {
     this.Start = start;
     this.End   = end;
     if (this.troop.GetPossibleMoveByPosition(end, kind) >= 0xdac)
     {
         return(this.movableAreaSearcher.Search(end, start, GameObjectConsts.FindMovableDestinationMaxCheckCount, kind) && this.BuildModifyFirstTierPath(start, this.CurrentDestination, middlePath, kind));
     }
     return(this.BuildModifyFirstTierPath(start, end, middlePath, kind));
 }
        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;
        }
Exemple #32
0
        private void CheckAdjacentSquares(GameSquare currentSquare, Point end, bool useAStar, MilitaryKind kind)
        {
            int leftSquareCost   = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X - 1, currentSquare.Position.Y), end, -1, useAStar, kind);
            int topSquareCost    = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X, currentSquare.Position.Y - 1), end, -1, useAStar, kind);
            int rightSquareCost  = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X + 1, currentSquare.Position.Y), end, -1, useAStar, kind);
            int bottomSquareCost = this.MakeSquare(currentSquare, false, new Point(currentSquare.Position.X, currentSquare.Position.Y + 1), end, -1, useAStar, kind);

            this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X - 1, currentSquare.Position.Y - 1), end, (topSquareCost > leftSquareCost) ? topSquareCost : leftSquareCost, useAStar, kind);
            this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X - 1, currentSquare.Position.Y + 1), end, (bottomSquareCost > leftSquareCost) ? bottomSquareCost : leftSquareCost, useAStar, kind);
            this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X + 1, currentSquare.Position.Y - 1), end, (topSquareCost > rightSquareCost) ? topSquareCost : rightSquareCost, useAStar, kind);
            this.MakeSquare(currentSquare, true, new Point(currentSquare.Position.X + 1, currentSquare.Position.Y + 1), end, (bottomSquareCost > rightSquareCost) ? bottomSquareCost : rightSquareCost, useAStar, kind);
        }
 public bool CanRecruitMilitary(MilitaryKind mk)
 {
     crlm_recurse_level = 0;
     return CanRecruitLowerMilitary_r(mk);
 }
        public List<string> LoadMilitaryKind(OleDbConnection connection, GameScenario scen)
        {
            List<string> errorMsg = new List<string>();
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                List<string> e = new List<string>();

                MilitaryKind militaryKind = new MilitaryKind();
                militaryKind.Scenario = scen;
                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"];

                try
                {
                    militaryKind.ObtainProb = (int)reader["ObtainProb"];
                }
                catch
                {
                    militaryKind.ObtainProb = 0;
                }
                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"];
                StaticMethods.LoadFromString(militaryKind.LevelUpKindID, reader["LevelUpKindID"].ToString());
                militaryKind.LevelUpKindID.RemoveAll(i => i == -1);
                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"]);
                try
                {
                    militaryKind.MorphToKindId = (int)reader["MorphTo"];
                    militaryKind.MinCommand = (int)reader["MinCommand"];
                }
                catch
                {
                }

                e.AddRange(militaryKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()));
                if (e.Count > 0)
                {
                    errorMsg.Add("兵种ID" + militaryKind.ID);
                    errorMsg.AddRange(e);
                }

                try
                {
                    e.AddRange(militaryKind.CreateConditions.LoadFromString(this.AllConditions, reader["CreateConditions"].ToString()));
                }
                catch { }
                if (e.Count > 0)
                {
                    errorMsg.Add("称号ID" + militaryKind.ID);
                    errorMsg.AddRange(e);
                }

                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();
                List<string> e = current.successor.LoadFromString(this.AllMilitaryKinds, reader["Successor"].ToString());
                if (e.Count > 0)
                {
                    errorMsg.Add("兵种ID" + current.ID);
                    errorMsg.AddRange(e);
                }
            }
            connection.Close();
            return errorMsg;
        }
 public int GetMapCost(Troop troop, Point position, MilitaryKind kind)
 {
     if (base.Scenario.PositionOutOfRange(position))
     {
         return 0xdac;
     }
     if (base.Scenario.GetTerrainDetailByPositionNoCheck(position).RoutewayConsumptionRate >= 1)
     {
         return 0xdac;
     }
     int terrainAdaptability = 0;
     if (base.Scenario.GetArchitectureByPositionNoCheck(position) == null)
     {
         terrainAdaptability = troop.GetTerrainAdaptability((TerrainKind) this.mapData[position.X, position.Y]);
     }
     int waterPunishment = 0;
     if (this.mapData[position.X, position.Y] == 6 && kind.Type != MilitaryType.水军 && base.Scenario.GetArchitectureByPositionNoCheck(position) == null)
     {
         waterPunishment = 3;
     }
     return ((terrainAdaptability + base.Scenario.GetWaterPositionMapCost(kind.Type, position)) + base.Scenario.GetPositionMapCost(this, position) + waterPunishment);
 }
Exemple #36
0
 private int troopAreaSearcher_OnGetCost(Point position, bool oblique, MilitaryKind kind)
 {
     return(this.troop.GetCostByPosition(position, oblique, -1, kind));
 }
 public static Military SimCreate(GameScenario scenario, Architecture architecture, MilitaryKind kind)
 {
     Military military = new Military();
     military.Scenario = scenario;
     military.KindID = kind.ID;
     military.ID = scenario.Militaries.GetFreeGameObjectID();
     if (kind.RecruitLimit == 1)
     {
         military.Name = kind.Name;
         return military;
     }
     military.Name = kind.Name + "队";
     return military;
 }
        private MilitaryKind findSuccessorRecruitable_r(MilitaryKindList allMilitaryKinds, Architecture recruiter, MilitaryKind prev)
        {
            if (prev.successor.GetMilitaryKindList().Count == 0)
            {
                return(prev);
            }
            prev.findSuccessor_visited = true;
            MilitaryKindList toVisit = new MilitaryKindList();

            foreach (MilitaryKind i in prev.successor.GetMilitaryKindList())
            {
                if (!i.findSuccessor_visited && recruiter.GetNewMilitaryKindList().GameObjects.Contains(i) && allMilitaryKinds.GetList().GameObjects.Contains(i))
                {
                    toVisit.Add(i);
                }
            }
            if (toVisit.Count == 0)
            {
                return(prev);
            }
            return(findSuccessorRecruitable_r(allMilitaryKinds, recruiter, toVisit[GameObject.Random(toVisit.Count)] as MilitaryKind));
        }
Exemple #39
0
 private int simplePathFinder_OnGetCost(Point position, bool Oblique, int DirectionCost, MilitaryKind kind)
 {
     return(1);
 }
Exemple #40
0
 private int simplepathFinder_OnGetCost(Point position, bool Oblique, int DirectionCost, MilitaryKind kind)
 {
     int mapCost = this.GetMapCost(position, kind);
     mapCost = (DirectionCost > mapCost) ? DirectionCost : mapCost;
     if (Oblique)
     {
         if (this.Movability >= (mapCost * 7))
         {
             return 1;
         }
     }
     else if (this.Movability >= (mapCost * 5))
     {
         return 1;
     }
     return 0xdac;
 }
Exemple #41
0
        private int NextPositionCost(Point currentPosition, Point nextPosition, MilitaryKind kind)
        {
            int num = 0;
            int num2 = 0;
            int num3 = 0;
            switch ((nextPosition.X - currentPosition.X))
            {
                case -1:
                    switch ((nextPosition.Y - currentPosition.Y))
                    {
                        case -1:
                            num = this.GetCostByPosition(new Point(currentPosition.X - 1, currentPosition.Y), false, -1, kind);
                            num2 = this.GetCostByPosition(new Point(currentPosition.X, currentPosition.Y - 1), false, -1, kind);
                            return (this.GetCostByPosition(nextPosition, true, (num > num2) ? num : num2, kind) * 7);

                        case 0:
                            return (this.GetCostByPosition(nextPosition, false, -1, kind) * 5);

                        case 1:
                            num = this.GetCostByPosition(new Point(currentPosition.X - 1, currentPosition.Y), false, -1, kind);
                            num2 = this.GetCostByPosition(new Point(currentPosition.X, currentPosition.Y + 1), false, -1, kind);
                            return (this.GetCostByPosition(nextPosition, true, (num > num2) ? num : num2, kind) * 7);
                    }
                    return num3;

                case 0:
                    switch ((nextPosition.Y - currentPosition.Y))
                    {
                        case -1:
                            return (this.GetCostByPosition(nextPosition, false, -1, kind) * 5);

                        case 0:
                            return 0xdac;

                        case 1:
                            return (this.GetCostByPosition(nextPosition, false, -1, kind) * 5);
                    }
                    return num3;

                case 1:
                    switch ((nextPosition.Y - currentPosition.Y))
                    {
                        case -1:
                            num = this.GetCostByPosition(new Point(currentPosition.X + 1, currentPosition.Y), false, -1, kind);
                            num2 = this.GetCostByPosition(new Point(currentPosition.X, currentPosition.Y - 1), false, -1, kind);
                            return (this.GetCostByPosition(nextPosition, true, (num > num2) ? num : num2, kind) * 7);

                        case 0:
                            return (this.GetCostByPosition(nextPosition, false, -1, kind) * 5);

                        case 1:
                            num = this.GetCostByPosition(new Point(currentPosition.X + 1, currentPosition.Y), false, -1, kind);
                            num2 = this.GetCostByPosition(new Point(currentPosition.X, currentPosition.Y + 1), false, -1, kind);
                            return (this.GetCostByPosition(nextPosition, true, (num > num2) ? num : num2, kind) * 7);
                    }
                    return num3;
            }
            return num3;
        }
Exemple #42
0
 public static bool LaunchThirdPathFinder(Point start, Point end, MilitaryKind kind)
 {
     return (GetDistance(start, end) > (GameObjectConsts.LaunchTierFinderDistance * GameObjectConsts.ThirdTierSquareSize));
 }
Exemple #43
0
        private PathResult conflictionPathSearcher_OnCheckPosition(Point position, List <Point> middlePath, MilitaryKind kind)
        {
            TroopList list  = new TroopList();
            TroopList list2 = new TroopList();

            foreach (Troop troop in this.troop.BelongedFaction.KnownTroops.Values)
            {
                if (!troop.IsFriendly(this.troop.BelongedFaction))
                {
                    switch (this.troop.HostileAction)
                    {
                    case HostileActionKind.EvadeEffect:
                        if (troop.OffenceArea.HasPoint(position))
                        {
                            list.Add(troop);
                        }
                        break;

                    case HostileActionKind.EvadeView:
                        if (troop.ViewArea.HasPoint(position))
                        {
                            list.Add(troop);
                        }
                        break;
                    }
                }
                else if (troop.Position == position)
                {
                    list2.Add(troop);
                }
            }
            if ((list.Count > 0) || (list2.Count > 0))
            {
                bool flag = false;
                foreach (Troop troop in list)
                {
                    switch (this.troop.HostileAction)
                    {
                    case HostileActionKind.NotCare:
                        Session.Current.Scenario.SetPenalizedMapDataByPosition(troop.Position, 0xdac);
                        break;

                    case HostileActionKind.Attack:
                        Session.Current.Scenario.SetPenalizedMapDataByPosition(troop.Position, 0xdac);
                        break;

                    case HostileActionKind.EvadeEffect:
                        Session.Current.Scenario.SetPenalizedMapDataByArea(troop.OffenceArea, 1);
                        break;

                    case HostileActionKind.EvadeView:
                        Session.Current.Scenario.SetPenalizedMapDataByArea(troop.ViewArea, 1);
                        break;
                    }
                }

                /*foreach (Troop troop in list2)
                 * {
                 *  switch (this.troop.FriendlyAction)
                 *  {
                 *  }
                 * }*/
                flag = this.ModifyFirstTierPath(this.troop.Position, this.troop.FirstTierDestination, middlePath, kind);
                foreach (Troop troop in list)
                {
                    switch (this.troop.HostileAction)
                    {
                    case HostileActionKind.NotCare:
                        Session.Current.Scenario.ClearPenalizedMapDataByPosition(troop.Position);
                        break;

                    case HostileActionKind.Attack:
                        Session.Current.Scenario.ClearPenalizedMapDataByPosition(troop.Position);
                        break;

                    case HostileActionKind.EvadeEffect:
                        Session.Current.Scenario.ClearPenalizedMapDataByArea(troop.OffenceArea);
                        break;

                    case HostileActionKind.EvadeView:
                        Session.Current.Scenario.ClearPenalizedMapDataByArea(troop.ViewArea);
                        break;
                    }
                }

                /*foreach (Troop troop in list2)
                 * {
                 *  switch (this.troop.FriendlyAction)
                 *  {
                 *  }
                 * }*/
                if (flag)
                {
                    return(PathResult.Found);
                }
                return(PathResult.NotFound);
            }
            return(PathResult.Aborted);
        }
 private MilitaryKind findSuccessorRecruitable_r(MilitaryKindList allMilitaryKinds, Architecture recruiter, MilitaryKind prev)
 {
     if (prev.successor.GetMilitaryKindList().Count == 0)
     {
         return prev;
     }
     prev.findSuccessor_visited = true;
     MilitaryKindList toVisit = new MilitaryKindList();
     foreach (MilitaryKind i in prev.successor.GetMilitaryKindList())
     {
         if (!i.findSuccessor_visited && recruiter.GetNewMilitaryKindList().GameObjects.Contains(i) && allMilitaryKinds.GetList().GameObjects.Contains(i))
         {
             toVisit.Add(i);
         }
     }
     if (toVisit.Count == 0)
     {
         return prev;
     }
     return findSuccessorRecruitable_r(allMilitaryKinds, recruiter, toVisit[GameObject.Random(toVisit.Count)] as MilitaryKind);
 }
Exemple #45
0
 private int thirdTierPathFinder_OnGetCost(Point position, bool oblique, int DirectionCost, MilitaryKind kind)
 {
     return(this.troop.GetCostByThirdTierPosition(position));
 }
Exemple #46
0
        private bool ConstructTruePath(List<Point> reference, MilitaryKind kind)
        {
            int minDistance = int.MaxValue;
            Point closestPoint = reference[0];

            // find and go to reference path
            List<Point> onReference = new List<Point>(reference);
            int i = 0;
            foreach (Point p in reference)
            {
                int distance = base.Scenario.GetSimpleDistance(this.Position, p);
                if (distance < minDistance)
                {
                    minDistance = distance;
                    closestPoint = p;
                    onReference.RemoveRange(0, i + 1);
                    i = 0;
                }
                else
                {
                    i++;
                }
            }

            // create path from here to reference path
            List<Point> section;
            if (minDistance > 0)
            {
                this.pathFinder.GetFirstTierPath(this.Position, closestPoint, kind);
                if (this.FirstTierPath == null) return false;
                section = new List<Point>(this.FirstTierPath);
                section.AddRange(onReference);
            }
            else
            {
                section = new List<Point>();
                section.Add(this.Position);
                section.AddRange(onReference);
            }

            // create path from end of reference path to destination
            if (section[section.Count - 1] != this.Destination)
            {
                this.pathFinder.GetFirstTierPath(section[section.Count - 1], this.Destination, kind);
                if (this.FirstTierPath == null) return false;
                section.RemoveAt(section.Count - 1);
                this.FirstTierPath.InsertRange(0, section);
            }
            else
            {
                this.FirstTierPath = section;
            }

            this.FirstIndex = 0;

            this.SecondTierPath = null;
            this.ThirdTierPath = null;
            this.secondTierPathDestinationIndex = 0;
            this.thirdTierPathDestinationIndex = 0;

            return true;

        }
Exemple #47
0
        private bool BuildThreeTierPath(MilitaryKind kind)
        {
            bool path = false;
            if (!this.HasPath)
            {
                if (this.BelongedFaction != null && !base.Scenario.IsPlayer(this.BelongedFaction) && this.TargetArchitecture == null && !this.IsViewingWillArchitecture() &&
                    this.TargetTroop == null && this.BelongedLegion != null && this.BelongedLegion.Kind == LegionKind.Offensive)
                {
                    MilitaryKind trueKind = this.Army.KindID == 28 ? this.Army.RealMilitaryKind : this.Army.Kind;
                    List<Point> refPath = null;
                    bool aapUsable = this.StartingArchitecture.GetAllContactArea().Area.Contains(this.Position);
                    if (aapUsable && base.Scenario.pathCache.ContainsKey(new PathCacheKey(this.StartingArchitecture, this.WillArchitecture, trueKind)))
                    {
                        refPath = base.Scenario.pathCache[new PathCacheKey(this.StartingArchitecture, this.WillArchitecture, trueKind)];
                    }
                    if (refPath != null && refPath.Count > 0 && aapUsable)
                    {
                        path = ConstructTruePath(refPath, kind);
                    }
                    else if (refPath == null && (this.StartingArchitecture != this.WillArchitecture || !aapUsable))
                    {
                        Point? p1;
                        Point? p2;
                        // 出发建筑的点应该包括建筑邻近的点
                        GameArea startingArea = new GameArea();
                        foreach (Point p in this.StartingArchitecture.ContactArea.Area)
                            startingArea.AddPoint(p);
                        foreach (Point p in this.StartingArchitecture.ArchitectureArea.Area)
                            startingArea.AddPoint(p);
                        startingArea.Centre = this.StartingArchitecture.ArchitectureArea.Centre;

                        GameArea willArea = new GameArea();
                        foreach (Point p in this.WillArchitecture.ArchitectureArea.Area)
                            willArea.AddPoint(p);
                        willArea.Centre = this.WillArchitecture.ArchitectureArea.Centre;

                        base.Scenario.GetClosestPointsBetweenTwoAreas(startingArea, willArea, out p1, out p2);
                        if (p1.HasValue && p2.HasValue)
                        {
                            bool ftPath = this.pathFinder.GetFirstTierPath(p1.Value, p2.Value, kind);
                            if (ftPath)
                            {
                                if (this.FirstTierPath != null && this.FirstTierPath.Count > 0)
                                {
                                    // 去除多余的点
                                    int i = 0;
                                    while (startingArea.HasPoint(this.FirstTierPath[i]))
                                    {
                                        i++;
                                        if (i >= this.FirstTierPath.Count)
                                        {
                                            i = this.FirstTierPath.Count - 1;
                                            break;
                                        }
                                    }
                                    this.FirstTierPath.RemoveRange(0, i);
                                    i = this.FirstTierPath.Count - 1;
                                    while (willArea.HasPoint(this.FirstTierPath[i]))
                                    {
                                        i--;
                                        if (i < 0)
                                        {
                                            i = 0;
                                            break;
                                        }
                                    }
                                    this.FirstTierPath.RemoveRange(i + 1, this.FirstTierPath.Count - i - 1);

                                    if (aapUsable)
                                    {
                                        base.Scenario.pathCache[new PathCacheKey(this.StartingArchitecture, this.WillArchitecture, this.Army.Kind)] = this.FirstTierPath;
                                    }
                                    path = ConstructTruePath(this.FirstTierPath, kind);
                                }
                                else
                                {
                                    if (aapUsable)
                                    {
                                        base.Scenario.pathCache[new PathCacheKey(this.StartingArchitecture, this.WillArchitecture, this.Army.Kind)] = new List<Point>();
                                    }
                                }
                            }
                        }
                    }
                    else if (refPath == null || (refPath.Count == 0 && this.Army.Kind.Type != MilitaryType.水军))
                    {
                        this.StartingArchitecture.actuallyUnreachableArch.Add(this.WillArchitecture);
                        this.GoBack();
                        return false;
                    }
                }

                if (!path)
                {
                    this.EnableOneAdaptablility = true;
                    bool flag2 = false;
                    if ((this.BelongedFaction != null) && !GameObject.Chance(0x21))
                    {
                        flag2 = true;
                        foreach (Troop troop in this.BelongedFaction.Troops)
                        {
                            if (!((troop == this) || troop.Destroyed))
                            {
                                base.Scenario.SetPenalizedMapDataByPosition(troop.Position, this.RealMovability);
                            }
                        }
                    }
                    path = this.pathFinder.GetPath(this.Position, this.Destination, kind);
                    if ((this.BelongedFaction != null) && flag2)
                    {
                        foreach (Troop troop in this.BelongedFaction.Troops)
                        {
                            if (!((troop == this) || troop.Destroyed))
                            {
                                base.Scenario.ClearPenalizedMapDataByPosition(troop.Position);
                            }
                        }
                    }
                    this.EnableOneAdaptablility = false;
                    if ((this.ThirdTierPath != null) && (this.SecondTierPath == null))
                    {
                        if (!path)
                        {
                            path = this.pathFinder.GetSecondTierPath(this.Position, this.GetSecondTierDestinationFromThirdTier(kind), kind);
                        }
                        else
                        {
                            this.pathFinder.GetSecondTierPath(this.Position, this.GetSecondTierDestinationFromThirdTier(kind), kind);
                        }
                    }
                    if ((this.SecondTierPath != null) && (this.FirstTierPath == null))
                    {
                        if (!path)
                        {
                            path = this.pathFinder.GetFirstTierPath(this.Position, this.GetFirstTierDestinationFromSecondTier(kind), kind);
                        }
                        else
                        {
                            this.pathFinder.GetFirstTierPath(this.Position, this.GetFirstTierDestinationFromSecondTier(kind), kind);
                        }
                    }
                }
                if (this.FirstTierPath != null)
                {
                    if (this.FirstTierPath.Count > 1)
                    {
                        this.HasPath = true;
                    }
                    cannotFindRouteRounds = 0;
                    return path;
                }
                if (this.Status != TroopStatus.一般)
                {
                    cannotFindRouteRounds = 0;
                    return path;
                }
                if (((((this.BelongedFaction != null) && (this.BelongedLegion != null)) && ((this.BelongedLegion.Kind == LegionKind.Offensive) && (this.StartingArchitecture != null))) &&
                    (this.StartingArchitecture.BelongedFaction == this.BelongedFaction)) && this.StartingArchitecture.ViewTroop(this) && (this.BelongedLegion.Troops.Count == 1))
                {
                    Routeway existingRouteway = this.StartingArchitecture.GetExistingRouteway(this.BelongedLegion.WillArchitecture);
                    if (existingRouteway != null)
                    {
                        base.Scenario.RemoveRouteway(existingRouteway);
                    }
                    Point key = new Point(this.StartingArchitecture.ID, this.BelongedLegion.WillArchitecture.ID);
                    if (!this.BelongedFaction.ClosedRouteways.ContainsKey(key))
                    {
                        this.BelongedFaction.ClosedRouteways.Add(key, null);
                    }
                }
                if (this.CanEnter() && this.Army.Kind.Movability > 1)
                {
                    if (base.Scenario.IsPlayer(this.BelongedFaction) && this.TargetArchitecture != null)
                    {
                        if (this.mingling == "入城" && this.Position == this.minglingweizhi)
                        {
                            this.Enter(this.TargetArchitecture);
                        }
                    }
                    else
                    {
                        this.Enter();
                    }
                    cannotFindRouteRounds = 0;
                    return path;
                }
                if (cannotFindRouteRounds > 5)
                {
                    this.GoBack();
                }
                else
                {
                    cannotFindRouteRounds++;
                }
                if (this.OnPathNotFound != null)
                {
                    this.OnPathNotFound(this);
                }
            }
            return path;
        }
 private int MakeSquare(GameSquare currentSquare, bool oblique, Point position, Point end, int DirectionCost, bool useAStar, MilitaryKind kind)
 {
     int num = this.GetCostByPosition(position, oblique, DirectionCost, kind);
     if (!this.IsInCloseList(position) && (num < 0xdac))
     {
         GameSquare square = new GameSquare();
         int num2;
         if (oblique)
         {
             num2 = currentSquare.RealG + (7 * num);
         }
         else
         {
             num2 = currentSquare.RealG + (5 * num);
         }
         GameSquare squareFromOpenList = this.GetSquareFromOpenList(position);
         if (squareFromOpenList == null)
         {
             square.Parent = currentSquare;
             square.Position = position;
             square.PenalizedCost = this.GetPenalizedCostByPosition(position, kind);
             if (useAStar)
                 square.H = distance(position, end);
             square.RealG = num2;
             this.AddToOpenList(square, useAStar);
         }
         else if (num2 < squareFromOpenList.RealG)
         {
             openDictionary.Remove(position);
             if (useAStar)
                 openList.Remove(squareFromOpenList.F * 160000 + (squareFromOpenList.Position.X * 400 + squareFromOpenList.Position.Y));
             else
                 openList.Remove(squareFromOpenList.G * 160000 + (squareFromOpenList.Position.X * 400 + squareFromOpenList.Position.Y));
             square.Parent = currentSquare;
             square.Position = position;
             square.PenalizedCost = this.GetPenalizedCostByPosition(position, kind);
             if (useAStar)
                 square.H = distance(position, end);
             square.RealG = num2;
             this.AddToOpenList(square, useAStar);
         }
     }
     return num;
 }
Exemple #49
0
 private bool BuildModifyFirstTierPath(Point start, Point end, List <Point> middlePath, MilitaryKind kind)
 {
     if (this.firstTierPathFinder.GetPath(start, end, kind))
     {
         this.firstTierPathFinder.SetPath(middlePath);
         return(true);
     }
     middlePath = null;
     return(false);
 }
Exemple #50
0
 private bool CheckReLaunchPathFinder(MilitaryKind kind)
 {
     bool secondTierPath = false;
     if (((((this.SecondTierPath != null) && (this.ThirdTierPath != null)) && (this.SecondTierPath.Count > 0)) && ((this.Movability == this.MovabilityLeft) && (this.SecondTierPath[this.SecondTierPath.Count - 1] != GetSecondTierCoordinate(this.Destination)))) && ReLaunchSecondPathFinder(this.Position, this.GetCentrePointInThirdTierPosition(this.ThirdTierPath[this.thirdTierPathDestinationIndex])))
     {
         if (!secondTierPath)
         {
             secondTierPath = this.pathFinder.GetSecondTierPath(this.Position, this.GetSecondTierDestinationFromThirdTier(kind), kind);
         }
         else
         {
             this.pathFinder.GetSecondTierPath(this.Position, this.GetSecondTierDestinationFromThirdTier(kind), kind);
         }
     }
     if (((((this.FirstTierPath != null) && (this.SecondTierPath != null)) && (this.FirstTierPath.Count > 0)) && ((this.Movability == this.MovabilityLeft) && (this.FirstTierPath[this.FirstTierPath.Count - 1] != this.Destination))) && ReLaunchFirstPathFinder(this.Position, this.GetCentrePointInSecondTierPosition(this.SecondTierPath[this.secondTierPathDestinationIndex])))
     {
         if (!secondTierPath)
         {
             return this.pathFinder.GetFirstTierPath(this.Position, this.GetFirstTierDestinationFromSecondTier(kind), kind);
         }
         this.pathFinder.GetFirstTierPath(this.Position, this.GetFirstTierDestinationFromSecondTier(kind), kind);
     }
     return secondTierPath;
 }
 private int GetPenalizedCostByPosition(Point position, MilitaryKind kind)
 {
     if (this.OnGetPenalizedCost != null)
     {
         return this.OnGetPenalizedCost(position, kind);
     }
     return 0;
 }
Exemple #52
0
 public int GetCostByPosition(Point position, bool oblique, int DirectionCost, MilitaryKind kind)
 {
     //if ((this.Army.Kind.OneAdaptabilityKind > 0) && (this.Army.Kind.OneAdaptabilityKind != (int) base.Scenario.GetTerrainKindByPosition(position)))
     if ((kind.OneAdaptabilityKind > 0) && (kind.OneAdaptabilityKind != (int)base.Scenario.GetTerrainKindByPosition(position))
         && base.Scenario.GetArchitectureByPosition(position) == null)
     {
         return 1000;
     }
     int mapCost = this.GetMapCost(position, kind);
     mapCost = (DirectionCost > mapCost) ? DirectionCost : mapCost;
     if (oblique)
     {
         if (this.MovabilityLeft >= (mapCost * 7))
         {
             return mapCost;
         }
     }
     else if (this.MovabilityLeft >= (mapCost * 5))
     {
         return mapCost;
     }
     return 0xdac;
 }
 public bool GetPath(Point start, Point end, MilitaryKind kind)
 {
     bool flag = false;
     openDictionary.Clear();
     openList.Clear();
     closeDictionary.Clear();
     closeList.Clear();
     GameSquare square = new GameSquare();
     square.Position = start;
     this.AddToCloseList(square);
     if (start == end)
     {
         return true;
     }
     do
     {
         CheckAdjacentSquares(square, end, true, kind);
         if (this.openList.Count == 0)
         {
             break;
         }
         square = this.AddToCloseList();
         if (square == null)
         {
             break;
         }
         flag = square.Position == end;
         if (closeList.Count > 2500 || closeDictionary.Count > 2500) break;
     }
     while (!flag && (square.RealG < 0xdac));
     saveLastPath();
     openDictionary.Clear();
     openList.Clear();
     closeDictionary.Clear();
     closeList.Clear();
     return flag;
 }
Exemple #54
0
 private int GetMapCost(Point position, MilitaryKind kind)
 {
     if (this.BelongedFaction != null)
     {
         return this.BelongedFaction.GetMapCost(this, position, kind);
     }
     if (base.Scenario.PositionOutOfRange(position))
     {
         return 0xdac;
     }
     return ((this.GetTerrainAdaptability((TerrainKind)base.Scenario.ScenarioMap.MapData[position.X, position.Y]) + base.Scenario.GetWaterPositionMapCost(this.Army.Kind, position)) + base.Scenario.GetPositionMapCost(null, position));
 }
 private bool CanRecruitLowerMilitary_r(MilitaryKind mk)
 {
     MilitaryKind current;
     Dictionary<int, MilitaryKind>.ValueCollection.Enumerator enumerator;
     using (enumerator = this.BelongedFaction.AvailableMilitaryKinds.MilitaryKinds.Values.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             current = enumerator.Current;
             if (current == mk)
             {
                 return true;
             }
         }
     }
     using (enumerator = this.PrivateMilitaryKinds.MilitaryKinds.Values.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             current = enumerator.Current;
             if (current == mk)
             {
                 return true;
             }
         }
     }
     foreach (MilitaryKind i in base.Scenario.GameCommonData.AllMilitaryKinds.MilitaryKinds.Values)
     {
         if (i.LevelUpKindID == mk.ID)
         {
             crlm_recurse_level++;
             if (crlm_recurse_level > 50)
             {
                 return false;
             }
             if (CanRecruitLowerMilitary_r(i))
             {
                 return true;
             }
         }
     }
     return false;
 }
Exemple #56
0
 private bool GetPath(MilitaryKind kind)
 {
     bool flag = this.BuildThreeTierPath(kind);
     if (!this.HasPath)
     {
         return flag;
     }
     return this.CheckReLaunchPathFinder(kind);
 }
 public void CreateMilitary(MilitaryKind mk)
 {
     Military military = Military.Create(base.Scenario, this, mk);
     if (this.OnMilitaryCreate != null)
     {
         this.OnMilitaryCreate(this, military);
     }
     if (this.HasSpy)
     {
         this.AddMessageToTodayNewMilitarySpyMessage(military);
     }
 }
Exemple #58
0
 public int GetPossibleMoveByPosition(Point position, MilitaryKind kind)
 {
     if (((this.BelongedFaction == null) && this.ViewArea.HasPoint(position)) || ((this.BelongedFaction != null) && this.BelongedFaction.IsPositionKnown(position)))
     {
         Troop troopByPosition = base.Scenario.GetTroopByPosition(position);
         if ((troopByPosition != null) && !troopByPosition.IsFriendly(this.BelongedFaction))
         {
             return 0xdac;
         }
     }
     int mapCost = this.GetMapCost(position, kind);
     if (this.Movability >= (mapCost * 5))
     {
         return mapCost;
     }
     return 0xdac;
 }
 public override void ObtainMilitaryKind(Faction f, Person giver, MilitaryKind m)
 {
     if (base.Scenario.CurrentPlayer == f || GlobalVariables.SkyEye) 
     {
         giver.TextResultString = m.Name;
         this.Plugins.tupianwenziPlugin.SetGameObjectBranch(giver, null, "SpyMessageNewFacility");
         this.Plugins.tupianwenziPlugin.SetPosition(ShowPosition.Bottom);
         this.Plugins.tupianwenziPlugin.IsShowing = true;
     }
 }
Exemple #60
0
 public Point GetSecondTierDestinationFromThirdTier(MilitaryKind kind)
 {
     if (!LaunchThirdPathFinder(this.Position, this.Destination, kind))
     {
         return this.Destination;
     }
     return this.GetCentrePointInThirdTierPosition(this.GetThirdTierDestination());
 }