void PointVillageGUI(VillageMapPointController point) { CityDataBase cityDataBase = (CityDataBase)AssetDatabase.LoadAssetAtPath("Assets/DataBase/Data_Cities.asset", typeof(CityDataBase)); GUILayout.BeginVertical("box"); GUILayout.Label("Village"); point.id = EditorGUILayout.IntField("ID Village:", point.id); GUILayout.Label("ID: 0-" + (cityDataBase.Cities.Count - 1)); foreach (var otherPoint in my.MapPoints) { if (otherPoint.TryGetComponent(out VillageMapPointController village)) { if (village.id == point.id && point.MapPoint.idPoint != village.MapPoint.idPoint) { point.id = -1; break; } } } if (point.id > cityDataBase.Cities.Count - 1) { point.id = -1; } if (point.id >= 0) { point.MapPoint.namePoint = cityDataBase.Cities[point.id].Name; GUILayout.Label("Village Name:" + point.MapPoint.namePoint); } GUILayout.EndVertical(); }
/// <summary> /// 通过[市ID]二分快速查表 /// </summary> /// <param name="dwID">市ID</param> /// <returns></returns> public static CityDataBase Query(this List <CityDataBase> sorted, uint dwID) { var key = new CityDataBase() { dwID = dwID }; var comparer = new Comparer1(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(CityDataBase)); }