예제 #1
0
파일: Program.cs 프로젝트: AciesNN/FSM
    static void Main(string[] args)
    {
        BaseFSM.FSM <StatesID> fsm = new BaseFSM.FSM <StatesID>("Main");

        /*************/

        //Main
        SwitchState stateOne = new SwitchState(StatesID.ONE)
        {
            isStart = true
        };

        stateOne.DefaultExit()
        .AddExitTransition(fsm, StatesID.FOUR);
        stateOne.AddTestExit(() => condition)
        .AddExitTransition(fsm, StatesID.TWO);

        SwitchState stateTwo = new SwitchState(StatesID.TWO);

        stateTwo.DefaultExit()
        .AddExitTransition(fsm, StatesID.FOUR);
        stateTwo.AddTestExit(() => condition)
        .AddExitTransition(fsm, StatesID.THREE);

        StableState stateThree = new StableState(StatesID.THREE);

        stateThree.AddAction("DoA", (o) => !condition, (o) => System.Console.WriteLine("action a"))
        .AddExitTransition(fsm, StatesID.ONE);
        stateThree.AddAction("DoB", (o) => condition, (o) => System.Console.WriteLine("action b"))
        .AddExitTransition(fsm, StatesID.FOUR);

        StateWithFSM stateFour = new StateWithFSM(StatesID.FOUR);

        stateFour.SubFSMExit()
        .AddExitTransition(fsm, StatesID.THREE);

        /////////////

        BaseFSM.Cursor <StatesID> cursor = fsm.GetCursor();
        System.Console.WriteLine(cursor);

        fsm.Start();
        System.Console.WriteLine(cursor);

        if (cursor.curState.id == StatesID.THREE)
        {
            cursor.DoAction("DoA");
        }
        System.Console.WriteLine(cursor);

        if (cursor.curState.id == StatesID.SUB_ONE)
        {
            cursor.DoAction("DoSubA");
        }
        System.Console.WriteLine(cursor);
    }
예제 #2
0
파일: Program.cs 프로젝트: AciesNN/FSM
    public override void LoadFSM()
    {
        BaseFSM.FSM <StatesID> subFsm = new BaseFSM.FSM <StatesID>("Sub");
        subFsm.OnFinish += (x, y) => { System.Console.WriteLine("*** subFSM onFinish()"); };

        SetSubFSM(subFsm);

        StableState stateSubOne = new StableState(StatesID.SUB_ONE)
        {
            isStart = true
        };

        stateSubOne.AddAction("DoSubA", (o) => true, (o) => System.Console.WriteLine("sub action a"))
        .AddExitTransition(subFsm, StatesID.SUB_TWO);

        SwitchState stateSubTwo = new SwitchState(StatesID.SUB_TWO)
        {
            isFinish = true
        };

        subFsm.AddState(stateSubTwo);
    }
예제 #3
0
        FSM <STATE_ID> fsm;        //todo убрать! есть в стеке

        public Cursor(FSM <STATE_ID> fsm)
        {
            this.fsm = fsm;
            SetCursor();
        }
예제 #4
0
 public void AddExitTransition(FSM <STATE_ID> fsm, STATE_ID nextState)
 {
     fsm.AddStateExit(state, exitId, nextState);
 }
예제 #5
0
파일: StateWithFSM.cs 프로젝트: AciesNN/FSM
 public void OnSubFSMFinish(FSM <STATE_ID> fsm, STATE_ID state_id)
 {
     subFsm.OnFinish -= OnSubFSMFinish;
     DoExitState(subFSMExitID);
 }
예제 #6
0
파일: StateWithFSM.cs 프로젝트: AciesNN/FSM
 public void SetSubFSM(FSM <STATE_ID> subFsm)
 {
     this.subFsm      = subFsm;
     subFsm.OnFinish += OnSubFSMFinish;
 }