Esempio n. 1
0
 public void ChangeState(GenericState newState)
 {
     if (myState != newState)
     {
         myState = newState;
     }
 }
Esempio n. 2
0
 public bool ChangeCurrentState(string stateName)
 {
     if (currentState == null || currentState.stateName != stateName)
     {
         // Need to stop the update of the state!
         if (updateStateCoroutine != null)
         {
             StopCoroutine(updateStateCoroutine);
         }
         // the current state is still active, make it inactive and reset current state
         if (currentState != null)
         {
             currentState.resetState();
         }
         // We loop it because no time to code faster search for states
         foreach (GenericState state in m_AllGenericStates)
         {
             if (state.stateName == stateName)
             {
                 // then set the state and begin the update!
                 state.enabled        = true;
                 currentState         = state;
                 updateStateCoroutine = StartCoroutine(UpdatingStates());
                 break;
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
 /// <summary>
 /// 创建一个泛型参数
 /// </summary>
 /// <returns></returns>
 public virtual TBuilder WithCreate(string name)
 {
     _this      = new GenericState();
     _this.Name = name;
     _generic.Add(_this);
     return(_TBuilder);
 }
Esempio n. 4
0
 public void AddState(GenericState <TBase> state)
 {
     if (state == null || StateList.Contains(state))
     {
         return;
     }
     StateList.Add(state);
 }
Esempio n. 5
0
 public FirebaseWithCloudAnchorDb(FirebaseWrapper firebaseWrapper, CloudAnchorsWrapper cloudAnchorsWrapper, Logger logger)
 {
     this.firebaseWrapper     = firebaseWrapper;
     this.cloudAnchorsWrapper = cloudAnchorsWrapper;
     this.logger    = logger;
     this.observers = new List <IDatabaseObserver>();
     GenericState <FirebaseWithCloudAnchorDb> .InitState <SReady>(this);
 }
Esempio n. 6
0
        public void TransitState(GenericState <TBase> target) // 名前が微妙かも
        {
            if (target == null || !StateList.Contains(target))
            {
                return;
            }

            TransitTo(target);
        }
Esempio n. 7
0
 public void SetCurrentState(GenericState <TBase> state)
 {
     if (state == null || !StateList.Contains(state))
     {
         return;
     }
     CurrentState = state;
     Debug.Log(gameObject.name + "is now State: " + CurrentState.Name);
 }
Esempio n. 8
0
 public TouchDetector(PlaneTouchHandler planeTouchHandler, VirtualObjectTouchHandler virtualObjectTouchHandler,
                      ARRaycastManager arRaycastmanager, Logger logger)
 {
     this.planeTouchHandler         = planeTouchHandler;
     this.virtualObjectTouchHandler = virtualObjectTouchHandler;
     this.arRaycastmanager          = arRaycastmanager;
     this.logger            = logger;
     this.lastTouch         = null;
     this.lastTouchResolved = false;
     GenericState <TouchDetector> .InitState <SNoTouch>(this);
 }
Esempio n. 9
0
 private void ChangeState(StateTransition <Data> stateTransition)
 {
     if (!stateTransition.IsNull)
     {
         if (m_currentState != null)
         {
             m_currentState.ExitState();
         }
         m_currentState = GetCachedState(stateTransition.StateType);
         m_currentState.OpenState(stateTransition.StateData);
     }
 }
Esempio n. 10
0
 private GenericState <Data> GetCachedState(Type stateType)
 {
     if (m_statesCache.ContainsKey(stateType))
     {
         return(m_statesCache[stateType]);
     }
     else
     {
         GenericState <Data> newState = (GenericState <Data>)Activator.CreateInstance(stateType);
         m_statesCache.Add(stateType, newState);
         return(newState);
     }
 }
Esempio n. 11
0
 private void TransitTo(GenericState <TBase> target) // null検証はしてません.
 {
     lock (locker)
     {
         if (CurrentState.OnExit != null)
         {
             CurrentState.OnExit();
         }
         CurrentState = target;
         if (CurrentState.OnEnter != null)
         {
             CurrentState.OnEnter();
         }
     }
 }
Esempio n. 12
0
    /// <summary>
    /// The coroutine to update the state update!
    /// </summary>
    /// <returns></returns>
    IEnumerator UpdatingStates()
    {
        // because the state should update on their own!
        Coroutine stateCoroutine = currentState.StartCoroutine(currentState.updateState());

        yield return(stateCoroutine);

        // reset the value once the update is done!
        if (currentState)
        {
            currentState.resetState();
            currentState = null;
        }
        updateStateCoroutine = null;
        yield break;
    }
Esempio n. 13
0
        public void SetCurrentState(string stateName)
        {
            if (stateName == null)
            {
                return; // これがいるかは不明.
            }
            var targetState = StateList.Find(s => s.Name == stateName);

            if (targetState == null)
            {
                Debug.Log(stateName + "instance has not been \"new\"ed.");
                return;
            }

            CurrentState = targetState;
            Debug.Log(gameObject.name + "is set to State: " + CurrentState.Name);
        }
Esempio n. 14
0
 public void SetState <ConcreteContext>(GenericState <ConcreteContext> state) where ConcreteContext : IStateContext
 {
     this.databaseState = (DatabaseStateBase)(object)state;
 }
Esempio n. 15
0
 public GenericStateContex()
 {
     CurrentState = null;
 }
Esempio n. 16
0
 /// <summary>
 /// 结束一个泛型参数的设计
 /// </summary>
 /// <returns></returns>
 public virtual GenericTemplate <TBuilder> WithEnd()
 {
     _this = null;
     return(this);
 }
Esempio n. 17
0
 void SetState(GenericState newState)
 {
     myState.ChangeState(newState);
 }