123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- 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<string, CFG_Metaverse_Area> dicArea;
- private JsonData metaverse_build;
- private Dictionary<string, CFG_Metaverse_Build> dicBuild;
- private JsonData metaverse_resource;
- private Dictionary<string, CFG_Metaverse_resource> dicmodel;
- private JsonData metaverse_ground;
- private Dictionary<string, CFG_Metaverse_Ground> dicGround;
- public void InitCfg(JsonData cfg)
- {
- this.metaverse_area_block = cfg["metaverse_area_block"];
- this.dicArea = new Dictionary<string, CFG_Metaverse_Area>();
- 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<string, CFG_Metaverse_Build>();
- 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<string, CFG_Metaverse_resource>();
- 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<string, CFG_Metaverse_Ground>();
- 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
- }
- /// <summary>
- /// 获取模型配置
- /// </summary>
- /// <param name="model_id"></param>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 获取大区块配置
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 获取建筑配置
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 获取ground
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- }
- }
|