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);
|
}
|
|
}
|
|