private static void CheckPoint(GameArea Area, List<Point> BlackAngles, Point point, GameScenario Scenario, Faction faction)
 {
     TerrainDetail terrainDetailByPosition = Scenario.GetTerrainDetailByPosition(point);
     if (terrainDetailByPosition != null)
     {
         if (terrainDetailByPosition.ViewThrough)
         {
             if (faction != null)
             {
                 Architecture architectureByPosition = Scenario.GetArchitectureByPosition(point);
                 if (!(architectureByPosition == null || architectureByPosition.Endurance <= 0 || faction.IsFriendlyWithoutTruce(architectureByPosition.BelongedFaction)))
                 {
                     BlackAngles.Add(point);
                     return;
                 }
             }
             if (!IsInBlackAngle(Area.Centre, BlackAngles, point))
             {
                 Area.AddPoint(point);
             }
         }
         else
         {
             BlackAngles.Add(point);
         }
     }
 }
Exemple #2
0
 public void RemoveArea(GameArea area)
 {
     foreach (Point point in area.Area)
     {
         this.Area.Remove(point);
     }
 }
Exemple #3
0
        private static void CheckPoint(GameArea Area, List <Point> BlackAngles, Point point, GameScenario Scenario, Faction faction)
        {
            TerrainDetail terrainDetailByPosition = Scenario.GetTerrainDetailByPosition(point);

            if (terrainDetailByPosition != null)
            {
                if (terrainDetailByPosition.ViewThrough)
                {
                    if (faction != null)
                    {
                        Architecture architectureByPosition = Scenario.GetArchitectureByPosition(point);
                        if (!(architectureByPosition == null || architectureByPosition.Endurance <= 0 || faction.IsFriendlyWithoutTruce(architectureByPosition.BelongedFaction)))
                        {
                            BlackAngles.Add(point);
                            return;
                        }
                    }
                    if (!IsInBlackAngle(Area.Centre, BlackAngles, point))
                    {
                        Area.AddPoint(point);
                    }
                }
                else
                {
                    BlackAngles.Add(point);
                }
            }
        }
 public override int GetCreditWithPosition(Troop source, out Point? position)
 {
     //position = 0;
     position = new Point(0, 0);
     TroopList hostileTroopsInView = source.GetHostileTroopsInView();
     TroopList list2 = new TroopList();
     foreach (Troop troop in hostileTroopsInView)
     {
         if ((troop.IsInArchitecture || !troop.DaysToReachPosition(source.Position, 1)) || (troop.Army.Kind.Type == MilitaryType.水军))
         {
             list2.Add(troop);
         }
     }
     foreach (Troop troop in list2)
     {
         hostileTroopsInView.Remove(troop);
     }
     if (hostileTroopsInView.Count == 0)
     {
         return 0;
     }
     List<Point> orientations = new List<Point>();
     int num = 0;
     foreach (Troop troop in hostileTroopsInView)
     {
         orientations.Add(troop.Position);
         num += troop.FightingForce;
     }
     int num2 = 0;
     int fightingForce = source.FightingForce;
     int num4 = source.TroopIntelligence + source.ChanceIncrementOfStratagem;
     if (num4 > 100)
     {
         num4 = 100;
     }
     num2 = (((GameObject.Square(num4) / 60) * num) / fightingForce) / 100;
     if (num2 > 0)
     {
         GameArea area = new GameArea();
         foreach (Point point in source.GetStratagemArea(source.Position).Area)
         {
             if (!source.Scenario.PositionIsOnFire(point) && (source.Scenario.IsPositionEmpty(point) && source.Scenario.IsFireVaild(point, false, MilitaryType.步兵)))
             {
                 area.Area.Add(point);
             }
         }
         if (area.Count > 0)
         {
             position = source.Scenario.GetClosestPosition(area, orientations);
         }
         else
         {
             num2 = 0;
         }
     }
     return num2;
 }
Exemple #5
0
 public void CombineArea(GameArea AreaToCombine, Dictionary <Point, object> ClosedList)
 {
     foreach (Point point in AreaToCombine.Area)
     {
         if (!ClosedList.ContainsKey(point))
         {
             ClosedList.Add(point, null);
         }
     }
 }
 public void CombineArea(GameArea AreaToCombine, Dictionary<Point, object> ClosedList)
 {
     foreach (Point point in AreaToCombine.Area)
     {
         if (!ClosedList.ContainsKey(point))
         {
             ClosedList.Add(point, null);
         }
     }
 }
Exemple #7
0
        public bool HasPointInArchitectureRoutewayStartArea(Architecture des)
        {
            GameArea routewayStartArea = des.GetRoutewayStartArea();

            foreach (Point point in routewayStartArea.Area)
            {
                if (this.GetNode(point) != null)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #8
0
        private void AddRoutePointArea(RoutePoint routePoint)
        {
            GameArea area = GameArea.GetViewArea(routePoint.Position, this.Radius, true, base.Scenario, this.BelongedFaction);

            foreach (Point point in area.Area)
            {
                if (!base.Scenario.PositionOutOfRange(point) && !this.RouteArea.ContainsKey(point))
                {
                    this.RouteArea.Add(point, routePoint);
                    base.Scenario.MapTileData[point.X, point.Y].AddSupplyingRoutePoint(routePoint);
                }
            }
        }
Exemple #9
0
 public GameArea(GameArea old)
 {
     this.Area   = new List <Point>(old.Area);
     this.Centre = new Point(old.Centre.X, old.Centre.Y);
     if (!old.topleft.HasValue)
     {
         this.topleft = null;
     }
     else
     {
         this.topleft = new Point(old.topleft.Value.X, old.topleft.Value.Y);
     }
 }
Exemple #10
0
        public bool EndedInArchitectureRoutewayStartArea(Architecture des)
        {
            GameArea routewayStartArea = des.GetRoutewayStartArea();

            foreach (Point point in routewayStartArea.Area)
            {
                if (this.LastPoint.Position == point)
                {
                    return(true);
                }
            }
            return(false);
        }
 public static GameArea GetAreaFromArea(GameArea area, int Radius, bool Oblique, GameScenario Scenario, Faction faction)
 {
     Dictionary<Point, object> closedList = new Dictionary<Point, object>();
     GameArea area2 = new GameArea();
     foreach (Point point in area.Area)
     {
         area2.CombineArea(GetViewArea(point, Radius, Oblique, Scenario, faction), closedList);
     }
     foreach (Point point in closedList.Keys)
     {
         area2.Area.Add(point);
     }
     return area2;
 }
Exemple #12
0
        private void RemoveRoutePointArea(RoutePoint routePoint)
        {
            GameArea area = GameArea.GetArea(routePoint.Position, this.Radius, true);

            foreach (Point point in area.Area)
            {
                RoutePoint point2 = null;
                this.RouteArea.TryGetValue(point, out point2);
                if (point2 == routePoint)
                {
                    this.RouteArea.Remove(point);
                    base.Scenario.MapTileData[point.X, point.Y].RemoveSupplyingRoutePoint(routePoint);
                }
            }
        }
        public static GameArea GetAreaFromArea(GameArea area, int Radius, bool Oblique, GameScenario Scenario, Faction faction)
        {
            Dictionary <Point, object> closedList = new Dictionary <Point, object>();
            GameArea area2 = new GameArea();

            foreach (Point point in area.Area)
            {
                area2.CombineArea(GetViewArea(point, Radius, Oblique, Scenario, faction), closedList);
            }
            foreach (Point point in closedList.Keys)
            {
                area2.Area.Add(point);
            }
            return(area2);
        }
 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;
 }
 public void ModifyAreaByTerrainAdaptablity(GameArea area)
 {
     for (int i = area.Count - 1; i >= 0; i--)
     {
         Architecture architectureByPosition = base.Scenario.GetArchitectureByPosition(area[i]);
         if (((architectureByPosition == null) || (this.BelongedFaction != architectureByPosition.BelongedFaction)) &&
             this.GetTerrainAdaptability(base.Scenario.GetTerrainKindByPosition(area[i])) > this.Kind.Movability)
         {
             area.Area.RemoveAt(i);
         }
         else if (base.Scenario.GetWaterPositionMapCost(this.Kind, area[i]) >= 0xdac)
         {
             area.Area.RemoveAt(i);
         }
     }
 }
Exemple #16
0
 public void DestinationToEnd()
 {
     if (((this.EndArchitecture == null) && (this.DestinationArchitecture != null)) && this.BelongedFaction.IsFriendly(this.DestinationArchitecture.BelongedFaction))
     {
         GameArea routewayStartArea = this.DestinationArchitecture.GetRoutewayStartArea();
         foreach (Point point in routewayStartArea.Area)
         {
             LinkedListNode <RoutePoint> node = this.GetNode(point);
             if (node != null)
             {
                 this.CutAt(node.Value.Position);
                 this.EndArchitecture = this.DestinationArchitecture;
             }
         }
     }
 }
Exemple #17
0
        public static GameArea GetAreaFromArea(GameArea area, int radius, bool oblique, GameScenario Scenario, Faction faction)
        {
            /*int longRadius;
             * if (area.Count <= 1)
             *  longRadius = radius;
             * else if (area.Count <= 5)
             *  longRadius = radius + 1;
             * else
             *  longRadius = radius + 2;
             * GameArea candidateArea = GetArea(area.Centre, longRadius, oblique);
             * if (longRadius >= (radius + 1))
             * {
             *  candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y - longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y + longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y - longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y + longRadius));
             * }
             * if (longRadius >= (radius + 2))
             * {
             *  candidateArea.Area.Remove(new Point(area.Centre.X - longRadius + 1, area.Centre.Y - longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y - longRadius + 1));
             *  candidateArea.Area.Remove(new Point(area.Centre.X - longRadius + 1, area.Centre.Y + longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X - longRadius, area.Centre.Y + longRadius - 1));
             *  candidateArea.Area.Remove(new Point(area.Centre.X + longRadius - 1, area.Centre.Y - longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y - longRadius + 1));
             *  candidateArea.Area.Remove(new Point(area.Centre.X + longRadius - 1, area.Centre.Y + longRadius));
             *  candidateArea.Area.Remove(new Point(area.Centre.X + longRadius, area.Centre.Y + longRadius - 1));
             * }
             * return candidateArea;*/
            Dictionary <Point, object> closedList = new Dictionary <Point, object>();
            GameArea area2 = new GameArea();

            foreach (Point point in area.Area)
            {
                area2.CombineArea(GetViewArea(point, radius, oblique, Scenario, faction), closedList);
            }
            foreach (Point point in closedList.Keys)
            {
                area2.Area.Add(point);
            }
            return(area2);
        }
Exemple #18
0
        public bool IsActiveInArea(GameArea area, out float minRate)
        {
            minRate = 1f;
            bool flag = false;
            LinkedListNode <RoutePoint> activeNode = null;

            foreach (Point point in area.Area)
            {
                activeNode = this.GetActiveNode(point);
                if (activeNode != null)
                {
                    flag = true;
                    if (activeNode.Value.ConsumptionRate < minRate)
                    {
                        minRate = activeNode.Value.ConsumptionRate;
                    }
                }
            }
            return(flag);
        }
 public static GameArea GetArea(Point Centre, int Radius, bool Oblique)
 {
     GameArea area = new GameArea();
     List<float> list = new List<float>();
     area.Centre = Centre;
     for (int i = -Radius; i <= Radius; i++)
     {
         for (int j = -Radius; j <= Radius; j++)
         {
             if (Oblique)
             {
                 area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
             }
             else if ((Math.Abs(i) + Math.Abs(j)) <= Radius)
             {
                 area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
             }
         }
     }
     return area;
 }
        public static GameArea GetArea(Point Centre, int Radius, bool Oblique)
        {
            GameArea     area = new GameArea();
            List <float> list = new List <float>();

            area.Centre = Centre;
            for (int i = -Radius; i <= Radius; i++)
            {
                for (int j = -Radius; j <= Radius; j++)
                {
                    if (Oblique)
                    {
                        area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
                    }
                    else if ((Math.Abs(i) + Math.Abs(j)) <= Radius)
                    {
                        area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
                    }
                }
            }
            return(area);
        }
Exemple #21
0
        public static GameArea GetArea(Point Centre, int Radius, bool Oblique)
        {
            GameArea     area = new GameArea();
            List <float> list = new List <float>();

            area.Centre = Centre;
            if (Oblique)
            {
                for (int i = Centre.X - Radius; i <= Centre.X + Radius; i++)
                {
                    for (int j = Centre.Y - Radius; j <= Centre.Y + Radius; j++)
                    {
                        area.AddPoint(new Point(i, j));
                    }
                }
            }
            else
            {
                for (int i = -Radius; i <= Radius; i++)
                {
                    if (i <= 0)
                    {
                        for (int j = -Radius - i; j <= i + Radius; j++)
                        {
                            area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
                        }
                    }
                    else
                    {
                        for (int j = i - Radius; j <= Radius - i; j++)
                        {
                            area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
                        }
                    }
                }
            }
            return(area);
        }
 public static GameArea GetArea(Point Centre, int Radius, bool Oblique)
 {
     GameArea area = new GameArea();
     List<float> list = new List<float>();
     area.Centre = Centre;
     if (Oblique)
     {
         for (int i = Centre.X - Radius; i <= Centre.X + Radius; i++)
         {
             for (int j = Centre.Y - Radius; j <= Centre.Y + Radius; j++)
             {
                 area.AddPoint(new Point(i, j));
             }
         }
     }
     else
     {
         for (int i = -Radius; i <= Radius; i++)
         {
             if (i <= 0)
             {
                 for (int j = -Radius - i; j <= i + Radius; j++)
                 {
                     area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
                 }
             }
             else
             {
                 for (int j = i - Radius; j <= Radius - i; j++)
                 {
                     area.AddPoint(new Point(Centre.X + i, Centre.Y + j));
                 }
             }
         }
     }
     return area;
 }
Exemple #23
0
        public static GameArea GetViewArea(Point Centre, int Radius, bool Oblique, GameScenario Scenario, Faction faction)
        {
            GameArea     area        = new GameArea();
            List <Point> blackAngles = new List <Point>();

            area.Centre = Centre;
            if (Radius < 0)
            {
                return(area);
            }
            if (Radius == 0)
            {
                area.AddPoint(Centre);
                return(area);
            }
            for (int i = 0; i <= Radius; i++)
            {
                int num2;
                if (i == 0)
                {
                    num2 = 0;
                    while (num2 <= Radius)
                    {
                        if (num2 != 0)
                        {
                            CheckPoint(area, blackAngles, new Point(Centre.X, Centre.Y + num2), Scenario, faction);
                            CheckPoint(area, blackAngles, new Point(Centre.X, Centre.Y - num2), Scenario, faction);
                        }
                        else
                        {
                            area.AddPoint(Centre);
                        }
                        num2++;
                    }
                }
                else
                {
                    int num3 = i;
                    if (Oblique)
                    {
                        num3 = 0;
                    }
                    num2 = 0;
                    while (num2 <= (Radius - num3))
                    {
                        CheckPoint(area, blackAngles, new Point(Centre.X + i, Centre.Y + num2), Scenario, faction);
                        if (num2 != 0)
                        {
                            CheckPoint(area, blackAngles, new Point(Centre.X + i, Centre.Y - num2), Scenario, faction);
                        }
                        num2++;
                    }
                    for (num2 = 0; num2 <= (Radius - num3); num2++)
                    {
                        CheckPoint(area, blackAngles, new Point(Centre.X - i, Centre.Y + num2), Scenario, faction);
                        if (num2 != 0)
                        {
                            CheckPoint(area, blackAngles, new Point(Centre.X - i, Centre.Y - num2), Scenario, faction);
                        }
                    }
                }
            }

            return(area);
        }
 private void screen_OnMouseMove(Point position, bool leftDown)
 {
     if (this.screen.EnableSelecting && (this.screen.ViewMoveDirection == ViewMove.Stop))
     {
         Point point = this.mainMapLayer.TranslateCoordinateToTilePosition(position.X, position.Y);
         if (!this.screen.Scenario.PositionOutOfRange(point))
         {
             if (this.SelectedPoint != point)
             {
                 this.effectingArea = null;
             }
             this.SelectedPoint = point;
         }
     }
 }
Exemple #25
0
 public bool IsActiveInArea(GameArea area, out float minRate)
 {
     minRate = 1f;
     bool flag = false;
     LinkedListNode<RoutePoint> activeNode = null;
     foreach (Point point in area.Area)
     {
         activeNode = this.GetActiveNode(point);
         if (activeNode != null)
         {
             flag = true;
             if (activeNode.Value.ConsumptionRate < minRate)
             {
                 minRate = activeNode.Value.ConsumptionRate;
             }
         }
     }
     return flag;
 }
 public void SetLongViewArea(GameArea area)
 {
     this.longViewArea = area;
 }
 public bool HasRelationUnderZeroHostileTroopsInView()
 {
     if (this.BelongedFaction != null)
     {
         GameArea viewArea = this.ViewArea;
         if (this.Kind.HasLongView && (this.ArmyScale < this.NormalArmyScale))
         {
             viewArea = this.LongViewArea;
         }
         foreach (Point point in viewArea.Area)
         {
             Troop troopByPosition = base.Scenario.GetTroopByPosition(point);
             if ((((troopByPosition != null) && (troopByPosition.BelongedFaction != null)) && (troopByPosition.Status != TroopStatus.埋伏)) && (base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, troopByPosition.BelongedFaction.ID) < 0))
             {
                 return true;
             }
         }
     }
     return false;
 }
 public GameArea GetTroopEnterableArea(Troop troop)
 {
     GameArea area = new GameArea();
     foreach (Point point in this.ArchitectureArea.Area)
     {
         if (base.Scenario.GetWaterPositionMapCost(troop.Army.Kind.Type, point) < 3500)
         {
             area.AddPoint(point);
         }
     }
     foreach (Point point in this.ContactArea.Area)
     {
         if (troop.IsMovableOnPosition(point) && (base.Scenario.GetWaterPositionMapCost(troop.Army.Kind.Type, point) < 3500))
         {
             area.AddPoint(point);
         }
     }
     return area;
 }
 public GameArea GetRoutewayStartPoints()
 {
     GameArea area = new GameArea();
     foreach (Point point in this.GetRoutewayStartArea().Area)
     {
         if (this.IsRoutewayPossible(point))
         {
             area.AddPoint(point);
         }
     }
     if (area.Count == 0)
     {
         foreach (Point point in this.ContactArea.Area)
         {
             if (this.IsRoutewayPossible(point))
             {
                 area.AddPoint(point);
             }
         }
     }
     if (area.Count == 0)
     {
         foreach (Point point in this.LongViewArea.Area)
         {
             if (this.IsRoutewayPossible(point))
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }
 public GameArea GetAvailableContactArea(bool Square)
 {
     GameArea area = new GameArea();
     foreach (Point point in this.ContactArea.Area)
     {
         if (base.Scenario.IsPositionEmpty(point))
         {
             area.AddPoint(point);
         }
     }
     if (area.Count > 0)
     {
         return area;
     }
     return null;
 }
 public GameArea GetAllContactArea()
 {
     GameArea area = new GameArea();
     foreach (Point point in this.ContactArea.Area)
     {
         area.AddPoint(point);
     }
     foreach (Point point in this.ArchitectureArea.Area)
     {
         area.AddPoint(point);
     }
     return area;
 }
Exemple #32
0
        public void ApplyEventEffects(Troop self)
        {
            if (((self != null) && !self.Destroyed) && (!this.Happened || this.Repeatable))
            {
                Troop troopByPositionNoCheck;
                this.Happened = true;
                TroopList list = new TroopList();
                if (this.SelfEffects.Count > 0)
                {
                    list.Add(self);
                    foreach (GameObjects.TroopDetail.EventEffect.EventEffect effect in this.SelfEffects)
                    {
                        effect.ApplyEffect(self.Leader);
                    }
                }
                foreach (TroopEffectPerson person in this.EffectPersons)
                {
                    person.Effect.ApplyEffect(person.EffectPerson);
                    if ((person.EffectPerson.LocationTroop != null) && (list.GetGameObject(person.EffectPerson.LocationTroop.ID) == null))
                    {
                        list.Add(person.EffectPerson.LocationTroop);
                    }
                }
                List <TroopEffectArea> list2 = new List <TroopEffectArea>();
                List <TroopEffectArea> list3 = new List <TroopEffectArea>();
                List <TroopEffectArea> list4 = new List <TroopEffectArea>();
                foreach (TroopEffectArea area in this.EffectAreas)
                {
                    switch (area.Kind)
                    {
                    case EffectAreaKind.视野敌军:
                        list2.Add(area);
                        break;

                    case EffectAreaKind.视野友军:
                        list2.Add(area);
                        break;

                    case EffectAreaKind.八格敌军:
                        list3.Add(area);
                        break;

                    case EffectAreaKind.八格友军:
                        list3.Add(area);
                        break;

                    case EffectAreaKind.攻击范围敌军:
                        list4.Add(area);
                        break;

                    case EffectAreaKind.攻击范围友军:
                        list4.Add(area);
                        break;
                    }
                }
                foreach (TroopEffectArea area in list2)
                {
                    foreach (Point point in self.BaseViewArea.Area)
                    {
                        if (self.BelongedFaction.IsPositionKnown(point))
                        {
                            troopByPositionNoCheck = Session.Current.Scenario.GetTroopByPositionNoCheck(point);
                            if (troopByPositionNoCheck != null)
                            {
                                switch (area.Kind)
                                {
                                case EffectAreaKind.视野敌军:
                                    if (!self.IsFriendly(troopByPositionNoCheck.BelongedFaction))
                                    {
                                        area.Effect.ApplyEffect(troopByPositionNoCheck.Leader);
                                    }
                                    break;

                                case EffectAreaKind.视野友军:
                                    if (self.IsFriendly(troopByPositionNoCheck.BelongedFaction))
                                    {
                                        area.Effect.ApplyEffect(troopByPositionNoCheck.Leader);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                foreach (TroopEffectArea area in list3)
                {
                    foreach (Point point in GameArea.GetArea(self.Position, 1, true).Area)
                    {
                        if (self.BelongedFaction.IsPositionKnown(point))
                        {
                            troopByPositionNoCheck = Session.Current.Scenario.GetTroopByPositionNoCheck(point);
                            if (troopByPositionNoCheck != null)
                            {
                                switch (area.Kind)
                                {
                                case EffectAreaKind.八格敌军:
                                    if (!self.IsFriendly(troopByPositionNoCheck.BelongedFaction))
                                    {
                                        area.Effect.ApplyEffect(troopByPositionNoCheck.Leader);
                                    }
                                    break;

                                case EffectAreaKind.八格友军:
                                    if (self.IsFriendly(troopByPositionNoCheck.BelongedFaction))
                                    {
                                        area.Effect.ApplyEffect(troopByPositionNoCheck.Leader);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                foreach (TroopEffectArea area in list4)
                {
                    //Label_0539:
                    foreach (Point point in self.OffenceArea.Area)
                    {
                        if (!self.BelongedFaction.IsPositionKnown(point))
                        {
                            continue;
                        }
                        troopByPositionNoCheck = Session.Current.Scenario.GetTroopByPositionNoCheck(point);
                        if (troopByPositionNoCheck != null)
                        {
                            switch (area.Kind)
                            {
                            case EffectAreaKind.攻击范围敌军:
                                if (!self.IsFriendly(troopByPositionNoCheck.BelongedFaction))
                                {
                                    area.Effect.ApplyEffect(troopByPositionNoCheck.Leader);
                                }
                                break;

                            case EffectAreaKind.攻击范围友军:
                                if (self.IsFriendly(troopByPositionNoCheck.BelongedFaction))
                                {
                                    area.Effect.ApplyEffect(troopByPositionNoCheck.Leader);
                                }
                                break;
                            }
                        }
                    }
                }
                foreach (Troop troop in list)
                {
                    Troop.CheckTroopRout(troop);
                }
            }
        }
Exemple #33
0
        public bool CheckTroop(Troop troop)
        {
            if (!this.Happened || this.Repeatable)
            {
                if (!((this.AfterHappenedEvent == null) || this.AfterHappenedEvent.Happened))
                {
                    return(false);
                }
                if (!GameObject.Chance(this.HappenChance))
                {
                    return(false);
                }
                if ((this.LaunchPerson == null) || troop.Persons.HasGameObject(this.LaunchPerson))
                {
                    if (!this.CheckCondition(troop))
                    {
                        return(false);
                    }
                    if (this.TargetPersons.Count <= 0)
                    {
                        return(true);
                    }
                    GameArea baseViewArea = null;
                    switch (this.CheckArea)
                    {
                    case EventCheckAreaKind.视野:
                        baseViewArea = troop.BaseViewArea;
                        break;

                    case EventCheckAreaKind.八格:
                        baseViewArea = GameArea.GetArea(troop.Position, 1, true);
                        break;

                    case EventCheckAreaKind.攻击范围:
                        baseViewArea = troop.OffenceArea;
                        break;
                    }
                    if (baseViewArea != null)
                    {
                        int num = 0;
                        foreach (Point point in baseViewArea.Area)
                        {
                            if (troop.BelongedFaction != null)
                            {
                                if (troop.BelongedFaction.IsPositionKnown(point))
                                {
                                    Troop troopByPositionNoCheck = Session.Current.Scenario.GetTroopByPositionNoCheck(point);
                                    if (troopByPositionNoCheck != null)
                                    {
                                        foreach (PersonRelation relation in this.TargetPersons)
                                        {
                                            if (((relation.Relation == PersonRelationKind.友好) == troop.IsFriendly(troopByPositionNoCheck.BelongedFaction)) && troopByPositionNoCheck.Persons.HasGameObject(relation.SpeakingPerson))
                                            {
                                                num++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        return(num == this.TargetPersons.Count);
                    }
                }
            }
            return(false);
        }
Exemple #34
0
        public GameArea GetContactArea(bool oblique, GameScenario scen, bool waterOnly, bool landOnly)
        {
            GameArea area = new GameArea();
            Dictionary <Point, object> dictionary = new Dictionary <Point, object>();

            foreach (Point point2 in this.Area)
            {
                bool ok = true;
                if (waterOnly && scen.GetTerrainDetailByPositionNoCheck(point2).ID != 6)
                {
                    ok = false;
                }
                if (landOnly && scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6)
                {
                    ok = false;
                }
                if (ok)
                {
                    dictionary.Add(point2, null);
                }
            }
            foreach (Point point2 in this.Area)
            {
                Point key = new Point(point2.X - 1, point2.Y);
                if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                {
                    dictionary.Add(key, null);
                    area.AddPoint(key);
                }
                key = new Point(point2.X + 1, point2.Y);
                if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                {
                    dictionary.Add(key, null);
                    area.AddPoint(key);
                }
                key = new Point(point2.X, point2.Y - 1);
                if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                {
                    dictionary.Add(key, null);
                    area.AddPoint(key);
                }
                key = new Point(point2.X, point2.Y + 1);
                if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                {
                    dictionary.Add(key, null);
                    area.AddPoint(key);
                }
                if (oblique)
                {
                    key = new Point(point2.X - 1, point2.Y - 1);
                    if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                    {
                        dictionary.Add(key, null);
                        area.AddPoint(key);
                    }
                    key = new Point(point2.X + 1, point2.Y - 1);
                    if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                    {
                        dictionary.Add(key, null);
                        area.AddPoint(key);
                    }
                    key = new Point(point2.X - 1, point2.Y + 1);
                    if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                    {
                        dictionary.Add(key, null);
                        area.AddPoint(key);
                    }
                    key = new Point(point2.X + 1, point2.Y + 1);
                    if (!dictionary.ContainsKey(key) && (!waterOnly || scen.GetTerrainDetailByPositionNoCheck(point2).ID == 6))
                    {
                        dictionary.Add(key, null);
                        area.AddPoint(key);
                    }
                }
            }
            return(area);
        }
        public GameArea GetPersonTransferArchitectureArea()
        {
            GameArea area = new GameArea();

            foreach (Architecture architecture in this.BelongedFaction.Architectures)
            {

                if (architecture == this)
                {
                    continue;
                }

                foreach (Point point in architecture.ArchitectureArea.Area)
                {
                    area.AddPoint(point);
                }

            }
            return area;
        }
 public GameArea GetRealTroopEnterableArea(Troop troop)
 {
     GameArea area = new GameArea();
     foreach (Point point in this.GetTroopEnterableArea(troop).Area)
     {
         //if (!base.Scenario.PositionIsTroop(point))
         //{
         area.AddPoint(point);
         //}
     }
     return area;
 }
 public Point? GetCampaignPosition(Troop troop, List<Point> orientations, bool close)
 {
     GameArea allAvailableArea = this.GetAllAvailableArea(false);
     GameArea sourceArea = new GameArea();
     foreach (Point point in allAvailableArea.Area)
     {
         if ((base.Scenario.GetArchitectureByPosition(point) == this || troop.IsMovableOnPosition(point)) && base.Scenario.GetTroopByPosition(point) == null)
         {
             sourceArea.Area.Add(point);
         }
     }
     GameArea highestFightingForceArea = troop.GetHighestFightingForceArea(sourceArea);
     if (highestFightingForceArea != null)
     {
         if (close)
         {
             return base.Scenario.GetClosestPosition(highestFightingForceArea, orientations);
         }
         return base.Scenario.GetFarthestPosition(highestFightingForceArea, orientations);
     }
     return null;
 }
 public GameArea GetSpyArchitectureArea()
 {
     GameArea area = new GameArea();
     foreach (Architecture architecture in base.Scenario.Architectures)
     {
         if ((architecture.BelongedFaction != null) && (architecture.BelongedFaction != this.BelongedFaction))
         {
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }
 public GameArea GetConvincePersonArchitectureArea()
 {
     GameArea area = new GameArea();
     //Label_0121:
     foreach (Architecture architecture in base.Scenario.Architectures)
     {
         if (architecture.BelongedFaction == this.BelongedFaction)
         {
             if (!architecture.HasCaptive() && !architecture.HasNoFactionPerson())
             {
                 //goto Label_0121;
                 continue;
             }
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
         else
         {
             if ((!architecture.HasPerson() && !architecture.HasNoFactionPerson()) || !this.BelongedFaction.IsArchitectureKnown(architecture))
             {
                 continue;
             }
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }
 public bool HasHostileTroopsInView()
 {
     GameArea viewArea = this.ViewArea;
     if ((this.RecentlyAttacked > 0) || (this.ArmyScale > this.NormalArmyScale))
     {
         viewArea = this.LongViewArea;
     }
     foreach (Point point in viewArea.Area)
     {
         Troop troopByPosition = base.Scenario.GetTroopByPosition(point);
         if ((troopByPosition != null) && (!troopByPosition.IsFriendly(this.BelongedFaction) && (troopByPosition.Status != TroopStatus.埋伏)))
         {
             return true;
         }
     }
     return false;
 }
 public GameArea GetDestroyArchitectureArea()
 {
     GameArea area = new GameArea();
     foreach (Architecture architecture in base.Scenario.Architectures)
     {
         if (!this.IsFriendly(architecture.BelongedFaction))
         {
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }
 public void LoadFromString(GameArea gameArea, string dataString)
 {
     char[] separator = new char[] { ' ', '\n', '\r', '\t' };
     string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     gameArea.Area.Clear();
     int minX = 10000, minY = 10000, maxX = -10000, maxY = -10000, x, y;
     for (int i = 0; i < strArray.Length; i += 2)
     {
         x = int.Parse(strArray[i]);
         y = int.Parse(strArray[i + 1]);
         gameArea.Area.Add(new Microsoft.Xna.Framework.Point(x, y));
         if (x < minX)
             minX = x;
         if (x > maxX)
             maxX = x;
         if (y < minY)
             minY = y;
         if (y > maxY)
             maxY = y;
     }
     gameArea.Centre = new Point((minX + maxX) / 2, (minY + maxY) / 2);
 }
 public GameArea GetGossipArchitectureArea()
 {
     GameArea area = new GameArea();
     foreach (Architecture architecture in base.Scenario.Architectures)
     {
         if ((((architecture.BelongedFaction != null) && !this.IsFriendly(architecture.BelongedFaction)) && architecture.HasPerson()) && this.BelongedFaction.IsArchitectureKnown(architecture))
         {
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }
 public void SetViewArea(GameArea area)
 {
     this.viewArea = area;
 }
 public TroopList GetHostileTroopsInView()
 {
     GameArea viewArea = this.ViewArea;
     if ((this.RecentlyAttacked > 0) || (this.ArmyScale > this.LargeArmyScale))
     {
         viewArea = this.LongViewArea;
     }
     TroopList list = new TroopList();
     foreach (Point point in viewArea.Area)
     {
         Troop troopByPosition = base.Scenario.GetTroopByPosition(point);
         if ((troopByPosition != null) && (!troopByPosition.IsFriendly(this.BelongedFaction) && (troopByPosition.Status != TroopStatus.埋伏)))
         {
             int days = 1;
             if ((((this.BelongedFaction != null) && (troopByPosition.BelongedFaction != null)) && (this.RecentlyAttacked <= 0)) && (base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, troopByPosition.BelongedFaction.ID) >= 0))
             {
                 days = 0;
             }
             if (troopByPosition.DaysToReachPosition(base.Scenario.GetClosestPoint(this.ArchitectureArea, troopByPosition.Position), days))
             {
                 list.Add(troopByPosition);
             }
         }
     }
     return list;
 }
 private void screen_OnMouseLeftUp(Point position)
 {
     if (((this.Area != null) && this.screen.EnableSelecting) && ((this.screen.ViewMoveDirection == ViewMove.Stop) && ((!this.screen.PositionOutOfScreen(position) && (this.CanSelectArchitecture || (this.screen.Scenario.GetArchitectureByPositionNoCheck(this.SelectedPoint) == null))) && (this.allowToSelectOutsideArea || this.Area.HasPoint(this.SelectedPoint)))))
     {
         this.AreaFrameKind = SelectingUndoneWorkKind.None;
         this.Area = null;
         this.EffectingAreaRadius = 0;
         this.EffectingAreaOblique = false;
         this.Canceled = false;
         this.allowToSelectOutsideArea = false;
         this.IsShowing = false;
     }
 }
 public GameArea GetInstigateArchitectureArea()
 {
     GameArea area = new GameArea();
     foreach (Architecture architecture in base.Scenario.Architectures)
     {
         if (architecture.Kind.HasDomination && !this.IsFriendly(architecture.BelongedFaction))
         {
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }
 private void screen_OnMouseRightUp(Point position)
 {
     if (this.screen.EnableSelecting)
     {
         this.AreaFrameKind = SelectingUndoneWorkKind.None;
         this.Area = null;
         this.EffectingAreaRadius = 0;
         this.EffectingAreaOblique = false;
         this.Canceled = true;
         this.allowToSelectOutsideArea = false;
         this.IsShowing = false;
     }
 }
 public GameArea GetJailBreakArchitectureArea()
 {
     GameArea area = new GameArea();
     foreach (Architecture architecture in base.Scenario.Architectures)
     {
         if (architecture.BelongedFaction != null && !this.IsFriendly(architecture.BelongedFaction) && architecture.HasFactionCaptive(this.BelongedFaction))
         {
             foreach (Point point in architecture.ArchitectureArea.Area)
             {
                 area.AddPoint(point);
             }
         }
     }
     return area;
 }