CfgManager.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using LitJson;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class CFG_Metaverse_Area
  6. {
  7. public string area_block_id;//大区块ID
  8. public JsonData area_block_export;//大区的系统数据 json
  9. public string[] area_block_nears; //大区块临近的大区块id序列
  10. //public IList area_block_bornpos;//大区块内的出生点位
  11. public string[] area_block_builds;//大区块上默认的build
  12. public CFG_Metaverse_Area(JsonData jsonData)
  13. {
  14. this.area_block_id = jsonData["area_block_id"].ToString();
  15. this.area_block_export = JsonMapper.ToObject(jsonData["area_block_export"].ToString());
  16. string str = jsonData["area_block_nears"].ToString();
  17. this.area_block_nears = str.Split(',');
  18. //this.area_block_bornpos = jsonData["area_block_bornpos"];
  19. string str1 = jsonData["area_block_builds"].ToString();
  20. this.area_block_builds = str1.Split(',');
  21. }
  22. }
  23. public class CFG_Metaverse_resource
  24. {
  25. //public string id;// 自增ID
  26. public string model_id;// 模型ID
  27. public string model_name;// 模型名称
  28. public string mode_pkg_name;// 模型包名
  29. public string model_icon;// 模型icon
  30. public string model_prefab;// 模型对应文件
  31. public CFG_Metaverse_resource(JsonData jsonData)
  32. {
  33. this.model_id = jsonData["model_id"].ToString();
  34. this.model_name = jsonData["model_name"].ToString();
  35. this.mode_pkg_name = jsonData["mode_pkg_name"].ToString();
  36. this.model_icon = jsonData["model_icon"].ToString();
  37. this.model_prefab = jsonData["model_prefab"].ToString();
  38. }
  39. }
  40. public class CFG_Metaverse_Ground
  41. {
  42. public string ground_id;// 地块ID
  43. public string area_block_id;// 属大区块ID
  44. public string ground_name;// 地块名称
  45. public string ground_area;// 地块面积
  46. public IList ground_location;// 地块位置
  47. public IList ground_rotate;// 地块旋转
  48. public IList ground_zoom;// 地块缩放
  49. public string ground_price;// 地块现价
  50. public string ground_price_origin;// 地块原价
  51. public string ground_sell_flag;// 0:不可出售 1:可出售
  52. public string ground_sell_sdate;// 开售日期
  53. public string ground_sell_edate;// 停售日期
  54. public string ground_room_large;// 挂载室内场景大小比例
  55. public string ground_scene_out;// 挂载的室外场景
  56. public string ground_scene_inner;// 挂载的室内场景
  57. public CFG_Metaverse_Ground(JsonData jsonData)
  58. {
  59. this.ground_id = jsonData["ground_id"].ToString();
  60. this.area_block_id = jsonData["area_block_id"].ToString();
  61. this.ground_name = jsonData["ground_name"].ToString();
  62. this.ground_area = jsonData["ground_area"].ToString();
  63. this.ground_location = JsonMapper.ToObject(jsonData["ground_location"].ToString());
  64. this.ground_rotate = JsonMapper.ToObject(jsonData["ground_rotate"].ToString());
  65. this.ground_zoom = JsonMapper.ToObject(jsonData["ground_zoom"].ToString());
  66. this.ground_price = jsonData["ground_price"].ToString();
  67. this.ground_price_origin = jsonData["ground_price_origin"].ToString();
  68. this.ground_sell_flag = jsonData["ground_sell_flag"].ToString();
  69. this.ground_sell_sdate = jsonData["ground_sell_sdate"].ToString();
  70. this.ground_sell_edate = jsonData["ground_sell_edate"].ToString();
  71. this.ground_room_large = jsonData["ground_room_large"].ToString();
  72. this.ground_scene_out = jsonData["ground_scene_out"].ToString();
  73. this.ground_scene_inner = jsonData["ground_scene_inner"].ToString();
  74. }
  75. }
  76. public class CFG_Metaverse_Build
  77. {
  78. public string build_id;// 建筑ID
  79. public string area_block_id;// 所属区块ID
  80. public string build_type;// 建筑类型
  81. public string build_name;// 建筑名称
  82. public JsonData build_indoor_pos;// 建筑入口位置
  83. public IList build_location;// 建筑位置
  84. public IList build_rotate;// 建筑旋转
  85. public IList build_zoom;// 建筑缩放
  86. public string build_outdoor_change;// 0:不可改变 1:可改变
  87. public string model_id;// 模型ID
  88. public string build_price;// 建筑现价
  89. public string build_price_origin;// 建筑原价
  90. public string build_sell_flag;// 0:不可出售 1:可出售
  91. //public string build_sell_sdate;// NULL开售时间
  92. //public string build_sell_edate;// NULL停售日期
  93. public CFG_Metaverse_Build(JsonData jsonData)
  94. {
  95. this.build_id = jsonData["build_id"].ToString();
  96. this.area_block_id = jsonData["area_block_id"].ToString();
  97. this.build_type = jsonData["build_type"].ToString();
  98. this.build_name = jsonData["build_name"].ToString();
  99. this.build_indoor_pos = JsonMapper.ToObject(jsonData["build_indoor_pos"].ToString());
  100. this.build_location = JsonMapper.ToObject(jsonData["build_location"].ToString());
  101. this.build_rotate = JsonMapper.ToObject(jsonData["build_rotate"].ToString());
  102. this.build_zoom = JsonMapper.ToObject(jsonData["build_zoom"].ToString());
  103. this.build_outdoor_change = jsonData["build_outdoor_change"].ToString();
  104. this.model_id = jsonData["model_id"].ToString();
  105. this.build_price = jsonData["build_price"].ToString();
  106. this.build_price_origin = jsonData["build_price_origin"].ToString();
  107. this.build_sell_flag = jsonData["build_sell_flag"].ToString();
  108. //this.build_sell_sdate = jsonData["build_sell_sdate"].ToString();
  109. //this.build_sell_edate = jsonData["build_sell_edate"].ToString();
  110. }
  111. }
  112. public class CfgManager
  113. {
  114. private static CfgManager _Instance;
  115. public static CfgManager Instance
  116. {
  117. get
  118. {
  119. if (CfgManager._Instance == null) CfgManager._Instance = new CfgManager();
  120. return CfgManager._Instance;
  121. }
  122. }
  123. private JsonData metaverse_area_block;
  124. private Dictionary<string, CFG_Metaverse_Area> dicArea;
  125. private JsonData metaverse_build;
  126. private Dictionary<string, CFG_Metaverse_Build> dicBuild;
  127. private JsonData metaverse_resource;
  128. private Dictionary<string, CFG_Metaverse_resource> dicmodel;
  129. private JsonData metaverse_ground;
  130. private Dictionary<string, CFG_Metaverse_Ground> dicGround;
  131. public void InitCfg(JsonData cfg)
  132. {
  133. this.metaverse_area_block = cfg["metaverse_area_block"];
  134. this.dicArea = new Dictionary<string, CFG_Metaverse_Area>();
  135. IList listArea = this.metaverse_area_block;
  136. for (int i = 0, n = listArea.Count; i < n; i++)
  137. {
  138. //Debug.Log(listArea[i]);
  139. var cFG_Metaverse_Area = new CFG_Metaverse_Area(listArea[i] as JsonData);
  140. this.dicArea.Add(cFG_Metaverse_Area.area_block_id, cFG_Metaverse_Area);
  141. }
  142. this.metaverse_build = cfg["metaverse_build"];
  143. this.dicBuild = new Dictionary<string, CFG_Metaverse_Build>();
  144. IList listBuild = this.metaverse_build;
  145. for (int i = 0, n = listBuild.Count; i < n; i++)
  146. {
  147. var cFG_Metaverse_Build = new CFG_Metaverse_Build(listBuild[i] as JsonData);
  148. this.dicBuild.Add(cFG_Metaverse_Build.build_id, cFG_Metaverse_Build);
  149. }
  150. this.metaverse_resource = cfg["metaverse_resource"];
  151. this.dicmodel = new Dictionary<string, CFG_Metaverse_resource>();
  152. IList listmodel = this.metaverse_resource;
  153. for (int i = 0, n = listmodel.Count; i < n; i++)
  154. {
  155. CFG_Metaverse_resource cFG_Metaverse_resource = new CFG_Metaverse_resource(listmodel[i] as JsonData);
  156. this.dicmodel.Add(cFG_Metaverse_resource.model_id, cFG_Metaverse_resource);
  157. }
  158. this.metaverse_ground = cfg["metaverse_ground"];
  159. this.dicGround = new Dictionary<string, CFG_Metaverse_Ground>();
  160. IList listGround = this.metaverse_ground;
  161. for (int i = 0, n = listGround.Count; i < n; i++)
  162. {
  163. CFG_Metaverse_Ground cFG_Metaverse_Ground = new CFG_Metaverse_Ground(listGround[i] as JsonData);
  164. this.dicGround.Add(cFG_Metaverse_Ground.ground_id, cFG_Metaverse_Ground);
  165. }
  166. //TODO
  167. }
  168. /// <summary>
  169. /// 获取模型配置
  170. /// </summary>
  171. /// <param name="model_id"></param>
  172. /// <returns></returns>
  173. public CFG_Metaverse_resource GetModel(string model_id)
  174. {
  175. if (this.dicmodel.ContainsKey(model_id))
  176. {
  177. return this.dicmodel[model_id];
  178. }
  179. else
  180. {
  181. Debug.LogError("CFG_Metaverse_resource NOT EXIST :" + model_id);
  182. return null;
  183. }
  184. }
  185. /// <summary>
  186. /// 获取大区块配置
  187. /// </summary>
  188. /// <param name="id"></param>
  189. /// <returns></returns>
  190. public CFG_Metaverse_Area GetArea(string id)
  191. {
  192. if (this.dicArea.ContainsKey(id))
  193. {
  194. return this.dicArea[id];
  195. }
  196. else
  197. {
  198. Debug.LogError("CFG_Metaverse_Area NOT EXIST :" + id);
  199. return null;
  200. }
  201. }
  202. /// <summary>
  203. /// 获取建筑配置
  204. /// </summary>
  205. /// <param name="id"></param>
  206. /// <returns></returns>
  207. public CFG_Metaverse_Build GetBuild(string id)
  208. {
  209. if (this.dicBuild.ContainsKey(id))
  210. {
  211. return this.dicBuild[id];
  212. }
  213. else
  214. {
  215. Debug.LogError("CFG_Metaverse_Build NOT EXIST :" + id);
  216. return null;
  217. }
  218. }
  219. /// <summary>
  220. /// 获取ground
  221. /// </summary>
  222. /// <param name="id"></param>
  223. /// <returns></returns>
  224. public CFG_Metaverse_Ground GetGround(string id)
  225. {
  226. if (this.dicGround.ContainsKey(id))
  227. {
  228. return this.dicGround[id];
  229. }
  230. else
  231. {
  232. Debug.LogError("CFG_Metaverse_Ground NOT EXIST :" + id);
  233. return null;
  234. }
  235. }
  236. }