少年修仙传客户端代码仓库
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
using System;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
   
    public class HolidayTravelAwardCell : CellView
    {
        [SerializeField] Text titleText;
        [SerializeField] Text remindText;
        [SerializeField] Button receiveBtn;
        [SerializeField] GameObject noReachImg;
        [SerializeField] GameObject alreadyImg;
        [SerializeField] List<ItemCell> itemBaiscs = new List<ItemCell>();
 
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        HolidayTravelModel model { get { return ModelCenter.Instance.GetModel<HolidayTravelModel>(); } }
 
        private void OnEnable()
        {
        }
 
        private void OnDisable()
        {
        }
        public void Init(byte awardIndex)
        {
            OperationHolidayTravel holiday;
            if (!OperationTimeHepler.Instance.TryGetOperation(model.operationType, out holiday))
            {
                return;
            }
            titleText.text = Language.Get("HolidayTravel1", holiday.travelAwards[awardIndex].NeedTravelPoint);
 
            //maxCnt 0 无限制 1 只有1次不需要显示 大于1显示剩余次数
            //剩余次数为0 不显示
            var maxCnt = holiday.travelAwards[awardIndex].AwardCountMax;
            if (maxCnt == 1)
            {
                remindText.text = string.Empty;
            }
            else if (maxCnt == 0)
            {
                remindText.text = Language.Get("HolidayTravel3", model.GetRemindTravelPoint(holiday, awardIndex), holiday.travelAwards[awardIndex].NeedTravelPoint);
            }
            else
            {
                var remindCnt = model.GetAwardRemindTimes(holiday, awardIndex);
                if (remindCnt == 0)
                {
                    remindText.text = string.Empty;
                }
                else
                { 
                    remindText.text = Language.Get("HolidayTravel2", remindCnt, model.GetRemindTravelPoint(holiday, awardIndex), holiday.travelAwards[awardIndex].NeedTravelPoint);
                }
            }
 
            for (int i = 0; i < itemBaiscs.Count; i++)
            {
                if (i < holiday.travelAwards[awardIndex].AwardItemCount)
                {
                    itemBaiscs[i].SetActive(true);
                    var item = holiday.travelAwards[awardIndex].AwardItemList[i];
                    ItemCellModel cellModel = new ItemCellModel((int)item.ItemID, false, item.ItemCount);
                    itemBaiscs[i].Init(cellModel);
                    itemBaiscs[i].auctionIcon.SetActive(item.IsBind > 0 ? true : false);
                    itemBaiscs[i].button.AddListener(() =>
                    {
                        ItemTipUtility.Show((int)item.ItemID);
                    });
                }
                else
                {
                    itemBaiscs[i].SetActive(false);
                }
            }
 
            RefreshAwardStateUI(holiday, awardIndex);
        }
 
        
 
        private void RefreshAwardStateUI(OperationHolidayTravel holiday, byte awardIndex)
        {
            int state = model.GetAwardState(holiday, awardIndex);
            switch (state)
            {
                case 0:
                    noReachImg.SetActive(true);
                    alreadyImg.SetActive(false);
                    receiveBtn.SetActive(false);
                    break;
                case 1:
                    noReachImg.SetActive(false);
                    alreadyImg.SetActive(false);
                    receiveBtn.SetActive(true);
                    receiveBtn.AddListener(()=> {
                        if (playerPack.GetEmptyGridCount(PackType.Item) >= holiday.travelAwards[awardIndex].AwardItemCount)
                        {
                            model.SendGetAward(awardIndex);
                        }
                        else
                        {
                            SysNotifyMgr.Instance.ShowTip("BagFull");
                        }
                    });
                    break;
                case 2:
                    noReachImg.SetActive(false);
                    alreadyImg.SetActive(true);
                    receiveBtn.SetActive(false);
                    break;
            }
        }
 
 
    }
}