示例#1
0
        protected void UpdateInteractions()
        {
            if (CurrentInteractionStyle == InterationStyle.Hold)
            {
                if (HoldButtonUp == true)
                {
                    VisibilityLocked = false;
                }

                if (HoldButtonDown == true)
                {
                    if (CurrentlyInteracting == null)
                    {
                        PickupClosest();
                    }
                }
                else if (HoldButtonUp == true && CurrentlyInteracting != null)
                {
                    EndInteraction(null);
                }
            }
            else if (CurrentInteractionStyle == InterationStyle.Toggle)
            {
                if (HoldButtonDown == true)
                {
                    if (CurrentHandState == HandState.Idle)
                    {
                        PickupClosest();
                        if (IsInteracting)
                        {
                            CurrentHandState = HandState.GripToggleOnInteracting;
                        }
                        else if (Player.PhysicalHands == true)
                        {
                            CurrentHandState = HandState.GripToggleOnNotInteracting;
                        }
                    }
                    else if (CurrentHandState == HandState.GripToggleOnInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                        EndInteraction(null);
                    }
                    else if (CurrentHandState == HandState.GripToggleOnNotInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                    }
                }
            }
            else if (CurrentInteractionStyle == InterationStyle.ByScript)
            {
                //this is handled by user customized scripts.
            }

            if (IsInteracting == true)
            {
                CurrentlyInteracting.InteractingUpdate(this);
            }
        }
示例#2
0
        protected virtual void Update()
        {
            if (Controller == null || CurrentHandState == HandState.Uninitialized)
            {
                return;
            }

            foreach (var button in Inputs)
            {
                button.Value.Axis       = Controller.GetAxis(button.Key);
                button.Value.SingleAxis = button.Value.Axis.x;
                button.Value.PressDown  = Controller.GetPressDown(button.Key);
                button.Value.PressUp    = Controller.GetPressUp(button.Key);
                button.Value.IsPressed  = Controller.GetPress(button.Key);
                button.Value.TouchDown  = Controller.GetTouchDown(button.Key);
                button.Value.TouchUp    = Controller.GetTouchUp(button.Key);
                button.Value.IsTouched  = Controller.GetTouch(button.Key);
            }


            HoldButtonPressed = Inputs[HoldButton].IsPressed;
            HoldButtonDown    = Inputs[HoldButton].PressDown;
            HoldButtonUp      = Inputs[HoldButton].PressUp;
            HoldButtonAxis    = Inputs[HoldButton].SingleAxis;

            UseButtonPressed = Inputs[UseButton].IsPressed;
            UseButtonDown    = Inputs[UseButton].PressDown;
            UseButtonUp      = Inputs[UseButton].PressUp;
            UseButtonAxis    = Inputs[UseButton].SingleAxis;

            if (HoldButtonUp)
            {
                VisibilityLocked = false;//xw:
            }

            if (HoldButtonDown == true)
            {
                if (CurrentlyInteracting == null)
                {
                    PickupClosest();
                }
            }
            else if (HoldButtonUp == true && CurrentlyInteracting != null)
            {
                EndInteraction(null);
            }

            //抓住物体的同时用其他按键触发时间
            if (IsInteracting == true)
            {
                CurrentlyInteracting.InteractingUpdate(this);
            }
            //物理手?打开时 根据手的状态决定手的显示透明度
            if (NVRPlayer.Instance.PhysicalHands == true)
            {
                UpdateVisibilityAndColliders();
            }
        }
示例#3
0
        private void Update()
        {
            if (Controller == null || CurrentHandState == HandState.Uninitialized)
            {
                return;
            }

            HoldButtonPressed = Controller.GetPress(HoldButton);
            HoldButtonDown    = Controller.GetPressDown(HoldButton);
            HoldButtonUp      = Controller.GetPressUp(HoldButton);

            UseButtonPressed = Controller.GetPress(UseButton);
            UseButtonDown    = Controller.GetPressDown(UseButton);
            UseButtonUp      = Controller.GetPressUp(UseButton);

            if (HoldButtonUp)
            {
                VisibilityLocked = false;
            }

            if (HoldButtonDown == true)
            {
                if (CurrentlyInteracting == null)
                {
                    PickupClosest();
                }
            }
            else if (HoldButtonUp == true && CurrentlyInteracting != null)
            {
                EndInteraction(null);
            }

            if (IsInteracting == true)
            {
                CurrentlyInteracting.InteractingUpdate(this);
            }

            if (NVRPlayer.Instance.PhysicalHands == true)
            {
                UpdateVisibilityAndColliders();
            }
        }
示例#4
0
        protected virtual void Update()
        {
            if (Controller == null || CurrentHandState == HandState.Uninitialized)
            {
                return;
            }

            foreach (var button in Inputs)
            {
                button.Value.Axis       = Controller.GetAxis(button.Key);
                button.Value.SingleAxis = button.Value.Axis.x;
                button.Value.PressDown  = Controller.GetPressDown(button.Key);
                button.Value.PressUp    = Controller.GetPressUp(button.Key);
                button.Value.IsPressed  = Controller.GetPress(button.Key);
                button.Value.TouchDown  = Controller.GetTouchDown(button.Key);
                button.Value.TouchUp    = Controller.GetTouchUp(button.Key);
                button.Value.IsTouched  = Controller.GetTouch(button.Key);
            }

            HoldButtonPressed = Inputs[HoldButton].IsPressed;
            HoldButtonDown    = Inputs[HoldButton].PressDown;
            HoldButtonUp      = Inputs[HoldButton].PressUp;
            HoldButtonAxis    = Inputs[HoldButton].SingleAxis;

            UseButtonPressed = Inputs[UseButton].IsPressed;
            UseButtonDown    = Inputs[UseButton].PressDown;
            UseButtonUp      = Inputs[UseButton].PressUp;
            UseButtonAxis    = Inputs[UseButton].SingleAxis;

            if (CurrentInteractionStyle == InterationStyle.GripDownToInteract)
            {
                if (HoldButtonUp == true)
                {
                    VisibilityLocked = false;
                }

                if (HoldButtonDown == true)
                {
                    if (CurrentlyInteracting == null)
                    {
                        PickupClosest();
                    }
                }
                else if (HoldButtonUp == true && CurrentlyInteracting != null)
                {
                    EndInteraction(null);
                }
            }
            else if (CurrentInteractionStyle == InterationStyle.GripToggleToInteract)
            {
                if (HoldButtonDown == true)
                {
                    if (CurrentHandState == HandState.Idle)
                    {
                        PickupClosest();
                        if (IsInteracting)
                        {
                            CurrentHandState = HandState.GripToggleOnInteracting;
                        }
                        else if (NVRPlayer.Instance.PhysicalHands == true)
                        {
                            CurrentHandState = HandState.GripToggleOnNotInteracting;
                        }
                    }
                    else if (CurrentHandState == HandState.GripToggleOnInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                        EndInteraction(null);
                    }
                    else if (CurrentHandState == HandState.GripToggleOnNotInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                    }
                }
            }

            if (IsInteracting == true)
            {
                CurrentlyInteracting.InteractingUpdate(this);
            }

            UpdateVisibilityAndColliders();
        }
示例#5
0
        protected virtual void Update()
        {
            if (CurrentHandState == HandState.Uninitialized)
            {
                return;
            }

            // button states should be updated by NVRDriver each frame, we just read them here
            HoldButtonPressed = Inputs[NVRButtonID.HoldButton].IsPressed;
            HoldButtonDown    = Inputs[NVRButtonID.HoldButton].PressDown;
            HoldButtonUp      = Inputs[NVRButtonID.HoldButton].PressUp;
            HoldButtonAxis    = Inputs[NVRButtonID.HoldButton].SingleAxis;

            UseButtonPressed = Inputs[NVRButtonID.UseButton].IsPressed;
            UseButtonDown    = Inputs[NVRButtonID.UseButton].PressDown;
            UseButtonUp      = Inputs[NVRButtonID.UseButton].PressUp;
            UseButtonAxis    = Inputs[NVRButtonID.UseButton].SingleAxis;

            /// TODO: Firing an event here instead might be a better idea
            if (HoldButtonDown)
            {
                ScenarioLogManager.Instance.LogEvent(this.gameObject, "HoldButtonDown");
            }
            else if (HoldButtonUp)
            {
                ScenarioLogManager.Instance.LogEvent(this.gameObject, "HoldButtonUp");
            }
            if (UseButtonDown)
            {
                ScenarioLogManager.Instance.LogEvent(this.gameObject, "UseButtonDown");
            }
            else if (UseButtonUp)
            {
                ScenarioLogManager.Instance.LogEvent(this.gameObject, "UseButtonUp");
            }

            if (CurrentInteractionStyle == InteractionStyle.GripDownToInteract)
            {
                if (HoldButtonUp == true)
                {
                    VisibilityLocked = false;
                }

                if (HoldButtonDown == true)
                {
                    if (CurrentlyInteracting == null)
                    {
                        PickupClosest();
                    }
                }
                else if (HoldButtonUp == true && CurrentlyInteracting != null)
                {
                    EndInteraction(null);
                }
            }
            else if (CurrentInteractionStyle == InteractionStyle.GripToggleToInteract)
            {
                if (HoldButtonDown == true)
                {
                    if (CurrentHandState == HandState.Idle)
                    {
                        PickupClosest();
                        if (IsInteracting)
                        {
                            CurrentHandState = HandState.GripToggleOnInteracting;
                        }
                        else if (player.PhysicalHands == true)
                        {
                            CurrentHandState = HandState.GripToggleOnNotInteracting;
                        }
                    }
                    else if (CurrentHandState == HandState.GripToggleOnInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                        EndInteraction(null);
                    }
                    else if (CurrentHandState == HandState.GripToggleOnNotInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                    }
                }
            }

            if (IsInteracting == true)
            {
                CurrentlyInteracting.InteractingUpdate(this);
            }

            UpdateVisibilityAndColliders();
        }
示例#6
0
        protected void UpdateInteractions()
        {
            if (!AbleToInteract)
            {
                if (CurrentInteractionStyle == InterationStyle.Hold)
                {
                    bool isHoldButtonUp        = (HoldButtonUp && !SecondHoldButtonPressed);
                    bool isSecondHoldButtonUp  = (SecondHoldButtonUp && !HoldButtonPressed);
                    bool isUsingTwoButtonsUp   = UseTwoButtonsToHold && (isHoldButtonUp || isSecondHoldButtonUp);
                    bool isUsingSingleButtonUp = !UseTwoButtonsToHold && HoldButtonUp;

                    if (isUsingSingleButtonUp || isUsingTwoButtonsUp)
                    {
                        // Implemented hand controller should subscribe to this event and implement appropriate functionality
                        OnChangeIsGrabbing.Invoke(false);
                    }
                }

                bool isUsingSingleButtonDown = !UseTwoButtonsToHold && HoldButtonDown;
                bool isUsingTwoButtonsDown   = UseTwoButtonsToHold && (HoldButtonDown || SecondHoldButtonDown);

                if (isUsingSingleButtonDown || isUsingTwoButtonsDown)
                {
                    // Implemented hand controller should subscribe to this event and implement appropriate functionality
                    OnChangeIsGrabbing.Invoke(true);
                }
                return;
            }


            if (CurrentInteractionStyle == InterationStyle.Hold)
            {
                bool isHoldButtonUp        = (HoldButtonUp && !SecondHoldButtonPressed);
                bool isSecondHoldButtonUp  = (SecondHoldButtonUp && !HoldButtonPressed);
                bool isUsingTwoButtonsUp   = UseTwoButtonsToHold && (isHoldButtonUp || isSecondHoldButtonUp);
                bool isUsingSingleButtonUp = !UseTwoButtonsToHold && HoldButtonUp;

                if (isUsingSingleButtonUp || isUsingTwoButtonsUp)
                {
                    VisibilityLocked = false;

                    // Implemented hand controller should subscribe to this event and implement appropriate functionality
                    OnChangeIsGrabbing.Invoke(false);
                    OnUnfreezeHand.Invoke();
                }

                bool isUsingSingleButtonDown = !UseTwoButtonsToHold && HoldButtonDown;
                bool isUsingTwoButtonsDown   = UseTwoButtonsToHold && (HoldButtonDown || SecondHoldButtonDown);

                if (isUsingSingleButtonDown || isUsingTwoButtonsDown)
                {
                    // Implemented hand controller should subscribe to this event and implement appropriate functionality
                    OnChangeIsGrabbing.Invoke(true);

                    if (CurrentlyInteracting == null)
                    {
                        PickupClosest();
                    }
                }
                else if ((isUsingSingleButtonUp || isUsingTwoButtonsUp) && CurrentlyInteracting != null)
                {
                    EndInteraction(null);
                }
            }
            else if (CurrentInteractionStyle == InterationStyle.Toggle)
            {
                bool isUsingSingleButtonDown = !UseTwoButtonsToHold && HoldButtonDown;
                bool isUsingTwoButtonsDown   = UseTwoButtonsToHold && (HoldButtonDown || SecondHoldButtonDown);

                if (isUsingSingleButtonDown || isUsingTwoButtonsDown)
                {
                    if (CurrentHandState == HandState.Idle)
                    {
                        PickupClosest();
                        if (IsInteracting)
                        {
                            CurrentHandState = HandState.GripToggleOnInteracting;
                        }
                        else if (Player.PhysicalHands == true)
                        {
                            CurrentHandState = HandState.GripToggleOnNotInteracting;
                        }
                    }
                    else if (CurrentHandState == HandState.GripToggleOnInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                        EndInteraction(null);
                    }
                    else if (CurrentHandState == HandState.GripToggleOnNotInteracting)
                    {
                        CurrentHandState = HandState.Idle;
                        VisibilityLocked = false;
                    }
                }
            }
            else if (CurrentInteractionStyle == InterationStyle.ByScript)
            {
                //this is handled by user customized scripts.
            }

            if (IsInteracting == true)
            {
                CurrentlyInteracting.InteractingUpdate(this);
            }
        }