admin 发表于 2009-12-4 22:28:25

传奇2地图读取(带寻路算法及源码)--火人出品

(**************************************************************************************************
关于TLegendMap(位于PathFind.pas)的用法
1、FLegendMap:=TLegendMap.Create;
   FLegendMap.LoadMap('mapfile')返回地图数据TMapData
   FLegendMap.SetStartPos(StartX, StartY,PathSpace)
   Path:=FLegendMap.FindPath(StopX, StopY)
2、FLegendMap:=TLegendMap.Create;
   FLegendMap.LoadMap('mapfile')返回地图数据TMapData
   Path:=FLegendMap.FindPath(StartX,StartY,StopX, StopY,PathSpace)

   其中
   Path为TPath = array of TPoint 为nil时表示不能到达
   第一个值为起点,最后一个值为终点

   PathSpace为离开障碍物多少个象素
**************************************************************************************************)

(**************************************************************************************************
关于TPathMap的特点
1、不需要传递地图数据,节省内存的频繁拷贝
2、可自定义估价函数,根据自己需要产生不同路径

关于TPathMap的用法
1、定义估价函数MovingCost(X, Y, Direction: Integer)
   只需根据自定义的地图格式编写)
2、FPathMap:=TPathMap.Create;
   FPathMap.MakePathMap(MapHeader.width, MapHeader.height, StartX, StartY,MovingCost);
   Path:=FPathMap.FindPathOnMap( EndX, EndY)
   其中Path为TPath = array of TPoint;

如果不喜欢在TPathMap外部定义估价函数,可继承TPathMap,
将地图数据的读取和估价函数封装成一个类使用。
****************************************************************************************************)




页: [1]
查看完整版本: 传奇2地图读取(带寻路算法及源码)--火人出品