109 lines
2.2 KiB
C#
109 lines
2.2 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2020-11-17
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "EquipmentSlotWidget" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public class EquipmentSlotWidget : KUIWidget
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
[KUIFlag]
|
|||
|
GameObject __goEquipment;
|
|||
|
[KUIFlag]
|
|||
|
Image _imgSuit;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpName;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpLevel;
|
|||
|
|
|||
|
private EquipmentWidget _equipmentWidget;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public void SetEquipmentIndex(int index)
|
|||
|
{
|
|||
|
this.index = index;
|
|||
|
}
|
|||
|
|
|||
|
public void SetEquipmentSlot(PlayerProxy.EquipmentSlotInfo equipmentSlot)
|
|||
|
{
|
|||
|
if (equipmentSlot != null)
|
|||
|
{
|
|||
|
var equipment = equipmentSlot.equipment;
|
|||
|
|
|||
|
_equipmentWidget.SetData(equipment);
|
|||
|
|
|||
|
if (equipmentSlot.grade > 0)
|
|||
|
_tmpLevel.text = $"+{equipmentSlot.grade}";
|
|||
|
else
|
|||
|
_tmpLevel.text = "";
|
|||
|
|
|||
|
if (_tmpName)
|
|||
|
_tmpName.text = equipment.propName;
|
|||
|
|
|||
|
var suitInfo = PlayerProxy.Instance.GetCurrEquipmentSuit();
|
|||
|
if (suitInfo != null && suitInfo.GetGrade(equipmentSlot.id) > 0)
|
|||
|
{
|
|||
|
_imgSuit.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_imgSuit.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_tmpLevel.text = "";
|
|||
|
_imgSuit.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is PlayerProxy.EquipmentSlotInfo equipmentSlot)
|
|||
|
{
|
|||
|
SetEquipmentSlot(equipmentSlot);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnBgBtnClick()
|
|||
|
{
|
|||
|
PostNotification(GlobalDefine.EVENT_EQUIPMENT_SLOT_SELECT, this.data, null);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
|
|||
|
_equipmentWidget = __goEquipment.AddComponent<EquipmentWidget>();
|
|||
|
_equipmentWidget.SetDefaultIcon(this.index);
|
|||
|
|
|||
|
var button = GetComponent<Button>();
|
|||
|
if (button)
|
|||
|
{
|
|||
|
button.onClick.AddListener(this.OnBgBtnClick);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|