Files
back_cantanBuilding/Assets/Scripts/Duel/UI/DuelRodItem.cs
2026-05-26 16:15:54 +08:00

42 lines
919 B
C#

using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class DuelRodItem : MonoBehaviour
{
public RodItem rodItem;
public GameObject selected;
public Button btn_item;
public TMP_Text power_text;
public Action<DuelRodItem> onClick;
public RodItemData data => rodItem?.data;
private void Start()
{
if (btn_item != null)
{
btn_item.onClick.AddListener(OnBtnItem);
}
}
public void Init(RodItemData _data)
{
rodItem.Init(_data);
if (power_text != null)
{
power_text.transform.parent.gameObject.SetActive(_data.RodPower > 0);
power_text.text = _data.RodPower.ToString();
}
}
void OnBtnItem()
{
onClick?.Invoke(this);
}
public void SetSelected(bool value)
{
selected.SetActive(value);
}
}