using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using UnityEngine.Events; using UnityEngine.UI; public class Card : MonoBehaviour { [SerializeField] public CardConfig cardConfig; private CardCharacteristics _card; [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; private void Start() { //SaveStartCharacterisics(cardObject); CheckLevel(cardObject); picture.sprite = cardConfig.CardCharacteristics.picture; _card = cardConfig.CardCharacteristics; picture.sprite = _card.picture; nameCard.text = _card.cardName; SetText(); } public void SetText() { string[,] allVariables = new string[,] {{ _card.addHealth.ToString(), "Heal" }, { _card.quantityStamina.ToString(), "Stam" }, { _card.damage.ToString(), "Atk" }, { _card.addStamina.ToString(), "AddStam" }, { _card.addArmor.ToString(), "Armor"} }; 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; 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 = ""; } } public void OnClick() { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //Этот метод - колхоз на колхазе сидит и колхозом погоняет //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (Session.main.waitingEndingRound || DeckManager.main.waitingEnemyTurn) return; var _card = cardConfig.CardCharacteristics; //ВАРНИНГ! НЕ РАБОТАЕТ С КАРТАМИ НА -ЗДОРОВЬЕ!! int _stamina = DeckManager.main.stamina; if (_stamina < cardConfig.CardCharacteristics.quantityStamina) return; else if (_card.specialization == Specialization.healing) { if (_card.addStamina > 0) { DeckManager.main.NewStaminaQuantity(_stamina + _card.addStamina); } else if (_card.addArmor > 0) { DeckManager.main.NewStaminaQuantity(_stamina - _card.quantityStamina); Player.main.AddArmor(_card.addArmor); } else if (_card.addHealth > 0) { DeckManager.main.NewStaminaQuantity(_stamina - _card.quantityStamina); Player.main.ChangeHp(-_card.addHealth); } DeckManager.main.currentCard = null; DeckManager.main.MarkersRegulator(); DestroyObject(); return; } else { DeckManager.main.currentCard = cardConfig; DeckManager.main.numberCurrentCard = number; DeckManager.main.MarkersRegulator(); } } public void CheckLevel(GameObject _card) { if(_card.GetComponent().cardConfig.improvedLevel) { _card.GetComponent().cardConfig.CardCharacteristics = _card.GetComponent().cardConfig.CardCharacteristicslvl2; } else { _card.GetComponent().cardConfig.CardCharacteristics = _card.GetComponent().cardConfig.CardCharacteristicslvl1; } } public void DestroyObject() { Destroy(cardObject); } }