Exemplo n.º 1
0
 public void updatePaths(Vector2 playerPos, Manhatten <Tile, Object> aStar)
 {
     foreach (Enemy e in container)
     {
         e.calculatePathToSimTargetUsingAStart(playerPos, aStar);
     }
 }
Exemplo n.º 2
0
 public void initLevel()
 {
     Tmb.initLevel(ref world, ref eContrainer, ref player, ref collectables);
     recalculatePath(player, new EventArgs());
     background = new Background();
     debug      = new DebugDraw(world, window);
     input      = new InputHandler(window);
     aStar      = new Manhatten <Tile, Object>(Tmb.Map.TileArray);
     statusbar  = new StatusBar();
     _test      = Tmb.GetObjectPositions(world);
 }
Exemplo n.º 3
0
        public void calculatePathToSimTargetUsingAStart(Vector2 position, Manhatten <Tile, Object> aStar)
        {
            playerPosition = position;
            List <Point>      backupPath  = Path;
            Vector2f          startVector = Vector2fExtensions.ToSf(this.body.Position);
            Vector2f          endVector   = Vector2fExtensions.ToSf(position);
            Point             start       = new Point((int)startVector.X / 32, (int)startVector.Y / 32);
            Point             end         = new Point((int)endVector.X / 32, (int)endVector.Y / 32);
            LinkedList <Tile> path        = aStar.Search(start, end, null);

            Path = new List <Point>();
            if (path != null)
            {
                foreach (Tile t in path)
                {
                    Path.Add(new Point(t.X, t.Y));
                }
            }
            else
            {
                Path = backupPath;
            }
        }