备份CatanBuilding瘦身独立工程
This commit is contained in:
42
Assets/Scripts/Duel/UI/DuelRodItem.cs
Normal file
42
Assets/Scripts/Duel/UI/DuelRodItem.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user