yyl
2 天以前 bcd1dcef07dc129d68539ca2d562c5df53007f36
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
using System.Collections.Generic;
using UnityEngine;
 
public class TimeRushTaskCell : MonoBehaviour
{
    [SerializeField] ButtonEx clickButton;
    [SerializeField] TextEx titleText;
    [SerializeField] ImageEx sliderImage;
    [SerializeField] ImageEx maskImage;
    [SerializeField] TextEx sliderText;
    [SerializeField] ItemCell[] itemCells;
    [SerializeField] ImageEx[] grays;
    [SerializeField] RotationTween[] tweens;
    [SerializeField] UIEffectPlayer uiEffectPlayer;
 
    int awardIndex;
    int roundType;
    int tabType;
    TimeRushManager manager { get { return TimeRushManager.Instance; } }
 
    private void OnEnable()
    {
        manager.PlayAnimationSync += OnPlaySyncAnimation;
        for (int i = 0; i < tweens.Length; i++)
        {
            tweens[i].Stop();
            tweens[i].SetStartState();
        }
 
        if (!manager.TryGetOperationInfo(out var act))
            return;
        if (!act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
            return;
        int state = manager.GetAwardState(roundType, awardIndex);
        for (int i = 0; i < tweens.Length; i++)
        {
            if (i < awardInfo.AwardItemList.Length)
            {
                if (state == 1)
                {
                    tweens[i].Play();
                }
            }
        }
 
    }
 
    private void OnDisable()
    {
        manager.PlayAnimationSync -= OnPlaySyncAnimation;
    }
 
    private void OnPlaySyncAnimation()
    {
        if (tabType != 1)
            return;
        for (int i = 0; i < tweens.Length; i++)
        {
            tweens[i].Stop();
            tweens[i].SetStartState();
        }
        if (!manager.TryGetOperationInfo(out var act))
            return;
        if (!act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
            return;
        int state = manager.GetAwardState(roundType, awardIndex);
        for (int i = 0; i < tweens.Length; i++)
        {
            if (tweens[i].isActiveAndEnabled && state == 1)
            {
                tweens[i].Play();
            }
        }
    }
 
    public void Display(int index, CellView cell, List<HAA88_tagMCActLunhuidianInfo.tagMCActLunhuidianAward> taskList)
    {
 
        roundType = cell.info.Value.infoInt1;
        tabType = cell.info.Value.infoInt2;
        if (taskList.IsNullOrEmpty() || index < 0 || index >= taskList.Count)
            return;
        var task = taskList[index];
        awardIndex = task.AwardIndex;
        if (!manager.TryGetOperationInfo(out var act))
            return;
        if (!act.TryGetRound(roundType, out var round))
            return;
        if (!manager.TryGetPlayerInfo(roundType, out var playerInfo))
            return;
        int state = manager.GetAwardState(roundType, awardIndex);
        maskImage.SetActive(state == 2);
        uiEffectPlayer.SetActive(state == 1);
        titleText.text = Language.Get($"TimeRushTaskTitle_{round.AwardType}_{round.AwardTypeValue}", task.NeedValue);
        sliderImage.fillAmount = playerInfo.CurValue / (float)task.NeedValue;
        sliderText.text = Language.Get("BoneField09", playerInfo.CurValue, task.NeedValue);
 
        for (int i = 0; i < itemCells.Length; i++)
        {
            var itemBaisc = itemCells[i];
            if (i < task.AwardItemList.Length)
            {
                var itemInfo = task.AwardItemList[i];
                itemBaisc.SetActive(true);
                grays[i].SetActive(state == 2);
                ItemCellModel cellModel = new ItemCellModel((int)itemInfo.ItemID, false, itemInfo.ItemCount);
                itemBaisc.Init(cellModel);
                itemBaisc.button.AddListener(() =>
                {
                    if (state == 1)
                    {
                        manager.HaveAllMissionAward(roundType);
                    }
                    else
                    {
                        ItemTipUtility.Show((int)itemInfo.ItemID);
                    }
                });
            }
            else
            {
                itemBaisc.SetActive(false);
                grays[i].SetActive(false);
            }
        }
 
        clickButton.SetListener(() =>
        {
            if (state == 1)
            {
                manager.HaveAllMissionAward(roundType);
            }
        });
    }
 
}