|
@@ -0,0 +1,77 @@
|
|
|
+using System.Collections.Generic;
|
|
|
+using System;
|
|
|
+
|
|
|
+namespace GFGGame
|
|
|
+{
|
|
|
+ public enum ResType
|
|
|
+ {
|
|
|
+ Sprite,
|
|
|
+ Animation,
|
|
|
+ Both
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ItemResPreloadManager : SingletonBase<ItemResPreloadManager>
|
|
|
+ {
|
|
|
+ public void AddSuit(int suitId, ResType resType, int[] excludeType, bool includeOptional)
|
|
|
+ {
|
|
|
+ SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
|
|
|
+ if (suitCfg == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //找到要穿的散件
|
|
|
+ List<int> targetItemList = DressUpUtil.GetSuitItems(suitId, resType != ResType.Sprite, excludeType, includeOptional, false);
|
|
|
+ foreach(var itemId in targetItemList)
|
|
|
+ {
|
|
|
+ PreloadDressUpRes(itemId, resType);
|
|
|
+ }
|
|
|
+ if(resType != ResType.Sprite)
|
|
|
+ {
|
|
|
+ if(!string.IsNullOrEmpty(suitCfg.aniRes))
|
|
|
+ {
|
|
|
+ string assetPath = ResPathUtil.GetDressUpAnimationPath(suitCfg.aniRes);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpEffectPath(suitCfg.aniRes);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void PreloadDressUpRes(int itemId, ResType resType = ResType.Sprite)
|
|
|
+ {
|
|
|
+ ItemCfg dressUpCfg = ItemCfgArray.Instance.GetCfg(itemId);
|
|
|
+ string assetPath;
|
|
|
+ if (resType != ResType.Animation)
|
|
|
+ {
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 1);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 2);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 3);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ }
|
|
|
+ if(resType != ResType.Sprite)
|
|
|
+ {
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 1);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 2);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 3);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void PreloadCardAnimationRes(int itemId)
|
|
|
+ {
|
|
|
+ ItemCfg cardCfg = ItemCfgArray.Instance.GetCfg(itemId);
|
|
|
+ string assetPath = ResPathUtil.GetCardAnimationPath(cardCfg.res);
|
|
|
+ PreloadManager.Instance.TryAdd(assetPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|