62 lines
2.8 KiB
C#
62 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class AddEquipment : MonoBehaviour
|
|
{
|
|
public void AddOrRemove()
|
|
{
|
|
if (Inventory.main.EquipedOrNot(Inventory.main.lastCardNum))
|
|
{
|
|
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]);
|
|
}
|
|
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;
|
|
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]);
|
|
}
|
|
Inventory.main.gameObject.GetComponent<SpawnButton>().InstantiateEquipmentButton(0, 9);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Inventory.main.LockPlace(Inventory.main.lastCardNum))
|
|
{
|
|
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);
|
|
|
|
}
|
|
}
|
|
|
|
DataHolder.main.PlayerEquipment = Inventory.main.playerEquipment;
|
|
DataHolder.main.AllEquipment = Inventory.main.allEquipment;
|
|
|
|
EquipmentInfo.main.CardAbout(Inventory.main.lastCardNum);
|
|
}
|
|
|
|
|
|
}
|