using cfg.ActorCfg;
using Framework;
using Gameplay;
using PhxhSDK;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
///
/// 通用道具
///
public class GenericItem : UIGameObjectWrapper
{
///
/// 置灰的灰度
///
private const float GREY = 0.5f;
///
/// 正常颜色
///
private const float NORMAL = 1f;
#region UI
///
/// 道具品质_蓝
///
private Image imageQuality_blue;
///
/// 道具品质_黄
///
private Image imageQuality_yellow;
///
/// 道具品质_红
///
private Image imageQuality_red;
///
/// 道具图标
///
private Image imageIcon;
///
/// 道具数量背景
///
private Image imageCount;
///
/// 道具数量文本
///
private TMP_Text textCount;
///
/// 道具按钮
///
private Button button;
#endregion
///
/// 道具配置
///
private DataItem dataItem;
///
/// 回调
///
private Action callbackAction;
#region 属性
///
/// 是否显示道具数量
///
public bool IsShowCount
{
set { imageCount.gameObject.IsScaleShow(value); }
}
///
/// 是否置灰
///
public bool IsGrey
{
set
{
if (value)
{
//imageQuality.color = new Color(GREY, GREY, GREY, imageQuality.color.a);
imageIcon.color = new Color(GREY, GREY, GREY, imageIcon.color.a);
imageCount.color = new Color(GREY, GREY, GREY, imageCount.color.a);
textCount.color = new Color(GREY, GREY, GREY, textCount.color.a);
}
else
{
//imageQuality.color = new Color(NORMAL, NORMAL, NORMAL, imageQuality.color.a);
imageIcon.color = new Color(NORMAL, NORMAL, NORMAL, imageIcon.color.a);
imageCount.color = new Color(NORMAL, NORMAL, NORMAL, imageCount.color.a);
textCount.color = new Color(NORMAL, NORMAL, NORMAL, textCount.color.a);
}
}
}
///
/// 是否开启按钮
///
public bool IsEnableButton
{
set { button.enabled = value; }
}
#endregion
#region 构造
///
/// 根据GameObject构造
///
///
public GenericItem(GameObject root, Action callback = null) : base(root, false)
{
Construct(callback);
}
///
/// 根据GameObject克隆并构造
///
///
///
public GenericItem(GameObject root, int i, Action callback = null) : base(root, i, false)
{
Construct(callback);
}
private void Construct(Action callback)
{
imageQuality_blue = GetComponent("BaseItem/Rarity/ItemQuality_blue");
imageQuality_yellow = GetComponent("BaseItem/Rarity/ItemQuality_yellow");
imageQuality_red = GetComponent("BaseItem/Rarity/ItemQuality_red");
imageIcon = GetComponent("BaseItem/ItemIcon");
imageCount = GetComponent("BaseItem/ImageCount");
textCount = GetComponent("BaseItem/ImageCount/TextCount");
button = GetComponent