99 lines
2.8 KiB
C#
99 lines
2.8 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine.UI;
|
|||
|
using Games.Item;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
|
|||
|
// 充值界面的Item
|
|||
|
public class CommonItemRecharge : UIItemBase {
|
|||
|
|
|||
|
private Image BG; // 物品背景,可能有品次的区分
|
|||
|
private Image icon; // 物品图标
|
|||
|
private Text num; // 物品数目
|
|||
|
private bool hasInit = false; // 标记是否已经初始化过(获得显示的各个组件)
|
|||
|
public Text itemName; // 物品名称
|
|||
|
|
|||
|
public MarketingActAwardItem gameItem; // 显示的数据
|
|||
|
|
|||
|
public override void Init()
|
|||
|
{
|
|||
|
if(!hasInit)
|
|||
|
{
|
|||
|
BG = transform.Find("IconBG").GetComponent<Image>();
|
|||
|
icon = transform.Find("Icon").GetComponent<Image>();
|
|||
|
num = transform.Find("Num").GetComponent<Text>();
|
|||
|
hasInit = true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Show(Hashtable obj)
|
|||
|
{
|
|||
|
gameItem = (MarketingActAwardItem)obj["InitObj"];
|
|||
|
if(gameItem != null)
|
|||
|
{
|
|||
|
if(!hasInit)
|
|||
|
{
|
|||
|
Init();
|
|||
|
}
|
|||
|
InitItem(gameItem);
|
|||
|
base.Show();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Show(MarketingActAwardItem info)
|
|||
|
{
|
|||
|
if(info != null)
|
|||
|
{
|
|||
|
gameItem = info;
|
|||
|
if (!hasInit)
|
|||
|
{
|
|||
|
Init();
|
|||
|
}
|
|||
|
|
|||
|
InitItem(gameItem);
|
|||
|
base.Show();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void InitItem(MarketingActAwardItem info)
|
|||
|
{
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(info.awardSubType, 0);
|
|||
|
|
|||
|
// Set sprite
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(icon, commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(BG, Utils.GetItemQualityFrame(commonItem.Quality, false));
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, icon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, icon.transform);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (itemName != null)
|
|||
|
{
|
|||
|
itemName.text = commonItem.Name;
|
|||
|
}
|
|||
|
|
|||
|
num.text = info.awardNum.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public override void OnItemClick()
|
|||
|
{
|
|||
|
base.OnItemClick();
|
|||
|
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(gameItem.awardSubType, 0);
|
|||
|
if(commonItem.ClassID == (int)ItemClass.EQUIP)
|
|||
|
{
|
|||
|
EquipTooltipsLogic.ShowEquipTooltip(commonItem.Id, ItemTooltipsLogic.ShowType.Info, transform.position);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(commonItem.Id, ItemTooltipsLogic.ShowType.Info, transform.position);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|