| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using UnityEngine.UI; | 
| using DG.Tweening; | 
| using System; | 
|   | 
| /// <summary> | 
| /// 官职 | 
| /// </summary> | 
| public class OfficialUpWin : UIBase | 
| { | 
|     [SerializeField] Text officialNameText; | 
|     [SerializeField] Text officialNextNameText; | 
|     [SerializeField] Image officialIcon; | 
|     [SerializeField] Image officialNextIcon; | 
|     [SerializeField] Button closeBtn; | 
|     [SerializeField] PositionTween[] paopaoArr; | 
|     [SerializeField] Text[] paopaoTextArrName; | 
|     [SerializeField] Text[] paopaoTextArrValue; | 
|     [SerializeField] OfficialUpCell[] missionCellArr; | 
|     [SerializeField] ButtonEx lvUpBtn; | 
|     [SerializeField] UIEffectPlayer effectPlayer; | 
|     [SerializeField] UIEffectPlayer upEffect; | 
|   | 
|     protected override void InitComponent() | 
|     { | 
|         closeBtn.AddListener(CloseWindow); | 
|         lvUpBtn.AddListener(OnLvUp); | 
|     } | 
|   | 
|     // 1    等级达到x级    x级         | 
|     // 2    通过主线关卡    关卡ID     | 
|     // 3    消耗战锤    x个 | 
|     // 4    祝福树    等级     | 
|     protected override void OnPreOpen() | 
|     { | 
|         OfficialRankManager.Instance.RealmMissionRefreshEvent += Refresh; | 
|         PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh; | 
|         BlessLVManager.Instance.OnBlessLVUpdateEvent += RefreshBtn; | 
|         Refresh(); | 
|     } | 
|   | 
|     protected override void OnPreClose() | 
|     { | 
|         OfficialRankManager.Instance.RealmMissionRefreshEvent -= Refresh; | 
|         PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh; | 
|         BlessLVManager.Instance.OnBlessLVUpdateEvent -= RefreshBtn; | 
|     } | 
|   | 
|     public override void Refresh() | 
|     { | 
|         var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel); | 
|         officialNameText.text = config.Name; | 
|         officialNameText.color = OfficialRankManager.Instance.GetOfficialRankColor(config.Quality); | 
|         officialIcon.SetSprite("OfficialRank" + config.Quality); | 
|         var nextConfig = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel + 1); | 
|         officialNextNameText.text = nextConfig.Name; | 
|         officialNextNameText.color = OfficialRankManager.Instance.GetOfficialRankColor(nextConfig.Quality); | 
|         officialNextIcon.SetSprite("OfficialRank" + nextConfig.Quality); | 
|         for (int i = 0; i < paopaoArr.Length; i++) | 
|         { | 
|             paopaoArr[i].Play(); | 
|             paopaoTextArrName[i].text = PlayerPropertyConfig.Get(nextConfig.AddAttrType[i]).Name; | 
|             paopaoTextArrValue[i].text = "+" + PlayerPropertyConfig.GetValueDescription(nextConfig.AddAttrType[i], nextConfig.AddAttrNum[i]); | 
|         } | 
|   | 
|         RefreshBtn(); | 
|     } | 
|   | 
|   | 
|     void OnLvUp() | 
|     { | 
|         var ids = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel); | 
|         foreach (var id in ids) | 
|         { | 
|             if (OfficialRankManager.Instance.GetMissionAwardState(id) != 1) | 
|             { | 
|                 SysNotifyMgr.Instance.ShowTip("OfficialTask1"); | 
|                 return; | 
|             } | 
|         } | 
|   | 
|         //所有泡泡飞向按钮 | 
|         for (int i = 0; i < paopaoArr.Length; i++) | 
|         { | 
|             paopaoArr[i].Stop(); | 
|             paopaoArr[i].transform.DOLocalMove(lvUpBtn.transform.localPosition, 0.4f); | 
|         } | 
|         effectPlayer.Play(); | 
|   | 
|         upEffect.onComplete = () => | 
|         { | 
|             CA523_tagCMRealmLVUp pak = new CA523_tagCMRealmLVUp(); | 
|             GameNetSystem.Instance.SendInfo(pak); | 
|         }; | 
|         upEffect.Play(); | 
|     } | 
|   | 
|   | 
|     void RefreshBtn() | 
|     { | 
|         var ids = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel); | 
|         for (int i = 0; i < missionCellArr.Length; i++) | 
|         { | 
|             missionCellArr[i].Display(ids[i]); | 
|         } | 
|   | 
|         // for (int i = 0; i < missionCellArr.Length; i++) | 
|         // { | 
|         //     if (OfficialRankManager.Instance.GetMissionAwardState(i + 1) != 1) | 
|         //     { | 
|         //         lvUpBtn.SetColorful(null, false); | 
|         //         return; | 
|         //     } | 
|         // } | 
|         // lvUpBtn.SetColorful(null, true); | 
|     } | 
|   | 
|   | 
|     void PlayerDataRefresh(PlayerDataType type) | 
|     { | 
|         if (type == PlayerDataType.RealmLevel) | 
|         { | 
|             Refresh(); | 
|         } | 
|         else if (type == PlayerDataType.LV || | 
|             type == PlayerDataType.ExAttr1 | 
|         ) | 
|         {  | 
|             //等级 通关 | 
|             RefreshBtn(); | 
|         } | 
|     } | 
| } |