• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TroopDetail.MilitaryKind类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中GameObjects.TroopDetail.MilitaryKind的典型用法代码示例。如果您正苦于以下问题:C# MilitaryKind类的具体用法?C# MilitaryKind怎么用?C# MilitaryKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MilitaryKind类属于GameObjects.TroopDetail命名空间,在下文中一共展示了MilitaryKind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Create

 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;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:26,代码来源:Military.cs


示例2: GetCostByPosition

 private int GetCostByPosition(Point position, bool oblique, int DirectionCost, MilitaryKind kind)
 {
     if (this.OnGetCost != null)
     {
         return this.OnGetCost(position, oblique, DirectionCost, kind);
     }
     return 0xdac;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:8,代码来源:TierPathFinder.cs


示例3: AddMilitaryKind

 public bool AddMilitaryKind(MilitaryKind militaryKind)
 {
     if (this.MilitaryKinds.ContainsKey(militaryKind.ID))
     {
         return false;
     }
     this.MilitaryKinds.Add(militaryKind.ID, militaryKind);
     return true;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:9,代码来源:MilitaryKindTable.cs


示例4: BuildFirstTierSimulatePath

 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;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:10,代码来源:TroopPathFinder.cs


示例5: BuildModifyFirstTierPath

 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;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:10,代码来源:TroopPathFinder.cs


示例6: CheckAdjacentSquares

 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);
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:11,代码来源:TierPathFinder.cs


示例7: BuildFirstTierPath

 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;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:18,代码来源:TroopPathFinder.cs


示例8: findSuccessorRecruitable_r

 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);
 }
开发者ID:hero1991,项目名称:ZhongHuaSanGuoZhi,代码行数:21,代码来源:MilitaryKind.cs


示例9: CanRecruitMilitary

 public bool CanRecruitMilitary(MilitaryKind mk)
 {
     crlm_recurse_level = 0;
     return CanRecruitLowerMilitary_r(mk);
 }
开发者ID:ptmaster,项目名称:ZhongHuaSanGuoZhi,代码行数:5,代码来源:Architecture.cs


示例10: SimCreate

 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;
 }
开发者ID:kpxp,项目名称:ZhongHuaSanGuoZhi-New-Code,代码行数:14,代码来源:Military.cs


示例11: MakeSquare

 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;
 }
开发者ID:kanjianlema,项目名称:ZhongHuaSanGuoZhi,代码行数:44,代码来源:TierPathFinder.cs


示例12: LoadFromDatabase


//.........这里部分代码省略.........
            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"];
开发者ID:ptmaster,项目名称:ZhongHuaSanGuoZhi,代码行数:67,代码来源:CommonData.cs


示例13: NextPositionCost

        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;
        }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:59,代码来源:Troop.cs


示例14: LoadMilitaryKind

        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"];
//.........这里部分代码省略.........
开发者ID:hero1991,项目名称:ZhongHuaSanGuoZhi,代码行数:101,代码来源:CommonData.cs


示例15: GetMapCost

 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);
 }
开发者ID:kanjianlema,项目名称:ZhongHuaSanGuoZhi,代码行数:22,代码来源:Faction.cs


示例16: GetSecondTierDestinationFromThirdTier

 public Point GetSecondTierDestinationFromThirdTier(MilitaryKind kind)
 {
     if (!LaunchThirdPathFinder(this.Position, this.Destination, kind))
     {
         return this.Destination;
     }
     return this.GetCentrePointInThirdTierPosition(this.GetThirdTierDestination());
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:8,代码来源:Troop.cs


示例17: LaunchThirdPathFinder

 public static bool LaunchThirdPathFinder(Point start, Point end, MilitaryKind kind)
 {
     return (GetDistance(start, end) > (GameObjectConsts.LaunchTierFinderDistance * GameObjectConsts.ThirdTierSquareSize));
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:4,代码来源:Troop.cs


示例18: ConstructTruePath

        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;

        }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:63,代码来源:Troop.cs


示例19: simplepathFinder_OnGetCost

 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;
 }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:17,代码来源:Troop.cs


示例20: BuildThreeTierPath

        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)
//.........这里部分代码省略.........
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:101,代码来源:Troop.cs



注:本文中的GameObjects.TroopDetail.MilitaryKind类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Serialization.Deserializer类代码示例发布时间:2022-05-26
下一篇:
C# GameObjects.TroopList类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap