本文整理汇总了C#中Waypoint.getX方法的典型用法代码示例。如果您正苦于以下问题:C# Waypoint.getX方法的具体用法?C# Waypoint.getX怎么用?C# Waypoint.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Waypoint
的用法示例。
在下文中一共展示了Waypoint.getX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getClosestWaypointForMap
public Waypoint getClosestWaypointForMap(short mapID, Waypoint location)
{
if(!towns.ContainsKey(mapID)) return null;
List<Waypoint> townsForCertainMap = new List<Waypoint>(towns[mapID]);
Dictionary<float, Waypoint> distances = new Dictionary<float, Waypoint>();
for(int i = 0;i < townsForCertainMap.Count;i++)
{
distances.Add(WMap.distance(townsForCertainMap[i].getX(), townsForCertainMap[i].getY(), location.getX(), location.getY()), townsForCertainMap[i]);
}
distances = distances.OrderBy(k => k.Key).ToDictionary(k => k.Key, k => k.Value);
if(distances.Count == 0)
return null;
return distances.ElementAt(0).Value;
}
示例2: loadTowns
public static int loadTowns(string mapIdentifier)
{
if(!Constants.VFSSkip)
vfsDataProvider.Instance.unpackFromVFS("data\\map" + mapIdentifier + "\\regiontable" + mapIdentifier + ".bin", "data\\maps\\regiontable" + mapIdentifier + ".bin");
if(!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "data/maps/regiontable" + mapIdentifier + ".bin"))
return 0;
int town_counts = 0;
short mapID = Convert.ToInt16(mapIdentifier);
byte[] data = File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "data/maps/regiontable" + mapIdentifier + ".bin");
int position = 32;
List<Waypoint> townz = new List<Waypoint>();
while(position < data.Length)
{
if(BitConverter.ToSingle(data, position) == 0.0)
{
position += 48;
continue;
}
if(data[position + 1] == 0x0 || data[position+2] == 0x0)
{
position += 48;
continue;
}
Waypoint waypoint = new Waypoint(BitConverter.ToSingle(data, position), BitConverter.ToSingle(data, position + 4));
Waypoint found = townz.Find(s => s.getX() == waypoint.getX() && s.getY() == waypoint.getY());
if(found != null)
{
position+=48;
continue;
}
if(townz.Contains(waypoint))
{
position += 48;
continue;
}
town_counts++;
townz.Add(waypoint);
position += 48;
}
TownCoordsCache.Instance.addTowns(mapID, townz);
return town_counts;
}