首次提交
This commit is contained in:
61
Assets/Scripts/UI/Bag/BagGearItem.cs
Normal file
61
Assets/Scripts/UI/Bag/BagGearItem.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using Fantasy;
|
||||
using NBC;
|
||||
using NBF.Utils;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BagGearItem : GButton
|
||||
{
|
||||
public Action<long, long> OnCloseAction;
|
||||
public ItemBindData BindData { get; private set; }
|
||||
public ItemInfo ItemInfo { get; private set; }
|
||||
|
||||
public long RigId { get; private set; }
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
BtnClose.onClick.Set(OnClose);
|
||||
}
|
||||
|
||||
private void OnClose(EventContext context)
|
||||
{
|
||||
OnCloseAction?.Invoke(ItemInfo.Id, RigId);
|
||||
context.StopPropagation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置数据
|
||||
/// </summary>
|
||||
/// <param name="item">主物体</param>
|
||||
/// <param name="bindData">可以装配的配件</param>
|
||||
/// <param name="bind">已绑定的配件</param>
|
||||
public void SetData(ItemInfo item, ItemBindData bindData, ItemInfo bind = null)
|
||||
{
|
||||
ItemInfo = item;
|
||||
BindData = bindData;
|
||||
Have.selectedIndex = bind != null ? 1 : 0;
|
||||
|
||||
if (bind != null)
|
||||
{
|
||||
RigId = bind.Id;
|
||||
this.SetIcon(bind.ConfigId);
|
||||
TextTitle.text = bind.ConfigId.GetName();
|
||||
Quality.SetQuality(bind.Config.Quality);
|
||||
// TextTitle.SetTitleQuality(bind.Config.Quality);
|
||||
TextDesc.text = bind.ConfigId.GetDesc();
|
||||
}
|
||||
else
|
||||
{
|
||||
RigId = 0;
|
||||
TextTitle.text = bindData.Type.ToString();
|
||||
// TextTitle.SetTitleQuality(0);
|
||||
TextDesc.text = bindData.Optional ? "非必要组件" : "必要组件";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user