少年修仙传客户端代码仓库
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, June 11, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
 
public class InvestWin : ILWindow
{
 
    Text m_LoginMoney;
    Text m_LevelMoney;
    Text m_BossMoney;
 
    //标语
    Transform m_LevelAD;
    Transform m_LoginAD;
    Transform m_BossAD;
 
    Button m_LevelTitle;
    Image m_SelectLogin;
    Button m_LoginTitle;
    Image m_SelectLevel;
    Button m_BossTitle;
    Image m_SelectBoss;
    Button m_Invest;
    Image m_State;
    Text m_Price;
    ScrollerController m_ScrollControl;
    TextEx orgPrice;
 
    #region Built-in
    protected override void BindController()
    {
        m_LoginMoney = proxy.GetWidgtEx<Text>("loginmoney");
        m_LevelMoney = proxy.GetWidgtEx<Text>("levelmoney");
        m_BossMoney = proxy.GetWidgtEx<Text>("bossmoney");
 
        m_LevelAD = proxy.GetWidgtEx<Transform>("levelAD");
        m_LoginAD = proxy.GetWidgtEx<Transform>("loginAD");
        m_BossAD = proxy.GetWidgtEx<Transform>("bossAD");
 
        m_LevelTitle = proxy.GetWidgtEx<Button>("LevelButton");
        m_LoginTitle = proxy.GetWidgtEx<Button>("LoginButton");
        m_BossTitle = proxy.GetWidgtEx<Button>("BossButton");
        m_SelectLogin = proxy.GetWidgtEx<Image>("selectLogin");
        m_SelectLevel = proxy.GetWidgtEx<Image>("selectLevel");
        m_SelectBoss = proxy.GetWidgtEx<Image>("selectBoss");
 
        m_Invest = proxy.GetWidgtEx<Button>("BuyButton");
        m_State = proxy.GetWidgtEx<Image>("state");
 
        m_Price = proxy.GetWidgtEx<Text>("price");
        m_ScrollControl = proxy.GetWidgtEx<ScrollerController>("Scroller");
 
        var obj = m_Invest.FindComponent("Text", "GameObject/Txt_orgPrice");
        if (obj != null)
            orgPrice = obj as TextEx;
    }
 
    protected override void AddListeners()
    {
        m_ScrollControl.OnRefreshCell += OnRefreshCell;
        m_Invest.AddListener(OnInvest);
    }
 
    protected override void OnPreOpen()
    {
        InvestModel.Instance.selectType = InvestModel.Instance.GetSelectType();
 
        InvestModel.Instance.onSelectUpdate += OnSelectUpdate;
        InvestModel.Instance.onInvestUpdate += OnInvestUpdate;
        PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
 
        
    }
 
 
    protected override void OnAfterOpen()
    {
        Display();
    }
 
    protected override void OnPreClose()
    {
        InvestModel.Instance.onSelectUpdate -= OnSelectUpdate;
        InvestModel.Instance.onInvestUpdate -= OnInvestUpdate;
        PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
    }
 
    protected override void OnAfterClose()
    {
    }
    #endregion
 
    void Display()
    {
        DisplayBase();
        DisplayInvests();
        DisplayInvestState();
    }
 
    void DisplayBase()
    {
        m_LoginMoney.text = InvestModel.Instance.GetTotalIncome(InvestModel.InvestType_Login).ToString();
        m_LevelMoney.text = InvestModel.Instance.GetTotalIncome(InvestModel.InvestType_Level).ToString();
        m_BossMoney.text = InvestModel.Instance.GetTotalIncome(InvestModel.InvestType_Boss).ToString();
 
        m_LoginAD.SetActiveIL(InvestModel.Instance.selectType == InvestModel.InvestType_Login);
        m_LevelAD.SetActiveIL(InvestModel.Instance.selectType == InvestModel.InvestType_Level);
        m_BossAD.SetActiveIL(InvestModel.Instance.selectType == InvestModel.InvestType_Boss);
        m_SelectLogin.SetActiveIL(InvestModel.Instance.selectType == InvestModel.InvestType_Login);
        m_SelectLevel.SetActiveIL(InvestModel.Instance.selectType == InvestModel.InvestType_Level);
        m_SelectBoss.SetActiveIL(InvestModel.Instance.selectType == InvestModel.InvestType_Boss);
 
        m_LoginTitle.SetActiveIL(InvestModel.Instance.hasInvestType(InvestModel.InvestType_Login));
        m_LevelTitle.SetActiveIL(InvestModel.Instance.hasInvestType(InvestModel.InvestType_Level));
        m_BossTitle.SetActiveIL(InvestModel.Instance.hasInvestType(InvestModel.InvestType_Boss));
 
        m_LoginTitle.SetListener(()=> {
            InvestModel.Instance.selectType = InvestModel.InvestType_Login;
        });
        m_LevelTitle.SetListener(() => {
            InvestModel.Instance.selectType = InvestModel.InvestType_Level;
        });
        m_BossTitle.SetListener(() => {
            InvestModel.Instance.selectType = InvestModel.InvestType_Boss;
        });
        var orderInfoId = InvestModel.Instance.GetOrderInfoId(InvestModel.Instance.selectType);
        var config = OrderInfoConfig.Get(orderInfoId);
        m_Price.text = Language.Get("MonthWeekPrice", UIHelper.GetMoneyFormat(config.PayRMBNum));
        if (orgPrice != null)
        {
            orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
            orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(config.m_PayRMBNum));
        }
    }
 
    void DisplayInvests()
    {
        var jumpIndex = -1;
        var index = 0;
        m_ScrollControl.Refresh();
        var typeList = InvestModel.Instance.GetIdsByType(InvestModel.Instance.selectType);
        for (int i = 0; i < typeList.Count; i++)
        {
            var investID = typeList[i];
            m_ScrollControl.AddCell(ScrollerDataType.Header, investID);
            var state = InvestModel.Instance.GetSingleInvestState(InvestModel.Instance.selectType, investID);
            if (state == 2)
            {
                jumpIndex = index;
            }
            if (jumpIndex == -1 && state == 1)
            {
                jumpIndex = index;
            }
            index++;
        }
 
        m_ScrollControl.Restart();
 
        if (jumpIndex != -1)
        {
            m_ScrollControl.JumpIndex(jumpIndex);
        }
    }
 
    void DisplayInvestState()
    {
        bool isbuy = InvestModel.Instance.IsInvested(InvestModel.Instance.selectType);
        m_Invest.SetActiveIL(!isbuy);
        m_State.SetActiveIL(isbuy);
    }
 
 
    private void OnInvest()
    {
        InvestModel.Instance.SendInvest(InvestModel.Instance.selectType);
    }
 
    private void OnSelectUpdate()
    {
        Display();
    }
 
    private void OnInvestUpdate()
    {
        m_ScrollControl.m_Scorller.RefreshActiveCellViews();
        DisplayInvestState();
    }
 
    private void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var invest = cell.GetILBehaviour<investCell>();
        invest.Display(cell.index);
    }
 
    private void PlayerDataRefreshEvent(PlayerDataType dataType)
    {
        if (dataType == PlayerDataType.LV && InvestModel.Instance.selectType == InvestModel.InvestType_Level)
        {
            m_ScrollControl.m_Scorller.RefreshActiveCellViews();
        }
    }
 
}