Exemplo n.º 1
0
    //建造状态机
    private void MakeFSM()
    {
        InspectionState inspection = new InspectionState();

        inspection.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);
        inspection.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

        PatrolState follow = new PatrolState(transform.position, scope);

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

        ChasePlayerState chase = new ChasePlayerState();

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

        AttackPlayerState attack = new AttackPlayerState();

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

        fsm = new FsmSystem();
        fsm.AddState(inspection);//添加状态到状态机,第一个添加的状态将作为初始状态
        fsm.AddState(follow);
        fsm.AddState(chase);
        fsm.AddState(attack);
    }
Exemplo n.º 2
0
    private void MakeFSM()
    {
        FollowPathState follow = new FollowPathState(path);
        follow.AddTransition(Transition.SawPlayer, StateID.ChasePlayer);

        ChasePlayerState chase = new ChasePlayerState();
        chase.AddTransition(Transition.LostPlayer, StateID.FollowPath);
        chase.AddTransition(Transition.NearPlayer, StateID.AttackPlayer);

        AttackPlayerState attack = new AttackPlayerState();
        attack.AddTransition(Transition.SawPlayer, StateID.ChasePlayer);

        sm = new FSMSystem();
        sm.AddState(follow);
        sm.AddState(chase);
        sm.AddState(attack);
    }
Exemplo n.º 3
0
	private void MakeFSM()
	{
		StayStillState stay = new StayStillState();
		stay.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);
		
		ChasePlayerState chase = new ChasePlayerState();
		chase.AddTransition(Transition.LostPlayer, StateID.FindPlayer);
		chase.AddTransition(Transition.ReachPlayer, StateID.AttackPlayer);
		
		AttackPlayerState attack = new AttackPlayerState();
		attack.AddTransition(Transition.LostPlayer, StateID.ChasingPlayer);
		
		//StayStillState stay = new StayStillState();
		
		fsm = new FSMSystem();
		fsm.AddState(stay);
		fsm.AddState(chase);
		fsm.AddState(attack);
		//fsm.AddState(stay);
		fsm.SetCurrentState(stay);
	}