| Main/System/HeroUI/HeroUIManager.Collect.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/PhantasmPavilion/PhantasmPavilionManager.Redpoint.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/PhantasmPavilion/PhantasmPavilionManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Main/System/PhantasmPavilion/PhantasmPavilionUnlockButton.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Main/System/HeroUI/HeroUIManager.Collect.cs
@@ -30,25 +30,10 @@ var newHeroData = netPack.HeroInfoList[i]; int heroID = (int)newHeroData.HeroID; // ---- 新增:对比旧数据,检测皮肤状态变化 ---- if (heroCollectInfoDic.TryGetValue(heroID, out var oldHeroData)) { if (newHeroData.SkinList != null) { foreach (var newSkin in newHeroData.SkinList) { // 在旧数据中寻找对应的皮肤 var oldSkin = oldHeroData.SkinList?.FirstOrDefault(s => s.SkinID == newSkin.SkinID); // 1. 调用封装好的方法:检测并触发新皮肤事件 CheckAndTriggerNewSkinEvents(heroID, newHeroData); // 如果旧数据中没有这个皮肤(首次获得),或者状态发生了变化 if (oldSkin == null || oldSkin.State != newSkin.State) { OnHeroSkinStateChanged?.Invoke(heroID, (int)newSkin.SkinID, newSkin.State); } } } } // 2. 更新字典为最新的网络包数据 heroCollectInfoDic[heroID] = newHeroData; } @@ -60,6 +45,70 @@ OnHeroCollectEvent?.Invoke(); } public event Action<int, int> OnNewSkinAcquired;// 当玩家获得新皮肤(激活皮肤)时触发的事件 HeroID SkinID /// <summary> /// 检查并触发获得新皮肤的事件 /// </summary> private void CheckAndTriggerNewSkinEvents(int heroID, HB122_tagSCHeroInfo.tagSCHero newHeroData) { // 如果新数据中没有皮肤信息,直接返回 if (newHeroData?.SkinList == null || newHeroData?.SkinCnt <= 0) return; // 尝试获取旧数据 bool isOldHeroExist = heroCollectInfoDic.TryGetValue(heroID, out var oldHeroData); for (int j = 0; j < newHeroData.SkinCnt; j++) { var newSkin = newHeroData.SkinList[j]; // 如果新皮肤未激活,直接跳过当前循环,检查下一个皮肤 if (newSkin.State <= 0) continue; bool isNewlyAcquired = false; if (!isOldHeroExist) { // 场景A:这是一个全新的武将,且自带了已激活的非默认皮肤 isNewlyAcquired = true; } else { // 场景B:已有的老武将,需要对比旧数据看这个皮肤是不是刚刚才获得的 bool foundOldSkin = false; if (oldHeroData.SkinList != null) { for (int k = 0; k < oldHeroData.SkinCnt; k++) { var oldSkin = oldHeroData.SkinList[k]; if (oldSkin.SkinID == newSkin.SkinID) { foundOldSkin = true; // 如果旧数据中该皮肤未激活 (State == 0),现在激活了,算作获得新皮肤 if (oldSkin.State == 0) { isNewlyAcquired = true; } break; } } } // 如果旧武将数据里压根没有这个皮肤的数据(现在是激活状态),也算作获得新皮肤 if (!foundOldSkin) { isNewlyAcquired = true; } } // 如果最终判定为“全新获得”的皮肤,则触发事件 if (isNewlyAcquired) { OnNewSkinAcquired?.Invoke(heroID, (int)newSkin.SkinID); } } } // public int GetHeroCollectBookPer() // { Main/System/PhantasmPavilion/PhantasmPavilionManager.Redpoint.cs
@@ -73,13 +73,22 @@ continue; int unlockWay = GetUnlockWay(type, id); int unlockValue = GetUnlockValue(type, id); if (unlockWay != 3) if (unlockWay != 3 && unlockWay != 4) continue; if (unlockWay == 3) { bool hasNewHero = HasNewHero(type, unlockValue); if (hasNewHero) { tabRedPointDict[redType].state = RedPointState.Simple; } } else if (unlockWay == 4) { if (HasNewSkin(type, unlockValue)) tabRedPointDict[redType].state = RedPointState.Simple; } } } @@ -102,15 +111,21 @@ } int unlockWay = GetUnlockWay(type, id); if (unlockWay != 3) if (unlockWay != 3 && unlockWay != 4) return; int unlockValue = GetUnlockValue(type, id); bool hasNewHero = HasNewHero(type, unlockValue); if (hasNewHero) if (unlockWay == 3) { if (HasNewHero(type, unlockValue)) imgRed.SetActive(true); } else if (unlockWay == 4) { if (HasNewSkin(type, unlockValue)) imgRed.SetActive(true); } } readonly int funcId = 3;//内政 //内政没开不刷红点 @@ -165,21 +180,42 @@ } } public List<int> newHeroIDModelList = new List<int>(); public List<int> newHeroIDFaceList = new List<int>(); public void AddNewHero(int heroID) public List<int> newSkinIDModelList = new List<int>(); public List<int> newSkinIDFaceList = new List<int>(); string modelSkinKey { get { return StringUtility.Concat("PhantasmPavilion_Redponit_ModelSkin_", PlayerDatas.Instance.PlayerId.ToString()); } } string faceSkinKey { get { return StringUtility.Concat("PhantasmPavilion_Redponit_FaceSkin_", PlayerDatas.Instance.PlayerId.ToString()); } } public void AddNewSkin(int skinID) { AddNewHero(newHeroIDModelList, heroID); AddNewHero(newHeroIDFaceList, heroID); AddNew(newSkinIDModelList, skinID); AddNew(newSkinIDFaceList, skinID); } void AddNewHero(List<int> list, int heroID) // 抽象添加逻辑 void AddNew(List<int> list, int id) { if (list.Contains(heroID)) if (list.Contains(id)) return; list.Add(heroID); list.Add(id); SaveLocal(); UpdateRedPoint(); } public bool HasNewSkin(PhantasmPavilionType type, int skinID) { switch (type) { case PhantasmPavilionType.Model: return newSkinIDModelList.Contains(skinID); case PhantasmPavilionType.Face: return newSkinIDFaceList.Contains(skinID); default: return false; } } public List<int> newHeroIDModelList = new List<int>(); public List<int> newHeroIDFaceList = new List<int>(); public void AddNewHero(int heroID) { AddNew(newHeroIDModelList, heroID); AddNew(newHeroIDFaceList, heroID); } public void RemoveAllNewHeroByTabType(PhantasmPavilionType type, int tabType = 0) @@ -212,31 +248,29 @@ return; int unlockWay = GetUnlockWay(type, id); int unlockValue = GetUnlockValue(type, id); if (unlockWay != 3) return; if (unlockWay != 3 && unlockWay != 4) return; switch (type) { case PhantasmPavilionType.Model: RemoveNewHero(newHeroIDModelList, unlockValue, isSave); if (unlockWay == 3) RemoveNew(newHeroIDModelList, unlockValue, isSave); else if (unlockWay == 4) RemoveNew(newSkinIDModelList, unlockValue, isSave); // 皮肤 break; case PhantasmPavilionType.Face: RemoveNewHero(newHeroIDFaceList, unlockValue, isSave); if (unlockWay == 3) RemoveNew(newHeroIDFaceList, unlockValue, isSave); else if (unlockWay == 4) RemoveNew(newSkinIDFaceList, unlockValue, isSave); // 皮肤 break; } } void RemoveNewHero(List<int> list, int heroID, bool isSave = true) void RemoveNew(List<int> list, int id, bool isSave = true) { if (!list.Contains(heroID)) return; list.Remove(heroID); if (isSave) { SaveLocal(); } if (!list.Contains(id)) return; list.Remove(id); if (isSave) SaveLocal(); UpdateRedPoint(); } public bool HasNewHero(PhantasmPavilionType type, int heroID) { @@ -258,11 +292,36 @@ { LocalSave.SetIntArray(modelkey, newHeroIDModelList.ToArray()); LocalSave.SetIntArray(facekey, newHeroIDFaceList.ToArray()); LocalSave.SetIntArray(modelSkinKey, newSkinIDModelList.ToArray()); LocalSave.SetIntArray(faceSkinKey, newSkinIDFaceList.ToArray()); } public void LoadLocal() { LoadLocalModel(); LoadLocalFace(); LoadLocalSkin(); } void LoadLocalSkin() { if (LocalSave.HasKey(modelSkinKey)) { int[] arr = LocalSave.GetIntArray(modelSkinKey); newSkinIDModelList = arr.IsNullOrEmpty() ? new List<int>() : arr.ToList(); } else { newSkinIDModelList = new List<int>(); } if (LocalSave.HasKey(faceSkinKey)) { int[] arr = LocalSave.GetIntArray(faceSkinKey); newSkinIDFaceList = arr.IsNullOrEmpty() ? new List<int>() : arr.ToList(); }else { newSkinIDFaceList = new List<int>(); } } void LoadLocalModel() Main/System/PhantasmPavilion/PhantasmPavilionManager.cs
@@ -53,6 +53,7 @@ PackManager.Instance.RefreshItemEvent += OnRefreshItemEvent; GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; HeroUIManager.Instance.OnNewSkinAcquired += OnNewSkinAcquired; InitTable(); InitTabRedPoint(); } @@ -65,6 +66,13 @@ PackManager.Instance.RefreshItemEvent -= OnRefreshItemEvent; GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; HeroUIManager.Instance.OnNewSkinAcquired -= OnNewSkinAcquired; } private void OnNewSkinAcquired(int arg1, int arg2) { AddNewSkin(arg2); UpdateRedPoint(); } private void OnFuncStateChangeEvent(int obj) @@ -200,15 +208,21 @@ 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 skinID = 0; if (UnlockWay == 3) { int heroID = unlockValue; if (!HeroConfig.HasKey(heroID)) return; HeroConfig heroConfig = HeroConfig.Get(heroID); int skinID = heroConfig.SkinIDList[0]; if (!HeroSkinConfig.HasKey(skinID)) return; 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 = UILoader.LoadSprite("HeroHead", skinConfig.SquareIcon); if (sprite == null) @@ -519,6 +533,9 @@ 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; } @@ -558,6 +575,10 @@ 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: @@ -870,6 +891,7 @@ Activate = 1, // 默认(创角色就可以用的) Item, // 道具 Hero, // 武将 Skin, // 皮肤 } /// 幻境阁物品的状态 Main/System/PhantasmPavilion/PhantasmPavilionUnlockButton.cs
@@ -40,6 +40,15 @@ return; } } else if (unlockWay == 4) // 新增:如果是皮肤解锁 { bool hasSkin = HeroUIManager.Instance.IsHeroSkinActive(HeroConfig.GetHeroIDBySkinID(unlockValue), unlockValue); if (!hasSkin) { SysNotifyMgr.Instance.ShowTip("UnLockFail1"); return; } } manager.SendOPPack(type, PhantasmPavilionOperation.Activate, (uint)id); SysNotifyMgr.Instance.ShowTip("UnLockSuccess"); });