| | |
| | | PackManager.Instance.RefreshItemEvent += OnRefreshItemEvent; |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; |
| | | HeroUIManager.Instance.OnNewSkinAcquired += OnNewSkinAcquired; |
| | | TimeMgr.Instance.OnDayEvent += OnDayEvent; |
| | | InitTable(); |
| | | InitTabRedPoint(); |
| | | } |
| | |
| | | PackManager.Instance.RefreshItemEvent -= OnRefreshItemEvent; |
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; |
| | | HeroUIManager.Instance.OnNewSkinAcquired -= OnNewSkinAcquired; |
| | | TimeMgr.Instance.OnDayEvent -= OnDayEvent; |
| | | } |
| | | |
| | | private void OnDayEvent() |
| | | { |
| | | UpdateRedPoint(); |
| | | } |
| | | |
| | | private void OnNewSkinAcquired(int arg1, int arg2) |
| | | { |
| | | AddNewSkin(arg2); |
| | | UpdateRedPoint(); |
| | | } |
| | | |
| | | private void OnFuncStateChangeEvent(int obj) |
| | |
| | | { |
| | | if (type != PackType.Item) |
| | | return; |
| | | if (itemID <= 0) |
| | | return; |
| | | if (ItemConfig.Get(itemID).Type != 146) |
| | | var map = GetUpdateRedPointItemSet(); |
| | | if (!map.Contains(itemID)) |
| | | return; |
| | | UpdateRedPoint(); |
| | | } |
| | |
| | | int unlockValue = GetUnlockValue(type, id); |
| | | int resourceType = GetResourceType(type, id); |
| | | string resourceValue = GetResourceValue(type, id); |
| | | if (UnlockWay == 3 && resourceValue == "") |
| | | if ((UnlockWay == 3 || UnlockWay == 4) && resourceValue == "") |
| | | { |
| | | int heroID = unlockValue; |
| | | if (!HeroConfig.HasKey(heroID)) |
| | | return; |
| | | HeroConfig heroConfig = HeroConfig.Get(heroID); |
| | | int skinID = heroConfig.SkinIDList[0]; |
| | | if (!HeroSkinConfig.HasKey(skinID)) |
| | | return; |
| | | int skinID = 0; |
| | | if (UnlockWay == 3) |
| | | { |
| | | int heroID = unlockValue; |
| | | if (!HeroConfig.HasKey(heroID)) return; |
| | | skinID = HeroConfig.Get(heroID).SkinIDList[0]; |
| | | } |
| | | else if (UnlockWay == 4) |
| | | { |
| | | skinID = unlockValue; // UnlockValue 直接就是 skinID |
| | | } |
| | | |
| | | if (!HeroSkinConfig.HasKey(skinID)) return; |
| | | HeroSkinConfig skinConfig = HeroSkinConfig.Get(skinID); |
| | | var sprite = await UILoader.LoadSpriteAsync("HeroHead", skinConfig.SquareIcon); |
| | | if (sprite == null) |
| | |
| | | var sprite = await UILoader.LoadSpriteAsync("HeroHead", skinConfig.SquareIcon); |
| | | if (sprite == null) |
| | | { |
| | | Show(imgFace, spine, uiFrame, resourceType, "herohead_default", null, ellipseMask); |
| | | Show(type, imgFace, spine, uiFrame, resourceType, "herohead_default", null, ellipseMask); |
| | | } |
| | | else |
| | | { |
| | | Show(imgFace, spine, uiFrame, resourceType, string.Empty, sprite, ellipseMask); |
| | | Show(type, imgFace, spine, uiFrame, resourceType, string.Empty, sprite, ellipseMask); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | resourceValue = GetResourceValue(type, id); |
| | | Show(imgFace, spine, uiFrame, resourceType, resourceValue, null, ellipseMask); |
| | | Show(type, imgFace, spine, uiFrame, resourceType, resourceValue, null, ellipseMask); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void Show(ImageEx imgFace, UIEffectPlayer spine, UIFrame uiFrame, int resourceType, string resourceValue, Sprite sprite = null, EllipseMask ellipseMask = null) |
| | | public void Show(PhantasmPavilionType type, ImageEx imgFace, UIEffectPlayer spine, UIFrame uiFrame, int resourceType, string resourceValue, Sprite sprite = null, EllipseMask ellipseMask = null) |
| | | { |
| | | spine.Stop(); |
| | | |
| | |
| | | { |
| | | imgFace.overrideSprite = sprite; |
| | | } |
| | | |
| | | if (type == PhantasmPavilionType.Title) |
| | | { |
| | | imgFace.SetNativeSize(); |
| | | } |
| | | |
| | | break; |
| | | case 2: // spine |
| | | imgFace.enabled = true; |
| | | imgFace.enabled = false; |
| | | uiFrame.enabled = false; |
| | | spine.enabled = true; |
| | | |
| | |
| | | imgFace.sprite = null; |
| | | imgFace.overrideSprite = null; |
| | | |
| | | if (!UIFrameMgr.Inst.ContainsDynamicImage(resourceValue)) |
| | | break; |
| | | //List<UnityEngine.Sprite> spriteList = UIFrameMgr.Inst.GetDynamicImage(resourceValue); |
| | | // if (!spriteList.IsNullOrEmpty()) |
| | | // { |
| | | // imgFace.rectTransform.sizeDelta = new Vector2(spriteList[0].rect.width, spriteList[0].rect.height); |
| | | // } |
| | | if (type == PhantasmPavilionType.Title) |
| | | { |
| | | if (!UIFrameMgr.Inst.ContainsDynamicImage(resourceValue)) |
| | | break; |
| | | List<Sprite> spriteList = UIFrameMgr.Inst.GetDynamicImage(resourceValue); |
| | | if (!spriteList.IsNullOrEmpty()) |
| | | { |
| | | imgFace.rectTransform.sizeDelta = new Vector2(spriteList[0].rect.width, spriteList[0].rect.height); |
| | | } |
| | | } |
| | | |
| | | uiFrame.ResetFrame(resourceValue); |
| | | uiFrame.enabled = true; |
| | |
| | | // 有没有属性 |
| | | public bool HasInitAttr(PhantasmPavilionType type, int id) |
| | | { |
| | | if (type == PhantasmPavilionType.Title) |
| | | { |
| | | //称号有特殊天赋效果 |
| | | var cfg = TitleConfig.Get(id); |
| | | if (cfg == null) |
| | | { |
| | | Debug.LogError($"TitleConfig.Get(id) is null, id: {id}"); |
| | | return false; |
| | | } |
| | | if (cfg.EffType > 0) |
| | | return true; |
| | | } |
| | | if (!Has(type, id)) |
| | | return false; |
| | | int[] attrIDList = GetAttrIDList(type, id); |
| | |
| | | |
| | | public int Cmp(int a, int b, PhantasmPavilionType type) |
| | | { |
| | | // 获取 a 和 b 的解锁状态 |
| | | // 1. 获取 a 和 b 的解锁状态 |
| | | int stateA = (int)GetUnLockState(type, a); |
| | | int stateB = (int)GetUnLockState(type, b); |
| | | |
| | |
| | | int priorityA = stateA == 2 ? 0 : (stateA == 1 ? 1 : 2); |
| | | int priorityB = stateB == 2 ? 0 : (stateB == 1 ? 1 : 2); |
| | | |
| | | |
| | | // 优先判断状态 |
| | | if (priorityA != priorityB) |
| | | { |
| | | return priorityA.CompareTo(priorityB); |
| | | } |
| | | |
| | | // 2. 状态相同的话,获取两者的 SortIndex |
| | | int sortIndexA = GetSortIndex(type, a); |
| | | int sortIndexB = GetSortIndex(type, b); |
| | | |
| | | if (sortIndexA != sortIndexB) |
| | | { |
| | | return sortIndexA.CompareTo(sortIndexB); |
| | | } |
| | | |
| | | // 3. 状态和 SortIndex 都相同的话,按唯一 ID 排序 |
| | | return a.CompareTo(b); |
| | | } |
| | | |
| | |
| | | if (IsExpired(info, unlockWay)) |
| | | return false; |
| | | return true; |
| | | case PhantasmPavilionUnlockWay.Skin: |
| | | bool hasSkin = HeroUIManager.Instance.IsHeroSkinActive(HeroConfig.GetHeroIDBySkinID(unlockValue), unlockValue); |
| | | return hasSkin; |
| | | default: |
| | | return false; |
| | | } |
| | |
| | | case PhantasmPavilionUnlockWay.Hero: |
| | | int heroID = unlockValue; |
| | | return HeroManager.Instance.HasHero(heroID) |
| | | ? PhantasmPavilionState.Activated |
| | | : PhantasmPavilionState.Locked; |
| | | case PhantasmPavilionUnlockWay.Skin: |
| | | return HeroUIManager.Instance.IsHeroSkinActive(HeroConfig.GetHeroIDBySkinID(unlockValue), unlockValue) |
| | | ? PhantasmPavilionState.Activated |
| | | : PhantasmPavilionState.Locked; |
| | | default: |
| | |
| | | RefreshAttr(); |
| | | UpdateRedPoint(); |
| | | OnTimeOut?.Invoke(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 判断该形象/头像是否可以显示在幻境阁列表中 |
| | | /// </summary> |
| | | public bool IsFaceOrModelVisible(int unlockWay, int unlockValue) |
| | | { |
| | | if (unlockWay == 3) |
| | | { |
| | | int heroId = unlockValue; |
| | | return IsHeroCollectionOpen(heroId); |
| | | } |
| | | else if (unlockWay == 4) |
| | | { |
| | | // 皮肤途径,UnlockValue 是 SkinID |
| | | int skinId = unlockValue; |
| | | return IsHeroCollectionOpen(HeroConfig.GetHeroIDBySkinID(skinId)); |
| | | } |
| | | |
| | | // 其他获取途径(如活动、默认等),不做限制,直接显示 |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查对应武将是否达到了开服天数要求 |
| | | /// </summary> |
| | | public bool IsHeroCollectionOpen(int heroId) |
| | | { |
| | | var config = HeroConfig.Get(heroId); |
| | | if (config == null) return false; |
| | | |
| | | // 0表示不限制开服天数 |
| | | if (config.OpenCollectionDay > 0 && TimeUtility.OpenDay + 1 < config.OpenCollectionDay) return false; |
| | | return true; |
| | | } |
| | | |
| | | #region 收封包 |
| | |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public class PhantasmPavilionData |
| | |
| | | Activate = 1, // 默认(创角色就可以用的) |
| | | Item, // 道具 |
| | | Hero, // 武将 |
| | | Skin, // 皮肤 |
| | | } |
| | | |
| | | /// 幻境阁物品的状态 |