示例#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);
    }
示例#2
0
    new void Start()
    {
        playerTransform = GameObject.FindGameObjectWithTag("Player").transform;

        var patrolState = new BasePatrolState(this);

        ChasePlayerStateModel chasePlayerStateModel = new ChasePlayerStateModel
        {
            playerTransform = playerTransform
        };
        var chasePlayerState = new ChasePlayerState(this, chasePlayerStateModel);

        AttackStateModel attackStateModel = new AttackStateModel
        {
            transform      = swordAttackPosition,
            range          = attackRange,
            delay          = attackDelay,
            damage         = attackDamage,
            onAttackStrike = onAttackStrike,
            attackSound    = attackSound
        };

        var attackState = new BaseAttackState(this, attackStateModel);

        stateMachine.AddTransition(patrolState, chasePlayerState, PlayerInAggroRange);
        stateMachine.AddAnyTransition(attackState, PlayerInAttackRange);
        stateMachine.AddAnyTransition(patrolState, () => !PlayerInAggroRange());
        stateMachine.AddTransition(attackState, chasePlayerState, () => !PlayerInAttackRange());

        stateMachine.SetState(patrolState);
    }
示例#3
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(/*path*/);

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

        ChasePlayerState chase = new ChasePlayerState();

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

        PatrolState patrolState = new PatrolState(PatrolWayPoints);

        patrolState.AddTransition(Transition.Alert, StateID.AlertNpc);

        AlertState alertState = new AlertState();

        alertState.AddTransition(Transition.Attack, StateID.AttackingPlayer);
        alertState.AddTransition(Transition.Patrol, StateID.Patroling);

        AttackState attackState = new AttackState();

        attackState.AddTransition(Transition.Alert, StateID.AlertNpc);


        fsm = new FSMSystem();
        fsm.AddState(patrolState);
        fsm.AddState(alertState);
        fsm.AddState(attackState);
        //fsm.AddState(chase);
        //fsm.AddState(follow);

        Debug.Log("First State: " + fsm.CurrentState.ToString());
    }
示例#4
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(path);
        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(path);
        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);
    }
    void MakeFSM()
    {
        FollowPathState state1 = new FollowPathState (path);
        state1.AddTransition (Transition.SawPlayer, StateID.ChasingPlayer);

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

        fsm = new FSMSystem ();
        fsm.AddState (state1);
        fsm.AddState (state2);
    }
示例#7
0
文件: NPCControl.cs 项目: sora929/TSC
    //NPC有两个状态分别是在路径中巡逻和追逐玩家
    //如果他在第一个状态并且SawPlayer 过度状态被出发了,它就转变到ChasePlayer状态
    //如果他在ChasePlayer状态并且LostPlayer状态被触发了,它就转变到FollowPath状态

    private void MakeFSM()//建造状态机
    {
        FollowPathState follow = new FollowPathState(path);

        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);
    }
示例#8
0
    private void MakeFSM()
    {
        FollowPathState follow = new FollowPathState(playerCharacterParameters.retreatRadius);

        follow.AddTransition(Transition.SawEnemy, StateID.ChasingEnemy);

        ChasePlayerState chase = new ChasePlayerState(playerCharacterParameters.retreatRadius);

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

        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
示例#9
0
    void MakeFSM()
    {
        FollowPathState state1 = new FollowPathState(path);

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

        ChasePlayerState state2 = new ChasePlayerState();

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

        fsm = new FSMSystem();
        fsm.AddState(state1);
        fsm.AddState(state2);
    }
示例#10
0
    private void MakeFSM()
    {
        //巡逻状态
        FollowPathState follow = new FollowPathState(path);

        follow.AddTransition(zhuangtaiji.Transition.sawPlayer, zhuangtaiji.StateID.ChasingPlayer);
        //追逐状态
        ChasePlayerState chase = new ChasePlayerState();

        chase.AddTransition(zhuangtaiji.Transition.lostPlayer, zhuangtaiji.StateID.FollowingPath);
        //初始化状态机
        fsm = new zhuangtaiji.FSMSystem(gameObject.transform, follow.wayPoints[follow.currentWayPoint]);
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
示例#11
0
文件: DumbAI.cs 项目: atxkirl/FYPJ2
    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);
    }
示例#12
0
    public void MakeFSM()
    {
        //List<Node> tempPath = GetComponent<FindPath>().GetFinalPath(this.gameObject, target);
        List <Node> tempPath = myAxing.GetFinalPath(this.gameObject, target);

        follow = new FollowPathState();
        follow.SetWayPoints(tempPath);
        follow.AddTransition(Transition.SeePlayerTrans, StateID.ChaseingplayerId);

        chase = new ChasePlayerState();
        chase.AddTransition(Transition.LosePlayerTrans, StateID.FollowPathId);

        fsm = new FSM_Manager();
        fsm.AddFsmState(follow);
        fsm.AddFsmState(chase);

        //SetTransition(Transition.LosePlayerTrans);
    }
示例#13
0
    private void MakeFSM()
    {
        //TODO: Create two states (PatrolState and ChasePlayerState), using the constructors defined below.
        //   Add one transition to each state (so each state can transit to the other), using the function FSMState.AddTransition
        //   Add both states to the FSM at the end of this method

        PatrolState patrol = new PatrolState(gameObject, wp);

        patrol.AddTransition(Transition.SawPlayer, StateID.ChasingPlayerID);
        ChasePlayerState chase = new ChasePlayerState(gameObject, player);

        chase.AddTransition(Transition.LostPlayer, StateID.PatrollingID);
        chase.AddTransition(Transition.Dead, StateID.DeathID);
        DeathState death = new DeathState(gameObject);

        fsm = new FSMSystem();
        fsm.AddState(patrol);
        fsm.AddState(chase);
        fsm.AddState(death);
    }
示例#14
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);
	}
示例#15
0
    //Finite State Machine Setup
    public void SetupFSM()
    {
        FollowPathState followState = new FollowPathState();

        followState.SetAgentHandler(this);
        followState.AddTransitionToState(fsmTransition.ToChase, fsmStateID.ChasePlayer);
        followState.AddTransitionToState(fsmTransition.ToAttack, fsmStateID.AttackPlayer);

        AttackState attackState = new AttackState();

        attackState.AddTransitionToState(fsmTransition.ToLostPlayer, fsmStateID.FollowPath);
        attackState.AddTransitionToState(fsmTransition.ToChase, fsmStateID.ChasePlayer);

        ChasePlayerState chaseState = new ChasePlayerState();

        chaseState.AddTransitionToState(fsmTransition.ToLostPlayer, fsmStateID.FollowPath);
        chaseState.AddTransitionToState(fsmTransition.ToAttack, fsmStateID.AttackPlayer);

        mBasicAgentFSM = new FiniteStateMachine();
        mBasicAgentFSM.AddState(attackState);
        mBasicAgentFSM.AddState(followState);
        mBasicAgentFSM.AddState(chaseState);
    }
    // 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()
    {
        ChasePlayerState chase = new ChasePlayerState();
        chase.AddTransition(Transition.LostPlayer, StateID.FollowingPath);

        Vector3[] path = new Vector3[waypoint[0].childCount];
        for (int i = 0; i < waypoint[0].childCount; i++)
        {
            path[i] = waypoint[0].GetChild(i).position;
        }
        FollowPathState follow = new FollowPathState(path);
        follow.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);

        fsm = new FSMSystem();
        fsm.AddState(follow);
        fsm.AddState(chase);
    }
示例#17
0
 public UnStunTransition(Enemy en)
 {
     enemy     = en;
     nextState = new ChasePlayerState();
 }
示例#18
0
 public WakeUpAlertTransition(Enemy theEnemy)
 {
     enemy     = theEnemy;
     nextState = new ChasePlayerState();
 }
示例#19
0
 public HaveAttackedTransition(Enemy e)
 {
     nextState = new ChasePlayerState();
     enemy     = e;
 }
示例#20
0
 public SeePlayerTransition(Enemy theEnemy)
 {
     enemy     = theEnemy;
     nextState = new ChasePlayerState();
 }