33 lines
1 KiB
C#
33 lines
1 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class UpgradeBoxUI : MonoBehaviour, IDropHandler
|
|
{
|
|
[SerializeField] private TextMeshProUGUI counterUI;
|
|
public Image upgradeImage;
|
|
public AbilityUpgrade thisAbilityUpgrade;
|
|
public PlayerAbility thisPlayerAbility;
|
|
public void UpdateCounter()
|
|
{
|
|
if (!thisAbilityUpgrade)
|
|
{
|
|
counterUI.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
counterUI.gameObject.SetActive(true);
|
|
counterUI.text = $"x{thisAbilityUpgrade.count}";
|
|
}
|
|
|
|
public void OnDrop(PointerEventData eventData)
|
|
{
|
|
Debug.Log("A");
|
|
if (eventData.pointerDrag.TryGetComponent(out StoredAbilityUpgradeUI isStoredUpgrade) && (!thisAbilityUpgrade || isStoredUpgrade.storedUpgrade == thisAbilityUpgrade))
|
|
{
|
|
thisAbilityUpgrade = isStoredUpgrade.storedUpgrade;
|
|
AbilityManager.instance.AddUpgrade(thisAbilityUpgrade, thisPlayerAbility);
|
|
UpdateCounter();
|
|
}
|
|
}
|
|
}
|