2024-11-13 16:56:37 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class ItemButton : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private int id;
|
|
|
|
[SerializeField] private Image _image;
|
|
|
|
[SerializeField] private TextMeshProUGUI numPro;
|
2024-11-21 10:26:47 +08:00
|
|
|
[SerializeField] private GameObject obj;
|
|
|
|
[SerializeField] private TextMeshProUGUI buyNum;
|
|
|
|
private int buy = 0;
|
2024-11-13 16:56:37 +08:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendID()
|
|
|
|
{
|
2024-11-21 10:26:47 +08:00
|
|
|
if (DataManager.item(id).num-GameSystem.ins.drawingManager.slotNum(id)>0)
|
|
|
|
{
|
|
|
|
GameSystem.ins.SaveSeledID(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (obj.activeSelf)
|
|
|
|
{
|
|
|
|
if (GameSystem.ins.goldCoin>buy)
|
|
|
|
{
|
|
|
|
Item item = new Item();
|
|
|
|
item.id = id;
|
|
|
|
DataManager.AddItem(item,1);
|
|
|
|
GameSystem.ins.goldCoin -= buy;
|
|
|
|
GameSystem.ins.ResetItem();
|
|
|
|
GameSystem.ins.forgePanel.ResetGold();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GameSystem.ins.forgePanel._buyEventButton.gameObject.SetActive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-11-13 16:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetItemData(int dataID)
|
|
|
|
{
|
|
|
|
id = dataID;
|
|
|
|
_image.sprite = GameSystem.ins.DataAsset.IconSprite(id);
|
|
|
|
numPro.text = (DataManager.item(id).num-GameSystem.ins.drawingManager.slotNum(id)).ToString();
|
2024-11-21 10:26:47 +08:00
|
|
|
|
|
|
|
if (DataManager.item(id).num-GameSystem.ins.drawingManager.slotNum(id)==0)
|
|
|
|
{
|
|
|
|
var num = GameSystem.ins.DataAsset.ItemValue(dataID);
|
|
|
|
if (num>0)
|
|
|
|
{
|
|
|
|
obj.SetActive(true);
|
|
|
|
numPro.gameObject.SetActive(false);
|
|
|
|
buyNum.text = num.ToString();
|
|
|
|
buy = num;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj.SetActive(false);
|
|
|
|
numPro.gameObject.SetActive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj.SetActive(false);
|
|
|
|
numPro.gameObject.SetActive(true);
|
|
|
|
}
|
2024-11-13 16:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnMouseDown()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|