2022-06-05 01:57:57 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2022-06-21 03:57:04 +02:00
|
|
|
using GUI_Scripts;
|
2022-06-05 01:57:57 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class ChestController : BaseWarehouseController
|
|
|
|
{
|
|
|
|
[SerializeField] public GameObject chest;
|
|
|
|
[SerializeField] public List<Item> developerList = new List<Item>(); // FOR DEVELOPER TESTE - remove later !!!
|
|
|
|
|
|
|
|
bool isTrigerred = false;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
chest = gameObject; // set object on current GameObject
|
|
|
|
|
|
|
|
// FOR DEVELOPER TESTE - remove later !!!
|
|
|
|
for(int i = 0; i < developerList.Count; i++)
|
|
|
|
{
|
|
|
|
SetItemOnPosition(i, developerList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (this._panel && this.isTrigerred && !this.isOpen) // we can open chest only when its closed
|
|
|
|
{
|
|
|
|
if (Input.GetKeyDown(KeyCode.E))
|
|
|
|
{
|
|
|
|
this.OpenPanel();
|
|
|
|
InventoryManager.Instance.OpenPanel();
|
2022-06-05 16:51:08 +02:00
|
|
|
EquipmentManager.Instance.OpenPanel();
|
2022-06-05 01:57:57 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-14 22:06:01 +02:00
|
|
|
|
|
|
|
if (!InventoryManager.Instance.isOpen)
|
|
|
|
{
|
|
|
|
if (Input.GetKeyDown(KeyCode.I))
|
|
|
|
{
|
|
|
|
InventoryManager.Instance.OpenPanel();
|
2022-06-21 03:57:04 +02:00
|
|
|
EquipmentManager.Instance.OpenPanel();
|
2022-06-14 22:06:01 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-21 03:57:04 +02:00
|
|
|
|
2022-06-05 01:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnTriggerExit2D(Collider2D collision)
|
|
|
|
{
|
|
|
|
if (this._panel != null)
|
|
|
|
{
|
|
|
|
this.ClosePanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isTrigerred = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
{
|
|
|
|
if (collision.tag == "Player")
|
|
|
|
{
|
|
|
|
this.isTrigerred = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ClosePanel()
|
|
|
|
{
|
|
|
|
base.ClosePanel();
|
|
|
|
InventoryManager.Instance.ClosePanel();
|
2022-06-05 16:51:08 +02:00
|
|
|
EquipmentManager.Instance.ClosePanel();
|
2022-06-05 01:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void SetupPanel()
|
|
|
|
{
|
|
|
|
if(this.dynamicPanel)
|
|
|
|
{
|
|
|
|
this.dynamicPanel.GetComponent<ChestPanelController>().Setup(gameObject, _items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// WARNING
|
|
|
|
// DANGER - functon override position which may be not free
|
|
|
|
|
|
|
|
}
|