Example #1
0
        public void MoveState(T _nextState)
        {
            if (!dicFun.ContainsKey(_nextState))
            {
                Debug.LogError("I don't know " + _nextState);
                return;
                //} else if (curState == _nextState) {
                //	return;
            }

            //state out is callback pInOut...
            if (cbOut != null)
            {
                cbOut();
            }

            //state
            preState  = gamestate;
            gamestate = _nextState;
            nextState = _nextState;

            //callback setting
            FSMData <T> _s = dicFun[gamestate];

            cbIn   = _s.cbIn;
            cbLoop = _s.cbLoop;
            cbOut  = _s.cbOut;

            //pIn start
            if (cbIn != null)
            {
                cbIn();
            }
        }
Example #2
0
 public void AddState(T _t, System.Action _cbIn, System.Action _cbLoop, System.Action _cbOut)
 {
     if (dicFun.ContainsKey(_t))
     {
         Debug.LogError("Already added state");
     }
     else
     {
         FSMData <T> _data = new FSMData <T> ();
         _data.t      = _t;
         _data.cbIn   = _cbIn;
         _data.cbLoop = _cbLoop;
         _data.cbOut  = _cbOut;
         dicFun.Add(_t, _data);
     }
 }