少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 11997ece0dc4980eba3dd8889d37adb8376e14cb
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, April 02, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//月卡投资
namespace Snxxz.UI {
 
    public class MonthlyInvestmentWin : Window
    {
        MonthlyInvestmentModel m_MonthlyInvestmentModel;
        MonthlyInvestmentModel monthlyInvestmentModel { get { return m_MonthlyInvestmentModel ?? (m_MonthlyInvestmentModel = ModelCenter.Instance.GetModel<MonthlyInvestmentModel>()); } }
        [SerializeField] ScrollerController m_ScrollerController;
        [SerializeField] Button m_InvestmentButton;
        [SerializeField] GameObject m_RealizedInvestment;
        #region Built-in
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
            m_InvestmentButton.AddListener(InvestmentButton);
        }
 
        protected override void OnPreOpen()
        {
        //    if (monthlyInvestmentModel.Days!=0)
        //    {
        //        m_RealizedInvestment.SetActive(true);
        //        m_InvestmentButton.gameObject.SetActive(false);
        //    }
        //    else
        //    {
                m_RealizedInvestment.SetActive(false);
                m_InvestmentButton.gameObject.SetActive(true);
            //}
 
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
            monthlyInvestmentModel.MonthlyInvestmentUpdating += MonthlyInvestmentUpdating;
            OnCreateGridLineCell(m_ScrollerController);
            m_ScrollerController.JumpIndex(JumpIndex());
        }
 
        
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
            monthlyInvestmentModel.MonthlyInvestmentUpdating -= MonthlyInvestmentUpdating;
        }
 
        private void MonthlyInvestmentUpdating()
        {
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
 
        protected override void OnAfterClose()
        {
        }
 
 
        void OnCreateGridLineCell(ScrollerController gridCtrl)//预制体创建
        {
            gridCtrl.Refresh();
 
            foreach (int key in monthlyInvestmentModel.MonthlyInvestmentDic.Keys)
            {
                gridCtrl.AddCell(ScrollerDataType.Header, key);
            }
            gridCtrl.Restart();
        }
 
        void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            MotnlyInvestmentItem motnlyInvestmentItem = cell.GetComponent<MotnlyInvestmentItem>();
            int day = cell.index;
            motnlyInvestmentItem.GetIsDays(day);
        }
 
 
        private void InvestmentButton()
        {
            ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),Language.Get("WhetherRecharge_Z"),(bool isOK) =>
             {
                 if (isOK)
                 {
                     if (UIHelper.GetMoneyCnt(1) >= 0)
                     {
                         monthlyInvestmentModel.InvestmentMonthlyInvestment(1, 300);
                     }
                     else
                     {
                         WindowCenter.Instance.Open<RechargeTipWin>();
                     }
                 }
             });            
        }
 
        private int JumpIndex()
        {
            if (monthlyInvestmentModel.Days != 0)
            {
                return monthlyInvestmentModel.Days - 1;
 
            }
            else
            {
                return 0;
            }
        }
        #endregion
 
    }
 
}