コード例 #1
0
		public AStarFinderPool(Field2D field_0) {
			this.pathQueue = new AStarFinderPool.TaskQueue ();
			this.field = field_0;
			this.running = true;
            this.pathfinderThread = new Thread(this, "AStarThread");
			this.pathfinderThread.Start();
		}
コード例 #2
0
ファイル: TileMapConfig.cs プロジェクト: keppelcao/LGame
 public static Field2D LoadCharsField(string resName, int tileWidth,
         int tileHeight)
 {
     Field2D field = new Field2D(LoadCharsMap(resName), tileWidth,
             tileHeight);
     return field;
 }
コード例 #3
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 private List <Vector2f> Astar(Field2D field_0, bool flag_1)
 {
     for (; pathes.Count > 0;)
     {
         AStarFinder.ScoredPath spath_2 = (AStarFinder.ScoredPath)CollectionUtils.RemoveAt(pathes, 0);
         Vector2f current = spath_2.path[spath_2.path.Count - 1];
         if (current.Equals(goal))
         {
             return(spath_2.path);
         }
         List <Vector2f> list = field_0.Neighbors(current, flag_1);
         int             size = list.Count;
         for (int i = 0; i < size; i++)
         {
             Vector2f next = list[i];
             if (CollectionUtils.Contains(next, visitedCache))
             {
                 continue;
             }
             CollectionUtils.Add(visitedCache, next);
             if (!field_0.IsHit(next) && !flying)
             {
                 continue;
             }
             List <Vector2f> path_3 = new List <Vector2f>(spath_2.path);
             CollectionUtils.Add(path_3, next);
             float score = spath_2.score
                           + findHeuristic
                           .GetScore(goal.x, goal.y, next.x, next.y);
             Insert(score, path_3);
         }
     }
     return(null);
 }
コード例 #4
0
ファイル: TileMapConfig.cs プロジェクト: zx8326123/LGame
        public static Field2D LoadCharsField(string resName, int tileWidth,
                                             int tileHeight)
        {
            Field2D field = new Field2D(LoadCharsMap(resName), tileWidth,
                                        tileHeight);

            return(field);
        }
コード例 #5
0
ファイル: AStarFinderPool.cs プロジェクト: vb0067/LGame
 public AStarFinderPool(Field2D field_0)
 {
     this.pathQueue        = new AStarFinderPool.TaskQueue();
     this.field            = field_0;
     this.running          = true;
     this.pathfinderThread = new Thread(this);
     this.pathfinderThread.Start();
 }
コード例 #6
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 public void Update(AStarFinder Find)
 {
     this.field         = Find.field;
     this.startX        = Find.startX;
     this.startY        = Find.startY;
     this.endX          = Find.endX;
     this.endY          = Find.endY;
     this.flying        = Find.flying;
     this.flag          = Find.flag;
     this.findHeuristic = Find.findHeuristic;
 }
コード例 #7
0
ファイル: MoveTo.cs プロジェクト: ordanielcmessias/LGame
 public MoveTo(Field2D map, int x, int y, bool flag_0)
 {
     this.pLocation = new Vector2f();
     this.startLocation = new Vector2f();
     this.endLocation = new Vector2f(x, y);
     this.layerMap = map;
     this.flag = flag_0;
     this.speed = 4;
     this.useCache = true;
     this.synchroLayerField = false;
 }
コード例 #8
0
 public void Convert(Field2D field, int ins0, int xout)
 {
     for (int xp = 0; xp < this.width; xp++)
     {
         for (int yp = 0; yp < this.height; yp++)
         {
             if (field.GetType(this.x + xp, this.y + yp) == ins0)
             {
                 field.SetType(this.x + xp, this.y + yp, xout);
             }
         }
     }
 }
コード例 #9
0
ファイル: TileRoom.cs プロジェクト: hellogithubtesting/LGame
 public void Convert(Field2D field, int ins0, int xout)
 {
     for (int xp = 0; xp < this.width; xp++)
     {
         for (int yp = 0; yp < this.height; yp++)
         {
             if (field.GetType(this.x + xp, this.y + yp) == ins0)
             {
                 field.SetType(this.x + xp, this.y + yp, xout);
             }
         }
     }
 }
コード例 #10
0
ファイル: TileMap.cs プロジェクト: vb0067/LGame
 public TileMap(Field2D field, int tileWidth, int tileHeight, int mWidth,
                int mHeight)
 {
     this.field       = field;
     this.maxWidth    = mWidth;
     this.maxHeight   = mHeight;
     this.offset      = new Vector2f(0, 0);
     this.imgPack     = new LTexturePack();
     this.lastOffsetX = -1;
     this.lastOffsetY = -1;
     this.active      = true;
     this.dirty       = true;
     this.visible     = true;
 }
コード例 #11
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 public AStarFinder(AStarFindHeuristic heuristic, Field2D field_0, int startX_1,
                    int startY_2, int endX_3, int endY_4, bool flying_5, bool flag_6,
                    AStarFinderListener callback)
 {
     this.field             = field_0;
     this.startX            = startX_1;
     this.startY            = startY_2;
     this.endX              = endX_3;
     this.endY              = endY_4;
     this.flying            = flying_5;
     this.flag              = flag_6;
     this.pathFoundListener = callback;
     this.findHeuristic     = heuristic;
 }
コード例 #12
0
ファイル: TileMap.cs プロジェクト: hellogithubtesting/LGame
 public TileMap(Field2D field, int tileWidth, int tileHeight, int mWidth,
         int mHeight)
 {
     this.field = field;
     this.maxWidth = mWidth;
     this.maxHeight = mHeight;
     this.offset = new Vector2f(0, 0);
     this.imgPack = new LTexturePack();
     this.lastOffsetX = -1;
     this.lastOffsetY = -1;
     this.active = true;
     this.dirty = true;
     this.visible = true;
 }
コード例 #13
0
 public TileMap(Field2D field, int mWidth, int mHeight, Loon.Core.Graphics.Opengl.LTexture.Format format)
 {
     this.field       = field;
     this.maxWidth    = mWidth;
     this.maxHeight   = mHeight;
     this.offset      = new Vector2f(0, 0);
     this.imgPack     = new LTexturePack();
     this.format      = format;
     this.lastOffsetX = -1;
     this.lastOffsetY = -1;
     this.active      = true;
     this.dirty       = true;
     this.visible     = true;
     imgPack.SetFormat(format);
 }
コード例 #14
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 private List <Vector2f> Calc(Field2D field, Vector2f start,
                              Vector2f goal, bool flag)
 {
     if (start.Equals(goal))
     {
         List <Vector2f> v = new List <Vector2f>();
         v.Add(start);
         return(v);
     }
     this.goal = goal;
     if (visitedCache == null)
     {
         visitedCache = new HashedSet();
     }
     else
     {
         visitedCache.Clear();
     }
     if (pathes == null)
     {
         pathes = new List <ScoredPath>();
     }
     else
     {
         pathes.Clear();
     }
     visitedCache.Add(start);
     if (path == null)
     {
         path = new List <Vector2f>();
     }
     else
     {
         path.Clear();
     }
     path.Add(start);
     if (spath == null)
     {
         spath = new ScoredPath(0, path);
     }
     else
     {
         spath.score = 0;
         spath.path  = path;
     }
     pathes.Add(spath);
     return(Astar(field, flag));
 }
コード例 #15
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 private List <Vector2f> Calc(Field2D field_0, Vector2f start,
                              Vector2f goal_1, bool flag_2)
 {
     if (start.Equals(goal_1))
     {
         List <Vector2f> v = new List <Vector2f>();
         CollectionUtils.Add(v, start);
         return(v);
     }
     this.goal = goal_1;
     if (visitedCache == null)
     {
         visitedCache = new HashedSet();
     }
     else
     {
         CollectionUtils.Clear(visitedCache);
     }
     if (pathes == null)
     {
         pathes = new List <ScoredPath>();
     }
     else
     {
         CollectionUtils.Clear(pathes);
     }
     CollectionUtils.Add(visitedCache, start);
     if (path == null)
     {
         path = new List <Vector2f>();
     }
     else
     {
         CollectionUtils.Clear(path);
     }
     CollectionUtils.Add(path, start);
     if (spath == null)
     {
         spath = new AStarFinder.ScoredPath(0, path);
     }
     else
     {
         spath.score = 0;
         spath.path  = path;
     }
     CollectionUtils.Add(pathes, spath);
     return(Astar(field_0, flag_2));
 }
コード例 #16
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 public static List <Vector2f> Find(AStarFindHeuristic heuristic,
                                    int[][] maps, int[] limits, int x1, int y1, int x2, int y2,
                                    bool flag)
 {
     heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic);
     lock (finderLazy)
     {
         if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10)
         {
             finderLazy.Clear();
         }
         int             key    = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag);
         List <Vector2f> result = (List <Vector2f>)CollectionUtils.Get(finderLazy, key);
         if (result == null)
         {
             AStarFinder astar    = new AStarFinder(heuristic);
             Field2D     fieldMap = new Field2D(maps);
             if (limits != null)
             {
                 fieldMap.SetLimit(limits);
             }
             Vector2f start = new Vector2f(x1, y1);
             Vector2f over  = new Vector2f(x2, y2);
             result = astar.Calc(fieldMap, start, over, flag);
             CollectionUtils.Put(finderLazy, key, result);
             astar.Dispose();
         }
         if (result != null)
         {
             List <Vector2f> newResult = new List <Vector2f>();
             CollectionUtils.AddAll(newResult, result);
             result = newResult;
         }
         return(result);
     }
 }
コード例 #17
0
ファイル: TileMap.cs プロジェクト: 207h2Flogintvg/LGame
		public TileMap(Field2D field, int mWidth, int mHeight, Loon.Core.Graphics.Opengl.LTexture.Format format) {
			this.field = field;
			this.maxWidth = mWidth;
			this.maxHeight = mHeight;
			this.offset = new Vector2f(0, 0);
			this.imgPack = new LTexturePack();
			this.format = format;
			this.lastOffsetX = -1;
			this.lastOffsetY = -1;
			this.active = true;
			this.dirty = true;
			this.visible = true;
			imgPack.SetFormat(format);
		}
コード例 #18
0
ファイル: LLayer.cs プロジェクト: keppelcao/LGame
 public virtual void SetField2DBackground(Field2D field, Dictionary<object, object> pathMap)
 {
     SetField2DBackground(field, pathMap, null);
 }
コード例 #19
0
ファイル: ActorLayer.cs プロジェクト: 207h2Flogintvg/LGame
 /// <summary>
 /// 设定Layer对应的二维数组地图
 /// </summary>
 ///
 /// <param name="map"></param>
 public void SetField2D(Field2D field)
 {
     if (isClose)
     {
         return;
     }
     if (field == null)
     {
         return;
     }
     if (tmpField != null)
     {
         if ((field.GetMap().Length == tmpField.GetMap().Length)
                 && (field.GetTileWidth() == tmpField.GetTileWidth())
                 && (field.GetTileHeight() == tmpField.GetTileHeight()))
         {
             tmpField.Set(field.GetMap(), field.GetTileWidth(),
                     field.GetTileHeight());
         }
     }
     else
     {
         tmpField = field;
     }
 }
コード例 #20
0
ファイル: ActorLayer.cs プロジェクト: 207h2Flogintvg/LGame
 /// <summary>
 /// 让指定对象执行MoveTo事件
 /// </summary>
 ///
 /// <param name="field"></param>
 /// <param name="o"></param>
 /// <param name="flag"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public MoveTo CallMoveTo(Field2D field, Loon.Action.ActionBind o, bool flag, int x, int y)
 {
     if (isClose)
     {
         return null;
     }
     MoveTo move = new MoveTo(field, x, y, flag);
     AddActionEvent(move, o);
     return move;
 }
コード例 #21
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 public static List<Vector2f> Find(AStarFindHeuristic heuristic,
         int[][] maps, int[] limits, int x1, int y1, int x2, int y2,
         bool flag)
 {
     heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic);
     lock (finderLazy)
     {
         if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10)
         {
             finderLazy.Clear();
         }
         int key = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag);
         List<Vector2f> result = (List<Vector2f>)CollectionUtils.Get(finderLazy, key);
         if (result == null)
         {
             AStarFinder astar = new AStarFinder(heuristic);
             Field2D fieldMap = new Field2D(maps);
             if (limits != null)
             {
                 fieldMap.SetLimit(limits);
             }
             Vector2f start = new Vector2f(x1, y1);
             Vector2f over = new Vector2f(x2, y2);
             result = astar.Calc(fieldMap, start, over, flag);
             CollectionUtils.Put(finderLazy, key, result);
             astar.Dispose();
         }
         if (result != null)
         {
             List<Vector2f> newResult = new List<Vector2f>();
             CollectionUtils.AddAll(newResult, result);
             result = newResult;
         }
         return result;
     }
 }
コード例 #22
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 public static List <Vector2f> Find(AStarFindHeuristic heuristic,
                                    Field2D maps, int x1, int y1, int x2, int y2, bool flag)
 {
     return(Find(heuristic, maps.GetMap(), maps.GetLimit(), x1, y1, x2, y2,
                 flag));
 }
コード例 #23
0
ファイル: TileMap.cs プロジェクト: 207h2Flogintvg/LGame
		public TileMap(Field2D field, Loon.Core.Graphics.Opengl.LTexture.Format format):this(field, LSystem.screenRect.width, LSystem.screenRect.height, format) {
			
		}
コード例 #24
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 private List<Vector2f> Calc(Field2D field_0, Vector2f start,
         Vector2f goal_1, bool flag_2)
 {
     if (start.Equals(goal_1))
     {
         List<Vector2f> v = new List<Vector2f>();
         CollectionUtils.Add(v, start);
         return v;
     }
     this.goal = goal_1;
     if (visitedCache == null)
     {
         visitedCache = new HashedSet();
     }
     else
     {
         CollectionUtils.Clear(visitedCache);
     }
     if (pathes == null)
     {
         pathes = new List<ScoredPath>();
     }
     else
     {
         CollectionUtils.Clear(pathes);
     }
     CollectionUtils.Add(visitedCache, start);
     if (path == null)
     {
         path = new List<Vector2f>();
     }
     else
     {
         CollectionUtils.Clear(path);
     }
     CollectionUtils.Add(path, start);
     if (spath == null)
     {
         spath = new AStarFinder.ScoredPath(0, path);
     }
     else
     {
         spath.score = 0;
         spath.path = path;
     }
     CollectionUtils.Add(pathes, spath);
     return Astar(field_0, flag_2);
 }
コード例 #25
0
ファイル: ActorLayer.cs プロジェクト: 207h2Flogintvg/LGame
 /// <summary>
 /// 以指定瓦片大小创建数组地图
 /// </summary>
 ///
 /// <param name="tileWidth"></param>
 /// <param name="tileHeight"></param>
 /// <returns></returns>
 public Field2D CreateArrayMap(int tileWidth, int tileHeight)
 {
     if (isClose)
     {
         return null;
     }
     tmpField = new Field2D((int[][])CollectionUtils.XNA_CreateJaggedArray(typeof(int), GetHeight() / tileHeight, GetWidth()
                     / tileWidth), tileWidth, tileHeight);
     return tmpField;
 }
コード例 #26
0
 public Field2D(Field2D field)
 {
     Copy(field);
 }
コード例 #27
0
ファイル: Field2D.cs プロジェクト: namecoo1iopl12/LGame
 public void Copy(Field2D field)
 {
            this.Set(CollectionUtils.CopyOf(field.data), field.tileWidth,
             field.tileHeight);
 }
コード例 #28
0
ファイル: Field2D.cs プロジェクト: namecoo1iopl12/LGame
 public Field2D(Field2D field)
 {
     Copy(field);
 }
コード例 #29
0
ファイル: LLayer.cs プロジェクト: keppelcao/LGame
        public virtual void SetField2DBackground(Field2D field, Dictionary<object, object> pathMap,
                string fileName)
        {
            SetField2D(field);
            LImage background = null;

            if (fileName != null)
            {
                LImage tmp = LImage.CreateImage(fileName);
                background = SetTileBackground(tmp, true);
                if (tmp != null)
                {
                    tmp.Dispose();
                    tmp = null;
                }
            }
            else
            {
                background = LImage.CreateImage(GetWidth(), GetHeight(), false);
            }
            int srcWidth = GetWidth();
            int srcHeight = GetHeight();
            //在C#环境下LGraphics采取像素渲染,得不到硬件加速,此处直接将像素操作方法粘过来了(虽然也快不了几毫秒……)
            int[] dstColors = background.GetIntPixels();
            int[] srcColors = null;
            for (int i = 0; i < field.GetWidth(); i++)
            {
                for (int j = 0; j < field.GetHeight(); j++)
                {
                    int index = field.GetType(j, i);
                    object o = CollectionUtils.Get(pathMap, index);
                    if (o != null)
                    {
                        if (o is LImage)
                        {
                            LImage img = (LImage)o;
                            srcColors = img.GetIntPixels();
                            int w = img.Width;
                            int h = img.Height;
                            int y = field.TilesToHeightPixels(j);
                            int x = field.TilesToWidthPixels(i);
                            if (x < 0)
                            {
                                w += x;
                                x = 0;
                            }
                            if (y < 0)
                            {
                                h += y;
                                y = 0;
                            }
                            if (x + w > srcWidth)
                            {
                                w = srcWidth - x;
                            }
                            if (y + h > srcHeight)
                            {
                                h = srcHeight - y;
                            }
                            if (img.hasAlpha)
                            {
                                int findIndex = y * srcWidth + x;
                                int drawIndex = 0;
                                int moveFind = srcWidth - w;
                                for (int col = 0; col < h; col++)
                                {
                                    for (int row = 0; row < w; )
                                    {
                                        if (srcColors[drawIndex] != 0)
                                        {
                                            dstColors[findIndex] = srcColors[drawIndex];
                                        }
                                        row++;
                                        findIndex++;
                                        drawIndex++;
                                    }
                                    findIndex += moveFind;
                                }
                            }
                            else
                            {
                                for (int size = 0; size < h; size++)
                                {
                                    System.Array.Copy(srcColors, size * w, dstColors,
                                                     (y + size) * srcWidth + x, w);
                                }
                            }
                        }
                        else if (o is Actor)
                        {
                            AddObject(((Actor)o), field.TilesToWidthPixels(i),
                                    field.TilesToHeightPixels(j));
                        }
                    }
                }
            }
            background.SetIntPixels(dstColors);
            background.SetFormat(Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
            SetBackground(background.GetTexture());
            srcColors = null;
            dstColors = null;
            if (background != null)
            {
                background.Dispose();
                background = null;
            }
        }
コード例 #30
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
        public AStarFinder(AStarFindHeuristic heuristic, Field2D field_0, int startX_1,
                int startY_2, int endX_3, int endY_4, bool flying_5, bool flag_6)
            : this(heuristic, field_0, startX_1, startY_2, endX_3, endY_4, flying_5, flag_6, null)
        {

        }
コード例 #31
0
ファイル: ActorLayer.cs プロジェクト: 207h2Flogintvg/LGame
 /// <summary>
 /// 让指定对象执行MoveTo事件
 /// </summary>
 ///
 /// <param name="o"></param>
 /// <param name="flag"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="w"></param>
 /// <param name="h"></param>
 /// <returns></returns>
 public MoveTo CallMoveTo(Loon.Action.ActionBind o, bool flag, int x, int y, int w, int h)
 {
     if (isClose)
     {
         return null;
     }
     if (tmpField == null)
     {
         tmpField = CreateArrayMap(w, h);
     }
     MoveTo move = new MoveTo(tmpField, x, y, flag);
     AddActionEvent(move, o);
     return move;
 }
コード例 #32
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 public void Update(AStarFinder Find)
 {
     this.field = Find.field;
     this.startX = Find.startX;
     this.startY = Find.startY;
     this.endX = Find.endX;
     this.endY = Find.endY;
     this.flying = Find.flying;
     this.flag = Find.flag;
     this.findHeuristic = Find.findHeuristic;
 }
コード例 #33
0
ファイル: LLayer.cs プロジェクト: hellogithubtesting/LGame
        public void SetField2DBackground(Field2D field, Dictionary<object, object> pathMap,
                String fileName)
        {
            SetField2D(field);
            LPixmap background = null;

            if (fileName != null)
            {
                LPixmap tmp = new LPixmap(fileName);
                background = SetTileBackground(tmp, true);
                if (tmp != null)
                {
                    tmp.Dispose();
                    tmp = null;
                }
            }
            else
            {
                background = new LPixmap(GetWidth(), GetHeight(), false);
            }

            for (int i = 0; i < field.GetWidth(); i++)
            {
                for (int j = 0; j < field.GetHeight(); j++)
                {
                    int index = field.GetType(j, i);
                    Object o = CollectionUtils.Get(pathMap, index);
                    if (o != null)
                    {
                        if (o is LPixmap)
                        {
                            background.DrawPixmap(((LPixmap)o), field.TilesToWidthPixels(i),
                                    field.TilesToHeightPixels(j));
                        }
                        else if (o is Actor)
                        {
                            AddObject(((Actor)o), field.TilesToWidthPixels(i),
                                    field.TilesToHeightPixels(j));
                        }
                    }
                }
            }
            SetBackground(background.Texture);
            if (background != null)
            {
                background.Dispose();
                background = null;
            }
        }
コード例 #34
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 private List<Vector2f> Astar(Field2D field_0, bool flag_1)
 {
     for (; pathes.Count > 0; )
     {
         AStarFinder.ScoredPath spath_2 = (AStarFinder.ScoredPath)CollectionUtils.RemoveAt(pathes, 0);
         Vector2f current = spath_2.path[spath_2.path.Count - 1];
         if (current.Equals(goal))
         {
             return spath_2.path;
         }
         List<Vector2f> list = field_0.Neighbors(current, flag_1);
         int size = list.Count;
         for (int i = 0; i < size; i++)
         {
             Vector2f next = list[i];
             if (CollectionUtils.Contains(next, visitedCache))
             {
                 continue;
             }
             CollectionUtils.Add(visitedCache, next);
             if (!field_0.IsHit(next) && !flying)
             {
                 continue;
             }
             List<Vector2f> path_3 = new List<Vector2f>(spath_2.path);
             CollectionUtils.Add(path_3, next);
             float score = spath_2.score
                     + findHeuristic
                             .GetScore(goal.x, goal.y, next.x, next.y);
             Insert(score, path_3);
         }
     }
     return null;
 }
コード例 #35
0
ファイル: MoveTo.cs プロジェクト: ordanielcmessias/LGame
 public void SetField2D(Field2D field)
 {
     if (field != null)
     {
         this.layerMap = field;
     }
 }
コード例 #36
0
 public Field2D GetField2D(string name, int width, int height,
         Field2D fallback)
 {
     int[][] arrays = GetArray2D(name,
             (fallback == null) ? null : fallback.GetMap());
     if (arrays != null)
     {
         return new Field2D(arrays, width, height);
     }
     return null;
 }
コード例 #37
0
ファイル: MoveTo.cs プロジェクト: ordanielcmessias/LGame
 public MoveTo(Field2D map, Vector2f pos, bool flag_0)
     : this(map, pos.X(), pos.Y(), flag_0)
 {
 }
コード例 #38
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 public static List <Vector2f> Find(AStarFindHeuristic heuristic,
                                    Field2D maps, Vector2f start, Vector2f goal, bool flag)
 {
     return(Find(heuristic, maps.GetMap(), maps.GetLimit(), start.X(),
                 start.Y(), goal.X(), goal.Y(), flag));
 }
コード例 #39
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 public static List<Vector2f> Find(AStarFindHeuristic heuristic,
         Field2D maps, int x1, int y1, int x2, int y2, bool flag)
 {
     return Find(heuristic, maps.GetMap(), maps.GetLimit(), x1, y1, x2, y2,
             flag);
 }
コード例 #40
0
ファイル: AStarFinder.cs プロジェクト: zx8326123/LGame
 public AStarFinder(AStarFindHeuristic heuristic, Field2D field_0, int startX_1,
                    int startY_2, int endX_3, int endY_4, bool flying_5, bool flag_6)
     : this(heuristic, field_0, startX_1, startY_2, endX_3, endY_4, flying_5, flag_6, null)
 {
 }
コード例 #41
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 public static List<Vector2f> Find(AStarFindHeuristic heuristic,
         Field2D maps, Vector2f start, Vector2f goal, bool flag)
 {
     return Find(heuristic, maps.GetMap(), maps.GetLimit(), start.X(),
             start.Y(), goal.X(), goal.Y(), flag);
 }
コード例 #42
0
ファイル: MoveTo.cs プロジェクト: ordanielcmessias/LGame
 public override void Update(long elapsedTime)
 {
     if (layerMap == null || original == null || pActorPath == null)
     {
         return;
     }
     lock (pActorPath)
     {
         if (synchroLayerField)
         {
             if (original != null)
             {
                 Field2D field = original.GetField2D();
                 if (field != null && layerMap != field)
                 {
                     this.layerMap = field;
                 }
             }
         }
         if (endX == startX && endY == startY)
         {
             if (pActorPath.Count > 1)
             {
                 Vector2f moveStart = pActorPath[0];
                 Vector2f moveEnd = pActorPath[1];
                 startX = layerMap.TilesToWidthPixels(moveStart.X());
                 startY = layerMap.TilesToHeightPixels(moveStart.Y());
                 endX = moveEnd.X() * layerMap.GetTileWidth();
                 endY = moveEnd.Y() * layerMap.GetTileHeight();
                 moveX = moveEnd.X() - moveStart.X();
                 moveY = moveEnd.Y() - moveStart.Y();
                 if (moveX > -2 && moveY > -2 && moveX < 2 && moveY < 2)
                 {
                     direction = Loon.Action.Map.Field2D.GetDirection(moveX, moveY,
                             direction);
                 }
             }
             CollectionUtils.RemoveAt(pActorPath, 0);
         }
         switch (direction)
         {
             case Config.TUP:
                 startY -= speed;
                 if (startY < endY)
                 {
                     startY = endY;
                 }
                 break;
             case Config.TDOWN:
                 startY += speed;
                 if (startY > endY)
                 {
                     startY = endY;
                 }
                 break;
             case Config.TLEFT:
                 startX -= speed;
                 if (startX < endX)
                 {
                     startX = endX;
                 }
                 break;
             case Config.TRIGHT:
                 startX += speed;
                 if (startX > endX)
                 {
                     startX = endX;
                 }
                 break;
             case Config.UP:
                 startX += speed;
                 startY -= speed;
                 if (startX > endX)
                 {
                     startX = endX;
                 }
                 if (startY < endY)
                 {
                     startY = endY;
                 }
                 break;
             case Config.DOWN:
                 startX -= speed;
                 startY += speed;
                 if (startX < endX)
                 {
                     startX = endX;
                 }
                 if (startY > endY)
                 {
                     startY = endY;
                 }
                 break;
             case Config.LEFT:
                 startX -= speed;
                 startY -= speed;
                 if (startX < endX)
                 {
                     startX = endX;
                 }
                 if (startY < endY)
                 {
                     startY = endY;
                 }
                 break;
             case Config.RIGHT:
                 startX += speed;
                 startY += speed;
                 if (startX > endX)
                 {
                     startX = endX;
                 }
                 if (startY > endY)
                 {
                     startY = endY;
                 }
                 break;
         }
         lock (original)
         {
             original.SetLocation(startX + offsetX, startY + offsetY);
         }
     }
 }
コード例 #43
0
ファイル: AStarFinder.cs プロジェクト: wethinkall/LGame
 public AStarFinder(AStarFindHeuristic heuristic, Field2D field_0, int startX_1,
         int startY_2, int endX_3, int endY_4, bool flying_5, bool flag_6,
         AStarFinderListener callback)
 {
     this.field = field_0;
     this.startX = startX_1;
     this.startY = startY_2;
     this.endX = endX_3;
     this.endY = endY_4;
     this.flying = flying_5;
     this.flag = flag_6;
     this.pathFoundListener = callback;
     this.findHeuristic = heuristic;
 }
コード例 #44
0
ファイル: ActorLayer.cs プロジェクト: 207h2Flogintvg/LGame
 /// <summary>
 /// 让指定对象执行MoveTo事件
 /// </summary>
 ///
 /// <param name="field"></param>
 /// <param name="o"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public MoveTo CallMoveTo(Field2D field, Loon.Action.ActionBind o, int x, int y)
 {
     return CallMoveTo(field, o, true, x, y);
 }
コード例 #45
0
 public TileMap(Field2D field, Loon.Core.Graphics.Opengl.LTexture.Format format) : this(field, LSystem.screenRect.width, LSystem.screenRect.height, format)
 {
 }
コード例 #46
0
 public void Copy(Field2D field)
 {
     this.Set(CollectionUtils.CopyOf(field.data), field.tileWidth,
              field.tileHeight);
 }
コード例 #47
0
ファイル: AStarFinder.cs プロジェクト: keppelcao/LGame
 private List<Vector2f> Calc(Field2D field, Vector2f start,
         Vector2f goal, bool flag)
 {
     if (start.Equals(goal))
     {
         List<Vector2f> v = new List<Vector2f>();
         v.Add(start);
         return v;
     }
     this.goal = goal;
     if (visitedCache == null)
     {
         visitedCache = new HashedSet();
     }
     else
     {
         visitedCache.Clear();
     }
     if (pathes == null)
     {
         pathes = new List<ScoredPath>();
     }
     else
     {
         pathes.Clear();
     }
     visitedCache.Add(start);
     if (path == null)
     {
         path = new List<Vector2f>();
     }
     else
     {
         path.Clear();
     }
     path.Add(start);
     if (spath == null)
     {
         spath = new ScoredPath(0, path);
     }
     else
     {
         spath.score = 0;
         spath.path = path;
     }
     pathes.Add(spath);
     return Astar(field, flag);
 }