public virtual List <IHexGridCell> GetPath(IHexGridCell currentLocation, int speed)
 {
     if (currentLocation != fixedLocation)
     {
         return(AStarModule.FindPath(currentLocation, fixedLocation, false));
     }
     return(new List <IHexGridCell>());
 }
 public override List <IHexGridCell> GetPath(IHexGridCell currentLocation, int speed)
 {
     foreach (IHexGridCell cell in guardedCells)
     {
         CreatureComponent creatureComponent = cell.GetComponent <CreatureComponent>();
         if (creatureComponent?.Creature?.GetType() == typeof(CreatureMovementController))
         {
             chasing = creatureComponent;
             return(AStarModule.FindPath(currentLocation, creatureComponent.Creature.Location, false));
         }
     }
     chasing = null;
     return(base.GetPath(currentLocation, speed));
 }
Ejemplo n.º 3
0
        public List <IHexGridCell> GetPath(IHexGridCell currentLocation, int speed)
        {
            IHexGridCell newLocation;
            int          iterations = 0;

            do
            {
                Point <int> start        = currentLocation.Position.GridPoint;
                Point <int> randomOffset = new Point <int>(start.X - speed + Odds.DiceRoll(2 * speed), start.Y - speed + Odds.DiceRoll(2 * speed));
                newLocation = currentLocation.ParentGrid[randomOffset];
                iterations++;
            } while ((newLocation == null || newLocation.HasComponent <UnselectableComponent>()) && iterations < MAX_ITERATIONS);
            if (iterations == MAX_ITERATIONS)
            {
                return(new List <IHexGridCell>());
            }
            return(AStarModule.FindPath(currentLocation, newLocation, false));
        }
Ejemplo n.º 4
0
        public void GoTo(IHexGridCell location)
        {
            //Make A* call here
            IHexGridCell start = Location;

            if (wipePath)
            {
                path.Clear();
                wipePath = false;
            }
            if (path.Count > 0)
            {
                start = path.Last;
            }
            foreach (IHexGridCell cell in AStarModule.FindPath(start, location))
            {
                path.Enqueue(cell);
            }
            TraversePath();
        }
 public List <IHexGridCell> GetPath(IHexGridCell currentLocation, int speed)
 {
     return(AStarModule.FindPath(currentLocation, chasing.Location, false));
 }