public bool active; // gui is active /// <summary> /// Initialize all components /// </summary> void Start() { guiHotbar = GetComponent <GuiHotbar>(); containerHotbar = GetComponent <ContainerHotbar>(); guiPlayerInventory = GetComponent <GuiInventory>(); containerPlayerInventory = GetComponent <ContainerSlots>(); containerCursor = GetComponent <ContainerCursor>(); player = GetComponent <EntityPlayer>(); }
/// <summary> /// Open or close the gui /// </summary> /// <param name="open"></param> private void setGuiOpen(bool open) { if (!open) { resetOther(); } else { if (player.LookObject != null && player.LookObject.GetComponent <ContainerSlots>() != null) { containerOtherInventory = player.LookObject.GetComponent <ContainerSlots>(); guiOtherInventory = player.LookObject.GetComponent <GuiInventory>(); } } this.active = open; Cursor.visible = open; }
/// <summary> /// Reset the other inventory to nothing /// </summary> public void resetOther() { this.guiOtherInventory = null; this.containerOtherInventory = null; }
/// <summary> /// Set the other inventory the player interact with /// </summary> /// <param name="gui"></param> /// <param name="container"></param> public void setOther(GuiInventory gui, ContainerSlots container) { this.guiOtherInventory = gui; this.containerOtherInventory = container; }