/// <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();
     }
 }
Example #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();
        }
Example #4
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>
        /// 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();
            }
        }
        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();
        }
Example #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();
        }