129 lines
2.7 KiB
C#
129 lines
2.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-11-17
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "EquipmentSlotItem" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace G.UI
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class EquipmentSlotItem : KUIWidget
|
|
{
|
|
#region Field
|
|
|
|
[KUIFlag]
|
|
GameObject __goEquipment;
|
|
[KUIFlag]
|
|
KUIImage _imgSuit;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpLevel;
|
|
[KUIFlag]
|
|
GameObject _goPoint;
|
|
[KUIFlag]
|
|
GameObject _goEqFx;
|
|
|
|
private EquipmentWidget _equipmentWidget;
|
|
private PlayerProxy.EquipmentSlotInfo _equipmentSlot;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
public void SetEquipmentIndex(int index)
|
|
{
|
|
_equipmentWidget.SetDefaultIcon(index);
|
|
}
|
|
|
|
public void SetEquipmentSlot(PlayerProxy.EquipmentSlotInfo equipmentSlot)
|
|
{
|
|
_equipmentSlot = equipmentSlot;
|
|
if (equipmentSlot != null)
|
|
{
|
|
if (equipmentSlot.equipment != _equipmentWidget.data)
|
|
PlayFx();
|
|
_equipmentWidget.SetData(equipmentSlot.equipment);
|
|
|
|
if (equipmentSlot.grade > 0)
|
|
_tmpLevel.text = $"+{equipmentSlot.grade}";
|
|
else
|
|
_tmpLevel.text = "";
|
|
|
|
var suitInfo = PlayerProxy.Instance.GetCurrEquipmentSuit();
|
|
int suitGrade = suitInfo != null ? suitInfo.GetGrade(equipmentSlot.id) : 0;
|
|
if (suitGrade > 0)
|
|
{
|
|
_imgSuit.gameObject.SetActive(true);
|
|
_imgSuit.ShowSprite(suitGrade - 1);
|
|
}
|
|
else
|
|
{
|
|
_imgSuit.gameObject.SetActive(false);
|
|
}
|
|
|
|
RefreshRedPoint();
|
|
}
|
|
else
|
|
{
|
|
_tmpLevel.text = "";
|
|
_imgSuit.gameObject.SetActive(false);
|
|
_goPoint.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void PlayFx()
|
|
{
|
|
_goEqFx.SetActive(true);
|
|
StopAllCoroutines();
|
|
StartCoroutine(PlayFxCO());
|
|
}
|
|
|
|
System.Collections.IEnumerator PlayFxCO()
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
_goEqFx.SetActive(false);
|
|
}
|
|
|
|
public void RefreshRedPoint()
|
|
{
|
|
if (_equipmentSlot != null)
|
|
{
|
|
var canUpgrade = PlayerProxy.Instance.GetUpgradeEquipmentSlotCost(_equipmentSlot.id, false, out var costId, out var cost);
|
|
_goPoint.SetActive(canUpgrade);
|
|
}
|
|
}
|
|
|
|
public override void Refresh()
|
|
{
|
|
if (this.data is PlayerProxy.EquipmentSlotInfo equipmentSlot)
|
|
{
|
|
SetEquipmentSlot(equipmentSlot);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
SetViewData();
|
|
_equipmentWidget = __goEquipment.AddComponent<EquipmentWidget>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_goEqFx.SetActive(false);
|
|
}
|
|
}
|
|
}
|