lcy
2 天以前 f66c4b9ca61638b0e76f4f82e34d19ae2117c88b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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] Text addLVText;
    [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();
            if (i < nextConfig.AddAttrType.Length)
            {
                paopaoTextArrName[i].text = PlayerPropertyConfig.Get(nextConfig.AddAttrType[i]).Name;
                paopaoTextArrValue[i].text = "+" + PlayerPropertyConfig.GetValueDescription(nextConfig.AddAttrType[i], nextConfig.AddAttrNum[i]);
            }
        }
 
        addLVText.text = "+" + (nextConfig.LVMax - config.LVMax);
 
        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;
            }
        }
 
        upEffect.onComplete = () =>
        {
            CA523_tagCMRealmLVUp pak = new CA523_tagCMRealmLVUp();
            GameNetSystem.Instance.SendInfo(pak);
        };
 
        effectPlayer.onComplete = () =>
        {
            upEffect.Play();
        };
 
        //所有泡泡飞向按钮
        for (int i = 0; i < paopaoArr.Length; i++)
        {
            int index = i;
            paopaoArr[i].Stop();
            paopaoArr[i].transform.DOLocalMove(lvUpBtn.transform.localPosition, 0.3f).onComplete = () =>
            {
                if (index == 0)
                {
                    effectPlayer.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();
        }
    }
}