62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using cfg.BlacksmithData;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class DrawingItem : MonoBehaviour
|
|
{
|
|
private Button _button;
|
|
private DrawingPanel _panel;
|
|
[SerializeField] private Image icon;
|
|
[SerializeField] private Text _proUGUI;
|
|
[SerializeField] private Text _num;
|
|
|
|
[SerializeField] private Slider _slider;
|
|
|
|
private WeaponAttributeData wData;
|
|
private void Awake()
|
|
{
|
|
_button = GetComponent<Button>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_button.onClick.AddListener(ButtonEvent);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_button.onClick.RemoveListener(ButtonEvent);
|
|
}
|
|
|
|
void ButtonEvent()
|
|
{
|
|
_panel.OpenDrawing();
|
|
_panel.OpenDrawDataPanel(wData.Arms);
|
|
_panel.Reset();
|
|
}
|
|
|
|
public void InitData(int id,DrawingPanel panel)
|
|
{
|
|
_panel = panel;
|
|
var le=DataManager.GetDrawLevel(id);
|
|
var data = JsonTab.Instance.tables.Weapon.Get(id);
|
|
wData = JsonTab.Instance.attributeData(data.ID, le);
|
|
_proUGUI.text = data.Name;
|
|
icon.sprite = AssetBundleManager.ins.Sprite(data.Icon, AtlasType.DrawingIcon);
|
|
_slider.value = (float)DataManager.GetItem(wData.Upgrade)/wData.Upgradenumber;
|
|
_num.text = DataManager.GetItem(wData.Upgrade) + " / " + wData.Upgradenumber;
|
|
if (DataManager.GetItem(wData.Upgrade)>=wData.Upgradenumber)
|
|
{
|
|
_num.color=Color.green;
|
|
}
|
|
else
|
|
{
|
|
_num.color=Color.red;
|
|
}
|
|
}
|
|
}
|