コード例 #1
0
        public MyPathNode AIStep(TiledMap map, Player target)
        {
            var mobs = World.NewMonsters.Where(xe => xe.Value != this && xe.Value.Alive && xe.Value.m_Map == target.Map);
            List <MyPathNode> tempsquares = new List <MyPathNode>();

            foreach (var mob in mobs)
            {
                var tile = map.tiles[mob.Value.m_Loc.X, mob.Value.m_Loc.Y];
                tile.IsWall = true;
                tempsquares.Add(tile);
            }

            aStar = new MySolver <MyPathNode, Object>(map.tiles);
            path  = aStar.SearchOnce(new Point(m_Loc.X, m_Loc.Y), new Point(target.X, target.Y), null);

            foreach (var tile in tempsquares)
            {
                map.tiles[tile.X, tile.Y].IsWall = false;
            }
            //   foreach (var mob in mobs)
            //      map.tiles[mob.Value.m_Loc.X, mob.Value.m_Loc.Y].IsWall = false;

            MyPathNode p = new MyPathNode(m_Loc.X, m_Loc.Y);

            if (path != null)
            {
                p.X = path.X;
                p.Y = path.Y;
            }
            path = null;
            aStar.Dispose();
            aStar = null;
            return(p);
        }
コード例 #2
0
ファイル: Monster.cs プロジェクト: sepharoph/LK2
        public MyPathNode AIStep(TiledMap map, Player target)
        {
            var mobs = World.NewMonsters.Where(xe => xe.Value != this && xe.Value.Alive && xe.Value.m_Map == target.Map);
            foreach (var mob in mobs)
                map.tiles[mob.Value.m_Loc.X, mob.Value.m_Loc.Y].IsWall = true;

            aStar = new MySolver<MyPathNode, Object>(map.tiles);
            path = aStar.SearchOnce(new Point(m_Loc.X, m_Loc.Y), new Point(target.X, target.Y), null);

            foreach (var mob in mobs)
                map.tiles[mob.Value.m_Loc.X, mob.Value.m_Loc.Y].IsWall = false;

            MyPathNode p = new MyPathNode(m_Loc.X, m_Loc.Y);
            if (path != null)
            {
                p.X = path.X;
                p.Y = path.Y;
            }
            path = null;
            aStar.Dispose();
            aStar = null;
            return p;
        }