少年修仙传客户端代码仓库
hch
4 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
using LitJson;
using vnxbqy.UI;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
//玩法前瞻
class FuncPreNoticeWin : ILWindow
{
    public int[][] itemArray;
 
    ButtonEx btnReward;
    List<ItemCell> items = new List<ItemCell>();
    Text stateTxt;
    Button close;
    protected override void BindController()
    {
        base.BindController();
        btnReward = proxy.GetWidgtEx<ButtonEx>("CommonButton");
        items.Add(proxy.GetWidgtEx<ItemCell>("itemcell0"));
        items.Add(proxy.GetWidgtEx<ItemCell>("itemcell1"));
        items.Add(proxy.GetWidgtEx<ItemCell>("itemcell2"));
        items.Add(proxy.GetWidgtEx<ItemCell>("itemcell3"));
        stateTxt = proxy.GetWidgtEx<Text>("TextEx");
        close = proxy.GetWidgtEx<Button>("Img_Close");
 
 
 
 
    }
 
    protected override void AddListeners()
    {
        base.AddListeners();
        btnReward.AddListener(() =>
        {//领取奖励
            var pack = new IL_CA504_tagCMPlayerGetReward();
            pack.RewardType = 48;
            GameNetSystem.Instance.SendInfo(pack);
        });
 
        close.AddListener(()=> {
            CloseWin<FuncPreNoticeWin>();
        });
    }
 
 
    protected override void OnPreOpen()
    {
        FuncAwardModel.Instance.onReceived += RefreshBtn;
        int state = FuncAwardModel.Instance.TryGetAwardState(48);
        if (state == -1)
            state = 0;
        RefreshBtn(state);
 
        if (itemArray == null || itemArray.Length < 1)
        { 
            var config = FuncConfigConfig.Get("GameNoticeReward");
            itemArray = JsonMapper.ToObject<int[][]>(config.Numerical1);
        }
 
        for (int i = 0; i < items.Count; i++)
        {
            items[i].SetActiveIL(false);
        }
 
        for (int i = 0; i < itemArray.Length; i++)
        {
            if (i >= items.Count)
            {
                continue;
            }
            items[i].SetActiveIL(true);
            var itemID = itemArray[i][0];
            var materialModel = new ItemCellModel(itemID, false, (ulong)itemArray[i][1]);
            items[i].Init(materialModel);
            items[i].button.SetListener(() =>
            {
                ItemTipUtility.Show(itemID);
            });
        }
    }
 
    protected override void OnAfterClose()
    {
        base.OnAfterClose();
        FuncAwardModel.Instance.onReceived -= RefreshBtn;
    }
 
 
 
    //刷新按钮的状态
    void RefreshBtn(int state)
    {
        btnReward.SetColorful(null, state == 0);
        //        RealmPractice109 领取
        //RealmPractice110 已领取
        stateTxt.text = Language.Get(state == 0 ? "RealmPractice109" : "RealmPractice110");
    }
 
}