Exemplo n.º 1
0
    private void Start()
    {
        _fsmSystem = new FSMSystem();

        IFSMState stateA = new StateA(_fsmSystem);

        IFSMState stateB = new StateB();

        IFSMState stateC = new StateC(_fsmSystem);

        stateA[(int)State.B] = stateB;

        stateA[(int)State.C] = stateC;

        stateB[(int)State.C] = stateC;

        stateC[(int)State.A] = stateA;

        stateC[(int)State.B] = stateB;

        _fsmSystem.AddState(stateA, true);

        _fsmSystem.AddState(stateB);

        _fsmSystem.AddState(stateC);
    }
Exemplo n.º 2
0
        /// <summary>
        /// 构建有限状态机
        /// </summary>
        private void GenerateFSM()
        {
            _fsmSystem = new FSMSystem();

            IFSMState defaultState = new FaceRecDefaultState(_fsmSystem, _viewModel);

            IFSMState detectState = new FaceDetectState(_fsmSystem, _viewModel);

            IFSMState analyzeState = new FaceAnalyzeState(_fsmSystem, _viewModel);

            _fsmSystem.AddState(defaultState, true);

            _fsmSystem.AddState(detectState);

            _fsmSystem.AddState(analyzeState);

            defaultState[(int)UIFaceRecTransition.Detect] = detectState;

            detectState[(int)UIFaceRecTransition.Default] = defaultState;

            detectState[(int)UIFaceRecTransition.Analyze] = analyzeState;

            analyzeState[(int)UIFaceRecTransition.Default] = defaultState;
        }