예제 #1
0
    //When entering the state, go through every actions initialise,OnExit and decision initialise
    public void onEnterState(DayFSM FSM)
    {
        Debug.Log(this);

        //Initialise the ForceStayInState if not null
        if (ForceStayInState)
        {
            ForceStayInState.Initialise(FSM);
        }

        //Go through all registered actions
        foreach (OnEnter onEnter in onEnters)
        {
            #region Warnings
            if (onEnter == null)
            {
                Debug.LogWarning("Carefull, you have setup an empty on enter !! check this state again : " + this);
            }
            #endregion

            onEnter.Act(FSM);
        }

        //Initialise Action State
        foreach (Action action in actions)
        {
            #region Warnings
            if (action == null)
            {
                Debug.LogWarning("Carefull, you have setup an empty action !! check this state again : " + this);
            }
            #endregion
            if (action != null)
            {
                action.Initialise(FSM);
            }
        }

        //Initialise Decision State
        foreach (Transition transition in transitions)
        {
            transition.decision.Initialise(FSM);
            //Debug.Log("On Enter");
        }
    }