55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
using System;
|
|
using Continentis.MainGame.Equipment;
|
|
using Lean.Pool;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public class EquipmentIcon : UIElementBase, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
public EquipmentBase equipment;
|
|
public Image background;
|
|
public Image icon;
|
|
private InformationBox infoBox;
|
|
|
|
public void Initialize(EquipmentBase equipment = null)
|
|
{
|
|
this.equipment = equipment;
|
|
|
|
if (equipment != null)
|
|
{
|
|
icon.gameObject.SetActive(true);
|
|
icon.sprite = equipment.contentSubmodule.equipmentIcon;
|
|
background.color = MainGameManager.Instance.basePrefabs.GetRarityColor(equipment.contentSubmodule.equipmentRarity);
|
|
}
|
|
else
|
|
{
|
|
icon.gameObject.SetActive(false);
|
|
background.color = Color.gray;
|
|
}
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if (equipment == null) return;
|
|
|
|
GameObject infoBoxPrefab = MainGameManager.Instance.basePrefabs.informationBox;
|
|
RectTransform canvasTransform = CombatUIManager.Instance.informationPage.rectTransform;
|
|
infoBox = LeanPool.Spawn(infoBoxPrefab, canvasTransform).GetComponent<InformationBox>();
|
|
string equipmentName = equipment.contentSubmodule.equipmentName;
|
|
string finalDescription = equipment.contentSubmodule.equipmentDescription;
|
|
infoBox.Initialize(equipmentName, finalDescription, canvasTransform.InverseTransformPoint(rectTransform.position));
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
if (infoBox != null)
|
|
{
|
|
LeanPool.Despawn(infoBox.gameObject);
|
|
infoBox = null;
|
|
}
|
|
}
|
|
}
|
|
} |