少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using UnityEngine;
using System.Collections.Generic;
 
public class CelestialPalaceTreeGain : MonoBehaviour
{
    [SerializeField] TextEx txtAwardCount;
    [SerializeField] TextEx txtFortuneCount;
    [SerializeField] ButtonEx btnGain;
    [SerializeField] UIEffect uiEffect;
 
    TiandaoTreeConfig config;
    int awardIndex;
    int state;
    CelestialPalaceModel model { get { return ModelCenter.Instance.GetModel<CelestialPalaceModel>(); } }
    public void Display(int awardIndex)
    {
        this.awardIndex = awardIndex;
        if (!TiandaoTreeConfig.Has(awardIndex))
            return;
        uiEffect.Stop();
        // 获取当前这档天道果的显示状态 0 不可领取(未达成) 1 可领取 2 已领取
        state = model.GetGainState(awardIndex);
        btnGain.SetColorful(null, state != 2);  // 领取后置灰
        if (state == 1)
            uiEffect.Play();
        config = TiandaoTreeConfig.Get(awardIndex);
        txtAwardCount.text = Language.Get("CelestialPalace13", model.GetAwardCount(awardIndex));
        txtFortuneCount.text = Language.Get("CelestialPalace12", model.nowQiYun, config.NeedQiyun);
        btnGain.SetListener(OnClickGain);
    }
 
    void OnClickGain()
    {
        if (state == 1)
        {
            if (model.TryAutoHaveAward(out List<Item> awardList) && !awardList.IsNullOrEmpty())
            {
                //ItemLogicUtility.Instance.ShowGetItem(awardList, "", 5);
            }
        }
        else
        {
            ItemTipUtility.Show(model.moneyItemId);
        }
    }
}