Exemplo 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>
        /// Calling this will enter the state machine's initial state(s)
        /// </summary>
        public virtual void StartSM()
        {
            FSMStateType stateType = FSMStateType.Type_OR;
            List<System.Type> children = new List<System.Type>();
            SetupDefinition(ref stateType, ref children);

            m_Logic = new FSMStateMachineLogic(stateType, children, this, null);
            m_Logic.Enter(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calling this will enter the state machine's initial state(s)
        /// </summary>
        public virtual void StartSM()
        {
            FSMStateType       stateType = FSMStateType.Type_OR;
            List <System.Type> children  = new List <System.Type>();

            SetupDefinition(ref stateType, ref children);

            m_Logic = new FSMStateMachineLogic(stateType, children, this, null);
            m_Logic.Enter(null);
        }
Exemplo n.º 4
0
 public void Enter(object[] args)
 {
     if (this.m_StateClass != null)
     {
         this.m_State = (BaseFSMState)Activator.CreateInstance(this.m_StateClass, args);
         this.m_State._InternalSetOwnerLogic(this);
         this.m_State.SetupDefinition(ref this.m_StateType, ref this.m_ChildrenTypes);
         this.m_State.Enter();
     }
     for (int i = 0; i < this.m_ChildrenTypes.Count; i++)
     {
         FSMStateMachineLogic fSMStateMachineLogic = new FSMStateMachineLogic(this.m_ChildrenTypes[i], this.m_OwnerSM, this);
         this.m_ChildSMs.Add(fSMStateMachineLogic);
         fSMStateMachineLogic.Enter(null);
         if (this.m_StateType == FSMStateType.Type_OR)
         {
             break;
         }
     }
 }
        /// <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
            }
        }