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(); } }
public void OpenUsePrompt(ItemUser user) { if (IsEnabled() && !InventoryMenuController.IsOpen) { ItemUsePromptController.Open(user); PlayerManager.SetInteractiveItem(user.GetItemPos(), user.GetItemLook()); } }
IEnumerator WaitingPlayer(ItemUser user, bool needTool) { while (PlayerManager.GetIsInteracting()) { yield return(null); } if (!needTool) { PlayerManager.PickAnimation(); } else { PlayerManager.PlayInteractAnimation(); } user.OnUse(); Debug.Log("usado"); }
void Start() { ItemUser = GetComponent <ItemUser>(); }