273 lines
8.6 KiB
C#
273 lines
8.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DrawingsInventoryManager : MonoBehaviour
|
|
{
|
|
public GameObject Inventory;
|
|
|
|
[Header("Selected Item UI")]
|
|
public Transform SelectedItemUI;
|
|
|
|
[Header("Cell Icons")]
|
|
public Transform Cell_Icon;
|
|
public Transform Cell1_Icon;
|
|
public Transform Cell2_Icon;
|
|
public Transform Cell3_Icon;
|
|
|
|
[Header("Drawings Icons")]
|
|
public GameObject LetterIcon;
|
|
public GameObject DrawingBathroom;
|
|
public GameObject DrawingByeMom;
|
|
public GameObject DrawingReveal;
|
|
|
|
[HideInInspector] public bool _inventoryOpen;
|
|
|
|
public bool Element0Selected;
|
|
public bool Element1Selected;
|
|
public bool Element2Selected;
|
|
public bool Element3Selected;
|
|
|
|
public bool Element0Taken;
|
|
public bool Element1Taken;
|
|
public bool Element3Taken;
|
|
public bool Element4Taken;
|
|
|
|
public int[] Cell_ItemID;
|
|
public int index;
|
|
public List<int> ItemsIDStorage;
|
|
public List<GameObject> IconsStorage;
|
|
|
|
private static DrawingsInventoryManager _instance;
|
|
public static DrawingsInventoryManager GetInstance() { return _instance;}
|
|
|
|
private void Awake()
|
|
{
|
|
if (!_instance)
|
|
{
|
|
_instance = this;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.I)) //If key pressed:
|
|
{
|
|
if (!_inventoryOpen) //If inventory is not open:
|
|
{
|
|
DisplayDrawingsInventory();
|
|
}
|
|
else //If inventory is open:
|
|
{
|
|
HideDrawingsInventory();
|
|
}
|
|
}
|
|
|
|
if (_inventoryOpen) //If inventory is open:
|
|
{
|
|
DrawingInput(); //Input to select item from inventory:
|
|
}
|
|
|
|
UpdateItems();
|
|
}
|
|
|
|
public void DrawingInput()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Alpha1))
|
|
{
|
|
Element0Selected = true;
|
|
Element1Selected = false;
|
|
Element2Selected = false;
|
|
Element3Selected = false;
|
|
SelectedItemUI.position = Cell_Icon.position;
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha2))
|
|
{
|
|
Element0Selected = false;
|
|
Element1Selected = true;
|
|
Element2Selected = false;
|
|
Element3Selected = false;
|
|
SelectedItemUI.position = Cell1_Icon.position;
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha3))
|
|
{
|
|
Element0Selected = false;
|
|
Element1Selected = false;
|
|
Element2Selected = true;
|
|
Element3Selected = false;
|
|
SelectedItemUI.position = Cell2_Icon.position;
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Alpha4))
|
|
{
|
|
Element0Selected = false;
|
|
Element1Selected = false;
|
|
Element2Selected = false;
|
|
Element3Selected = true;
|
|
SelectedItemUI.position = Cell3_Icon.position;
|
|
}
|
|
}
|
|
|
|
public void DisplayDrawingsInventory()
|
|
{
|
|
Element0Selected = true;
|
|
SelectedItemUI.position = Cell_Icon.position;
|
|
_inventoryOpen = true;
|
|
Inventory.SetActive(true);
|
|
}
|
|
|
|
public void HideDrawingsInventory()
|
|
{
|
|
_inventoryOpen = false;
|
|
Inventory.SetActive(false);
|
|
}
|
|
|
|
void UpdateItems()
|
|
{
|
|
if (LampsSequence.GetInstance().UpdateItemIndex)
|
|
{
|
|
//CountItems.Add(index);
|
|
Cell_ItemID[index] = LampsSequence.GetInstance().ItemID;
|
|
|
|
#region Cell0
|
|
if (index == 0)
|
|
{
|
|
if (Cell_ItemID[0] == 0) //Letter in Cell0
|
|
{
|
|
LetterIcon.SetActive(true);
|
|
LetterIcon.transform.localPosition = Cell_Icon.localPosition;
|
|
//#region Stack Item
|
|
//StackItem(0,0,LetterIcon);
|
|
//#endregion
|
|
}
|
|
else if (Cell_ItemID[0] == 1) //DrawingBathroom in Cell0
|
|
{
|
|
DrawingBathroom.SetActive(true);
|
|
DrawingBathroom.transform.localPosition = Cell_Icon.localPosition;
|
|
//#region Stack Item
|
|
//StackItem(0, 1, DrawingBathroom);
|
|
//#endregion
|
|
}
|
|
else if (Cell_ItemID[0] == 2) //DrawingByeMom in Cell0
|
|
{
|
|
DrawingByeMom.SetActive(true);
|
|
DrawingByeMom.transform.localPosition = Cell_Icon.localPosition;
|
|
//#region Stack Item
|
|
//StackItem(0, 2, DrawingByeMom);
|
|
//#endregion
|
|
}
|
|
else if (Cell_ItemID[0] == 3) //DrawingReveal in Cell0
|
|
{
|
|
DrawingReveal.SetActive(true);
|
|
DrawingReveal.transform.localPosition = Cell_Icon.localPosition;
|
|
//#region Stack Item
|
|
//StackItem(0, 3, DrawingReveal);
|
|
//#endregion
|
|
}
|
|
print("Cell0 Updated");
|
|
}
|
|
#endregion
|
|
|
|
#region Cell1
|
|
if (index == 1)
|
|
{
|
|
if (Cell_ItemID[1] == 0) //Letter in Cell1
|
|
{
|
|
LetterIcon.SetActive(true);
|
|
LetterIcon.transform.localPosition = Cell1_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[1] == 1) //DrawingBathroom in Cell1
|
|
{
|
|
DrawingBathroom.SetActive(true);
|
|
DrawingBathroom.transform.localPosition = Cell1_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[1] == 2) //DrawingByeMom in Cell1
|
|
{
|
|
DrawingByeMom.SetActive(true);
|
|
DrawingByeMom.transform.localPosition = Cell1_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[1] == 3) //DrawingReveal in Cell1
|
|
{
|
|
DrawingReveal.SetActive(true);
|
|
DrawingReveal.transform.localPosition = Cell1_Icon.localPosition;
|
|
}
|
|
print("Cell1 Updated");
|
|
}
|
|
#endregion
|
|
|
|
#region Cell2
|
|
if (index == 2)
|
|
{
|
|
if (Cell_ItemID[2] == 0) //Letter in Cell2
|
|
{
|
|
LetterIcon.SetActive(true);
|
|
LetterIcon.transform.localPosition = Cell2_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[2] == 1) //DrawingBathroom in Cell2
|
|
{
|
|
DrawingBathroom.SetActive(true);
|
|
DrawingBathroom.transform.localPosition = Cell2_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[2] == 2) //DrawingByeMom in Cell2
|
|
{
|
|
DrawingByeMom.SetActive(true);
|
|
DrawingByeMom.transform.localPosition = Cell2_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[2] == 3) //DrawingReveal in Cell2
|
|
{
|
|
DrawingReveal.SetActive(true);
|
|
DrawingReveal.transform.localPosition = Cell2_Icon.localPosition;
|
|
}
|
|
print("Cell2 Updated");
|
|
}
|
|
#endregion
|
|
|
|
#region Cell3
|
|
if (index == 3)
|
|
{
|
|
if (Cell_ItemID[3] == 0) //Letter in Cell3
|
|
{
|
|
LetterIcon.SetActive(true);
|
|
LetterIcon.transform.localPosition = Cell3_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[3] == 1) //DrawingBathroom in Cell3
|
|
{
|
|
DrawingBathroom.SetActive(true);
|
|
DrawingBathroom.transform.localPosition = Cell3_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[3] == 2) //DrawingByeMom in Cell3
|
|
{
|
|
DrawingByeMom.SetActive(true);
|
|
DrawingByeMom.transform.localPosition = Cell3_Icon.localPosition;
|
|
}
|
|
else if (Cell_ItemID[3] == 3) //DrawingReveal in Cell3
|
|
{
|
|
DrawingReveal.SetActive(true);
|
|
DrawingReveal.transform.localPosition = Cell3_Icon.localPosition;
|
|
}
|
|
print("Cell3 Updated");
|
|
}
|
|
#endregion
|
|
index += 1;
|
|
LampsSequence.GetInstance().UpdateItemIndex = false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public void StackItem(int ElementID, int ItemID, GameObject ItemIcon)
|
|
{
|
|
ItemsIDStorage.Insert(ElementID, ItemID);
|
|
IconsStorage.Insert(ElementID, ItemIcon);
|
|
|
|
}
|
|
|
|
public void UseItem(GameObject ItemIcon)
|
|
{
|
|
ItemIcon.SetActive(false);
|
|
index -= 1;
|
|
}
|
|
|
|
}
|