Ejemplo n.º 1
0
 public override void PerformAction()
 {
     if (Parent.Position != Goal)
     {
         Map.GameMap map = (Map.GameMap)Parent.CurrentMap;
         GoRogue.Pathing.FastAStar pathing = new GoRogue.Pathing.FastAStar(map.GetWalkabilityMap(), GoRogue.Distance.EUCLIDEAN);
         GoRogue.Pathing.Path      path    = pathing.ShortestPath(Parent.Position, Goal);
         if (path != null)
         {
             GoRogue.Coord next   = path.GetStepWithStart(1);
             GoRogue.Coord toMove = next - Parent.Position;
             Parent.Position += toMove;
         }
     }
 }
Ejemplo n.º 2
0
        public override void PerformAction()
        {
            if (Goal == Parent.Position || Goal.X == -1)
            {
                GoRogue.Coord zero = new GoRogue.Coord(0, 0);
                int           x;
                int           y;
                do
                {
                    x    = rand.Next(0, Parent.CurrentMap.Width);
                    y    = rand.Next(0, Parent.CurrentMap.Height);
                    Goal = new GoRogue.Coord(x, y);
                } while ((Goal - Parent.Position) == zero || !Parent.CurrentMap.GetWalkabilityMap()[x, y]);
            }

            Map.GameMap map = (Map.GameMap)Parent.CurrentMap;
            GoRogue.Pathing.FastAStar pathing = new GoRogue.Pathing.FastAStar(map.GetWalkabilityMap(), GoRogue.Distance.EUCLIDEAN);
            GoRogue.Pathing.Path      path    = pathing.ShortestPath(Parent.Position, Goal);
            if (path != null)
            {
                GoRogue.Coord next   = path.GetStepWithStart(1);
                GoRogue.Coord toMove = next - Parent.Position;
                Parent.Position += toMove;
            }
            else
            {
                if (WaitTime > 10)
                {
                    Goal     = new GoRogue.Coord(-1, -1);
                    WaitTime = 0;
                }
                else
                {
                    WaitTime++;
                }
            }
        }