// Update is called once per frame void Update() { if (cinemachineBrain.ActiveVirtualCamera as CinemachineVirtualCamera != Camera.GetComponent <CinemachineVirtualCamera>()) { return; } bool canInteract = interactableInRange && !character.HasItem(); if (canInteract) { Interactable newInteractable = null; try { newInteractable = interactableObject.GetComponent <Interactable>(); } catch { //Debug.Log("Interactable is null"); } //currentInteractable = newInteractable; if (newInteractable != null) { //Debug.Log("current interactable has a pick up script"); if (((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("P") == 0))) { if (newInteractable.GetComponent <Breakable>() != null) { //photonView.RPC("SetBreakHandsInactive", GetComponent<PhotonView>().Owner); SetBreakHandsInactive(); newInteractable.PrimaryInteraction(character); return; } } //d is for opening //u is closing if (Input.GetKeyDown(KeyCode.E)) { if (newInteractable.GetComponent <Openable>() != null) { newInteractable.PrimaryInteraction(character); return; } } if (PoseParser.GETGestureAsString().CompareTo("D") == 0) { if (newInteractable.GetComponent <Openable>() != null && newInteractable.GetComponent <Openable>().isOpened == false) { newInteractable.PrimaryInteraction(character); return; } } if (PoseParser.GETGestureAsString().CompareTo("U") == 0) { if (newInteractable.GetComponent <Openable>() != null && newInteractable.GetComponent <Openable>().isOpened == true) { newInteractable.PrimaryInteraction(character); return; } } if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newInteractable.GetComponent <Breakable>() == null && newInteractable.GetComponent <Openable>() == null) { if (newInteractable.GetComponent <Switchable>() != null) { newInteractable.PrimaryInteraction(character); } else if (newInteractable.GetComponent <Droppable>() != null) { newInteractable.PrimaryInteraction(character); //photonView.RPC("SetPressDropToNotActive", GetComponent<PhotonView>().Owner); SetPressDropToNotActive(); } else { currentInteractable = newInteractable; currentInteractable.GetComponent <Outline>().enabled = false; // Debug.Log("F was pressed"); currentInteractable.PrimaryInteraction(character); } } } } // if we are holding something, we are limited to the possible interactions else if (currentInteractable != null) { // check if there is a bag nearby as we can still pickup bags if we are holding an item Grabbable newBag = null; Switchable newSwitch = null; Droppable dropBag = null; Breakable breakableObject = null; Openable openableObject = null; try { newBag = interactableObject.GetComponent <Grabbable>(); } catch { //Debug.Log("rock is null"); } try { newSwitch = interactableObject.GetComponent <Switchable>(); } catch { //Debug.Log("switch is null"); } try { dropBag = interactableObject.GetComponent <Droppable>(); } catch { //Debug.Log("switch is null"); } try { breakableObject = interactableObject.GetComponent <Breakable>(); } catch { //Debug.Log("breakable is null"); } try { openableObject = interactableObject.GetComponent <Openable>(); } catch { //Debug.Log("Opanable is null"); } if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("P") == 0) && openableObject != null) { openableObject.PrimaryInteraction(character); } if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newBag != null) { newBag.PrimaryInteraction(character); } if ((Input.GetKeyDown(KeyCode.E) || PoseParser.GETGestureAsString().CompareTo("B") == 0) && newSwitch != null) { newSwitch.PrimaryInteraction(character); } if (Input.GetKeyDown(KeyCode.E) && dropBag != null) { dropBag.PrimaryInteraction(character); //photonView.RPC("SetPressDropToNotActive", GetComponent<PhotonView>().Owner); SetPressDropToNotActive(); } if (Input.GetKeyDown(KeyCode.E) && breakableObject != null) { breakableObject.PrimaryInteraction(character); } // press G to drop/throw item if (Input.GetKeyDown(KeyCode.G)) { // we drop/throw item and turn off its outline currentInteractable.SecondaryInteraction(character); currentInteractable.GetComponent <Outline>().enabled = true; currentInteractable = null; } else if ((Input.GetMouseButtonDown(0) || PoseParser.GETGestureAsString().CompareTo("R") == 0) && currentInteractable.GetComponent <Throwable>() != null) { currentInteractable.GetComponent <Throwable>().ThrowRock(character); currentInteractable.GetComponent <Outline>().enabled = true; currentInteractable = null; } else // if item is shootable if (Input.GetMouseButtonDown(0) && currentInteractable.GetComponent <Shootable>() != null) { //Debug.Log(currentInteractable); currentInteractable.GetComponent <Shootable>().ShootGun(character); } } }