public override void OnUpdate(InteractableStates state, Interactable source)
        {
            if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0 && !hasDown)
            {
                hasDown    = true;
                clickTimer = 0;
            }
            else if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value < 1)
            {
                hasDown = false;
            }

            Debug.Log(HoldTime);

            if (hasDown && clickTimer < HoldTime)
            {
                clickTimer += Time.deltaTime;

                if (clickTimer >= HoldTime)
                {
                    Debug.Log("Hold!!");
                    uEvent.Invoke();
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Called on update, check to see if the state has changed sense the last call
 /// </summary>
 /// <param name="state"></param>
 /// <param name="source"></param>
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
     if (state.CurrentState() != lastState)
     {
         lastState = state.CurrentState();
     }
 }
 /// <summary>
 /// Called on update, check to see if the state has changed sense the last call
 /// </summary>
 /// <param name="state"></param>
 /// <param name="source"></param>
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
     if (state.CurrentState() != lastState)
     {
         // the state has changed, do something new
         lastState = state.CurrentState();
     }
 }
 /// <summary>
 /// A state has changed
 /// </summary>
 /// <param name="state"></param>
 /// <param name="source"></param>
 public override void OnStateChange(InteractableStates state, Interactable source)
 {
     base.OnStateChange(state, source);
     if (Events.Count > 0)
     {
         if (Events[0].Receiver != null)
         {
             Events[0].Receiver.OnUpdate(state, source);
         }
     }
 }
        /// <summary>
        /// captures voice commands
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        /// <param name="command"></param>
        /// <param name="index">index of the voice command</param>
        /// <param name="length">voice command array length</param>
        public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
        {
            base.OnVoiceCommand(state, source, command, index, length);

            for (int i = 0; i < Events.Count; i++)
            {
                if (Events[i].Receiver != null)
                {
                    Events[i].Receiver.OnVoiceCommand(state, source, command, index, length);
                }
            }
        }
        /// <summary>
        /// .A state has changed
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        public override void OnStateChange(InteractableStates state, Interactable source)
        {
            base.OnStateChange(state, source);

            for (int i = 0; i < Events.Count; i++)
            {
                if (Events[i].Receiver != null)
                {
                    Events[i].Receiver.OnUpdate(state, source);
                }
            }
        }
        /// <summary>
        /// captures click events
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        /// <param name="pointer"></param>
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            base.OnClick(state, source, pointer);

            for (int i = 0; i < Events.Count; i++)
            {
                if (Events[i].Receiver != null)
                {
                    Events[i].Receiver.OnClick(state, source, pointer);
                }
            }
        }
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            int currentIndex = source.GetDimensionIndex();

            if (currentIndex % 2 == 0)
            {
                OnDeselect.Invoke();
            }
            else
            {
                uEvent.Invoke();
            }
        }
Пример #9
0
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            base.OnClick(state, source, pointer);

            if (spawnCoro == null)
            {
                spawnCoro = Host.StartCoroutine(SpawnDatasets());
            }
            else
            {
                Host.StopCoroutine(spawnCoro);
                Manipulation.UpdatePanelVisName("No Visualization Running");
                Manipulation.UpdatePanelInfo("-- No Info --");
            }
        }
Пример #10
0
 State myLastState = null; // will automatically update on first state change
 public override void OnStateChange(InteractableStates state, Interactable source)
 {
     base.OnStateChange(state, source);
     if (myLastState != state.CurrentState()) // state change
     {
         myLastState = state.CurrentState();
         if (myLastState.Name == "Pressed" && !currentlyManipulating)
         {
             CurAction = grabInteractableS;
             LogManipulationStart();
         }
         else
         {
             StopLogging();
         }
     }
 }
        /// <summary>
        /// click happened
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        /// <param name="pointer"></param>
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            base.OnClick(state, source);
            if (Host != null)
            {
                if (showClicked != null)
                {
                    Host.StopCoroutine(showClicked);
                    showClicked = null;
                }

                showClicked = Host.StartCoroutine(ClickTimer(clickTime));
            }

            clickCount++;
            SetOutput();
        }
        /// <summary>
        /// Called on update, check to see if the state has changed sense the last call
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            if (state.CurrentState() != lastState)
            {
                // the state has changed, do something new

                /*
                 * bool hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;
                 *
                 * bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;
                 *
                 * bool isDisabled = state.GetState(InteractableStates.InteractableStateEnum.Disabled).Value > 0;
                 *
                 * bool hasInteractive = state.GetState(InteractableStates.InteractableStateEnum.Interactive).Value > 0;
                 *
                 * bool hasObservation = state.GetState(InteractableStates.InteractableStateEnum.Observation).Value > 0;
                 *
                 * bool hasObservationTargeted = state.GetState(InteractableStates.InteractableStateEnum.ObservationTargeted).Value > 0;
                 *
                 * bool isTargeted = state.GetState(InteractableStates.InteractableStateEnum.Targeted).Value > 0;
                 *
                 * bool isToggled = state.GetState(InteractableStates.InteractableStateEnum.Toggled).Value > 0;
                 *
                 * bool isVisited = state.GetState(InteractableStates.InteractableStateEnum.Visited).Value > 0;
                 *
                 * bool isDefault = state.GetState(InteractableStates.InteractableStateEnum.Default).Value > 0;
                 *
                 * bool hasGesture = state.GetState(InteractableStates.InteractableStateEnum.Gesture).Value > 0;
                 *
                 * bool hasGestureMax = state.GetState(InteractableStates.InteractableStateEnum.GestureMax).Value > 0;
                 *
                 * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.Collision).Value > 0;
                 *
                 * bool hasCustom = state.GetState(InteractableStates.InteractableStateEnum.Custom).Value > 0;
                 *
                 * or:
                 *
                 * bool hasFocus = source.HasFocus;
                 * bool hasPress = source.HasPress;
                 */

                lastState = state.CurrentState();
                SetOutput();
            }
        }
        /// <summary>
        /// voice command called
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        /// <param name="command"></param>
        /// <param name="index"></param>
        /// <param name="length"></param>
        public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
        {
            base.OnVoiceCommand(state, source, command, index, length);
            lastVoiceCommand = command;

            if (Host != null)
            {
                if (showVoice != null)
                {
                    Host.StopCoroutine(showVoice);
                    showVoice = null;
                }

                showVoice = Host.StartCoroutine(VoiceTimer(clickTime));
            }

            SetOutput();
        }
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool changed = state.CurrentState() != lastState;

            bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;

            if (hadFocus != hasFocus && changed)
            {
                if (hasFocus)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnFocusOff.Invoke();
                }
            }

            hadFocus  = hasFocus;
            lastState = state.CurrentState();
        }
        /// <summary>
        /// a state has changed
        /// </summary>
        /// <param name="state"></param>
        /// <param name="source"></param>
        public virtual void OnStateChange(InteractableStates state, Interactable source)
        {
            // the state has changed, do something new

            /*
             * bool hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;
             *
             * bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;
             *
             * bool isDisabled = state.GetState(InteractableStates.InteractableStateEnum.Disabled).Value > 0;
             *
             * bool hasInteractive = state.GetState(InteractableStates.InteractableStateEnum.Interactive).Value > 0;
             *
             * bool hasObservation = state.GetState(InteractableStates.InteractableStateEnum.Observation).Value > 0;
             *
             * bool hasObservationTargeted = state.GetState(InteractableStates.InteractableStateEnum.ObservationTargeted).Value > 0;
             *
             * bool isTargeted = state.GetState(InteractableStates.InteractableStateEnum.Targeted).Value > 0;
             *
             * bool isToggled = state.GetState(InteractableStates.InteractableStateEnum.Toggled).Value > 0;
             *
             * bool isVisited = state.GetState(InteractableStates.InteractableStateEnum.Visited).Value > 0;
             *
             * bool isDefault = state.GetState(InteractableStates.InteractableStateEnum.Default).Value > 0;
             *
             * bool hasGesture = state.GetState(InteractableStates.InteractableStateEnum.Gesture).Value > 0;
             *
             * bool hasGestureMax = state.GetState(InteractableStates.InteractableStateEnum.GestureMax).Value > 0;
             *
             * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.Collision).Value > 0;
             *
             * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.VoiceCommand).Value > 0;
             *
             * bool hasCustom = state.GetState(InteractableStates.InteractableStateEnum.Custom).Value > 0;
             */
        }
Пример #16
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool changed = state.CurrentState() != lastState;

            bool hadDown = hasDown;

            hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;

            bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;

            if (changed && hasDown != hadDown && focused)
            {
                if (hasDown)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnRelease.Invoke();
                }
            }

            lastState = state.CurrentState();
        }
Пример #17
0
 /// <summary>
 /// The state has changed
 /// </summary>
 /// <param name="state"></param>
 /// <param name="source"></param>
 public abstract void OnUpdate(InteractableStates state, Interactable source);
 /// <summary>
 /// click happened
 /// </summary>
 /// <param name="state"></param>
 /// <param name="source"></param>
 /// <param name="pointer"></param>
 public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     base.OnClick(state, source);
     PlayAudio(source);
 }
 /// <summary>
 /// voice command called
 /// </summary>
 /// <param name="state"></param>
 /// <param name="source"></param>
 /// <param name="command"></param>
 /// <param name="index"></param>
 /// <param name="length"></param>
 public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
 {
     base.OnVoiceCommand(state, source, command, index, length);
     PlayAudio(source);
 }
Пример #20
0
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
 }
 public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     uEvent.Invoke();
 }
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
     // using onClick
 }
 /// <inheritdoc />
 public virtual void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
 {
     // Voice Command Happened
 }
 /// <inheritdoc />
 public virtual void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     // Click Happened
 }
Пример #25
0
 /// <summary>
 /// starts the StateManager
 /// </summary>
 protected virtual void SetupStates()
 {
     StateManager = States.SetupLogic();
 }
Пример #26
0
    // Update is called once per frame
    void Update()
    {
        if (GameManager.m_gameManager.m_useController)
        {
            switch (GameManager.m_gameManager.m_controllerType)
            {
            case "Xbox":
                //Xbox controller ability changes

                //Press A to change Toggle ability
                if (Input.GetButtonDown("A"))
                {
                    if (m_state != InteractableStates.TOGGLE)
                    {
                        m_state          = InteractableStates.TOGGLE;
                        m_currentAbility = "TOGGLE";
                    }
                    else
                    {
                        m_state          = InteractableStates.NORMAL;
                        m_currentAbility = "NORMAL";
                    }
                }

                //Press B to change Modify ability
                if (Input.GetButtonDown("B"))
                {
                    if (m_state != InteractableStates.MODIFY)
                    {
                        m_state          = InteractableStates.MODIFY;
                        m_currentAbility = "MODIFY";
                    }
                    else
                    {
                        m_state          = InteractableStates.NORMAL;
                        m_currentAbility = "NORMAL";
                    }
                }

                //Press X to change Swap ability
                if (Input.GetButtonDown("X(Xbox)"))
                {
                    if (m_state != InteractableStates.SWAP)
                    {
                        m_state          = InteractableStates.SWAP;
                        m_currentAbility = "SWAP";
                    }
                    else
                    {
                        m_state          = InteractableStates.NORMAL;
                        m_currentAbility = "NORMAL";
                    }
                }

                //Press Y to change ability to normal
                if (Input.GetButtonDown("Y"))
                {
                    m_state          = InteractableStates.NORMAL;
                    m_currentAbility = "NORMAL";
                }

                //Press Right trigger to activate ability over an interactable object
                if (m_currentInteractable != null)
                {
                    if (Input.GetAxis("Triggers") < 0.0f)
                    {
                        Debug.Log("Right Trigger pulled");
                        m_currentInteractable.GetComponent <InteractableBase>().SetState(m_state);
                    }
                }

                break;

            case "PS4":
                //PS4 controller ability changes

                //Press X to change Toggle ability
                if (Input.GetButtonDown("X(PS4)"))
                {
                    if (m_state != InteractableStates.TOGGLE)
                    {
                        m_state          = InteractableStates.TOGGLE;
                        m_currentAbility = "TOGGLE";
                    }
                    else
                    {
                        m_state          = InteractableStates.NORMAL;
                        m_currentAbility = "NORMAL";
                    }
                }

                //Press Circle to change Modify ability
                if (Input.GetButtonDown("Circle"))
                {
                    if (m_state != InteractableStates.MODIFY)
                    {
                        m_state          = InteractableStates.MODIFY;
                        m_currentAbility = "MODIFY";
                    }
                    else
                    {
                        m_state          = InteractableStates.NORMAL;
                        m_currentAbility = "NORMAL";
                    }
                }

                //Press Square to change Swap ability
                if (Input.GetButtonDown("Square"))
                {
                    if (m_state != InteractableStates.SWAP)
                    {
                        m_state          = InteractableStates.SWAP;
                        m_currentAbility = "SWAP";
                    }
                    else
                    {
                        m_state          = InteractableStates.NORMAL;
                        m_currentAbility = "NORMAL";
                    }
                }

                //Press Triangle to change ability to normal
                if (Input.GetButtonDown("Triangle"))
                {
                    m_state          = InteractableStates.NORMAL;
                    m_currentAbility = "NORMAL";
                }

                //Press R2 to activate ability over an interactable object
                if (m_currentInteractable != null)
                {
                    if (Input.GetAxis("R2") > -1.0f)
                    {
                        Debug.Log("R2 pulled");
                        m_currentInteractable.GetComponent <InteractableBase>().SetState(m_state);
                    }
                }
                break;

            default:
                break;
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                if (m_state != InteractableStates.TOGGLE)
                {
                    m_state          = InteractableStates.TOGGLE;
                    m_currentAbility = "TOGGLE";
                }
                else
                {
                    m_state          = InteractableStates.NORMAL;
                    m_currentAbility = "NORMAL";
                }
            }

            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                if (m_state != InteractableStates.MODIFY)
                {
                    m_state          = InteractableStates.MODIFY;
                    m_currentAbility = "MODIFY";
                }
                else
                {
                    m_state          = InteractableStates.NORMAL;
                    m_currentAbility = "NORMAL";
                }
            }

            if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                if (m_state != InteractableStates.SWAP)
                {
                    m_state          = InteractableStates.SWAP;
                    m_currentAbility = "SWAP";
                }
                else
                {
                    m_state          = InteractableStates.NORMAL;
                    m_currentAbility = "NORMAL";
                }
            }

            if (Input.GetKeyDown(KeyCode.Alpha4))
            {
                m_state          = InteractableStates.NORMAL;
                m_currentAbility = "NORMAL";
            }

            if (m_currentInteractable != null)
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    m_currentInteractable.GetComponent <InteractableBase>().SetState(m_state);
                }
            }
        }

        m_abilityText.text = m_currentAbility;
    }