少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using System;
 
namespace vnxbqy.UI
{
    public class NewYearCeremonyRechargeGiftWin : Window
    {
        [SerializeField] Button receiveBtn;
        [SerializeField] Button rechargeBtn;
        [SerializeField] Text receiveBtnText;
        [SerializeField] Image receiveBtnImg;
        [SerializeField] Text remainTimeText;
        [SerializeField] List<CommonItemBaisc> itemBaiscs = new List<CommonItemBaisc>();
 
        List<NewYearFairylandCeremonyModel.AwardItem> itemlist;
        NewYearFairylandCeremonyModel ceremonyModel { get { return ModelCenter.Instance.GetModel<NewYearFairylandCeremonyModel>(); } }
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
            rechargeBtn.AddListener(ClickRecharge);
            receiveBtn.AddListener(OnReceiveGift);
        }
 
        protected override void OnPreOpen()
        {
            GlobalTimeEvent.Instance.secondEvent += RefreshSecond;
            ceremonyModel.RefreshRechargeStateAct += SetReceiveBtnState;
            itemlist = ceremonyModel.GetRechargeAwardByLv();
            Init();
        }
 
        protected override void OnAfterOpen()
        {
           
        }
 
        protected override void OnPreClose()
        {
            GlobalTimeEvent.Instance.secondEvent -= RefreshSecond;
            ceremonyModel.RefreshRechargeStateAct -= SetReceiveBtnState;
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        private void Init()
        {
            if (itemlist == null) return;
 
            for(int i = 0; i < itemBaiscs.Count; i++)
            {
                if(i < itemlist.Count)
                {
                    itemBaiscs[i].SetActive(true);
                    NewYearFairylandCeremonyModel.AwardItem itemData = itemlist[i];
                    ItemCellModel cellModel = new ItemCellModel(itemData.itemId,true, (ulong)itemData.itemCount);
                    itemBaiscs[i].Init(cellModel);
                    itemBaiscs[i].button.RemoveAllListeners();
                    itemBaiscs[i].button.AddListener(()=>
                    {
                        ItemTipUtility.Show(itemData.itemId);
                    });
                }
                else
                {
                    itemBaiscs[i].SetActive(false);
                }
            }
            RefreshSecond();
            SetReceiveBtnState();
        }
 
 
        private void RefreshSecond()
        {
            int seconds = OperationTimeHepler.Instance.GetOperationSurplusTime(Operation.NewYearFairyCeremony);
            if (seconds > 0)
            {
                remainTimeText.text = StringUtility.Contact("<color=#8DDC11FF>", TimeUtility.SecondsToHMS(seconds), "</color>");
            }
            else
            {
                remainTimeText.text = UIHelper.AppendColor(TextColType.Red, Language.Get("XMZZ110"));
            }
        }
 
        private void SetReceiveBtnState()
        {
            switch (ceremonyModel.receiveState)
            {
                case NewYearFairylandCeremonyModel.ReceiveState.NoReach:
                    receiveBtnImg.material = MaterialUtility.GetDefaultSpriteGrayMaterial();
                    receiveBtnText.text = Language.Get("AccumulateRecharge_GetReward");
                    break;
                case NewYearFairylandCeremonyModel.ReceiveState.Reach:
                    receiveBtnImg.material = MaterialUtility.GetUIDefaultGraphicMaterial();
                    receiveBtnText.text = Language.Get("AccumulateRecharge_GetReward");
                    break;
                case NewYearFairylandCeremonyModel.ReceiveState.Already:
                    receiveBtnImg.material = MaterialUtility.GetDefaultSpriteGrayMaterial();
                    receiveBtnText.text = Language.Get("Z1044");
                    break;
            }
        }
 
        private void OnReceiveGift()
        {
            if (itemlist == null) return;
 
            switch (ceremonyModel.receiveState)
            {
                case NewYearFairylandCeremonyModel.ReceiveState.NoReach:
                    SysNotifyMgr.Instance.ShowTip("FairylandCermonyRecharge1");
                    break;
                case NewYearFairylandCeremonyModel.ReceiveState.Reach:
                    bool isGrid = playerPack.GetEmptyGridCount(PackType.Item) - itemlist.Count >= 0 ? true : false;
                    if (isGrid)
                    {
                        ceremonyModel.SendReceiveAward(GotServerRewardType.Def_RewardType_NewFairyCRecharge, 0);
                    }
                    else
                    {
                        SysNotifyMgr.Instance.ShowTip("BagFull");
                    }
                    break;
                case NewYearFairylandCeremonyModel.ReceiveState.Already:
                    SysNotifyMgr.Instance.ShowTip("FairylandCermonyRecharge2");
                    break;
            }
        }
 
        private void ClickRecharge()
        {
            WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
        }
    }
}