private void InitializeFSM()
    {
        ZombieChaseState chase = new ZombieChaseState();

        chase.AddTransition(Transition.PlayerLost, StateID.Idling);
        chase.AddTransition(Transition.PlayerReached, StateID.Attacking);
        chase.AddTransition(Transition.NoHealth, StateID.Dead);

        ZombieIdleState idle = new ZombieIdleState();

        idle.AddTransition(Transition.PlayerSpotted, StateID.Chasing);
        idle.AddTransition(Transition.PlayerHeard, StateID.Alert);
        idle.AddTransition(Transition.NoHealth, StateID.Dead);

        ZombieAttackingState attack = new ZombieAttackingState();

        attack.AddTransition(Transition.PlayerOutOfRange, StateID.Chasing);
        attack.AddTransition(Transition.NoHealth, StateID.Dead);

        ZombieAlertState alert = new ZombieAlertState();

        alert.AddTransition(Transition.PlayerLost, StateID.Idling);
        alert.AddTransition(Transition.PlayerSpotted, StateID.Chasing);
        alert.AddTransition(Transition.NoHealth, StateID.Dead);

        ZombieDeadState dead = new ZombieDeadState();

        AddState(attack);
        AddState(chase);
        AddState(idle);
        AddState(alert);
        AddState(dead);
    }
예제 #2
0
    public void Initialize(GameObject followTarget)
    {
        FollowTarget = followTarget;

        ZombieIdleState idleState = new ZombieIdleState(this, StateMachine);

        StateMachine.AddState(ZombieStateType.Idle, idleState);

        ZombieFollowState followState = new ZombieFollowState(FollowTarget, this, StateMachine);

        StateMachine.AddState(ZombieStateType.Follow, followState);

        ZombieAttackState attackState = new ZombieAttackState(FollowTarget, this, StateMachine);

        StateMachine.AddState(ZombieStateType.Attack, attackState);


        ZombieDeadState deadState = new ZombieDeadState(this, StateMachine);

        StateMachine.AddState(ZombieStateType.Dead, deadState);


        //StateMachine.Intialize(ZombieStateType.Idle);
        //StateMachine.Intialize(ZombieStateType.Follow);
        //StateMachine.Intialize(ZombieStateType.Attack);
        StateMachine.Intialize(ZombieStateType.Dead);
    }