Exemple #1
0
        /// <summary>
        /// 通过[地图ID]二分快速查表
        /// </summary>
        /// <param name="map_id">地图ID</param>
        /// <returns></returns>
        public static CangBaoTuDataBase Query(this List <CangBaoTuDataBase> sorted, uint map_id)
        {
            var key = new CangBaoTuDataBase()
            {
                map_id = map_id
            };
            var comparer = new Comparer1();
            var index    = sorted.BinarySearch(key, comparer);

            return(index >= 0 ? sorted[index] : default(CangBaoTuDataBase));
        }
Exemple #2
0
    Vector2 GetMapPos(int type)
    {
        Vector2 vec = Vector2.zero;

        if (IsTreasureMap)
        {
            CangBaoTuDataBase tabData = GameTableManager.Instance.GetTableItem <CangBaoTuDataBase>(MapID);
            if (tabData != null)
            {
                string[] str = tabData.pos_list.Split(';');
                if (MapIndex < str.Length)
                {
                    string   targetPos = str[(int)MapIndex];
                    string[] vecStr    = targetPos.Split('_');
                    string[] transPos  = tabData.goto_pos.Split('_');
                    if (vecStr.Length == 2)
                    {
                        if (type == 1)
                        {
                            float x = float.Parse(vecStr[0]);
                            float y = float.Parse(vecStr[1]);
                            vec = new Vector2(x, y);
                        }
                        else
                        {
                            float tx = float.Parse(transPos[0]);
                            float ty = float.Parse(transPos[1]);
                            vec = new Vector2(tx, ty);
                        }
                    }
                }
            }
        }

        return(vec);
    }