133 lines
3.8 KiB
C#
133 lines
3.8 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using System;
|
||
using UnityEngine.Events;
|
||
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;
|
||
|
||
string[,] allVariables = new string[,] {{ _card.healing.ToString(), "Heal" }, { _card.quantityStamina.ToString(), "Stam" },
|
||
{ _card.damage.ToString(), "Atk" }, { _card.addStamina.ToString(), "AddStam" } };
|
||
|
||
|
||
int _max = 0;
|
||
int _num = 0;
|
||
for (int i = 0; i < allVariables.Length / 2; i++)
|
||
{
|
||
if (_max < Convert.ToInt32(allVariables[i, 0]))
|
||
{
|
||
_max = Convert.ToInt32(allVariables[i, 0]);
|
||
_num = i;
|
||
}
|
||
}
|
||
costTitle.text = allVariables[_num, 1];
|
||
cost.text = allVariables[_num, 0];
|
||
allVariables[_num, 0] = "-1";
|
||
|
||
_max = -1;
|
||
print(_max);
|
||
for (int i = 0; i < allVariables.Length / 2; i++)
|
||
{
|
||
if (_max < Convert.ToInt32(allVariables[i, 0]))
|
||
{
|
||
_max = Convert.ToInt32(allVariables[i, 0]);
|
||
_num = i;
|
||
}
|
||
}
|
||
if (_max != 0)
|
||
{
|
||
type.text = allVariables[_num, 1];
|
||
quantity.text = allVariables[_num, 0];
|
||
}
|
||
else
|
||
{
|
||
type.text = "";
|
||
quantity.text = "";
|
||
}
|
||
|
||
|
||
|
||
//if (_card.quantityStamina > 0 || _card.quantityHealth == 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 if (_card.healing > 0)
|
||
//{
|
||
// type.text = "Heal";
|
||
|
||
// quantity.text = _card.healing.ToString();
|
||
//}
|
||
//else
|
||
//{
|
||
// type.text = "Stam";
|
||
|
||
// quantity.text = _card.addStamina.ToString();
|
||
//}
|
||
}
|
||
public void OnClick()
|
||
{
|
||
var _card = cardConfig.CardCharacteristics;
|
||
//ВАРНИНГ! НЕ РАБОТАЕТ С КАРТАМИ НА -ЗДОРОВЬЕ!!
|
||
int _stamina = DeckManager.main.stamina;
|
||
if (_card.addStamina > 0)
|
||
{
|
||
DeckManager.main.NewStaminaQuantity(_stamina + _card.addStamina);
|
||
DeckManager.main.currentCard = null;
|
||
DeckManager.main.MarkersRegulator();
|
||
DestroyObject();
|
||
return;
|
||
}
|
||
if(_stamina >= cardConfig.CardCharacteristics.quantityStamina)
|
||
{
|
||
DeckManager.main.currentCard = cardConfig;
|
||
DeckManager.main.numberCurrentCard = number;
|
||
DeckManager.main.MarkersRegulator();
|
||
}
|
||
}
|
||
|
||
public void DestroyObject()
|
||
{
|
||
Destroy(cardObject);
|
||
//Camera.main.GetComponent<DeckManager>().CardInTable.RemoveAt(number);
|
||
}
|
||
}
|