Ejemplo n.º 1
0
        /// <summary>
        /// Enters the specified state. It will also enter all necessary children state.
        /// </summary>
        /// <param name="args"> The arguments passed in the transition. The state's constructor will be chosen to match the arguments specified.
        /// If args is null, the default constructor will be used.</param>
        public void Enter(object[] args)
        {
            // create an instance of the actual state
            // call enter on it

            if (m_StateClass != null)
            {
                m_State = (BaseFSMState)System.Activator.CreateInstance(m_StateClass, args);
                m_State._InternalSetOwnerLogic(this);
                m_State.SetupDefinition(ref m_StateType, ref m_ChildrenTypes);
                m_State.Enter();
            }

            // create an instance of the necessary child state machines
            // call enter on them


            for (int i = 0; i < m_ChildrenTypes.Count; i++)
            {
                FSMStateMachineLogic childSM = new FSMStateMachineLogic(m_ChildrenTypes[i], m_OwnerSM, this);
                m_ChildSMs.Add(childSM);
                childSM.Enter(null);
                if (m_StateType == FSMStateType.Type_OR)
                {
                    // just add the first child and exit
                    break;
                }
                // else add all the children
            }
        }
        /// <summary>
        /// Enters the specified state. It will also enter all necessary children state.
        /// </summary>
        /// <param name="args"> The arguments passed in the transition. The state's constructor will be chosen to match the arguments specified.
        /// If args is null, the default constructor will be used.</param>
        public void Enter(object[] args)
        {
            // create an instance of the actual state
            // call enter on it

            if (m_StateClass != null)
            {
                m_State = (BaseFSMState)System.Activator.CreateInstance(m_StateClass, args);
                m_State._InternalSetOwnerLogic(this);
                m_State.SetupDefinition(ref m_StateType, ref m_ChildrenTypes);
                m_State.Enter();
            }

            // create an instance of the necessary child state machines
            // call enter on them


            for (int i = 0; i < m_ChildrenTypes.Count; i++)
            {
                FSMStateMachineLogic childSM = new FSMStateMachineLogic(m_ChildrenTypes[i], m_OwnerSM, this);
                m_ChildSMs.Add(childSM);
                childSM.Enter(null);
                if (m_StateType == FSMStateType.Type_OR)
                {
                    // just add the first child and exit
                    break;
                }
                // else add all the children
            }
        }