Esempio n. 1
0
        public FDMoveRange CalculateMoveRange()
        {
            FDPosition  central = this.creature.Position;
            FDMoveRange range   = new FDMoveRange(central);

            int movePoint = creature.Data.CalculatedMv;

            positionQueue = new Queue <MoveRangeQueueObject>();

            range.AddPosition(central, null);
            positionQueue.Enqueue(new MoveRangeQueueObject(central, movePoint));

            while (positionQueue.Count > 0)
            {
                MoveRangeQueueObject queueObject = positionQueue.Dequeue();
                WalkOnPosition(queueObject.Position, queueObject.LeftMovePoint, range);
            }

            // Remove the friend creatures from range
            List <FDCreature> creatureInRange = gameAction.GetCreatureInRange(range, creature.Faction);

            if (creature.Faction == CreatureFaction.Friend)
            {
                creatureInRange.AddRange(gameAction.GetCreatureInRange(range, CreatureFaction.Npc));
            }
            else if (creature.Faction == CreatureFaction.Npc)
            {
                creatureInRange.AddRange(gameAction.GetCreatureInRange(range, CreatureFaction.Friend));
            }

            foreach (FDCreature c in creatureInRange)
            {
                if (c.CreatureId == creature.CreatureId)
                {
                    continue;
                }

                range.AddSkipPosition(c.Position);
            }

            return(range);
        }