少年修仙传客户端代码仓库
hch
2024-12-16 9377811d0ba27047e1e5ec2348a28eba1033d59d
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
using System;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using vnxbqy.UI;
 
public class CrossServerGodBattleFieldAssortApplicationListWin : Window
{
    [SerializeField] TextEx txtCount;
    [SerializeField] ButtonEx btnClose;
    [SerializeField] ButtonEx btnBatchNo;
    [SerializeField] Button btnAutoJoin;
    [SerializeField] Image imgAutoJoin;
    [SerializeField] ScrollerController scroller;
    [SerializeField] InputField inputField;
    bool isHaveTeam;
    bool isCaptain;
    uint teamID;
    AssortTeamInfo teamInfo;
    CrossServerGodBattleFieldAssortModel model { get { return ModelCenter.Instance.GetModel<CrossServerGodBattleFieldAssortModel>(); } }
    protected override void BindController()
    {
 
    }
 
    protected override void AddListeners()
    {
        btnClose.SetListener(CloseClick);
        btnBatchNo.SetListener(BatchNo);
        btnAutoJoin.SetListener(AutoJoin);
        inputField.RemoveAllListeners();
        inputField.onEndEdit.AddListener(OnInputFieldEndEdit);
    }
 
    private void OnInputFieldEndEdit(string str)
    {
        long result;
        if (long.TryParse(str, out result))
        {
            model.nowPowerNum = result;
        }
        else
        {
            model.nowPowerNum = 0;
        }
        model.SavePowerNum();
        SendPack();
    }
 
    protected override void OnPreOpen()
    {
        scroller.OnRefreshCell += OnRefreshCell;
        model.UpdateTeamInfoEvent += OnUpdateTeamInfoEvent;
        model.UpdateTeamDissolveEvent += OnUpdateTeamDissolveEvent;
        Display();
    }
 
    private void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as CrossServerGodBattleFieldAssortApplicationListCell;
        _cell.Display(_cell.index, cell);
    }
 
    void CreateScroller()
    {
        scroller.Refresh();
        var keys = teamInfo.ApplicantDict.Keys.ToList();
        keys = model.GetApplicantSortList(keys);
        for (int i = 0; i < keys.Count; i++)
        {
            uint playerId = keys[i];
            CellInfo cellInfo = new CellInfo();
            cellInfo.infoInt1 = (int)playerId;
            scroller.AddCell(ScrollerDataType.Header, i, cellInfo);
        }
        scroller.Restart();
    }
 
    void Display()
    {
 
        isHaveTeam = model.TryGetPlayerTeamInfo(out isCaptain, out teamID, out teamInfo);
        if (!isHaveTeam || teamInfo.ApplicantDict == null)
        {
            WindowCenter.Instance.Close<CrossServerGodBattleFieldAssortApplicationListWin>();
            return;
        }
        inputField.text = model.nowPowerNum.ToString();
        imgAutoJoin.SetActive(model.isAutoJoin);
        txtCount.text = Language.Get("GodBattleFieldAssort21", StringUtility.Contact(teamInfo.ApplicantDict.Count, "/", FunctionTeamSetConfig.Get((int)model.FuncMapID).ApplyMax));
    }
 
    protected override void OnAfterOpen()
    {
        CreateScroller();
    }
 
    protected override void OnAfterClose()
    {
 
    }
 
    private void OnUpdateTeamInfoEvent()
    {
        Display();
        CreateScroller();
    }
 
    void OnUpdateTeamDissolveEvent()
    {
        bool isHaveTeam = model.TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo);
        if (!isHaveTeam)
        {
            WindowCenter.Instance.Close<CrossServerGodBattleFieldAssortApplicationListWin>();
        }
    }
 
    protected override void OnPreClose()
    {
        scroller.OnRefreshCell -= OnRefreshCell;
        model.UpdateTeamInfoEvent -= OnUpdateTeamInfoEvent;
        model.UpdateTeamDissolveEvent -= OnUpdateTeamDissolveEvent;
        
    }
 
    void BatchNo()
    {
        if (model.IsOpenAction())
        {
            SysNotifyMgr.Instance.ShowTip("GodBattleFieldAssort03");
            return;
        }
        model.SendFuncTeamMemOP(teamID, model.FuncMapID, 4, 0);
    }
 
    void AutoJoin()
    {
        if (model.IsOpenAction())
        {
            SysNotifyMgr.Instance.ShowTip("GodBattleFieldAssort03");
            return;
        }
        model.isAutoJoin = !model.isAutoJoin;
        LocalSave.SetBool(StringUtility.Contact("gszczd_toggle1_", PlayerDatas.Instance.baseData.PlayerID), model.isAutoJoin);
        imgAutoJoin.SetActive(model.isAutoJoin);
        SendPack();
    }
 
    void SendPack()
    {
        ulong minFightPower = ulong.Parse(inputField.text) % 100000000;
        ulong minFightPowerEx = ulong.Parse(inputField.text) / 100000000;
        int needCheck = model.isAutoJoin ? 0 : 1;
        model.SendChangeFuncTeam(teamID, model.FuncMapID, 0, (uint)minFightPower, (uint)minFightPowerEx, 0, (byte)needCheck);
    }
}