示例#1
0
        // The NPC has two states: FollowPath and ChasePlayer
        // If it's on the first state and SawPlayer transition is fired, it changes to ChasePlayer
        // If it's on ChasePlayerState and LostPlayer transition is fired, it returns to FollowPath
        private void MakeFSM()
        {
            FollowPathState follow = new FollowPathState("path1");

            follow.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);

            ChasePlayerState chase = new ChasePlayerState();

            chase.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

            fsm = new FSMSystem();
            fsm.AddState(follow);
            fsm.AddState(chase);
        }
        // The NPC has two states: FollowPath and ChasePlayer
        // If it's on the first state and SawPlayer transition is fired, it changes to ChasePlayer
        // If it's on ChasePlayerState and LostPlayer transition is fired, it returns to FollowPath
        private void MakeFSM()
        {
            FollowPathState follow = new FollowPathState("path1");
            follow.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);

            ChasePlayerState chase = new ChasePlayerState();
            chase.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

            fsm = new FSMSystem();
            fsm.AddState(follow);
            fsm.AddState(chase);
        }