From d2dd33cc0ca421e276d50abc46688f5db83aa42b Mon Sep 17 00:00:00 2001
From: client_Zxw <826696702@qq.com>
Date: 星期二, 13 十一月 2018 19:45:39 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
---
Core/ResModule/InstanceResourcesLoader.cs | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 211 insertions(+), 6 deletions(-)
diff --git a/Core/ResModule/InstanceResourcesLoader.cs b/Core/ResModule/InstanceResourcesLoader.cs
index 1a3d2f9..df3f2ce 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,113 @@
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;
+ if (_soSkill != null)
+ {
+ 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);
+ }
+ }
+ }
+ }
+ }
+ }
}
--
Gitblit v1.8.0