예제 #1
0
        public void UseItem(ItemUser user)
        {
            // Si no es necesario un item para usarlo, entonces se usa directamente
            if (string.IsNullOrEmpty(user.Item.VariableName))
            {
                PlayerManager.SetIsInteracting(true);
                StartCoroutine(WaitingPlayer(user, false));
            }
            else if (IsItemInInventory(user.Item))
            {
                //Pasarlo a ItemInfo del inventario
                ItemInfo inventoryItem = GetInventoryItem(user.Item);

                if (inventoryItem.IsEquippable)
                {
                    if (IsItemEquipped(inventoryItem))
                    {
                        PlayerManager.SetIsInteracting(true);
                        StartCoroutine(WaitingPlayer(user, true));

                        CloseUsePrompt();
                    }
                    else
                    {
                        user.OnUnableUse();
                    }
                }

                UseItem(user.Item);
            }
            else
            {
                user.OnUnableUse();
            }
        }
예제 #2
0
 public void OpenUsePrompt(ItemUser user)
 {
     if (IsEnabled() && !InventoryMenuController.IsOpen)
     {
         ItemUsePromptController.Open(user);
         PlayerManager.SetInteractiveItem(user.GetItemPos(), user.GetItemLook());
     }
 }
예제 #3
0
        IEnumerator WaitingPlayer(ItemUser user, bool needTool)
        {
            while (PlayerManager.GetIsInteracting())
            {
                yield return(null);
            }

            if (!needTool)
            {
                PlayerManager.PickAnimation();
            }
            else
            {
                PlayerManager.PlayInteractAnimation();
            }

            user.OnUse();
            Debug.Log("usado");
        }
예제 #4
0
 void Start()
 {
     ItemUser = GetComponent <ItemUser>();
 }