/// <summary> /// 初始化 /// </summary> /// <param name="parse"></param> public void Init(MapParse parse) { m_areas = new AreaComponent[parse.areaCount]; for (int i = 0; i < parse.areaCount; i++) { GameObject go = new GameObject(); go.name = parse.areas[i].index.ToString(); go.transform.parent = transform; var ac = go.AddComponent <AreaComponent>(); ac.Init(parse.areas[i]); m_areas[i] = ac; } }
/// <summary> /// 初始化地图 /// </summary> /// <param name="mapName"></param> public void InitMap(string mapName) { // 加载地图配置 var bundleName = "maps/datas/" + mapName.ToLower(); var assetName = mapName + ".xml"; var ml = ResMgr.Instance.LoadSync(bundleName, assetName, null); var asset = ml.assetRes.GetAsset <TextAsset>(); MapParse parse = new MapParse(asset.text); parse.Parse(); ml.Unload(); ml = null; // 初始化地图组件 GameObject map = new GameObject(); map.name = "MapComponent"; m_mapComponent = map.AddComponent <MapComponent>(); m_mapComponent.Init(parse); }