Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ItemPickUp : MonoBehaviour, IInteractable
- {
- public Outline objectOutline;
- public Item itemOnGround;
- public bool CanInteract(bool isPlayerInteraction)
- {
- return isPlayerInteraction;
- }
- private void Start()
- {
- StopHover();
- }
- public void Interact(PlayerMovement player)
- {
- if (player.TryGetComponent(out Inventory playerInventory))
- {
- if (playerInventory.AddToBackPack(itemOnGround))
- {
- Destroy(gameObject);
- }
- else
- {
- objectOutline.OutlineColor = Color.red;
- }
- }
- }
- public void StartHover()
- {
- objectOutline.enabled = true;
- objectOutline.OutlineColor = itemOnGround.itemColor;
- }
- public void StopHover()
- {
- objectOutline.enabled = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement