private void ReadObjsInConfig(SceneVo scene_vo, string scene_content, string pattern, Dictionary <int, List <SceneObjVo> > dic, SceneObjType obj_type) { Match match = Regex.Match(scene_content, pattern); if (match.Groups.Count < 2) { return; } bool is_first = true; Match m = Regex.Match(match.Groups[1].ToString(), "id=(\\d*), x=(\\d*), y=(\\d*)"); while (m.Success) { if (m.Groups.Count >= 4) { SceneObjVo vo = new SceneObjVo(); vo.sceneId = scene_vo.sceneId; vo.id = Convert.ToInt32(m.Groups[1].ToString()); vo.x = Convert.ToInt32(m.Groups[2].ToString()); vo.y = Convert.ToInt32(m.Groups[3].ToString()); // 普通场景的限制 if (0 == scene_vo.sceneType) { if (SceneObjType.NPC == obj_type && dic.ContainsKey(vo.id)) { Command.Instance.PrintLog(string.Format("错误:有相同的NPC,可能导致任务寻路失败, scene_id={0}, npc_id = {1}", vo.sceneId, vo.id), Color.Red); } if (is_first) { is_first = false; if (SceneObjType.MONSTER == obj_type && dic.ContainsKey(vo.id)) { Command.Instance.PrintLog(string.Format("警告:不同场景有相同的怪物,可能导致任务寻路失败, scene_id={0}, monster_id = {1}", vo.sceneId, vo.id), Color.YellowGreen); } if (SceneObjType.GATHER == obj_type && dic.ContainsKey(vo.id)) { Command.Instance.PrintLog(string.Format("错误:不同场景有相同的的采集物,可能导致任务寻路失败, scene_id={0}, gather_id = {1}", vo.sceneId, vo.id), Color.Red); } } } List <SceneObjVo> vo_list; if (!dic.TryGetValue(vo.id, out vo_list)) { vo_list = new List <SceneObjVo>(); dic.Add(vo.id, vo_list); } vo_list.Add(vo); } m = m.NextMatch(); } }
private bool ReadSceneIdList() { this.sceneVoList.Clear(); string path = string.Format("{0}/../config_map.lua", ConfigIni.LuaDir); if (!File.Exists(path)) { return(false); } try { string content = File.ReadAllText(path); MatchCollection match_list = Regex.Matches(content, "\\[(\\d*)\\].*sceneType = (\\d*)"); foreach (Match m in match_list) { if (m.Groups.Count >= 3) { SceneVo vo = new SceneVo(); vo.sceneId = Convert.ToInt32(m.Groups[1].ToString()); vo.sceneType = Convert.ToInt32(m.Groups[2].ToString()); this.sceneVoList.Add(vo); } } return(true); } catch (Exception) { return(false); throw; } }