Ejemplo n.º 1
0
    private void MakeFSM()
    {
        mFSMSystem = new FSMSystem();

        FSMState standbyState = new StateStandby(mFSMSystem);

        ///standbyState StateID.StandbyState,转换条件分别为
        ///Transition.SeeEnemy
        standbyState.AddTransition(Transition.SeeEnemy, StateID.ChaseState);

        FSMState chaseState = new StateChase(mFSMSystem);

        ///由ChaseState状态可以转换到 StateID.StandbyState StateID.AttackState,转换条件分别为
        ///Transition.DonotSeeEnemy  Transition.EnemyInTheAttackRange
        chaseState.AddTransition(Transition.DonotSeeEnemy, StateID.StandbyState);
        chaseState.AddTransition(Transition.EnemyInTheAttackRange, StateID.AttackState);

        FSMState attackState = new StateAttack(mFSMSystem);

        ///由attackState状态可以转换到 StateID.StandbyState StateID.ChaseState,转换条件分别为
        ///Transition.DonotSeeEnemy  Transition.EnemyOutOfTheAttackRange
        attackState.AddTransition(Transition.DonotSeeEnemy, StateID.StandbyState);
        attackState.AddTransition(Transition.EnemyOutOfTheAttackRange, StateID.ChaseState);

        mFSMSystem.AddState(standbyState);
        mFSMSystem.AddState(chaseState);
        mFSMSystem.AddState(attackState);
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        statePursuePlayer = new StatePursuePlayer(this);
        stateStandby      = new StateStandby(this);

        agent = GetComponent <NavMeshAgent>();
    }