csv配置按需加载,优化之前的全部加载,造成加载时间太长
This commit is contained in:
parent
94c6ddb31b
commit
2ed158b4d3
@ -27,4 +27,9 @@ public static class Config
|
||||
public const string BossMapCfg = "BossMapCfg"; //boss 战斗地图
|
||||
public const string ResidentResCfg = "ResidentResCfg"; //常驻内存资源配置表格
|
||||
public const string MarkCfgName = "MarkCfg"; //印记配置表
|
||||
|
||||
public static string P(string tableName)
|
||||
{
|
||||
return $"Assets/Content/Config/{tableName}.csv";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public class ConfigMgr : Singleton<ConfigMgr>
|
||||
{
|
||||
@ -332,6 +336,35 @@ public class ConfigMgr : Singleton<ConfigMgr>
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void getCsvTableSync(string tablename, Action<Dictionary<string, Dictionary<string, string>>> callback)
|
||||
{
|
||||
var path = tablename;
|
||||
if (!InitFinished || ConfigDictionary == null)
|
||||
callback(null);
|
||||
Dictionary<string, Dictionary<string, string>> ts;
|
||||
ConfigDictionary.TryGetValue(tablename, out ts);
|
||||
if (ts != null && ts.Count > 0)
|
||||
callback(ts);
|
||||
else
|
||||
{
|
||||
DebugHelper.LogWarning("[ConfigMgr] {0} cant find", tablename);
|
||||
Addressables.LoadAssetAsync<TextAsset>(path).Completed += handle =>
|
||||
{
|
||||
var textAsset = handle.Result;
|
||||
Dictionary<string, Dictionary<string, string>> ts = getData(tablename, textAsset.text);
|
||||
if (ConfigDictionary.ContainsKey(tablename))
|
||||
{
|
||||
ConfigDictionary[tablename] = ts;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfigDictionary.Add(tablename, ts);
|
||||
}
|
||||
callback(ts);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public string GetXmlCfg(string fileName)
|
||||
{
|
||||
@ -354,6 +387,46 @@ public class ConfigMgr : Singleton<ConfigMgr>
|
||||
{
|
||||
return getLine(id.ToString(), tablename);
|
||||
}
|
||||
|
||||
public async UniTask<Dictionary<string, string>> getLineSync(int id, string tableName)
|
||||
{
|
||||
return await getLineSync(id.ToString(), tableName);
|
||||
}
|
||||
|
||||
public async UniTask<Dictionary<string, string>> getLineSync(string id, string tableName)
|
||||
{
|
||||
if (!InitFinished) {
|
||||
Debug.LogError("配置未加载!!!");
|
||||
return null;
|
||||
}
|
||||
var ts = await getTableSync(tableName);
|
||||
if (ts != null && ts.ContainsKey(id))
|
||||
{
|
||||
return ts[id];
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public async UniTask<Dictionary<string, Dictionary<string, string>>> getTableSync(string tableName)
|
||||
{
|
||||
if (!InitFinished || ConfigDictionary == null)
|
||||
return null;
|
||||
Dictionary<string, Dictionary<string, string>> ts;
|
||||
ConfigDictionary.TryGetValue(tableName, out ts);
|
||||
if (ts != null && ts.Count > 0)
|
||||
{
|
||||
return ts;
|
||||
}
|
||||
else
|
||||
{
|
||||
var path = tableName;
|
||||
var textAsset = await AssetsMgr.Instance.LoadAddressableAssetAsync<TextAsset>(path);
|
||||
var data = getData(tableName, textAsset.text);
|
||||
ConfigDictionary.Add(tableName, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, string> getLine(string id, string tablename)
|
||||
{
|
||||
|
||||
@ -5,12 +5,14 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Video;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using Object = UnityEngine.Object;
|
||||
public enum ELoadType : int
|
||||
{
|
||||
@ -1120,6 +1122,27 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
return 1;
|
||||
}
|
||||
|
||||
public async UniTask<T> LoadAddressableAssetAsync<T>(string assetAddress) where T : UnityEngine.Object
|
||||
{
|
||||
AssetReference assetReference = new AssetReference(assetAddress);
|
||||
// Use Addressables to load the asset asynchronously
|
||||
AsyncOperationHandle<T> handle = Addressables.LoadAssetAsync<T>(assetReference);
|
||||
|
||||
// Wait for the asset to load
|
||||
await handle.ToUniTask();
|
||||
|
||||
// If the asset was loaded successfully, return it
|
||||
if (handle.Status == AsyncOperationStatus.Succeeded)
|
||||
{
|
||||
return handle.Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Failed to load asset of type {typeof(T)}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Tag: Addressable
|
||||
IEnumerator LoadFromAddressable<T>(AssetCallbackWithParams<T> callback, long seqId, string pathName, params string[] assetName)
|
||||
{
|
||||
@ -1228,6 +1251,12 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
List<TextAsset> gos = new List<TextAsset>();
|
||||
if (assetName.Length <= 0)
|
||||
{
|
||||
Debug.Log($"[LoadFromAddressable] Start Load TextAsset from {pathName}");
|
||||
// var ids = new List<string>() { pathName };
|
||||
// var resourceLocationsHandle = Addressables.LoadResourceLocationsAsync(ids, Addressables.MergeMode.UseFirst, null);
|
||||
// yield return resourceLocationsHandle;
|
||||
// var loadAssetsHandle = Addressables.LoadAssetsAsync<TextAsset>(resourceLocationsHandle.Result, null);
|
||||
// yield return loadAssetsHandle;
|
||||
var loadHandle = Addressables.LoadAssetsAsync<TextAsset>(
|
||||
new List<string>() {pathName}, // Either a single key or a List of keys
|
||||
addressable =>
|
||||
@ -1237,9 +1266,10 @@ public class AssetsMgr : SingletonMono<AssetsMgr>
|
||||
}, Addressables.MergeMode.Union, // How to combine multiple labels
|
||||
false); // Whether to fail if any asset fails to load
|
||||
yield return loadHandle;
|
||||
foreach (var addressable in loadHandle.Result)
|
||||
Debug.Log($"[LoadFromAddressable] End Load TextAsset from {pathName}");
|
||||
foreach (var t in loadHandle.Result)
|
||||
{
|
||||
gos.Add(addressable);
|
||||
gos.Add(t);
|
||||
}
|
||||
// List<string> files = FileSystem.getAllFilesPath(pathName);
|
||||
// for (int i = 0; i < files.Count; ++i)
|
||||
|
||||
@ -913,7 +913,7 @@ public class ResourceMgr : Singleton<ResourceMgr>
|
||||
{
|
||||
if (assetNames[idx] == "Null" || string.IsNullOrEmpty(assetNames[idx]))
|
||||
{
|
||||
DebugHelper.LogError("加载的资源存在Null,请检查配置");
|
||||
DebugHelper.LogError($"加载的资源{pathName}/{assetNames[idx]}存在Null,请检查配置");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public class AvatarData
|
||||
{
|
||||
@ -58,7 +59,12 @@ public class AvatarData
|
||||
|
||||
public AvatarData(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id,Config.AvatarCfgName);
|
||||
Init(id).Forget();
|
||||
}
|
||||
|
||||
private async UniTask Init(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.AvatarCfgName));
|
||||
if(dic==null)
|
||||
{
|
||||
DebugHelper.Log("没有找到相应的avatar配置: {0}", id);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public class ProfessionData
|
||||
{
|
||||
@ -83,9 +84,14 @@ public class ProfessionData
|
||||
#endregion
|
||||
|
||||
public ProfessionData(int id)
|
||||
{
|
||||
ProfessionDataInit(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask ProfessionDataInit(int id)
|
||||
{
|
||||
//DebugHelper.Log("profession Id:" + id);
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.JobCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.JobCfgName));
|
||||
if(dic!=null)
|
||||
{
|
||||
this.mID = id;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
/// 角色基础属性内容相关信息
|
||||
/// </summary>
|
||||
@ -16,10 +18,10 @@ public class RoleAttributeData
|
||||
private bool bValid = false;
|
||||
public bool valid { get { return bValid; } }
|
||||
|
||||
public RoleAttributeData(int level)
|
||||
async UniTask RoleAttributeDataInit(int level)
|
||||
{
|
||||
this.id = level;
|
||||
Dictionary<string,string> dic = ConfigMgr.Instance.getLine(level, Config.RoleAttrCfgName);
|
||||
Dictionary<string,string> dic = await ConfigMgr.Instance.getLineSync(level, Config.P(Config.RoleAttrCfgName));
|
||||
if(dic == null)
|
||||
{
|
||||
DebugHelper.LogError(string.Format("加载角色属性数据失败 id = {0}", id));
|
||||
@ -89,6 +91,10 @@ public class RoleAttributeData
|
||||
}
|
||||
bValid = true;
|
||||
}
|
||||
public RoleAttributeData(int level)
|
||||
{
|
||||
RoleAttributeDataInit(level).Forget();
|
||||
}
|
||||
|
||||
public SInt GetAttr(int attrId)
|
||||
{
|
||||
@ -138,7 +144,12 @@ public class RoleBaseData
|
||||
public RoleBaseData(int id)
|
||||
{
|
||||
Id = id;
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.RoleCfgName);
|
||||
RoleBaseDataInit(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask RoleBaseDataInit(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.RoleCfgName));
|
||||
if(dic!=null)
|
||||
{
|
||||
if (dic.ContainsKey("Name"))
|
||||
@ -261,12 +272,12 @@ public class NpcBaseData
|
||||
public NpcBaseData(int id)
|
||||
{
|
||||
npcId = id;
|
||||
ReadFromConfig();
|
||||
ReadFromConfig().Forget();
|
||||
}
|
||||
|
||||
void ReadFromConfig()
|
||||
async UniTask ReadFromConfig()
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(this.npcId, Config.NpcCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(this.npcId, Config.P(Config.NpcCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.npcName = dic["Name"];
|
||||
@ -532,7 +543,12 @@ public class PetBossBaseData: PetBaseData
|
||||
}
|
||||
protected override void ReadFromConfig()
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(petId, Config.PetBossCfgName);
|
||||
ReadFromConfigAsync().Forget();
|
||||
}
|
||||
|
||||
async UniTask ReadFromConfigAsync()
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(petId, Config.P(Config.PetBossCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.petName = dic["Name"];
|
||||
@ -775,7 +791,12 @@ public class PetBaseData
|
||||
|
||||
protected virtual void ReadFromConfig()
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(petId, Config.PetCfgName);
|
||||
ReadFromConfigAsync().Forget();
|
||||
}
|
||||
|
||||
async UniTask ReadFromConfigAsync()
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(petId, Config.P(Config.PetCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.petName = dic["Name"];
|
||||
@ -994,12 +1015,12 @@ public class PetAdvanceData
|
||||
public Dictionary<int, List<ValType>> advanceRateData;
|
||||
public PetAdvanceData(int id)
|
||||
{
|
||||
ReadFromConfig(id);
|
||||
ReadFromConfig(id).Forget();
|
||||
}
|
||||
|
||||
void ReadFromConfig(int petId)
|
||||
async UniTask ReadFromConfig(int petId)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(petId, Config.PetProgressCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(petId, Config.P(Config.PetProgressCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
advanceData = new Dictionary<int, List<ValType>>();
|
||||
@ -1110,7 +1131,12 @@ public class FellowBaseData
|
||||
|
||||
public FellowBaseData(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.FellowCfgName);
|
||||
FellowBaseDataInit(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask FellowBaseDataInit(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.FellowCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.Id = id;
|
||||
@ -1273,9 +1299,14 @@ public class FellowAttributeData
|
||||
public bool valid { get { return bValid; } }
|
||||
|
||||
public FellowAttributeData(int level)
|
||||
{
|
||||
FellowAttributeDataInit(level).Forget();
|
||||
}
|
||||
|
||||
async UniTask FellowAttributeDataInit(int level)
|
||||
{
|
||||
this.id = level;
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(level, Config.FellowAttrCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(level, Config.P(Config.FellowAttrCfgName));
|
||||
if (dic == null)
|
||||
{
|
||||
DebugHelper.LogError(string.Format("加载角色属性数据失败 id = {0}", id));
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public class BossMapData
|
||||
{
|
||||
@ -13,7 +14,12 @@ public class BossMapData
|
||||
|
||||
public BossMapData(int mapId)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(mapId, Config.BossMapCfg);
|
||||
BulletDataInit(mapId).Forget();
|
||||
}
|
||||
|
||||
async UniTask BulletDataInit(int mapId)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(mapId, Config.P(Config.BossMapCfg));
|
||||
if(dic!=null)
|
||||
{
|
||||
this.id = mapId;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public enum BattleBuffType
|
||||
{
|
||||
@ -452,7 +453,13 @@ public class BuffFunctionData
|
||||
|
||||
public BuffFunctionData(int id, float val, float incVal, float duration, float incDur, int[] fromAttr, float intervalTime,string extendParam)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.FunctionCfgName);
|
||||
BuffFunctionDataInit(id, val, incVal, duration, incDur, fromAttr, intervalTime, extendParam).Forget();
|
||||
}
|
||||
|
||||
async UniTask BuffFunctionDataInit(int id, float val, float incVal, float duration, float incDur, int[] fromAttr, float intervalTime,
|
||||
string extendParam)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.FunctionCfgName));
|
||||
if (dic == null) return;
|
||||
|
||||
this.id = id;
|
||||
@ -640,7 +647,12 @@ public class BuffData
|
||||
|
||||
public BuffData(int id, int gender, ProfessionType jobType, int jobStage, int jobBranch)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.BuffCfgName);
|
||||
BuffDataInit(id, gender, jobType, jobStage, jobBranch).Forget();
|
||||
}
|
||||
|
||||
async UniTask BuffDataInit(int id, int gender, ProfessionType jobType, int jobStage, int jobBranch)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.BuffCfgName));
|
||||
if (dic == null)
|
||||
{
|
||||
DebugHelper.LogWarning(string.Format("{0} buff 在buff配表中不存在", id));
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
//子弹移动类型
|
||||
public enum BulletMoveType
|
||||
@ -64,7 +65,12 @@ public class BulletData
|
||||
|
||||
public BulletData(int id)
|
||||
{
|
||||
Dictionary<string, string> cfg = ConfigMgr.Instance.getLine(id, Config.BulletCfgName);
|
||||
BulletDataInit(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask BulletDataInit(int id)
|
||||
{
|
||||
Dictionary<string, string> cfg = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.BulletCfgName));
|
||||
if(cfg!=null)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public enum EffectFollowType
|
||||
{
|
||||
@ -71,7 +72,12 @@ public class EffectData
|
||||
|
||||
if (id == 0) return;
|
||||
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.EffectCfgName);
|
||||
Init(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask Init(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.EffectCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Collections;
|
||||
using LuaInterface;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public static class LuaBattleBridge
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
//关卡数据
|
||||
public class LevelItem : IComparable<LevelItem>
|
||||
@ -158,20 +159,25 @@ public class LevelItem : IComparable<LevelItem>
|
||||
#endregion
|
||||
|
||||
public LevelItem(int mapId, int levelId)
|
||||
{
|
||||
LevelItemInit(mapId, levelId).Forget();
|
||||
}
|
||||
|
||||
async UniTask LevelItemInit(int mapId, int levelId)
|
||||
{
|
||||
this.LevelId = levelId;
|
||||
this.MapId = mapId;
|
||||
ReadFromConfig();
|
||||
await ReadFromConfig();
|
||||
InitMonsterData();
|
||||
}
|
||||
|
||||
void ReadFromConfig()
|
||||
async UniTask ReadFromConfig()
|
||||
{
|
||||
int miniRewardTime = GlobalConfig.Instance.GetConfigIntValue(GlobalConfig.c_miniRewardTime_cfg_id) / 60;
|
||||
if (miniRewardTime == 0) miniRewardTime = 1;
|
||||
|
||||
int id = MapId * 10000 + LevelId;
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.LevelCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.LevelCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.Name = dic["Name"];
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public class SceneData
|
||||
{
|
||||
@ -225,7 +226,7 @@ public class SceneItem : IComparable<SceneItem>
|
||||
public SceneItem(int id)
|
||||
{
|
||||
this.mMapId = id;
|
||||
ReadLevelFromConfig();
|
||||
ReadLevelFromConfig().Forget();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
@ -344,14 +345,14 @@ public class SceneItem : IComparable<SceneItem>
|
||||
// return mLevelItems[mLevelItems.Count - 1].LevelId == levelId;
|
||||
//}
|
||||
|
||||
void ReadLevelFromConfig()
|
||||
async UniTask ReadLevelFromConfig()
|
||||
{
|
||||
List<LevelItem> levelList = new List<LevelItem>();
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(MapId,Config.MapCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(MapId,Config.MapCfgName);
|
||||
if (dic != null)
|
||||
{
|
||||
int levelId = 1;
|
||||
while (ConfigUtil.HasLevel(this.MapId, levelId))
|
||||
while (await ConfigUtil.HasLevel(this.MapId, levelId))
|
||||
{
|
||||
LevelItem li = new LevelItem(this.MapId, levelId);
|
||||
levelList.Add(li);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public class MarkData
|
||||
{
|
||||
@ -45,7 +46,12 @@ public class MarkData
|
||||
|
||||
public MarkData(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.MarkCfgName);
|
||||
MarkDataInit(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask MarkDataInit(int id)
|
||||
{
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.MarkCfgName));
|
||||
if(dic == null)
|
||||
{
|
||||
DebugHelper.LogError(string.Format("印记 {0} 没有配置", id));
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public enum SkillRangeType
|
||||
{
|
||||
@ -511,10 +512,15 @@ public class SkillData
|
||||
private bool mbDisposed = false;
|
||||
|
||||
public SkillData(int skillId,int level)
|
||||
{
|
||||
SkillDataInit(skillId, level).Forget();
|
||||
}
|
||||
|
||||
async UniTask SkillDataInit(int skillId, int level)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(skillId, Config.SkillCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(skillId, Config.P(Config.SkillCfgName));
|
||||
if (dic != null)
|
||||
{
|
||||
this.skillId = skillId;
|
||||
@ -571,7 +577,7 @@ public class SkillData
|
||||
extendBuffIds = StringUtil.convert2IntList(dic["ExtendBuffs"],';');
|
||||
}
|
||||
|
||||
ReadSkillLevelCfg(skillId, level);
|
||||
await ReadSkillLevelCfg(skillId, level);
|
||||
valid = true;
|
||||
}
|
||||
else
|
||||
@ -585,11 +591,11 @@ public class SkillData
|
||||
}
|
||||
}
|
||||
|
||||
void ReadSkillLevelCfg(int skillId, int level)
|
||||
async UniTask ReadSkillLevelCfg(int skillId, int level)
|
||||
{
|
||||
int id = skillId * 1000 + level;
|
||||
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.SkillLvCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(id, Config.P(Config.SkillLvCfgName));
|
||||
if(dic != null)
|
||||
{
|
||||
if (dic.ContainsKey("Cost"))
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.UI;
|
||||
@ -260,6 +261,11 @@ public class StoryMgr : SingletonMono<StoryMgr>
|
||||
}
|
||||
[NoToLua]
|
||||
public void StartStory(int id)
|
||||
{
|
||||
StartStoryInit(id).Forget();
|
||||
}
|
||||
|
||||
async UniTask StartStoryInit(int id)
|
||||
{
|
||||
InitStoryUIRoot();
|
||||
|
||||
@ -269,7 +275,7 @@ public class StoryMgr : SingletonMono<StoryMgr>
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<string, string> data = ConfigMgr.Instance.getLine(id, storyCfgName);
|
||||
Dictionary<string, string> data = await ConfigMgr.Instance.getLineSync(id, Config.P(storyCfgName));
|
||||
if (data == null)
|
||||
{
|
||||
DebugHelper.LogError(id + " StoryData isnt exist,please check!!!");
|
||||
@ -279,7 +285,7 @@ public class StoryMgr : SingletonMono<StoryMgr>
|
||||
if (data["type"].CompareTo("0") == 0)
|
||||
{
|
||||
//simple story
|
||||
PlaySimpleStory(data);
|
||||
PlaySimpleStory(data).Forget();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -416,12 +422,9 @@ public class StoryMgr : SingletonMono<StoryMgr>
|
||||
talkText.text = ConfigMgr.Instance.getValue(dlgId, "content", dlgCfgName);
|
||||
}
|
||||
[NoToLua]
|
||||
IPlayableAssetDeal AssembleStoryPlayableAsset(int id, out int endTime)
|
||||
IPlayableAssetDeal AssembleStoryPlayableAsset(Dictionary<string, string> data)
|
||||
{
|
||||
Dictionary<string, string> data = ConfigMgr.Instance.getLine(id, "SStoryContentCfg");
|
||||
endTime = (int)Double.Parse(data["endTime"]);
|
||||
int aniType = (int)Double.Parse(data["aniType"]);
|
||||
|
||||
IPlayableAssetDeal pa = null;
|
||||
switch(aniType)
|
||||
{
|
||||
@ -447,8 +450,9 @@ public class StoryMgr : SingletonMono<StoryMgr>
|
||||
|
||||
return pa;
|
||||
}
|
||||
|
||||
[NoToLua]
|
||||
void PlaySimpleStory(Dictionary<string, string> data)
|
||||
async UniTask PlaySimpleStory(Dictionary<string, string> data)
|
||||
{
|
||||
SimpleStoryModule sStoryModule = new SimpleStoryModule();
|
||||
sStoryModule.storyPAs = new List<IPlayableAssetDeal>();
|
||||
@ -457,7 +461,8 @@ public class StoryMgr : SingletonMono<StoryMgr>
|
||||
string[] storyIds = data["storyId"].Split(';');
|
||||
foreach (var id in storyIds)
|
||||
{
|
||||
IPlayableAssetDeal pa = AssembleStoryPlayableAsset((int)Double.Parse(id), out endTime); ;
|
||||
Dictionary<string, string> cfg = await ConfigMgr.Instance.getLineSync(id, "SStoryContentCfg");
|
||||
IPlayableAssetDeal pa = AssembleStoryPlayableAsset(cfg);
|
||||
if (pa != null)
|
||||
{
|
||||
sStoryModule.storyPAs.Add(pa);
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
public static class ConfigUtil
|
||||
{
|
||||
public static bool HasLevel(int mapId,int levelId)
|
||||
public static async UniTask<bool> HasLevel(int mapId,int levelId)
|
||||
{
|
||||
int tempId = mapId * 10000 + levelId;
|
||||
Dictionary<string, string> dic = ConfigMgr.Instance.getLine(tempId, Config.LevelCfgName);
|
||||
Dictionary<string, string> dic = await ConfigMgr.Instance.getLineSync(tempId, Config.P(Config.LevelCfgName));
|
||||
return dic != null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user