private void Interact() { if (CurrentInteractable is InventoryItem) { InventoryItems.AddToInventory(CurrentInteractable as InventoryItem); } //Remove item from inventory if (InventoryItems.HasRequirements(CurrentInteractable)) { // Interact with current detected interactable CurrentInteractable.Interact(); OnInteracted(CurrentInteractable); RemoveItemFromInventory(); } }
/// <summary> /// Method that sets the interactable the player is interacting with /// </summary> /// <param name="newInteractable">Dete </param> private void SetInteractable(IInteractable newInteractable) { CurrentInteractable = newInteractable; // If interactable is NPC if (CurrentInteractable is NPC) { _canvasManager.ShowInteractionPanel(CurrentInteractable.InteractionText); } else if (CurrentInteractable is StaticInteractable) { if ((CurrentInteractable as StaticInteractable).AfterQuest) { _canvasManager.ShowInteractionPanel( (CurrentInteractable as StaticInteractable).TextAfterQuest); } else if (InventoryItems.HasRequirements(CurrentInteractable) && CurrentInteractable.IsActive) { _canvasManager.ShowInteractionPanel(CurrentInteractable.InteractionText); } else { _canvasManager.ShowInteractionPanel(CurrentInteractable.RequirementText); } } // If interactable is a map object else { if (InventoryItems.HasRequirements(CurrentInteractable) && CurrentInteractable.IsActive) { _canvasManager.ShowInteractionPanel(CurrentInteractable.InteractionText); } else if (!InventoryItems.HasRequirements(CurrentInteractable) || !CurrentInteractable.IsActive) { _canvasManager.ShowInteractionPanel(CurrentInteractable.RequirementText); } } }