少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, April 02, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
 
 
namespace Snxxz.UI {
 
    public class MotnlyInvestmentItem:MonoBehaviour {
        [SerializeField] Transform m_Group;//奖励品组
        [SerializeField] Button m_ReceiveAwardBtn;//领奖按钮
        [SerializeField] Image m_IsDrawImage;//是否领取
        [SerializeField] Text m_TimeRemaining;//领取时间剩余
        [SerializeField] GameObject m_Uieffect;//特效
        MonthlyInvestmentModel m_MonthlyInvestmentModel;
        MonthlyInvestmentModel monthlyInvestmentModel { get { return m_MonthlyInvestmentModel ?? (m_MonthlyInvestmentModel = ModelCenter.Instance.GetModel<MonthlyInvestmentModel>()); } }
        public void GetIsDays(int Day)
        {
            if (Day < monthlyInvestmentModel.Days)
            {
                UsedDay(Day);//过天
            }
            else if (Day == monthlyInvestmentModel.Days)
            {
                TheSameDay(Day);//当天
            }
            else if (Day > monthlyInvestmentModel.Days)
            {
                NonArrival(Day);//未到
            }
 
        }
 
        private void UsedDay( int Day)//过天
        {
          bool isBool=  monthlyInvestmentModel.IsTagGetInfoSeriors(Day);
            m_TimeRemaining.gameObject.SetActive(false);
            m_Uieffect.SetActive(false);
            if (monthlyInvestmentModel.Days != 0)
            {
                m_ReceiveAwardBtn.gameObject.SetActive(false);
                m_IsDrawImage.gameObject.SetActive(true);
                if (isBool)
                {
                   // m_IsDrawImage.SetSprite();//已领取
                }
                else
                {
                    // m_IsDrawImage.SetSprite();//已错过
                }
 
            }
            else
            {
                m_IsDrawImage.gameObject.SetActive(false);
                m_ReceiveAwardBtn.gameObject.SetActive(true);
                m_ReceiveAwardBtn.interactable = false;
                m_ReceiveAwardBtn.GetComponent<ImageEx>().gray = false;
            }
 
            ItemCellAssignment(Day);
        }
        private void NonArrival(int Day)//未到
        {
         
            if (monthlyInvestmentModel.Days != 0)
            {
                m_ReceiveAwardBtn.gameObject.SetActive(false);
                m_IsDrawImage.gameObject.SetActive(false);
                m_TimeRemaining.gameObject.SetActive(true);
                int MinimumDays = 0;
                MinimumDays = Day - monthlyInvestmentModel.Days;
                if (MinimumDays > 1)
                {
                    m_TimeRemaining.text = string.Format(Language.Get("Rest_Time"), MinimumDays);
                }
                else
                {
                    m_TimeRemaining.text = Language.Get("Tomorrow_Draw");
                }             
            }
            else
            {
                m_ReceiveAwardBtn.gameObject.SetActive(true);
                m_IsDrawImage.gameObject.SetActive(false);
                m_ReceiveAwardBtn.interactable = false;
                m_TimeRemaining.gameObject.SetActive(false);
                m_Uieffect.SetActive(false);
                
                m_ReceiveAwardBtn.GetComponent<ImageEx>().gray = false;
            }
                ItemCellAssignment(Day);
        }
        private void TheSameDay(int Day)//当天
        {
            bool isBool = monthlyInvestmentModel.IsTagGetInfoSeriors(Day);
            m_TimeRemaining.gameObject.SetActive(false);
            if (monthlyInvestmentModel.Days != 0)
            {
                if (isBool)
                {
                    m_ReceiveAwardBtn.gameObject.SetActive(false);
                    m_IsDrawImage.gameObject.SetActive(true);
                    // m_IsDrawImage.SetSprite();//已领取
                }
                else
                {
                    m_IsDrawImage.gameObject.SetActive(false);
                    m_ReceiveAwardBtn.gameObject.SetActive(true);
                    m_ReceiveAwardBtn.interactable = true;
                    m_Uieffect.SetActive(true);
                    m_ReceiveAwardBtn.RemoveAllListeners();
                    m_ReceiveAwardBtn.AddListener(()=> 
                    {
                        monthlyInvestmentModel.SendInvestment(1, Day);
                    });
                }
            }
            else
            {
                m_ReceiveAwardBtn.gameObject.SetActive(true);
                m_IsDrawImage.gameObject.SetActive(false);
                m_ReceiveAwardBtn.interactable = false;
                m_Uieffect.SetActive(false);
                m_ReceiveAwardBtn.GetComponent<ImageEx>().gray = false;
            }
                ItemCellAssignment(Day);
        }
        private void ItemCellAssignment(int Day)
        {
            if (monthlyInvestmentModel.MonthlyInvestmentDic.ContainsKey(Day))
            {
                List<Item> monthlyInvestmentItem = monthlyInvestmentModel.MonthlyInvestmentDic[Day].monthlyInvestmentItem.GetAwardItem(1);
                for (int i = 0; i < m_Group.childCount; i++)
                {
                    if (i < monthlyInvestmentItem.Count)
                    {
                        m_Group.GetChild(i).gameObject.SetActive(true);
                        Item item = monthlyInvestmentItem[i];
                        MotnlyItem motnlyItem = m_Group.GetChild(i).GetComponent<MotnlyItem>();
                        var Item = ItemConfig.Get(item.id);
                        ItemCellModel cellModel = new ItemCellModel(item.id, true, (ulong)1);
                        motnlyItem.Item_Cell.Init(cellModel);
                        motnlyItem.NameText.text = Item.ItemName;
                        motnlyItem.MoneyNumberText.text = item.count.ToString();
                        motnlyItem.MoneyImage.SetSprite(Item.IconKey);
                    }
                    else
                    {
                        m_Group.GetChild(i).gameObject.SetActive(false);
                    }
 
                }
            }
        }
    }
   
}