2022-01-17 17:49:27 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class AddEquipment : MonoBehaviour
|
2022-01-20 11:44:38 +03:00
|
|
|
{
|
2022-01-17 17:49:27 +03:00
|
|
|
public void AddOrRemove()
|
|
|
|
{
|
|
|
|
if (Inventory.main.EquipedOrNot(Inventory.main.lastCardNum))
|
|
|
|
{
|
2022-01-20 11:44:38 +03:00
|
|
|
GameObject[] _cards =
|
|
|
|
Inventory.main.allEquipment[Inventory.main.lastCardNum].GetComponent<Equipment>().equipmentConfig.equipmentCharacteristics.equipmentCards;
|
|
|
|
for (int j = 0; j < _cards.Length; j++)
|
|
|
|
{
|
|
|
|
DeckManager.main.DeletedCard(_cards[j]);
|
|
|
|
}
|
2022-01-17 17:49:27 +03:00
|
|
|
Inventory.main.playerEquipment.Remove(Inventory.main.allEquipment[Inventory.main.lastCardNum]);
|
|
|
|
for (int i = 0; i < Inventory.main.playerPlace.Count; i++)
|
|
|
|
{
|
|
|
|
if (Inventory.main.playerPlace[i].name == Inventory.main.allEquipment[Inventory.main.lastCardNum].GetComponent<Equipment>().equipmentConfig.equipmentCharacteristics.place.ToString())
|
|
|
|
{
|
|
|
|
Inventory.main.playerPlace[i].image.sprite = Inventory.main.imagePlug;
|
|
|
|
Inventory.main.playerPlace[i].GetComponent<PlaceEquipment>().equipmentNum = -1;
|
2022-01-20 11:44:38 +03:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Inventory.main.localplayerEquipment.Insert(Inventory.main.lastCardNum, Inventory.main.allEquipment[Inventory.main.lastCardNum]);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
Inventory.main.localplayerEquipment.Insert(Inventory.main.localplayerEquipment.Count, Inventory.main.allEquipment[Inventory.main.lastCardNum]);
|
|
|
|
}
|
2022-01-17 23:09:07 +03:00
|
|
|
Inventory.main.gameObject.GetComponent<SpawnButton>().InstantiateEquipmentButton(0, 9);
|
2022-01-17 17:49:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-28 19:47:38 +03:00
|
|
|
if (Inventory.main.LockPlace(Inventory.main.lastCardNum))
|
2022-01-20 11:44:38 +03:00
|
|
|
{
|
2022-01-28 19:47:38 +03:00
|
|
|
GameObject[] _cards =
|
|
|
|
Inventory.main.allEquipment[Inventory.main.lastCardNum].GetComponent<Equipment>().equipmentConfig.equipmentCharacteristics.equipmentCards;
|
|
|
|
for (int j = 0; j < _cards.Length; j++)
|
|
|
|
{
|
|
|
|
DeckManager.main.AddCard(_cards[j]);
|
|
|
|
}
|
|
|
|
Inventory.main.playerEquipment.Add(Inventory.main.allEquipment[Inventory.main.lastCardNum]);
|
|
|
|
Inventory.main.WhichPlace(Inventory.main.lastCardNum);
|
|
|
|
Inventory.main.localplayerEquipment.Remove(Inventory.main.allEquipment[Inventory.main.lastCardNum]);
|
|
|
|
Inventory.main.gameObject.GetComponent<SpawnButton>().InstantiateEquipmentButton(0, 9);
|
|
|
|
|
2022-01-20 11:44:38 +03:00
|
|
|
}
|
2022-01-17 17:49:27 +03:00
|
|
|
}
|
|
|
|
|
2022-01-18 22:10:57 +03:00
|
|
|
DataHolder.main.PlayerEquipment = Inventory.main.playerEquipment;
|
2022-01-19 20:27:33 +03:00
|
|
|
DataHolder.main.AllEquipment = Inventory.main.allEquipment;
|
2022-01-17 17:49:27 +03:00
|
|
|
|
|
|
|
EquipmentInfo.main.CardAbout(Inventory.main.lastCardNum);
|
|
|
|
}
|
|
|
|
|
2022-01-20 11:44:38 +03:00
|
|
|
|
2022-01-17 17:49:27 +03:00
|
|
|
}
|