Пример #1
0
    public static void AddInteractable(Interactable interactable)
    {
        Instance.interactables.Add(interactable);
        interactable.OnSelected();
        OnUpdated?.Invoke();

        Collider collider = interactable.GetComponent <Collider>();

        Instance.selectionMarker.transform.localScale = collider.bounds.size * 2f;
        //Instance.selectionMarker.transform.localPosition = collider.bounds.min + new Vector3(collider.bounds.extents.x, 0, collider.bounds.extents.z);
        Instance.selectionMarker.transform.SetParent(interactable.transform);
        Instance.selectionMarker.transform.localPosition = Vector3.zero;
        Instance.selectionMarker.SetActive(true);
    }
Пример #2
0
 protected virtual void ActivateEnd()
 {
     if (VolumeActivateEnd != null)
     {
         VolumeActivateEnd.Invoke(InteractingGO);
     }
 }
Пример #3
0
 protected virtual void Activating()
 {
     if (VolumeActivating != null)
     {
         VolumeActivating.Invoke(InteractingGO);
     }
 }
Пример #4
0
 protected virtual void ActivateBegin()
 {
     if (VolumeActivateBegin != null)
     {
         VolumeActivateBegin.Invoke(InteractingGO);
     }
 }
Пример #5
0
 protected virtual void HoverEnd()
 {
     if (VolumeHoverEnd != null)
     {
         VolumeHoverEnd.Invoke(InteractingGO);
     }
 }
Пример #6
0
 protected virtual void Hovering()
 {
     if (VolumeHovering != null)
     {
         VolumeHovering.Invoke(InteractingGO);
     }
 }
Пример #7
0
    /* ============== Virtual Event Functions ============== */

    protected virtual void HoverBegin()
    {
        if (VolumeHoverBegin != null)
        {
            VolumeHoverBegin.Invoke(InteractingGO);
        }
    }
Пример #8
0
        // This function tries to do the following things in order:
        // tries to use an item if inventory is open
        // tries to interact with terrain under player
        // tries to pick up Item
        private void HandleSpacePressed()
        {
            if (UI.InventoryOpen)
            {
                //Console.WriteLine("Space trigger item use!");
                //Console.WriteLine("UsedItemEvent null? " + UsedItemEvent == null);
                UsedItemEvent?.Invoke(Util.PlayerID, EntityManager.GetComponent <InventoryComponent>(Util.PlayerID).Items[UI.InventoryCursorPosition - 1], ItemUsage.Consume);
                return;
            }

            var playerPos = EntityManager.GetComponent <TransformComponent>(Util.PlayerID).Position;

            int terrain = Util.CurrentFloor.GetTerrain(playerPos);

            if (terrain != 0) // is there special terrain?
            {
                var terrainInteraction = EntityManager.GetComponent <InteractableComponent>(terrain);

                if (terrainInteraction != null) // is it interactable?
                {
                    InteractionEvent?.Invoke(Util.PlayerID, terrain);
                    return;
                }
            }

            bool itemsOnFloor = Util.CurrentFloor.GetItems(playerPos).Count() > 0; // are there items here?

            if (!itemsOnFloor)
            {
                UISystem.Message("No items here to be picked up!");
                return;
            }

            PickupItemEvent?.Invoke(Util.PlayerID);
        }
Пример #9
0
 public void OnObjectCovid(VrController _controller)
 {
     if (isTouchable && (_controller.InputSource == allowedSource || allowedSource == SteamVrInputSource.Any))
     {
         onCovid.Invoke(GenerateArgs(_controller));
     }
 }
 public void OnHoveredOut(VRInteractor interactor)
 {
     if (OnHoveredOutEvent != null)
     {
         OnHoveredOutEvent.Invoke(interactor);
     }
 }
Пример #11
0
        /// <summary>
        /// Invokes the interact event.
        /// </summary>
        /// <param name="bypassIsInteractable">If true, it will ignore the Is Interactable property.</param>
        /// <param name="bypassLimit">If true, it will ignore the max limit property.</param>
        public void Interact(bool bypassIsInteractable, bool bypassLimit)
        {
            // If we can't interact and we're not bypassing the check, stop here.
            if (!isInteractable && !bypassIsInteractable)
            {
                return;
            }

            // If there's a limit on interactions, we've reached the max interactions, and we're not bypassing the check, stop here.
            if (limitedInteractions && interactions >= maxInteractions && !bypassLimit)
            {
                return;
            }

            // If limited interactions are enabled, add one to the interaction amount.
            if (limitedInteractions)
            {
                interactions++;
            }

            // Call the interact event.
            onInteract.Invoke();

            // If the interactions has reached it's max, invoke the reached max interactions event.
            if (interactions == maxInteractions)
            {
                onReachedMaxInteractions.Invoke();
            }
        }
 public void OnInteractionFinished(VRInteractor interactor)
 {
     if (OnInteractionFinishedEvent != null)
     {
         OnInteractionFinishedEvent.Invoke(interactor);
     }
 }
Пример #13
0
    //Debug
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (GameState != GameStates.Paused)
            {
                GameState = GameStates.Paused;
            }
            else
            {
                GameState = lastState;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Tab))
        {
            OnHighLightAll.Invoke(true);
        }
        else if (Input.GetKeyUp(KeyCode.Tab))
        {
            OnHighLightAll.Invoke(false);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            OnInteractButtonPressed.Invoke();
        }
    }
 public void OnObjectUntouched(VrController _controller)
 {
     if (isTouchable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any))
     {
         onUntouched.Invoke(GenerateArgs(_controller));
     }
 }
Пример #15
0
 public void OnObjectStopUsed(VrController _controller)
 {
     if (isUsable && (_controller.InputSource == allowedSource || allowedSource == SteamVRInputSource.Any))
     {
         onStopUsed.Invoke(GenerateArgs(_controller));
     }
 }
Пример #16
0
 public void OnObjectStopUsing(VRController _controller)
 {
     if (isUsable && IsInputSourceAllowed(_controller))
     {
         onStopUsing.Invoke(GenerateArgs(_controller));
     }
 }
 public void OnObjectReleased(VrController _controller)
 {
     if (isGrabbable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any))
     {
         onReleased.Invoke(GenerateArgs(_controller));
     }
 }
Пример #18
0
 public void OnObjectReleased(VRController _controller)
 {
     if (isGrabbable && IsInputSourceAllowed(_controller))
     {
         onReleased.Invoke(GenerateArgs(_controller));
     }
 }
Пример #19
0
 public void OnObjectTouched(VRController _controller)
 {
     if (isTouchable && IsInputSourceAllowed(_controller))
     {
         onTouched.Invoke(GenerateArgs(_controller));
     }
 }
 public void OnInteractionStart(VRInteractor interactor)
 {
     if (OnInteractionStartEvent != null)
     {
         OnInteractionStartEvent.Invoke(interactor);
     }
 }
Пример #21
0
 public void OnObjectReleased(VrCtrl _controller)
 {
     //If the object is grabbable or if it is any input source
     if (isGrabbable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any))
     {
         onReleased.Invoke(GenerateArgs(_controller));
     }
 }
Пример #22
0
 public virtual void OnObjectReleased(VrController _controller)
 {
     if (_controller.InputSource == allowedSource || allowedSource == SteamVrInputSource.Any)
     {
         onReleased.Invoke(GenerateArgs(_controller));
         Grabbed = null;
     }
 }
Пример #23
0
 public void OnObjectUsed(VrCtrl _controller)
 {
     //If the object is being used or if it is any input source
     if (isUsable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any))
     {
         onUsed.Invoke(GenerateArgs(_controller));
     }
 }
Пример #24
0
 public void OnObjectStopTouching(VrCtrl _controller)
 {
     //If the object is not being touched or if it is any input source
     if (isTouchable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any))
     {
         onStopTouching.Invoke(GenerateArgs(_controller));
     }
 }
Пример #25
0
 public void OnObjectStopUsing(VrCtrl _controller)
 {
     //If the object has stopped being using or if it is any input source
     if (isUsable && (_controller.InputSource == allowedSource || allowedSource == SteamVR_Input_Sources.Any))
     {
         onStopUsing.Invoke(GenerateArgs(_controller));
     }
 }
Пример #26
0
 public virtual void OnObjectGrabbed(VrController _controller)
 {
     if (isGrabbable && (_controller.InputSource == allowedSource || allowedSource == SteamVrInputSource.Any))
     {
         onGrabbed.Invoke(GenerateArgs(_controller));
         Grabbed = _controller.GetComponent <InteractGrab>();
     }
 }
Пример #27
0
    public void Damage(int amount)
    {
        ReduceHealth(amount);
        OnDamage.Invoke();
        // Debug.Log("Damage amount " + amount);
        // if (!isItSchild)
        //    ReduceHealth(amount);

        ShowEffects();
    }
    public virtual void OnInteract(PlayerHandler ph)
    {
        onInteract.Invoke(ph);
        EventJunction.Transmit(new InteractMessage(ph, this));

        if (cooldown > 0)
        {
            coolingDown = Cooldown(cooldown);
            StartCoroutine(coolingDown);
        }
    }
Пример #29
0
        private void ReleaseObject()
        {
            heldObject.Rigidbody.isKinematic = false;
            heldObject.transform.SetParent(heldOriginalParent);

            heldObject.Rigidbody.velocity        = input.Controller.Velocity;
            heldObject.Rigidbody.angularVelocity = input.Controller.AngularVelocity;

            heldObject.OnObjectReleased(input.Controller);
            released.Invoke(new InteractEventArgs(input.Controller, heldObject.Rigidbody, heldObject.Collider));
            heldObject = null;
        }
Пример #30
0
        private void GrabObject()
        {
            heldObject      = collidingObject;
            collidingObject = null;

            heldOriginalParent = heldObject.transform.parent;
            heldObject.Rigidbody.isKinematic = true;
            SnapObject(heldObject.transform, heldObject.AttachPoint);

            heldObject.OnObjectGrabbed(input.Controller);
            grabbed.Invoke(new InteractEventArgs(input.Controller, heldObject.Rigidbody, heldObject.Collider));
        }