lcy
4 天以前 2dd1841d03a730d3d369092c2a3ad656cee4bf64
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
using System.Linq;
using UnityEngine;
 
public class HeroReturnZhanLingCell : CellView
{
    [SerializeField] ItemCell freeItemCell;
    [SerializeField] Transform freeGotRect;
    [SerializeField] Transform baseCanGetAwardRect;
 
    [SerializeField] ItemCell[] paidAwards;
    [SerializeField] Transform[] paidGotRects;
    [SerializeField] Transform[] paidCanGetRects;
    [SerializeField] Transform[] paidLockRects;
    [SerializeField] ItemCell[] paidHAwards;
    [SerializeField] Transform[] paidHGotRects;
    [SerializeField] Transform[] paidHCanGetRects;
    [SerializeField] Transform[] paidHLockRects;
    [SerializeField] Transform upProcssBGRect;
    [SerializeField] Transform upProcessRect;
    [SerializeField] Transform downProcssBGRect;
    [SerializeField] Transform downProcessRect;
    [SerializeField] TextEx txtUnlockLV;
    [SerializeField] Transform mask;
 
    HeroReturnManager zhanLingModel => HeroReturnManager.Instance;
 
    public void Display(int needValue)
    {
        var totalValue = BattlePassManager.Instance.GetTotalValue(zhanLingModel.ZhanLingType);
        int zhanlingId = ZhanlingConfig.GetTypeToIDDict(zhanLingModel.ZhanLingType)[needValue];
        int freeState = zhanLingModel.GetZhanLingFreeGiftState(needValue);
        int paidState = zhanLingModel.GetZhanLingPaidGiftState(needValue);
        int paidHState = zhanLingModel.GetZhanLingPaidGiftHState(needValue);
        int buyState = zhanLingModel.GetZhanLingBuyState();
 
        freeGotRect.SetActive(freeState == 2);
        baseCanGetAwardRect.SetActive(freeState == 1);
        mask.SetActive(freeState == 0);
 
        for (int i = 0; i < paidAwards.Length; i++)
        {
            bool isBuy = buyState == 1 || buyState == 3;
            paidGotRects[i].SetActive(paidState == 2);
            paidCanGetRects[i].SetActive(paidState == 1 && isBuy);
            paidLockRects[i].SetActive(!isBuy || paidState == 0);
        }
        for (int i = 0; i < paidHAwards.Length; i++)
        {
            bool isBuy = buyState == 2 || buyState == 3;
            paidHGotRects[i].SetActive(paidHState == 2);
            paidHCanGetRects[i].SetActive(paidHState == 1 && isBuy);
            paidHLockRects[i].SetActive(!isBuy || paidHState == 0);
        }
        txtUnlockLV.text = needValue.ToString();
 
        // 进度条显示逻辑
        var ids = ZhanlingConfig.GetTypeToIDDict(zhanLingModel.ZhanLingType).Values.ToList();
        ids.Sort();
        upProcssBGRect.SetActive(ids[0] != zhanlingId);
        upProcessRect.SetActive(freeState != 0);
 
        downProcssBGRect.SetActive(ids[ids.Count - 1] != zhanlingId);
        var nextConfig = ZhanlingConfig.Get(zhanlingId + 1);
        downProcessRect.SetActive(nextConfig != null && totalValue >= nextConfig.NeedValue);
 
        // 展示ItemCell
        var config = ZhanlingConfig.Get(zhanlingId);
        if (config == null)
            return;
 
        // 免费奖励
        int freeItemId = config.FreeRewardItemList[0][0];
        freeItemCell.Init(new ItemCellModel(freeItemId, false, config.FreeRewardItemList[0][1]));
        freeItemCell.button.onClick.RemoveAllListeners();
        freeItemCell.button.onClick.AddListener(() =>
        {
            if (freeState == 1)
                zhanLingModel.HaveAllZhanLingGift();
            else
                ItemTipUtility.Show(freeItemId);
        });
 
        // 普通奖励
        for (int i = 0; i < paidAwards.Length; i++)
        {
            if (i >= config.ZLRewardItemList.Length)
                continue;
            int itemId2 = config.ZLRewardItemList[i][0];
            paidAwards[i].Init(new ItemCellModel(itemId2, false, config.ZLRewardItemList[i][1]));
            paidAwards[i].button.onClick.RemoveAllListeners();
            paidAwards[i].button.onClick.AddListener(() =>
            {
                if (buyState == 0 || buyState == 2)
                    zhanLingModel.ShowZhanLingHBuy(zhanLingModel.ZhanLingType, 1);
                else if (paidState == 1)
                    zhanLingModel.HaveAllZhanLingGift();
                else
                    ItemTipUtility.Show(itemId2);
            });
        }
 
        // 高级奖励
        for (int i = 0; i < paidHAwards.Length; i++)
        {
            if (i >= config.ZLRewardItemListH.Length)
                continue;
            int itemId3 = config.ZLRewardItemListH[i][0];
            paidHAwards[i].Init(new ItemCellModel(itemId3, false, config.ZLRewardItemListH[i][1]));
            paidHAwards[i].button.onClick.RemoveAllListeners();
            paidHAwards[i].button.onClick.AddListener(() =>
            {
                if (buyState == 0 || buyState == 1)
                    zhanLingModel.ShowZhanLingHBuy(zhanLingModel.ZhanLingType, 2);
                else if (paidHState == 1)
                    zhanLingModel.HaveAllZhanLingGift();
                else
                    ItemTipUtility.Show(itemId3);
            });
        }
    }
}