2022-01-12 10:06:03 +03:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2022-01-13 11:00:37 +03:00
|
|
|
|
using UnityEngine.Events;
|
2022-01-12 10:06:03 +03:00
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class Card : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private CardConfig cardConfig;
|
2022-01-13 11:00:37 +03:00
|
|
|
|
|
|
|
|
|
|
2022-01-12 10:06:03 +03:00
|
|
|
|
[Space(3)]
|
|
|
|
|
[HideInInspector] public int number;
|
2022-01-13 11:00:37 +03:00
|
|
|
|
|
2022-01-12 10:06:03 +03:00
|
|
|
|
[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;
|
2022-01-13 16:15:53 +03:00
|
|
|
|
if(_card.quantityStamina > 0 || _card.quantityHealth == 0)
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
2022-01-13 16:15:53 +03:00
|
|
|
|
else if (_card.healing > 0)
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
|
|
|
|
type.text = "Heal";
|
|
|
|
|
|
|
|
|
|
quantity.text = _card.healing.ToString();
|
2022-01-13 16:15:53 +03:00
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
type.text = "Stam";
|
|
|
|
|
|
|
|
|
|
quantity.text = _card.addStamina.ToString();
|
2022-01-12 10:06:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void OnClick()
|
|
|
|
|
{
|
2022-01-13 16:15:53 +03:00
|
|
|
|
var _card = cardConfig.CardCharacteristics;
|
2022-01-12 10:06:03 +03:00
|
|
|
|
//ВАРНИНГ! НЕ РАБОТАЕТ С КАРТАМИ НА -ЗДОРОВЬЕ!!
|
2022-01-13 16:15:53 +03:00
|
|
|
|
int _stamina = DeckManager.main.stamina;
|
|
|
|
|
if (_card.addStamina > 0)
|
|
|
|
|
{
|
|
|
|
|
DeckManager.main.NewStaminaQuantity(_stamina + _card.addStamina);
|
|
|
|
|
DestroyObject();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-01-12 10:06:03 +03:00
|
|
|
|
if(_stamina >= cardConfig.CardCharacteristics.quantityStamina)
|
|
|
|
|
{
|
2022-01-13 16:15:53 +03:00
|
|
|
|
DeckManager.main.currentCard = cardConfig;
|
|
|
|
|
DeckManager.main.numberCurrentCard = number;
|
2022-01-12 10:06:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DestroyObject()
|
|
|
|
|
{
|
|
|
|
|
Destroy(cardObject);
|
|
|
|
|
//Camera.main.GetComponent<DeckManager>().CardInTable.RemoveAt(number);
|
|
|
|
|
}
|
|
|
|
|
}
|