当前位置: 首页>>代码示例>>C#>>正文


C# Waypoint.getY方法代码示例

本文整理汇总了C#中Waypoint.getY方法的典型用法代码示例。如果您正苦于以下问题:C# Waypoint.getY方法的具体用法?C# Waypoint.getY怎么用?C# Waypoint.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Waypoint的用法示例。


在下文中一共展示了Waypoint.getY方法的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;
        }
开发者ID:cjs3187607,项目名称:brightmh,代码行数:16,代码来源:TownCoordsCache.cs

示例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;
        }
开发者ID:cjs3187607,项目名称:brightmh,代码行数:51,代码来源:mapProviding.cs


注:本文中的Waypoint.getY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。