Exemple #1
0
 public void DisplayInventoryUI()
 {
     inventoryCanvas.SetActive(true);
     dm.DisablePlayer();
 }
    private void Update()
    {
        #region show inventory
        if (Input.GetKeyDown(KeyCode.I))
        {
            inventoryEnabled = !inventoryEnabled;


            if (inventoryEnabled)
            {
                inventoryUI.SetActive(true);
                disableMan.DisablePlayer();
            }
            else
            {
                inventoryUI.SetActive(false);
                disableMan.EnablePlayer();
            }
        }
        #endregion

        if (inventoryEnabled)
        {
            #region drop item
            if (Input.GetKeyDown(KeyCode.Q))
            {
                if (active != null && active.item != null)
                {
                    if (active.item.equippable)
                    {
                        Unequip(eq[(int)active.item.eqPart]);
                        ((GameObject)Instantiate(Resources.Load(active.item.name), spawnPoint.position, spawnPoint.rotation)).AddComponent <Rigidbody>();
                    }
                    else
                    {
                        Instantiate(Resources.Load(active.item.name), spawnPoint.position, spawnPoint.rotation);
                    }
                    RemoveItem(active);
                }
            }

            if (Input.GetMouseButtonDown(0) && !hold)
            {
                if (active != null && active.item != null)
                {
                    slotMove = active;
                    hold     = true;
                }
            }
            if (Input.GetMouseButtonUp(0) && hold)
            {
                if (active != null)
                {
                    if (active.tag == "Equip")
                    {
                        EquipItem(slotMove);
                        hold = false;
                    }
                    else
                    {
                        ChangeSlot(slotMove, active);
                        hold = false;
                    }
                }
                else
                {
                    //if destination is not slot
                    ChangeSlot(slotMove, active);
                    hold = false;
                }
                slotMove = null;
            }
            #endregion

            if (Input.GetMouseButtonDown(1)) // Use item
            {
                if (active != null && active.item != null && !active.item.equippable)
                {
                    UseItem(active);
                }
                else if (active != null && active.item != null && active.item.equippable)
                {
                    EquipItem(active);
                }
            }
        }
    }
Exemple #3
0
 public void EnableSleepUI()
 {
     sleepUI.SetActive(true);
     disableManager.DisablePlayer();
 }
 public void CharacterDeath()
 {
     deathUI.SetActive(true);
     disableManager.DisablePlayer();
 }