public void UpdateUI() { hotbar.UpdateHotbar(); if (Input.GetKeyDown(KeyCode.F1)) { hideUI = !hideUI; playingUI.gameObject.SetActive(!hideUI); } if (Input.GetKeyDown(KeyCode.Slash)) { console.gameObject.SetActive(true); } if (console.gameObject.activeSelf) { console.UpdateConsole(); } if (errorTimer > 0) { errorCanvasGroup.gameObject.SetActive(true); errorTimer -= Time.deltaTime; errorCanvasGroup.alpha = Mathf.Clamp01(errorTimer); } else { errorCanvasGroup.gameObject.SetActive(false); } }
public void UpdateUI() { hotbar.UpdateHotbar(); if (Input.GetKeyDown(KeyCode.F1)) { hideUI = !hideUI; playingUI.gameObject.SetActive(!hideUI); } }
// Update is called once per frame public void AddItem(ItemList.ItemType _item, int numItem) { int _numItem = numItem; if (slots.Count == maxSlots) { if (slots[maxSlots - 1].item == null) { StartCoroutine(wait(_item, _numItem)); } else { //All slots are spawned foreach (Slot _slot in slots) { if (_numItem == 0) { return; } if (_slot.item.item == _item || _slot.item.noItem == true) { if (_slot.item.item == _item) { //Debug.Log("_numItem =" + _numItem + "For starting with slot" + _slot.slotID); //Debug.Log("-1"); //4 already 16 stacksize we wanted to add 14 //4+14-16 if (_slot.item.MaxStackSize > (_slot.item.StackSize + _numItem)) { //Debug.Log("0"); _slot.item.item = _item; _slot.item.StackSize = _slot.item.StackSize + _numItem; _slot.item.noItem = false; _numItem = 0; if (isHotbar) { hotbar.UpdateHotbar(); return; } return; } else { // Debug.Log("1"); _slot.item.item = _item; _slot.item.noItem = false; _numItem = (_slot.item.StackSize + _numItem) - _slot.item.MaxStackSize; _slot.item.StackSize = _slot.item.MaxStackSize; if (isHotbar) { hotbar.UpdateHotbar(); } } } if (_slot.item.noItem == true) { // Debug.Log("2"); //Debug.Log("Max Stack Size:" + _slot.item.MaxStackSize + "Num Items:" + _numItem); if (_slot.item.MaxStackSize > _numItem) { //Max stack size or 16 is greater then the number of items we want to add so therefore we don't need to go to the next slot //Debug.Log("3"); _slot.item.item = _item; _slot.item.StackSize = _numItem; _slot.item.noItem = false; _numItem = 0; if (isHotbar) { hotbar.UpdateHotbar(); return; } return; } else { //Debug.Log("4"); _slot.item.item = _item; _slot.item.noItem = false; _numItem = (_slot.item.StackSize + _numItem) - _slot.item.MaxStackSize; _slot.item.StackSize = _slot.item.MaxStackSize; //Debug.Log("Set _numItem To:" + _numItem + "For slot" + _slot.slotID); if (isHotbar) { hotbar.UpdateHotbar(); } } } } else { if (_slot.slotID == 9) { return; } } } if (isHotbar) { hotbar.UpdateHotbar(); } } } else { StartCoroutine(wait(_item, _numItem)); } }