2022-01-16 23:20:47 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
2022-01-17 17:49:27 +03:00
|
|
|
public class Inventory : MonoBehaviour
|
2022-01-16 23:20:47 +03:00
|
|
|
{
|
2022-01-17 17:49:27 +03:00
|
|
|
public static Inventory main;
|
2022-01-16 23:20:47 +03:00
|
|
|
public List<GameObject> allEquipment = new List<GameObject>();
|
|
|
|
public List<GameObject> playerEquipment = new List<GameObject>();
|
2022-01-17 23:09:07 +03:00
|
|
|
[SerializeField] public List<GameObject> localplayerEquipment = new List<GameObject>();
|
2022-01-16 23:20:47 +03:00
|
|
|
|
|
|
|
public Sprite imagePlug;
|
|
|
|
|
|
|
|
//0 - Hat, 1 - Gloves, 2 - Armor, 3 - Weapon, 4 - Pet, 5 - Shoes
|
|
|
|
public List<Button> playerPlace = new List<Button>();
|
|
|
|
|
|
|
|
public int lastCardNum;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
2022-01-20 11:44:38 +03:00
|
|
|
if (main != null && main != this)
|
2022-01-19 20:27:33 +03:00
|
|
|
{
|
2022-01-20 11:44:38 +03:00
|
|
|
Debug.LogWarning("2 inventory on the scene");
|
|
|
|
Destroy(this);
|
|
|
|
return;
|
2022-01-19 20:27:33 +03:00
|
|
|
}
|
2022-01-20 11:44:38 +03:00
|
|
|
main = this;
|
|
|
|
CheckData();
|
2022-01-17 23:09:07 +03:00
|
|
|
localplayerEquipment.AddRange(allEquipment);
|
2022-01-16 23:20:47 +03:00
|
|
|
}
|
2022-01-20 11:44:38 +03:00
|
|
|
public void CheckData()
|
|
|
|
{
|
|
|
|
playerEquipment = DataHolder.main.PlayerEquipment;
|
|
|
|
allEquipment = DataHolder.main.AllEquipment;
|
|
|
|
}
|
2022-01-16 23:20:47 +03:00
|
|
|
public bool EquipedOrNot(int _num)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < playerEquipment.Count; i++)
|
|
|
|
{
|
|
|
|
if (playerEquipment[i].name == allEquipment[_num].name)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void WhichPlace(int _num)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < playerPlace.Count; i++)
|
|
|
|
{
|
2022-01-17 17:49:27 +03:00
|
|
|
var _config =
|
|
|
|
allEquipment[_num].GetComponent<Equipment>().equipmentConfig.
|
|
|
|
equipmentCharacteristics;
|
|
|
|
if (_config == null) Debug.LogError("config not found!");
|
2022-01-17 23:09:07 +03:00
|
|
|
if (playerPlace[i].name == _config.place.ToString())
|
2022-01-16 23:20:47 +03:00
|
|
|
{
|
2022-01-17 17:49:27 +03:00
|
|
|
playerPlace[i].image.sprite = _config.sprite;
|
2022-01-16 23:20:47 +03:00
|
|
|
playerPlace[i].GetComponent<PlaceEquipment>().equipmentNum = lastCardNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-28 19:47:38 +03:00
|
|
|
|
|
|
|
public bool LockPlace(int _num)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < playerPlace.Count; i++)
|
|
|
|
{
|
|
|
|
var _config =
|
|
|
|
allEquipment[_num].GetComponent<Equipment>().equipmentConfig.
|
|
|
|
equipmentCharacteristics;
|
|
|
|
if (_config == null) Debug.LogError("config not found!");
|
|
|
|
if (playerPlace[i].name == _config.place.ToString())
|
|
|
|
{
|
|
|
|
if (playerPlace[i].GetComponent<PlaceEquipment>().equipmentNum == -1)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-16 23:20:47 +03:00
|
|
|
}
|