Beispiel #1
0
    private void MakeFSM()
    {
        MovementState movement = new MovementState(path);

        movement.AddTransition(Transition.NearNPC, StateID.TrackNPC);
        movement.AddTransition(Transition.AngryNPC, StateID.AggroNPC);


        PlayerNearState track = new PlayerNearState();

        track.AddTransition(Transition.RoamNPC, StateID.MovementNPC);
        track.AddTransition(Transition.InteractNPC, StateID.InteractionNPC);
        track.AddDialogue(NPCDialogue);

        InteractionState interact = new InteractionState();

        interact.AddTransition(Transition.NearNPC, StateID.TrackNPC);

        AggroState aggro = new AggroState();

        aggro.AddTransition(Transition.RoamNPC, StateID.MovementNPC);
        aggro.AddTransition(Transition.AttackNPC, StateID.DamageNPC);

        AttackState attack = new AttackState();

        attack.AddTransition(Transition.AngryNPC, StateID.AggroNPC);


        sm = new FSMSystem();
        sm.AddState(movement);
        sm.AddState(track);
        sm.AddState(interact);
        sm.AddState(aggro);
        sm.AddState(attack);
    }
Beispiel #2
0
        /// <summary>
        /// creates a movement state based on this data, for the state machine
        /// </summary>
        /// <param name="machineFor">the machine that is gonna contain this state</param>
        /// <returns>the created state</returns>
        public MovementState Create(MovementStateMachine machineFor)
        {
            MovementState state = new MovementState(id, name, machineFor);

            state.IsInitialState = isInitial;

            state.Initialize(allowedMovements, requestPriorities);

            for (int i = 0; i < dataTransitions.Count; i++)
            {
                state.AddTransition(dataTransitions[i].Create(machineFor));
            }

            return(state);
        }