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

            bool hadDown = hasDown;

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


            if (changed && hasDown != hadDown)
            {
                if (hasDown)
                {
                    isNear = state.GetState(InteractableStates.InteractableStateEnum.PhysicalTouch).Value > 0;
                    if (IsFilterValid())
                    {
                        uEvent.Invoke();
                    }
                }
                else
                {
                    if (IsFilterValid())
                    {
                        OnRelease.Invoke();
                    }
                }
            }

            lastState = state.CurrentState();
        }
 /// <summary>
 /// Called on update, check to see if the state has changed sense the last call
 /// </summary>
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
     if (state.CurrentState() != lastState)
     {
         // the state has changed, do something new
         lastState = state.CurrentState();
     }
 }
Beispiel #3
0
        protected virtual void Update()
        {
            if (rollOffTimer < rollOffTime && HasPress)
            {
                rollOffTimer += Time.deltaTime;

                if (rollOffTimer >= rollOffTime)
                {
                    SetPress(false);
                }
            }

            for (int i = 0; i < Events.Count; i++)
            {
                if (Events[i].Receiver != null)
                {
                    Events[i].Receiver.OnUpdate(StateManager, this);
                }
            }

            for (int i = 0; i < runningThemesList.Count; i++)
            {
                if (runningThemesList[i].Loaded)
                {
                    runningThemesList[i].OnUpdate(StateManager.CurrentState().ActiveIndex, forceUpdate);
                }
            }

            if (lastState != StateManager.CurrentState())
            {
                for (int i = 0; i < handlers.Count; i++)
                {
                    if (handlers[i] != null)
                    {
                        handlers[i].OnStateChange(StateManager, this);
                    }
                }
            }

            if (forceUpdate)
            {
                forceUpdate = false;
            }

            if (IsDisabled == Enabled)
            {
                SetDisabled(!Enabled);
            }

            lastState = StateManager.CurrentState();
        }
        /// <summary>
        /// Called on update, check to see if the state has changed sense the last call
        /// </summary>
        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();
            }
        }
        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();
        }
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;

            float focusTime = source.gameObject.GetComponent <ButtonFocusTime>().GetFocusTime();

            //if button is focused for focusTime seconds, change button's focus state to be false
            if (hasFocus && focusTimer < focusTime)
            {
                focusTimer += Time.deltaTime;

                if (focusTimer >= focusTime)
                {
                    source.SetState(InteractableStates.InteractableStateEnum.Focus, false);
                }
            }
            else
            {
                focusTimer = 0;
            }


            bool changed = state.CurrentState() != lastState;

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

            hadFocus  = hasFocus;
            lastState = state.CurrentState();
        }
Beispiel #7
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();
        }
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hadTouch = state.GetState(InteractableStates.InteractableStateEnum.PhysicalTouch).Value > 0;

            if (this.hadTouch != hadTouch)
            {
                if (hadTouch)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnTouchEnd.Invoke();
                }
            }

            this.hadTouch = hadTouch;
            lastState     = state.CurrentState();
        }
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hasGrab = state.GetState(InteractableStates.InteractableStateEnum.Grab).Value > 0;

            if (hadGrab != hasGrab)
            {
                if (hasGrab)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnRelease.Invoke();
                }
            }

            hadGrab   = hasGrab;
            lastState = state.CurrentState();
        }
Beispiel #10
0
        private void InternalUpdate()
        {
            if (rollOffTimer < rollOffTime && HasPress)
            {
                rollOffTimer += Time.deltaTime;

                if (rollOffTimer >= rollOffTime)
                {
                    SetPress(false);
                }
            }

            for (int i = 0; i < Events.Count; i++)
            {
                if (Events[i].Receiver != null)
                {
                    Events[i].Receiver.OnUpdate(StateManager, this);
                }
            }

            for (int i = 0; i < runningThemesList.Count; i++)
            {
                if (runningThemesList[i].Loaded)
                {
                    runningThemesList[i].OnUpdate(StateManager.CurrentState().ActiveIndex, this, forceUpdate);
                }
            }

            if (lastState != StateManager.CurrentState())
            {
                for (int i = 0; i < handlers.Count; i++)
                {
                    if (handlers[i] != null)
                    {
                        handlers[i].OnStateChange(StateManager, this);
                    }
                }
            }

            if (forceUpdate)
            {
                forceUpdate = false;
            }

            if (IsDisabled == Enabled)
            {
                SetDisabled(!Enabled);
            }

            lastState = StateManager.CurrentState();

            if (isGlobalValueCheck != IsGlobal)
            {
                isGlobalValueCheck = IsGlobal;
                RegisterGlobalInputHandler(IsGlobal);
            }

            if (requiresFocusValueCheck != RequiresFocus)
            {
                requiresFocusValueCheck = RequiresFocus;
                RegisterGlobalSpeechHandler(!RequiresFocus);
            }
        }