public GameArea GetDayArea(Troop troop, int Days)
        {
            GameArea area = new GameArea();

            this.openDictionary.Clear();
            this.closeDictionary.Clear();
            this.openList.Clear();
            this.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;
            int num4 = 0;

            do
            {
                try
                {
                    this.CheckAdjacentSquares(square, troop.Position);
                    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);
                        }
                        num4 = 0;
                    }
                    else
                    {
                        num4++;
                    }
                }
                catch (OutOfMemoryException)
                {
                    openList.Clear();
                    closeList.Clear();
                    return(area);
                }
            }while (num4 < (num3 * 2));
            troop.MovabilityLeft = movabilityLeft;
            return(area);
        }
Example #2
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);
        }