using LitJson; using System.Collections; using System.Collections.Generic; using UnityEngine; public class CFG_Metaverse_Area { public string area_block_id;//大区块ID public JsonData area_block_export;//大区的系统数据 json public string[] area_block_nears; //大区块临近的大区块id序列 //public IList area_block_bornpos;//大区块内的出生点位 public string[] area_block_builds;//大区块上默认的build public CFG_Metaverse_Area(JsonData jsonData) { this.area_block_id = jsonData["area_block_id"].ToString(); this.area_block_export = JsonMapper.ToObject(jsonData["area_block_export"].ToString()); string str = jsonData["area_block_nears"].ToString(); this.area_block_nears = str.Split(','); //this.area_block_bornpos = jsonData["area_block_bornpos"]; string str1 = jsonData["area_block_builds"].ToString(); this.area_block_builds = str1.Split(','); } } public class CFG_Metaverse_resource { //public string id;// 自增ID public string model_id;// 模型ID public string model_name;// 模型名称 public string mode_pkg_name;// 模型包名 public string model_icon;// 模型icon public string model_prefab;// 模型对应文件 public CFG_Metaverse_resource(JsonData jsonData) { this.model_id = jsonData["model_id"].ToString(); this.model_name = jsonData["model_name"].ToString(); this.mode_pkg_name = jsonData["mode_pkg_name"].ToString(); this.model_icon = jsonData["model_icon"].ToString(); this.model_prefab = jsonData["model_prefab"].ToString(); } } public class CFG_Metaverse_Ground { public string ground_id;// 地块ID public string area_block_id;// 属大区块ID public string ground_name;// 地块名称 public string ground_area;// 地块面积 public IList ground_location;// 地块位置 public IList ground_rotate;// 地块旋转 public IList ground_zoom;// 地块缩放 public string ground_price;// 地块现价 public string ground_price_origin;// 地块原价 public string ground_sell_flag;// 0:不可出售 1:可出售 public string ground_sell_sdate;// 开售日期 public string ground_sell_edate;// 停售日期 public string ground_room_large;// 挂载室内场景大小比例 public string ground_scene_out;// 挂载的室外场景 public string ground_scene_inner;// 挂载的室内场景 public CFG_Metaverse_Ground(JsonData jsonData) { this.ground_id = jsonData["ground_id"].ToString(); this.area_block_id = jsonData["area_block_id"].ToString(); this.ground_name = jsonData["ground_name"].ToString(); this.ground_area = jsonData["ground_area"].ToString(); this.ground_location = JsonMapper.ToObject(jsonData["ground_location"].ToString()); this.ground_rotate = JsonMapper.ToObject(jsonData["ground_rotate"].ToString()); this.ground_zoom = JsonMapper.ToObject(jsonData["ground_zoom"].ToString()); this.ground_price = jsonData["ground_price"].ToString(); this.ground_price_origin = jsonData["ground_price_origin"].ToString(); this.ground_sell_flag = jsonData["ground_sell_flag"].ToString(); this.ground_sell_sdate = jsonData["ground_sell_sdate"].ToString(); this.ground_sell_edate = jsonData["ground_sell_edate"].ToString(); this.ground_room_large = jsonData["ground_room_large"].ToString(); this.ground_scene_out = jsonData["ground_scene_out"].ToString(); this.ground_scene_inner = jsonData["ground_scene_inner"].ToString(); } } public class CFG_Metaverse_Build { public string build_id;// 建筑ID public string area_block_id;// 所属区块ID public string build_type;// 建筑类型 public string build_name;// 建筑名称 public JsonData build_indoor_pos;// 建筑入口位置 public IList build_location;// 建筑位置 public IList build_rotate;// 建筑旋转 public IList build_zoom;// 建筑缩放 public string build_outdoor_change;// 0:不可改变 1:可改变 public string model_id;// 模型ID public string build_price;// 建筑现价 public string build_price_origin;// 建筑原价 public string build_sell_flag;// 0:不可出售 1:可出售 //public string build_sell_sdate;// NULL开售时间 //public string build_sell_edate;// NULL停售日期 public CFG_Metaverse_Build(JsonData jsonData) { this.build_id = jsonData["build_id"].ToString(); this.area_block_id = jsonData["area_block_id"].ToString(); this.build_type = jsonData["build_type"].ToString(); this.build_name = jsonData["build_name"].ToString(); this.build_indoor_pos = JsonMapper.ToObject(jsonData["build_indoor_pos"].ToString()); this.build_location = JsonMapper.ToObject(jsonData["build_location"].ToString()); this.build_rotate = JsonMapper.ToObject(jsonData["build_rotate"].ToString()); this.build_zoom = JsonMapper.ToObject(jsonData["build_zoom"].ToString()); this.build_outdoor_change = jsonData["build_outdoor_change"].ToString(); this.model_id = jsonData["model_id"].ToString(); this.build_price = jsonData["build_price"].ToString(); this.build_price_origin = jsonData["build_price_origin"].ToString(); this.build_sell_flag = jsonData["build_sell_flag"].ToString(); //this.build_sell_sdate = jsonData["build_sell_sdate"].ToString(); //this.build_sell_edate = jsonData["build_sell_edate"].ToString(); } } public class CfgManager { private static CfgManager _Instance; public static CfgManager Instance { get { if (CfgManager._Instance == null) CfgManager._Instance = new CfgManager(); return CfgManager._Instance; } } private JsonData metaverse_area_block; private Dictionary dicArea; private JsonData metaverse_build; private Dictionary dicBuild; private JsonData metaverse_resource; private Dictionary dicmodel; private JsonData metaverse_ground; private Dictionary dicGround; public void InitCfg(JsonData cfg) { this.metaverse_area_block = cfg["metaverse_area_block"]; this.dicArea = new Dictionary(); IList listArea = this.metaverse_area_block; for (int i = 0, n = listArea.Count; i < n; i++) { //Debug.Log(listArea[i]); var cFG_Metaverse_Area = new CFG_Metaverse_Area(listArea[i] as JsonData); this.dicArea.Add(cFG_Metaverse_Area.area_block_id, cFG_Metaverse_Area); } this.metaverse_build = cfg["metaverse_build"]; this.dicBuild = new Dictionary(); IList listBuild = this.metaverse_build; for (int i = 0, n = listBuild.Count; i < n; i++) { var cFG_Metaverse_Build = new CFG_Metaverse_Build(listBuild[i] as JsonData); this.dicBuild.Add(cFG_Metaverse_Build.build_id, cFG_Metaverse_Build); } this.metaverse_resource = cfg["metaverse_resource"]; this.dicmodel = new Dictionary(); IList listmodel = this.metaverse_resource; for (int i = 0, n = listmodel.Count; i < n; i++) { CFG_Metaverse_resource cFG_Metaverse_resource = new CFG_Metaverse_resource(listmodel[i] as JsonData); this.dicmodel.Add(cFG_Metaverse_resource.model_id, cFG_Metaverse_resource); } this.metaverse_ground = cfg["metaverse_ground"]; this.dicGround = new Dictionary(); IList listGround = this.metaverse_ground; for (int i = 0, n = listGround.Count; i < n; i++) { CFG_Metaverse_Ground cFG_Metaverse_Ground = new CFG_Metaverse_Ground(listGround[i] as JsonData); this.dicGround.Add(cFG_Metaverse_Ground.ground_id, cFG_Metaverse_Ground); } //TODO } /// /// 获取模型配置 /// /// /// public CFG_Metaverse_resource GetModel(string model_id) { if (this.dicmodel.ContainsKey(model_id)) { return this.dicmodel[model_id]; } else { Debug.LogError("CFG_Metaverse_resource NOT EXIST :" + model_id); return null; } } /// /// 获取大区块配置 /// /// /// public CFG_Metaverse_Area GetArea(string id) { if (this.dicArea.ContainsKey(id)) { return this.dicArea[id]; } else { Debug.LogError("CFG_Metaverse_Area NOT EXIST :" + id); return null; } } /// /// 获取建筑配置 /// /// /// public CFG_Metaverse_Build GetBuild(string id) { if (this.dicBuild.ContainsKey(id)) { return this.dicBuild[id]; } else { Debug.LogError("CFG_Metaverse_Build NOT EXIST :" + id); return null; } } /// /// 获取ground /// /// /// public CFG_Metaverse_Ground GetGround(string id) { if (this.dicGround.ContainsKey(id)) { return this.dicGround[id]; } else { Debug.LogError("CFG_Metaverse_Ground NOT EXIST :" + id); return null; } } }