using System; using System.Collections.Generic; using Cute; using UnityEngine; namespace Wizard; public class DegreeHelper { public enum DegreeType { SMALL, MIDDLE } private static ResourcesManager.AssetLoadPathType GetResourceType(DegreeType type) { if (type == DegreeType.SMALL) { return ResourcesManager.AssetLoadPathType.Degree_S; } return ResourcesManager.AssetLoadPathType.Degree_M; } private static ResourcesManager.AssetLoadPathType GetMaterialType(DegreeType type) { if (type == DegreeType.SMALL) { return ResourcesManager.AssetLoadPathType.DegreeMaterial_S; } return ResourcesManager.AssetLoadPathType.DegreeMaterial_M; } public static List GetDegreeResourceList(long id, DegreeType type, bool isFetch) { List list = new List(); list.Add(GetDegreePath(id, type, isFetch)); if (Data.Master.DegreeMgr.Get((int)id).IsPremium) { list.Add(GetDegreeMaterialPath(id, type, isFetch)); list.Add(GetMaskPath(id, isFetch)); } return list; } private static string GetDegreePath(long id, DegreeType type, bool isFetch) { return Toolbox.ResourcesManager.GetAssetTypePath(id.ToString("0000"), GetResourceType(type), isFetch); } private static string GetDegreeMaterialPath(long id, DegreeType type, bool isFetch) { return Toolbox.ResourcesManager.GetAssetTypePath(id.ToString("0000"), GetMaterialType(type), isFetch); } private static string GetMaskPath(long id, bool isFetch) { return Toolbox.ResourcesManager.GetAssetTypePath(id.ToString("0000"), ResourcesManager.AssetLoadPathType.DegreeMask, isFetch); } public static void InitializeDegree(UITexture texture, long id, DegreeType type) { string degreePath = GetDegreePath(id, type, isFetch: true); texture.mainTexture = Toolbox.ResourcesManager.LoadObject(degreePath); if (Data.Master.DegreeMgr.Get((int)id).IsPremium) { string degreeMaterialPath = GetDegreeMaterialPath(id, type, isFetch: true); texture.material = Toolbox.ResourcesManager.LoadObject(degreeMaterialPath); Texture value = Toolbox.ResourcesManager.LoadObject(GetMaskPath(id, isFetch: true)); texture.material.SetTexture("_MaskTex", value); } else { texture.material = null; } } public static void LoadInstant(UITexture texture, long id, DegreeType type, Action> onFinish) { List path = GetDegreeResourceList(id, type, isFetch: false); UIManager.GetInstance().StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupSync(path, delegate { InitializeDegree(texture, id, type); onFinish(path); })); } }