少年修仙传客户端代码仓库
hch
3 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, January 28, 2019
//--------------------------------------------------------
 
using System;
using UnityEngine;
using UnityEngine.UI;
using vnxbqy.UI;
using System.Collections.Generic;
using System.Linq;
 
public class CrossServerBattleFieldResultWin : ILWindow
{
    Button exit;
    Text fightTime;
    Button seeOther;
    ScrollerController scroller;
    Image factionIcon;
    Transform defeatObj;
    Transform winObj;
    Text factionState;
    List<ItemCell> itemCells = new List<ItemCell>();
    ItemCell godAward;
    Text quitTime;
    Text seeFactionResult;
    Text names;
    Text myScore;
 
 
    const int outTime = 50; //退出倒计时
    float starTime;
 
    #region Built-in
    protected override void BindController()
    {
        exit = proxy.GetWidgtEx<Button>("Btn_Quit");
        fightTime = proxy.GetWidgtEx<Text>("Txt_TotalTime");
        seeOther = proxy.GetWidgtEx<Button>("seeOther");
        scroller = proxy.GetWidgtEx<ScrollerController>("Scroller");
        factionIcon = proxy.GetWidgtEx<Image>("factionIcon");
        defeatObj = proxy.GetWidgtEx<Transform>("Container_Defeat");
        winObj = proxy.GetWidgtEx<Transform>("Container_Win");
        factionState = proxy.GetWidgtEx<Text>("stateTitle");
        for (int i = 0; i < 6; i++)
        {
            itemCells.Add(proxy.GetWidgtEx<ItemCell>(i.ToString()));
        }
 
        godAward = proxy.GetWidgtEx<ItemCell>("bigAward");
        quitTime = proxy.GetWidgtEx<Text>("quitText");
        seeFactionResult = proxy.GetWidgtEx<Text>("seeTextEx");
        names = proxy.GetWidgtEx<Text>("names");
        myScore = proxy.GetWidgtEx<Text>("myScore");
    }
 
    protected override void AddListeners()
    {
        exit.SetListener(()=> {
            ILCrossServerModel.Instance.RequestExit();
        });
 
        seeOther.SetListener(() => {
            ILCrossServerModel.Instance.seeFaction = ILCrossServerModel.Instance.seeFaction == 1 ? 2 : 1;
            DisplayByFaction(ILCrossServerModel.Instance.seeFaction);
        });
    }
 
    protected override void OnPreOpen()
    {
        starTime = Time.time;
        ILCrossServerModel.Instance.seeFaction = ILCrossServerModel.Instance.dungeonResult.faction;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        scroller.OnRefreshCell += OnRefreshCell;
        
    }
 
    protected override void OnAfterOpen()
    {
        fightTime.text = TimeUtility.SecondsToMS(ILCrossServerModel.Instance.dungeonResult.costTime);
 
        var bigItemID = ILCrossServerModel.Instance.superItemInfo[0];
        var bigModel = new ItemCellModel(bigItemID, false, (ulong)ILCrossServerModel.Instance.superItemInfo[1]);
        godAward.Init(bigModel);
        godAward.button.SetListener(() =>
        {
            ItemTipUtility.Show(bigItemID);
        });
 
        names.text = string.Format("{0},{1},{2}", ILCrossServerModel.Instance.dungeonResult.finalSuperItemPlayerName,
        ILCrossServerModel.Instance.dungeonResult.factionInfoList[0].superItemPlayerName,
        ILCrossServerModel.Instance.dungeonResult.factionInfoList[1].superItemPlayerName
        );
 
        myScore.text = Language.Get("CrossBattleField88") + ILCrossServerModel.Instance.dungeonResult.score;
        DisplayByFaction(ILCrossServerModel.Instance.seeFaction);
    }
 
    protected override void OnPreClose()
    {
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        scroller.OnRefreshCell -= OnRefreshCell;
    }
    #endregion
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetILBehaviour<CrossServerBattleFieldResultCell>();
        _cell?.Display(cell.index);
    }
 
    void OnSecondEvent()
    {
        var endTime = Math.Max(outTime - (int)(Time.time - starTime), 0);
        if (endTime == 0)
        {
            ILCrossServerModel.Instance.RequestExit();
            WindowCenter.Instance.CloseIL<CrossServerBattleFieldResultWin>();
            return;
        }
        quitTime.text = Language.Get("CrossBattleField84", endTime);
    }
 
    void DisplayByFaction(int faction)
    {
        seeFactionResult.text = Language.Get(faction == ILCrossServerModel.Instance.dungeonResult.faction ? "CrossBattleField82" : "CrossBattleField82_0");
        CreateScroller(faction);
        factionIcon.SetSprite("GSZCIcon" + faction);
        defeatObj.SetActiveIL(ILCrossServerModel.Instance.dungeonResult.winnerFaction != faction);
        winObj.SetActiveIL(ILCrossServerModel.Instance.dungeonResult.winnerFaction == faction);
        factionState.text = Language.Get(ILCrossServerModel.Instance.dungeonResult.winnerFaction == faction ? "CrossBattleField85" : "CrossBattleField86");
 
        var commonAwards = ILCrossServerModel.Instance.dungeonResult.winnerFaction == faction ? ILCrossServerModel.Instance.winFactionAwards : ILCrossServerModel.Instance.defeatFactionAwards;
 
        for (int i = 0; i < itemCells.Count; i++)
        {
            if (i < commonAwards.Length)
            {
                itemCells[i].SetActiveIL(true);
                var itemID = commonAwards[i][0];
                var model = new ItemCellModel(itemID, false, (ulong)commonAwards[i][1]);
                itemCells[i].Init(model);
                itemCells[i].button.SetListener(() =>
                {
                    ItemTipUtility.Show(itemID);
                });
            }
            else
            {
                itemCells[i].SetActiveIL(false);
            }
        }
    }
 
    void CreateScroller(int faction)
    {
        scroller.Refresh();
        for (int i = 0; i < ILCrossServerModel.Instance.dungeonResult.factionInfoList[faction - 1].rankPlayerList.Length; i++)
        {
            scroller.AddCell(ScrollerDataType.Header, i);
        }
        scroller.Restart();
        scroller.m_Scorller.RefreshActiveCellViews();
        if (faction == ILCrossServerModel.Instance.dungeonResult.faction)
        {
            scroller.JumpIndex(ILCrossServerModel.Instance.dungeonResult.rank - 1);
        }
    }
}