少年修仙传客户端代码仓库
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
 
namespace vnxbqy.UI
{
    public class DayOnlineCell : CellView
    {
        [SerializeField] Text m_TimeInfo;
        [SerializeField] ItemCell[] m_Items;
        [SerializeField] Image m_StateImg;
        [SerializeField] ButtonEx m_GetBtn;
        [SerializeField] UIEffect m_GetEffect;
 
        DayOnlineModel model { get { return ModelCenter.Instance.GetModel<DayOnlineModel>(); } }
 
        public void Display(int index)
        {
            //原索引对应的物品奖励;index是排序后的索引
            int realIndex = Array.IndexOf(model.timeArr, model.indexSort[index]) + 1;
 
            for (int i = 0; i < m_Items.Length; i++)
            {
                if (model.awards.ContainsKey(realIndex) && i < model.awards[realIndex].Count)
                {
                    m_Items[i].SetActive(true);
                    var itemID = model.awards[realIndex][i][0];
                    var itemCount = model.awards[realIndex][i][1];
 
                    var Item = ItemConfig.Get(itemID);
                    ItemCellModel cellModel = new ItemCellModel(itemID, true, (ulong)itemCount);
                    m_Items[i].Init(cellModel);
                    m_Items[i].button.SetListener(() =>
                    {
                        ItemTipUtility.Show(itemID);
                    });
 
                }
                else
                {
                    m_Items[i].SetActive(false);
                }
            }
 
            m_TimeInfo.text = Language.Get("dayOnline_2", model.indexSort[index]);
            m_GetEffect.SetActive(false);
            m_GetEffect.Stop();
            var state = model.GetAwardState(realIndex - 1);
            if (state == 2)
            {
                m_StateImg.SetActive(true);
                m_GetBtn.SetActive(false);
            }
            else
            {
                m_StateImg.SetActive(false);
                m_GetBtn.SetActive(true);
                if (state == 0)
                { 
                    m_GetEffect.SetActive(true);
                    m_GetEffect.Play();
                }
                m_GetBtn.SetColorful(null, state == 0);
 
                m_GetBtn.SetListener(() => {
                    CA506_tagCMGetOnlinePrize pack = new CA506_tagCMGetOnlinePrize();
                    pack.Index = (byte)realIndex;
                    pack.IsDaily = 1;
                    GameNetSystem.Instance.SendInfo(pack);
                });
            }
        }
    }
}