From cbc700bb714489f5f1b3e51ce705ae763cf612e0 Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期二, 13 十一月 2018 16:29:37 +0800
Subject: [PATCH] 4129 技能相关特效预加载及异步加载逻辑修改
---
System/GeneralConfig/GeneralDefine.cs | 6 +
UI/Common/UI3DShowHero.cs | 24 ++--
Core/NetworkPackage/DTCFile/ServerPack/H03_MainCharacter/DTC0310_tagRoleSkillChange.cs | 3
Core/ResModule/AssetBundle/AssetBundleUtility.cs | 41 ++++++
Core/ResModule/InstanceResourcesLoader.cs | 214 ++++++++++++++++++++++++++++++++++-
Fight/Stage/StageManager.cs | 41 +++++-
Core/SFX/SFXPlayUtility.cs | 5
7 files changed, 300 insertions(+), 34 deletions(-)
diff --git a/Core/NetworkPackage/DTCFile/ServerPack/H03_MainCharacter/DTC0310_tagRoleSkillChange.cs b/Core/NetworkPackage/DTCFile/ServerPack/H03_MainCharacter/DTC0310_tagRoleSkillChange.cs
index af0faa5..616e43a 100644
--- a/Core/NetworkPackage/DTCFile/ServerPack/H03_MainCharacter/DTC0310_tagRoleSkillChange.cs
+++ b/Core/NetworkPackage/DTCFile/ServerPack/H03_MainCharacter/DTC0310_tagRoleSkillChange.cs
@@ -68,7 +68,8 @@
{
SkillHelper.Instance.OnSpSkillChange(vNetData.NewSkillID, 1);
}
+
+ InstanceResourcesLoader.PreloadSkillEffect(vNetData.NewSkillID);
}
}
-
}
diff --git a/Core/ResModule/AssetBundle/AssetBundleUtility.cs b/Core/ResModule/AssetBundle/AssetBundleUtility.cs
index e2b4702..9919ef1 100644
--- a/Core/ResModule/AssetBundle/AssetBundleUtility.cs
+++ b/Core/ResModule/AssetBundle/AssetBundleUtility.cs
@@ -8,6 +8,8 @@
public class AssetBundleUtility : SingletonMonobehaviour<AssetBundleUtility>
{
private List<AssetBundleInfo> m_AssetBundleInfoList = new List<AssetBundleInfo>();
+ private List<string> m_LoadingAssetBundleList = new List<string>();
+ private List<string> m_LoadingAssetList = new List<string>();
private Dictionary<string, AssetInfo> m_AssetInfoDict = new Dictionary<string, AssetInfo>();
private Dictionary<string, AssetBundle> m_AssetBundleDict = new Dictionary<string, AssetBundle>();
private Dictionary<string, Dictionary<string, UnityEngine.Object>> m_AssetDict = new Dictionary<string, Dictionary<string, UnityEngine.Object>>();
@@ -187,6 +189,18 @@
yield break;
}
+ if (m_LoadingAssetBundleList.Contains(assetBundleName))
+ {
+ while (!m_AssetBundleDict.ContainsKey(assetBundleName))
+ {
+ // Debug.Log(Time.frameCount + " ] 姝e湪鍔犺浇AssetBundle: " + assetBundleName + ", 璇风瓑寰�...");
+ yield return null;
+ }
+ yield break;
+ }
+
+ m_LoadingAssetBundleList.Add(assetBundleName);
+
var _assetBundleInfo = GetAssetBundleInfo(assetBundleName);
if (_assetBundleInfo == null)
{
@@ -211,6 +225,8 @@
}
CacheAssetBundle(assetBundleName, _request.assetBundle);
+
+ m_LoadingAssetBundleList.Remove(assetBundleName);
}
private IEnumerator Co_LoadAssetBundleDependenice(AssetBundleInfo assetBundleInfo)
@@ -242,11 +258,35 @@
private IEnumerator Co_DoLoadAsset(string assetBundleName, string assetName, Action<bool, UnityEngine.Object> callBack = null)
{
+#if UNITY_5
+ assetBundleName = assetBundleName.ToLower();
+#endif
+
#if UNITY_EDITOR
RunTimeABLoadLog.AddLog(assetBundleName, assetName, UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
#endif
yield return Co_LoadAssetBundle(assetBundleName);
+
+ string _checkTag = assetBundleName + "@" + assetName;
+ if (m_LoadingAssetList.Contains(_checkTag))
+ {
+ while (!m_AssetDict.ContainsKey(assetBundleName)
+ || !m_AssetDict[assetBundleName].ContainsKey(assetName))
+ {
+ // Debug.Log(Time.frameCount + " ] 姝e湪鍔犺浇Asset: " + _checkTag + ", 璇风瓑寰�...");
+ yield return null;
+ }
+
+ if (callBack != null)
+ {
+ callBack(true, m_AssetDict[assetBundleName][assetName]);
+ }
+
+ yield break;
+ }
+
+ m_LoadingAssetList.Add(_checkTag);
var request = m_AssetBundleDict[assetBundleName].LoadAssetAsync(assetName);
while (!request.isDone)
@@ -270,6 +310,7 @@
}
}
+ m_LoadingAssetList.Remove(_checkTag);
}
private IEnumerator Co_DoLoadAsset(AssetInfo assetInfo, Action<bool, UnityEngine.Object> callBack = null)
diff --git a/Core/ResModule/InstanceResourcesLoader.cs b/Core/ResModule/InstanceResourcesLoader.cs
index 1a3d2f9..69c67c9 100644
--- a/Core/ResModule/InstanceResourcesLoader.cs
+++ b/Core/ResModule/InstanceResourcesLoader.cs
@@ -29,25 +29,25 @@
public static RuntimeAnimatorController LoadDefaultMobAnimatorController_Fight()
{
return AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix,
- GeneralDefine.ModeDefaultConfig[1][1]);
+ GeneralDefine.ModeDefaultConfig[1][1].Replace("Prefab_Race_", ""));
}
public static RuntimeAnimatorController LoadDefaultMobAnimatorController_Func()
{
return AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix,
- GeneralDefine.ModeDefaultConfig[0][1]);
+ GeneralDefine.ModeDefaultConfig[0][1].Replace("Prefab_Race_", ""));
}
public static RuntimeAnimatorController LoadDefaultMobAnimatorController_Horse()
{
return AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix,
- GeneralDefine.ModeDefaultConfig[3][1]);
+ GeneralDefine.ModeDefaultConfig[3][1].Replace("Prefab_Horse_", ""));
}
public static RuntimeAnimatorController LoadDefaultMobAnimatorController_Pet()
{
return AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix,
- GeneralDefine.ModeDefaultConfig[2][1]);
+ GeneralDefine.ModeDefaultConfig[2][1].Replace("Prefab_Race_", ""));
}
public static GameObject LoadDefaultFightNPC()
@@ -60,6 +60,25 @@
{
return LoadMob(GeneralDefine.ModeDefaultConfig[0][0],
GeneralDefine.ModeDefaultConfig[0][1]);
+ }
+
+ public static void AsyncLoadDefaultFuncNpc(Action<bool, UnityEngine.Object> callBack)
+ {
+ AsyncLoadNpc(GeneralDefine.ModeDefaultConfig[0][0],
+ GeneralDefine.ModeDefaultConfig[0][1],
+ callBack);
+ }
+ public static void AsyncLoadDefaultFightNpc(Action<bool, UnityEngine.Object> callBack)
+ {
+ AsyncLoadNpc(GeneralDefine.ModeDefaultConfig[1][0],
+ GeneralDefine.ModeDefaultConfig[1][1],
+ callBack);
+ }
+ public static void AsyncLoadDefaultPet(Action<bool, UnityEngine.Object> callBack)
+ {
+ AsyncLoadNpc(GeneralDefine.ModeDefaultConfig[2][0],
+ GeneralDefine.ModeDefaultConfig[2][1],
+ callBack);
}
public static GameObject LoadDefaultHorse()
@@ -228,6 +247,84 @@
return prefab;
}
+ public static void AsyncLoadModelRes(int id, Action<bool, UnityEngine.Object> callback = null)
+ {
+ ModelResConfig _m = Config.Instance.Get<ModelResConfig>(id);
+
+ if (_m == null)
+ {
+ return;
+ }
+
+ string _name = _m.ResourcesName;
+ int _index = _name.IndexOf('/');
+ if (_index != -1)
+ {
+ _name = _name.Substring(_index + 1);
+ }
+
+ string _suffix = string.Empty;
+
+ if (_m.Type == (int)E_ModelResType.Suit)
+ {
+ _suffix = raceSuffix;
+ }
+ else if (_m.Type == (int)E_ModelResType.Horse)
+ {
+ _suffix = horseSuffix;
+ }
+ else if (_m.Type == (int)E_ModelResType.Wing)
+ {
+ _suffix = wingSuffix;
+ }
+ else if (_m.Type == (int)E_ModelResType.Weapon)
+ {
+ _suffix = weaponSuffix;
+ }
+ else if (_m.Type == (int)E_ModelResType.Secondary)
+ {
+ _suffix = secondarySuffix;
+ }
+ else if (_m.Type == (int)E_ModelResType.Hand)
+ {
+ _suffix = handSuffix;
+ }
+
+ if (AssetSource.mobFromEditor)
+ {
+#if UNITY_EDITOR
+ string _resourcePath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
+ "Mob/",
+ _suffix + _name,
+ ".prefab");
+
+ var _gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(_resourcePath);
+
+ if (_gameObject)
+ {
+ if (callback != null)
+ {
+ callback(true, _gameObject);
+ }
+ }
+ else
+ {
+ if (callback != null)
+ {
+ callback(false, null);
+ }
+ }
+#endif
+ }
+ else
+ {
+ string _bundleName = StringUtility.Contact(ResourcesPath.MOB_FOLDER_NAME, "prefab_race_" + _name.Replace("_UI", ""));
+ string _assetName = _suffix + _name;
+
+ AssetBundleUtility.Instance.Co_LoadAsset(_bundleName, _assetName, callback);
+ }
+ }
+
public static GameObject LoadMob(string assetBundleName, string assetName)
{
GameObject _gameObject = null;
@@ -301,8 +398,7 @@
return _gameObject;
}
-
- public static void LoadEffectAsync(int _id, Action<bool, UnityEngine.Object> _callBack)
+ public static void LoadEffectAsync(int _id, Action<bool, UnityEngine.Object> _callBack = null)
{
GameObject gameObject = null;
var config = Config.Instance.Get<EffectConfig>(_id);
@@ -334,4 +430,110 @@
AssetBundleUtility.Instance.Co_LoadAsset(bundleName, config.fxName, _callBack);
}
}
+
+ public static void AsyncLoadNpc(int npcID, Action<bool, UnityEngine.Object> callBack = null)
+ {
+ NPCConfig _m = Config.Instance.Get<NPCConfig>(npcID);
+
+ if (_m == null || _m.MODE.Equals("0"))
+ {
+ if (callBack != null)
+ {
+ callBack(false, null);
+ }
+ }
+
+ string _assetName;
+ string _assetBundleName;
+
+ if (GAMgr.Instance.s_NpcID2Assetname.TryGetValue(npcID, out _assetName))
+ {
+ _assetBundleName = GAMgr.Instance.s_NpcID2BundleName[npcID];
+ }
+ else
+ {
+ _assetName = StringUtility.Contact(raceSuffix, _m.MODE);
+ _assetBundleName = StringUtility.Contact(ResourcesPath.MOB_FOLDER_NAME, _assetName);
+ GAMgr.Instance.s_NpcID2Assetname[npcID] = _assetName;
+ GAMgr.Instance.s_NpcID2BundleName[npcID] = _assetBundleName;
+ }
+
+ AsyncLoadNpc(_assetBundleName, _assetName, callBack);
+ }
+
+ public static void AsyncLoadNpc(string assetBundleName, string assetName, Action<bool, UnityEngine.Object> callBack = null)
+ {
+ if (AssetSource.mobFromEditor)
+ {
+#if UNITY_EDITOR
+ string _resourcePath = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
+ "Mob/",
+ assetName,
+ ".prefab");
+
+ var _p = AssetDatabase.LoadAssetAtPath<GameObject>(_resourcePath);
+ if (callBack != null)
+ {
+ callBack(true, _p);
+ }
+#endif
+ }
+ else
+ {
+ AssetBundleUtility.Instance.Co_LoadAsset(assetBundleName, assetName, callBack);
+ }
+ }
+
+ public static void PreloadSkillEffect(int id)
+ {
+ var _skillInfo = SkillHelper.Instance.Get(id);
+ // 鎶�鑳界壒鏁堥鍔犺浇
+ if (_skillInfo.config.EffectName > 0)
+ {
+ InstanceResourcesLoader.LoadEffectAsync(_skillInfo.config.EffectName);
+ }
+ if (_skillInfo.config.BuffEffectID > 0)
+ {
+ InstanceResourcesLoader.LoadEffectAsync(_skillInfo.config.EffectName);
+ }
+
+ var _soSkill = _skillInfo.soFile;
+ for (int i = 0; i < _soSkill.animationEventList.Count; ++i)
+ {
+ if (_soSkill.animationEventList[i].frameEventType == E_FrameEventType.OnPlayEffect)
+ {
+ if (_soSkill.animationEventList[i].intParam > 0)
+ {
+ InstanceResourcesLoader.LoadEffectAsync(_soSkill.animationEventList[i].intParam);
+ }
+ }
+ else if (_soSkill.animationEventList[i].frameEventType == E_FrameEventType.OnSkillEvent)
+ {
+ var _param = _soSkill.animationEventList[i].intParam;
+ var _type = SoSkill.GetAttactType(_param);
+ var _id = SoSkill.GetFrameEventId(_param);
+ if (_type == SoSkill.E_AttackType.Sweep)
+ {
+ var _config = ScriptableObjectLoader.LoadSoSweepHit(_id);
+ if (_config.hitEffectId > 0)
+ {
+ InstanceResourcesLoader.LoadEffectAsync(_config.hitEffectId);
+ }
+ }
+ else if (_type == SoSkill.E_AttackType.FlyObject)
+ {
+ var _config = ScriptableObjectLoader.LoadSoFlyObject(_id);
+ if (_config.hitEffectId > 0)
+ {
+ InstanceResourcesLoader.LoadEffectAsync(_config.hitEffectId);
+ }
+
+ if (_config.ammoEffectId > 0)
+ {
+ InstanceResourcesLoader.LoadEffectAsync(_config.hitEffectId);
+ }
+ }
+ }
+ }
+ }
}
diff --git a/Core/SFX/SFXPlayUtility.cs b/Core/SFX/SFXPlayUtility.cs
index 1733ea4..485c57e 100644
--- a/Core/SFX/SFXPlayUtility.cs
+++ b/Core/SFX/SFXPlayUtility.cs
@@ -18,7 +18,6 @@
public SFXController PlayEffectAsync(int id, Transform parent, float scale = 1)
{
var config = Config.Instance.Get<EffectConfig>(id);
- Debug.LogFormat("[{0}] 寮�濮嬪紓姝ュ姞杞�: {1}", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), config.fxName);
var bundleName = StringUtility.Contact(ResourcesPath.EFFECT_Folder_Name, config.packageName);
if (AssetSource.effectFromEditor || AssetBundleUtility.Instance.JudgeExistAsset(bundleName, config.fxName))
{
@@ -41,7 +40,6 @@
}
else
{
- Debug.LogFormat("[{0}] 寮�濮嬪紓姝ュ姞杞�: {1}", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), config.fxName);
AssetBundleUtility.Instance.Co_LoadAsset(bundleName, config.fxName, OnEffectLoaded);
return null;
}
@@ -55,7 +53,6 @@
if (_prefab)
{
GameObjectPoolManager.Instance.CacheGameObject(_prefab, 1, false);
- Debug.LogFormat("[{0}] 寮傛鍔犺浇: {1} 瀹屾瘯", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), _prefab.name);
}
}
}
@@ -134,7 +131,7 @@
}
else
{
- Debug.LogFormat("[{0}] 寮�濮嬪紓姝ュ姞杞�: {1}", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), config.fxName);
+ // Debug.LogFormat("[{0}] 寮�濮嬪紓姝ュ姞杞�: {1}", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), config.fxName);
AssetBundleUtility.Instance.Co_LoadAsset(bundleName, config.fxName, OnEffectLoaded);
return null;
}
diff --git a/Fight/Stage/StageManager.cs b/Fight/Stage/StageManager.cs
index 803999b..28b6234 100644
--- a/Fight/Stage/StageManager.cs
+++ b/Fight/Stage/StageManager.cs
@@ -8,7 +8,7 @@
[XLua.LuaCallCSharp]
public class StageManager : Singleton<StageManager>
-
+
{
private Stage m_CurrentStage;
@@ -19,32 +19,40 @@
public event Action<float> loadingProgressEvent;
bool m_IsServerPreparing = false;
- public bool isServerPreparing {
+ public bool isServerPreparing
+ {
get { return m_IsServerPreparing; }
set { m_IsServerPreparing = value; }
}
- public Stage.E_StageType StageType {
- get {
+ public Stage.E_StageType StageType
+ {
+ get
+ {
return m_StageType;
}
}
- public Stage CurrentStage {
- get {
+ public Stage CurrentStage
+ {
+ get
+ {
return m_CurrentStage;
}
}
int m_CurrentMapId;
- public int currentMapId {
+ public int currentMapId
+ {
get { return m_CurrentMapId; }
private set { m_CurrentMapId = value; }
}
int m_CurrentMapResID;
- public int currentMapResId {
- get {
+ public int currentMapResId
+ {
+ get
+ {
return m_CurrentMapResID;
}
private set { m_CurrentMapResID = value; }
@@ -55,9 +63,11 @@
float m_LoadingProgress = 0f;
- float loadingProgress {
+ float loadingProgress
+ {
get { return m_LoadingProgress; }
- set {
+ set
+ {
m_LoadingProgress = value;
if (loadingProgressEvent != null)
{
@@ -584,6 +594,15 @@
_hero.RequestLight();
PlayerDatas.Instance.hero = _hero;
+
+ var _preloadEffectList = GeneralDefine.PreloadSkillEffect[_hero.JobSetup.Job - 1];
+ if (_preloadEffectList != null && _preloadEffectList.Length > 0)
+ {
+ foreach (var _id in _preloadEffectList)
+ {
+ InstanceResourcesLoader.PreloadSkillEffect(_id);
+ }
+ }
}
private string GetAssetBundleNameByStageId(int stageID, int mapResID)
diff --git a/System/GeneralConfig/GeneralDefine.cs b/System/GeneralConfig/GeneralDefine.cs
index 5394965..08c720e 100644
--- a/System/GeneralConfig/GeneralDefine.cs
+++ b/System/GeneralConfig/GeneralDefine.cs
@@ -122,6 +122,7 @@
public static List<int> dogzNoRebornRemindMaps = null;
public static string[][] ModeDefaultConfig { get; private set; }
+ public static int[][] PreloadSkillEffect { get; private set; }
public static int[] RealmGroup { get; private set; }
public static float PrefightAtkRange { get; private set; }
@@ -529,6 +530,11 @@
fairyLandBuffCondition = GetInt("XjmjAddHarm", 1);
fairyLandBuffId = GetInt("XjmjAddHarm", 2);
achievementEarlierStageLevel = GetInt("AchieveLV");
+
+ func = Config.Instance.Get<FuncConfigConfig>("PreloadSkillEffect");
+ PreloadSkillEffect = new int[2][];
+ PreloadSkillEffect[0] = GetIntArray("PreloadSkillEffect");
+ PreloadSkillEffect[1] = GetIntArray("PreloadSkillEffect", 2);
}
catch (Exception ex)
{
diff --git a/UI/Common/UI3DShowHero.cs b/UI/Common/UI3DShowHero.cs
index fcd4831..b166958 100644
--- a/UI/Common/UI3DShowHero.cs
+++ b/UI/Common/UI3DShowHero.cs
@@ -108,7 +108,7 @@
if (weaponId != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(weaponId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(weaponId);
if (prefab)
{
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
@@ -119,7 +119,7 @@
if (secondaryId != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(secondaryId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(secondaryId);
if (prefab)
{
if (secondaryModel)
@@ -134,7 +134,7 @@
if (wingsId != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(wingsId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(wingsId);
if (prefab)
{
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
@@ -329,18 +329,18 @@
if (oldWeapon != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(oldWeapon, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(oldWeapon);
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
pool.Release(weaponModel);
weaponModel = null;
}
- prefab = InstanceResourcesLoader.LoadModelRes(resoureceId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(resoureceId);
if (!prefab)
{
resoureceId = config.BaseEquip[1];
- prefab = InstanceResourcesLoader.LoadModelRes(resoureceId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(resoureceId);
}
if (prefab)
@@ -372,7 +372,7 @@
if (oldSecondary != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(oldSecondary, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(oldSecondary);
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
pool.Release(secondaryModel);
secondaryModel = null;
@@ -380,12 +380,12 @@
if (secondaryResId != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(secondaryResId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(secondaryResId);
if (!prefab)
{
var config = Config.Instance.Get<JobSetupConfig>(_job);
secondaryResId = config.BaseEquip[2];
- prefab = InstanceResourcesLoader.LoadModelRes(secondaryResId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(secondaryResId);
}
if (prefab)
@@ -415,7 +415,7 @@
if (oldWings != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(oldWings, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(oldWings);
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
pool.Release(wingsModel);
wingsModel = null;
@@ -423,12 +423,12 @@
if (resourceId != 0)
{
- prefab = InstanceResourcesLoader.LoadModelRes(resourceId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(resourceId);
if (!prefab)
{
resourceId = config.BaseEquip[3];
- prefab = InstanceResourcesLoader.LoadModelRes(resourceId, true);
+ prefab = InstanceResourcesLoader.LoadModelRes(resourceId);
}
if (prefab)
--
Gitblit v1.8.0