少年修仙传客户端代码仓库
hch
5 天以前 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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
 
class PetHorseDevourBehaviour
{
    PetHorseAwakingModel model { get { return PetHorseAwakingModel.Instance; } }
    PackModel packModel;
 
    SmoothMask smoothMask;
    ScrollItem scrollItem;
 
    Text txt_name;
    Text txt_exp;
    ItemBehaviour item;
    Button btn_devour;
    Text txt_devourLabel;
 
    int itemId;
 
    public void Bind(Transform parent, SmoothMask smoothMask)
    {
        packModel = ModelCenter.Instance.GetModelEx<PackModel>();
 
        this.smoothMask = smoothMask;
        this.scrollItem = parent.GetComponentEx<ScrollItem>();
        this.scrollItem.LuaRegister(Display, Dispose);
 
        this.txt_name = parent.FindComponentEx<Text>("Txt_Title");
        this.txt_exp = parent.FindComponentEx<Text>("Txt_Exp");
        this.item = parent.FindComponentEx<ItemBehaviour>("Item");
        this.btn_devour = parent.FindComponentEx<Button>("Btn_Devour");
        this.txt_devourLabel = parent.FindComponentEx<Text>("Btn_Devour/Text");
 
        this.btn_devour.SetListener(() =>
        {
            this.OnDevour();
        });
    }
 
    void Display(int index)
    {
        var items = model.devourItems;
        this.itemId = items.Get(index);
        var itemConfig = ItemConfig.Get(this.itemId);
        this.txt_name.text = Language.Get("PetHorseAwaking_4", itemConfig.ItemName);
        this.txt_exp.text = Language.Get("PetHorseAwaking_5", itemConfig.EffectValueA5);
 
        this.DisplayItem();
    }
 
    public void DisplayItem()
    {
        var count = packModel.GetItemCountByID(PackType.Item, this.itemId);
        this.item.SetItem(this.itemId, 1);
        this.btn_devour.interactable = count > 0;
        if (count > 0)
        {
            this.btn_devour.image.material = this.smoothMask.imageMaterials[0];
            this.txt_devourLabel.color = UIHelper.GetUIColor(TextColType.NavyBrown);
        }
        else
        {
            this.btn_devour.image.material = this.smoothMask.imageMaterials[1];
            this.txt_devourLabel.color = UIHelper.GetUIColor(TextColType.White);
        }
    }
 
    void Dispose() { }
 
    void OnDevour()
    {
        var config = ILPetHorseDevourConfig.Get(this.itemId);
        if (!model.IsPetOrHorseUnlock(config.id, config.type))
        {
            ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("PetHorseAwaking_7"), (bool isOk) =>
            {
                if (isOk)
                    model.SendDevour(model.selectId, this.itemId);
            });
        }
        else if (model.IsFirstTimeDevour())
        {
            ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("PetHorseAwaking_6"), (bool isOk) =>
            {
                if (isOk)
                    model.SendDevour(model.selectId, this.itemId);
            });
        }
        else
            model.SendDevour(model.selectId, this.itemId);
    }
 
}