42 lines
919 B
C#
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);
|
|
}
|
|
} |