PO/Assets/Scripts/Card.cs

69 lines
2.0 KiB
C#
Raw Normal View History

2022-01-12 10:06:03 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Card : MonoBehaviour
{
[SerializeField] private CardConfig cardConfig;
[Space(3)]
[HideInInspector] public int number;
[Header("DON'T TOUCH THIS! IT STANDART PRESET!")]
[SerializeField] private GameObject cardObject;
[SerializeField] private Image picture;
[SerializeField] private Text nameCard;
[SerializeField] private Text costTitle;
[SerializeField] private Text cost;
[SerializeField] private Text type;
[SerializeField] private Text quantity;
//этот колхоз надо переделать 100 процентов
private void Start()
{
picture.sprite = cardConfig.CardCharacteristics.picture;
var _card = cardConfig.CardCharacteristics;
picture.sprite = _card.picture;
nameCard.text = _card.cardName;
if(_card.quantityStamina > 0)
{
costTitle.text = "Stam";
cost.text = _card.quantityStamina.ToString();
} else
{
costTitle.text = "Heal";
cost.text = _card.quantityHealth.ToString();
}
if(_card.damage > 0)
{
type.text = "Atk";
quantity.text = _card.damage.ToString();
}
else
{
type.text = "Heal";
quantity.text = _card.healing.ToString();
}
}
public void OnClick()
{
//ВАРНИНГ! НЕ РАБОТАЕТ С КАРТАМИ НА -ЗДОРОВЬЕ!!
int _stamina = Camera.main.GetComponent<DeckManager>().stamina;
if(_stamina >= cardConfig.CardCharacteristics.quantityStamina)
{
Camera.main.GetComponent<DeckManager>().currentCard = cardConfig;
Camera.main.GetComponent<DeckManager>().numberCurrentCard = number;
}
}
public void DestroyObject()
{
Destroy(cardObject);
//Camera.main.GetComponent<DeckManager>().CardInTable.RemoveAt(number);
}
}