private static void initLink() { dMapLink = new Dictionary <int, MapLinkItem>(); Dictionary <uint, Variant> l = SvrMapConfig.instance._mapConfs; foreach (Variant v in l.Values) { MapLinkItem item = new MapLinkItem(); item.mapid = v["id"]; if (!v.ContainsKey("l")) { continue; } List <Variant> ll = v["l"]._arr; for (int k = 0; k < ll.Count; k++) { Variant vinfo = ll[k]; if (vinfo.ContainsKey("trans") && vinfo["trans"] == 1) { MapLinkInfo info = new MapLinkInfo(); info.id = vinfo["id"]; info.mapid = item.mapid; info.toMap = vinfo["id"]; info.id = vinfo["gto"]; info.x = vinfo["ux"]; info.y = vinfo["uz"]; item.lLink.Add(info); } } dMapLink[item.mapid] = item; } }
public static bool getMapLine(int begin, int end, List <MapLinkInfo> line, Dictionary <int, int> dfinded = null) { if (dMapLink == null) { initLink(); } if (dfinded == null) { dfinded = new Dictionary <int, int>(); } if (begin == end) { return(true); } if (!dMapLink.ContainsKey(begin)) { return(false); } MapLinkItem item = dMapLink[begin]; dfinded[begin] = 1; for (int i = 0; i < item.lLink.Count; i++) { int id = item.lLink[i].id; if (dfinded.ContainsKey(id)) { continue; } if (id == end) { line.Insert(0, item.lLink[i]); return(true); } if (getMapLine(id, end, line, dfinded)) { line.Insert(0, item.lLink[i]); return(true); } } return(false); }