PO/Assets/Inventory/AddEquipment.cs

39 lines
1.7 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))
{
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;
Inventory.main.localplayerEquipment.Add(Inventory.main.allEquipment[Inventory.main.lastCardNum]);
Inventory.main.gameObject.GetComponent<SpawnButton>().InstantiateEquipmentButton(0, 9);
}
}
}
else
{
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);
}
}