コード例 #1
0
 public virtual List <IHexGridCell> GetPath(IHexGridCell currentLocation, int speed)
 {
     if (currentLocation != fixedLocation)
     {
         return(AStarModule.FindPath(currentLocation, fixedLocation, false));
     }
     return(new List <IHexGridCell>());
 }
コード例 #2
0
 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));
 }
コード例 #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));
        }
コード例 #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();
        }
コード例 #5
0
 public List <IHexGridCell> GetPath(IHexGridCell currentLocation, int speed)
 {
     return(AStarModule.FindPath(currentLocation, chasing.Location, false));
 }