Пример #1
0
 public void Update()
 {
     if (null != this.finiteStateEntity.state && false == this.finiteStateEntity.state.complete)
     {
         if (this.finiteStateEntity.isNewState)
         {
             if (null != this.paramter)
             {
                 this.finiteStateEntity.state.Create(this.paramter);
             }
             else
             {
                 this.finiteStateEntity.state.Create();
             }
             this.finiteStateEntity.isNewState = false;
         }
         if (null != this.finiteStateEntity.state && false == this.finiteStateEntity.state.complete && false == this.finiteStateEntity.state.wait)
         {
             this.finiteStateEntity.state.Update();
         }
     }
     foreach (string key in this.persistentStateList.Keys)
     {
         FiniteState <T> state = this.persistentStateList [key];
         if (false == state.complete)
         {
             state.Update();
         }
     }
 }
Пример #2
0
 public void Update(string nextStateName, FiniteState <T> nextState)
 {
     if (false == this.currentStateName.Equals(nextStateName))
     {
         this.previousStateName = this.currentStateName;
         this.currentStateName  = nextStateName;
     }
     this.state      = nextState;
     this.isNewState = true;
 }
Пример #3
0
 public void Play()
 {
     foreach (string key in this.stateList.Keys)
     {
         FiniteState <T> state = this.stateList [key];
         state.wait     = false;
         state.complete = false;
     }
     foreach (string key in this.persistentStateList.Keys)
     {
         FiniteState <T> state = this.persistentStateList [key];
         state.wait     = false;
         state.complete = false;
         state.Create();
     }
 }
Пример #4
0
        public void Change(string newStateName, Parameter paramter, bool update = false)
        {
            this.paramter = paramter;
            FiniteState <T> nextState = this.Get(newStateName);

            if (null == nextState)
            {
                return;
            }
            this.finiteStateEntity.Update(newStateName, nextState);
            if (false != update)
            {
                this.Update();
            }
            return;
        }
Пример #5
0
 public bool Add(string stateName, FiniteState <T> state, bool isFirstState = false)
 {
     if (false == state.persistent)
     {
         if (false == this.stateList.ContainsKey(stateName))
         {
             state.owner        = this.owner;
             state.stateMachine = this;
             this.stateList.Add(stateName, state);
             return(true);
         }
     }
     else
     {
         if (false == this.persistentStateList.ContainsKey(stateName))
         {
             state.owner        = this.owner;
             state.stateMachine = this;
             this.persistentStateList.Add(stateName, state);
             return(true);
         }
     }
     return(false);
 }