hch
4 天以前 47aa85c49c2f31f6ac728ea66defb1425bae85ba
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Tuesday, July 24, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
public class MainBossEnterWin : UIBase
{
    [SerializeField] Text fbNameText;
    [SerializeField] Button CloseBtn;
    [SerializeField] Text bossNameText;
    [SerializeField] Image bossBG;
    [SerializeField] SkillWordCell[] skillWordCells;
    [SerializeField] UIHeroController bossModel;
    [SerializeField] Text fightPowerText;
    [SerializeField] Button rankBtn;
    [SerializeField] ItemCell[] passAwards;
    [SerializeField] Button fightBtn;
    [SerializeField] ScrollerController dropItemScroller;
 
 
    protected override void InitComponent()
    {
        CloseBtn.AddListener(CloseWindow);
        rankBtn.AddListener(() =>
        {
            RankModel.Instance.ResetQueryParam();
            RankModel.Instance.QueryRankByPage(0, watchID: (int)PlayerDatas.Instance.baseData.PlayerID);
            var win = UIManager.Instance.OpenWindow<PlayerRankWin>();
            win.rankType = 0;
 
        });
 
        fightBtn.AddListener(FightBoss);
    }
 
    protected override void OnPreOpen()
    {
        PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
        dropItemScroller.OnRefreshCell += OnRefreshCell;
        MainLevelManager.Instance.OnUpdateDayBooty += UpdateDayBooty;
        Display();
        CreateScroller();
    }
 
 
    protected override void OnPreClose()
    {
        PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh;
        dropItemScroller.OnRefreshCell -= OnRefreshCell;
        MainLevelManager.Instance.OnUpdateDayBooty -= UpdateDayBooty;
    }
 
    void Display()
    {
        var value = PlayerDatas.Instance.baseData.ExAttr2;
        var chapterID = value / 10000;
        var levelNum = value % 10000 / 100;
 
        var chapterConfig = MainChapterConfig.Get(chapterID);
 
        //【普通】关卡名字1-6
        fbNameText.text = Language.Get("mainui7", chapterConfig.Level, chapterConfig.ChapterName, chapterID, levelNum);
 
        var levelConfig = MainLevelConfig.GetMainLevelConfig(chapterID, levelNum);
        var lineUPID = levelConfig.BossLineupIDList[levelConfig.BossLineupIDList.Length - 1];
        var lineUPConfig = NPCLineupConfig.Get(lineUPID);
        var npcConfig = NPCConfig.Get(lineUPConfig.BossID);
        if (npcConfig == null)
        {
            Debug.LogErrorFormat("NPC未配置 : {0}", lineUPConfig.BossID);
            return;
        }
 
 
        bossNameText.text = npcConfig.NPCName;
 
        for (int i = 0; i < skillWordCells.Length; i++)
        {
            if (i < lineUPConfig.SkillIDExList.Length)
            {
                skillWordCells[i].SetActive(true);
                int skillID = lineUPConfig.SkillIDExList[i];
                skillWordCells[i].Init(skillID, () =>
                {
                    SmallTipWin.showText = Language.Get("SmallTipFomat",SkillConfig.Get(skillID)?.SkillName, SkillConfig.Get(skillID)?.Description) ;
                    SmallTipWin.worldPos = CameraManager.uiCamera.ScreenToWorldPoint(Input.mousePosition);
                    SmallTipWin.isDownShow = true;
                    UIManager.Instance.OpenWindow<SmallTipWin>();
                });
            }
            else
            {
                skillWordCells[i].SetActive(false);
            }
        }
 
        bossModel.Create(npcConfig.SkinID, npcConfig.ModelScale);
 
        fightPowerText.text = UIHelper.ReplaceLargeArtNum(levelConfig.FightPower);
 
        var canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
 
        fightBtn.SetInteractable(canChallengeBoss);
 
        for (int i = 0; i < passAwards.Length; i++)
        {
            if (i < levelConfig.AwardItemList.Length)
            {
                passAwards[i].SetActive(true);
                int id = levelConfig.AwardItemList[i][0];
                passAwards[i].Init(new ItemCellModel(id, false, levelConfig.AwardItemList[i][1]));
                passAwards[i].button.AddListener(() =>
                {
                    ItemTipUtility.Show(id);
                });
            }
            else
            {
                passAwards[i].SetActive(false);
            }
        }
        bossBG.SetOrgSprite(chapterConfig.BG, "MainLevel");
    }
 
 
    void FightBoss()
    {
        if (AutoFightModel.Instance.CanChallengeBoss())
        {
            var pack = new CB410_tagCMTurnFight();
            pack.MapID = 2;
            GameNetSystem.Instance.SendInfo(pack);
 
            AutoFightModel.Instance.isPause = true;
        }
        CloseWindow();
    }
 
 
    void PlayerDataRefresh(PlayerDataType type)
    {
        switch (type)
        {
            case PlayerDataType.ExAttr1:
            case PlayerDataType.ExAttr2:
                var canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
 
                fightBtn.interactable = canChallengeBoss;
                fightBtn.SetColorful(null, canChallengeBoss);
                break;
        }
 
    }
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as MainLevelDropCell;
        _cell.Display(cell.index);
    }
 
    void UpdateDayBooty()
    {
        dropItemScroller.m_Scorller.RefreshActiveCellViews();
    }
 
 
    void CreateScroller()
    {
        dropItemScroller.Refresh();
        foreach (DictionaryEntry item in MainChapterConfig.unLockedChapterDict)
        {
            dropItemScroller.AddCell(ScrollerDataType.Header, (int)item.Key);
        }
        dropItemScroller.Restart();
    }
}