2022-01-12 10:06:03 +03:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2022-01-13 23:33:21 +03:00
|
|
|
|
using System;
|
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
|
|
|
|
|
{
|
2022-02-02 22:22:36 +03:00
|
|
|
|
[SerializeField] public CardConfig cardConfig;
|
2022-01-15 21:47:03 +03:00
|
|
|
|
private CardCharacteristics _card;
|
2022-01-13 11:00:37 +03:00
|
|
|
|
|
2022-01-15 23:26:40 +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 процентов
|
2022-02-05 12:23:41 +03:00
|
|
|
|
[HideInInspector] int localquantityStamina = 0;
|
|
|
|
|
[HideInInspector] int localquantityHealth = 0;
|
|
|
|
|
[HideInInspector] int localdamage = 0;
|
|
|
|
|
[HideInInspector] int localaddHealth = 0;
|
|
|
|
|
[HideInInspector] int localaddStamina = 0;
|
|
|
|
|
[HideInInspector] int localaddArmor = 0;
|
2022-01-12 10:06:03 +03:00
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
2022-02-05 12:23:41 +03:00
|
|
|
|
SaveStartCharacterisics(cardObject);
|
|
|
|
|
CheckLevel(cardObject);
|
2022-01-12 10:06:03 +03:00
|
|
|
|
picture.sprite = cardConfig.CardCharacteristics.picture;
|
2022-01-15 21:47:03 +03:00
|
|
|
|
_card = cardConfig.CardCharacteristics;
|
2022-01-12 10:06:03 +03:00
|
|
|
|
picture.sprite = _card.picture;
|
|
|
|
|
nameCard.text = _card.cardName;
|
2022-01-15 23:26:40 +03:00
|
|
|
|
SetText();
|
2022-01-15 21:47:03 +03:00
|
|
|
|
}
|
2022-01-13 23:33:21 +03:00
|
|
|
|
|
2022-01-15 23:26:40 +03:00
|
|
|
|
public void SetText()
|
2022-01-15 21:47:03 +03:00
|
|
|
|
{
|
2022-01-15 23:26:40 +03:00
|
|
|
|
string[,] allVariables = new string[,] {{ _card.addHealth.ToString(), "Heal" },
|
|
|
|
|
{ _card.quantityStamina.ToString(), "Stam" },
|
|
|
|
|
{ _card.damage.ToString(), "Atk" },
|
|
|
|
|
{ _card.addStamina.ToString(), "AddStam" },
|
|
|
|
|
{ _card.addArmor.ToString(), "Armor"} };
|
2022-01-13 23:33:21 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int _max = 0;
|
|
|
|
|
int _num = 0;
|
|
|
|
|
for (int i = 0; i < allVariables.Length / 2; i++)
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
2022-01-13 23:33:21 +03:00
|
|
|
|
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;
|
|
|
|
|
for (int i = 0; i < allVariables.Length / 2; i++)
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
2022-01-13 23:33:21 +03:00
|
|
|
|
if (_max < Convert.ToInt32(allVariables[i, 0]))
|
|
|
|
|
{
|
|
|
|
|
_max = Convert.ToInt32(allVariables[i, 0]);
|
|
|
|
|
_num = i;
|
|
|
|
|
}
|
2022-01-12 10:06:03 +03:00
|
|
|
|
}
|
2022-01-13 23:33:21 +03:00
|
|
|
|
if (_max != 0)
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
2022-01-13 23:33:21 +03:00
|
|
|
|
type.text = allVariables[_num, 1];
|
|
|
|
|
quantity.text = allVariables[_num, 0];
|
2022-01-12 10:06:03 +03:00
|
|
|
|
}
|
2022-01-13 23:33:21 +03:00
|
|
|
|
else
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
2022-01-13 23:33:21 +03:00
|
|
|
|
type.text = "";
|
|
|
|
|
quantity.text = "";
|
|
|
|
|
}
|
2022-01-12 10:06:03 +03:00
|
|
|
|
}
|
2022-01-15 21:47:03 +03:00
|
|
|
|
|
2022-01-12 10:06:03 +03:00
|
|
|
|
public void OnClick()
|
|
|
|
|
{
|
2022-01-15 23:26:40 +03:00
|
|
|
|
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
//Этот метод - колхоз на колхазе сидит и колхозом погоняет
|
|
|
|
|
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2022-01-15 10:29:16 +03:00
|
|
|
|
if (Session.main.waitingEndingRound || DeckManager.main.waitingEnemyTurn) return;
|
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;
|
2022-01-20 11:44:38 +03:00
|
|
|
|
if (_stamina < cardConfig.CardCharacteristics.quantityStamina) return;
|
2022-01-15 23:26:40 +03:00
|
|
|
|
if (_card.specialization == Specialization.healing)
|
2022-01-13 16:15:53 +03:00
|
|
|
|
{
|
2022-01-15 23:26:40 +03:00
|
|
|
|
if (_card.addStamina > 0)
|
|
|
|
|
{
|
|
|
|
|
DeckManager.main.NewStaminaQuantity(_stamina + _card.addStamina);
|
|
|
|
|
}
|
2022-01-17 17:49:27 +03:00
|
|
|
|
else if (_card.addArmor > 0)
|
|
|
|
|
{
|
2022-01-15 23:26:40 +03:00
|
|
|
|
DeckManager.main.NewStaminaQuantity(_stamina - _card.quantityStamina);
|
|
|
|
|
Player.main.AddArmor(_card.addArmor);
|
2022-01-17 17:49:27 +03:00
|
|
|
|
}
|
|
|
|
|
else if (_card.addHealth > 0)
|
|
|
|
|
{
|
2022-01-15 23:26:40 +03:00
|
|
|
|
DeckManager.main.NewStaminaQuantity(_stamina - _card.quantityStamina);
|
|
|
|
|
Player.main.ChangeHp(-_card.addHealth);
|
2022-01-17 17:49:27 +03:00
|
|
|
|
}
|
2022-01-14 10:42:43 +03:00
|
|
|
|
DeckManager.main.currentCard = null;
|
|
|
|
|
DeckManager.main.MarkersRegulator();
|
2022-01-13 16:15:53 +03:00
|
|
|
|
DestroyObject();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-01-20 11:44:38 +03:00
|
|
|
|
else
|
2022-01-12 10:06:03 +03:00
|
|
|
|
{
|
2022-01-13 16:15:53 +03:00
|
|
|
|
DeckManager.main.currentCard = cardConfig;
|
|
|
|
|
DeckManager.main.numberCurrentCard = number;
|
2022-01-14 10:42:43 +03:00
|
|
|
|
DeckManager.main.MarkersRegulator();
|
2022-01-12 10:06:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 12:23:41 +03:00
|
|
|
|
public void SaveStartCharacterisics(GameObject _card)
|
|
|
|
|
{
|
|
|
|
|
var _cardCharacteristics = _card.GetComponent<Card>().cardConfig.CardCharacteristics;
|
|
|
|
|
|
|
|
|
|
localquantityStamina = _cardCharacteristics.quantityStamina;
|
|
|
|
|
localquantityHealth = _cardCharacteristics.quantityHealth;
|
|
|
|
|
localdamage = _cardCharacteristics.damage;
|
|
|
|
|
localaddHealth = _cardCharacteristics.addHealth;
|
|
|
|
|
localaddStamina = _cardCharacteristics.addStamina;
|
|
|
|
|
localaddArmor = _cardCharacteristics.addArmor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CheckLevel(GameObject _card)
|
|
|
|
|
{
|
|
|
|
|
// Мне за это стыдно, но в голову иных варинтов не приходит
|
|
|
|
|
var _cardCharacteristics = _card.GetComponent<Card>().cardConfig.CardCharacteristics;
|
|
|
|
|
if (_cardCharacteristics.improvedLevel is true)
|
|
|
|
|
{
|
|
|
|
|
_cardCharacteristics.quantityStamina = _cardCharacteristics.quantityStamina2;
|
|
|
|
|
_cardCharacteristics.quantityHealth = _cardCharacteristics.quantityHealth2;
|
|
|
|
|
_cardCharacteristics.damage = _cardCharacteristics.damage2;
|
|
|
|
|
_cardCharacteristics.addHealth = _cardCharacteristics.addHealth2;
|
|
|
|
|
_cardCharacteristics.addStamina = _cardCharacteristics.addStamina2;
|
|
|
|
|
_cardCharacteristics.addArmor = _cardCharacteristics.addArmor2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetCardCharacteristic(GameObject _card)
|
|
|
|
|
{
|
|
|
|
|
var _cardCharacteristics = _card.GetComponent<Card>().cardConfig.CardCharacteristics;
|
|
|
|
|
|
|
|
|
|
_cardCharacteristics.quantityStamina = localquantityStamina;
|
|
|
|
|
_cardCharacteristics.quantityHealth = localquantityHealth;
|
|
|
|
|
_cardCharacteristics.damage = localdamage;
|
|
|
|
|
_cardCharacteristics.addHealth = localaddHealth;
|
|
|
|
|
_cardCharacteristics.addStamina = localaddStamina;
|
|
|
|
|
_cardCharacteristics.addArmor = localaddArmor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-12 10:06:03 +03:00
|
|
|
|
public void DestroyObject()
|
|
|
|
|
{
|
2022-02-05 12:23:41 +03:00
|
|
|
|
ResetCardCharacteristic(cardObject);
|
2022-01-12 10:06:03 +03:00
|
|
|
|
Destroy(cardObject);
|
|
|
|
|
//Camera.main.GetComponent<DeckManager>().CardInTable.RemoveAt(number);
|
|
|
|
|
}
|
|
|
|
|
}
|