Ejemplo n.º 1
0
        //协程初始化流程,如果不等待一帧,进入ProcedureLaunch时,初始化辅助器的操作还未完成
        private IEnumerator InitProcedures(ProcedureBase[] procedures, ProcedureBase entranceProcedure)
        {
            m_ProcedureManager.Initialize(GameFrameworkEntry.GetModule <IFsmManager>(), procedures);    //初始化流程管理器
            yield return(UnityExtension.waitOneFrame);

            m_ProcedureManager.StartProcedure(entranceProcedure.GetType());   //开始入口流程
        }
Ejemplo n.º 2
0
        internal void StartProcedure()
        {
            if (m_FirstProcedure == null)
            {
                throw new GameFrameworkException("First procedure is invalid.");
            }

            m_ProcedureManager.StartProcedure(m_FirstProcedure.GetType());
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        public ProcedureComponent()
        {
            m_ProcedureManager = GameFrameworkEntry.GetModule <IProcedureManager>();
            if (m_ProcedureManager == null)
            {
                Log.Fatal("Procedure manager is invalid.");
                return;
            }

            //初始化  所有的流程
            List <ProcedureBase> procedures = new List <ProcedureBase>();

            Type[] types = GameEntry.HotfixTypes;
            foreach (var item in types)
            {
                if (item.IsAbstract)
                {
                    continue;
                }
                object[] objs = item.GetCustomAttributes(typeof(GfProcedureAttribute), false);
                if (objs.Length == 0)
                {
                    continue;
                }
                Debug.Log("创建物体:" + objs[0] + "----" + item.FullName);
                GfProcedureAttribute obj = (GfProcedureAttribute)objs[0];
                if (obj.ProceType == ProcedureType.Ignore)
                {
                    continue;
                }
                ProcedureBase procedure = (ProcedureBase)Activator.CreateInstance(item);
                if (procedure != null)
                {
                    procedures.Add(procedure);
                    if (obj.ProceType == ProcedureType.Start)
                    {
                        m_EntranceProcedure = procedure;
                    }
                }
                else
                {
                    Log.Error("流程没有继承:ProcedureBase----" + item);
                }
            }
            Debug.Log("初始流程Type:" + m_EntranceProcedure.GetType().FullName);
            m_ProcedureManager.Initialize(GameFrameworkEntry.GetModule <IFsmManager>(), procedures.ToArray());
            // 开始流程
            m_ProcedureManager.StartProcedure(m_EntranceProcedure.GetType());

            //   WaitToRunProcedure();
        }
Ejemplo n.º 4
0
        private IEnumerator Start()
        {
            ProcedureBase[] procedures = new ProcedureBase[m_AvailableProcedureTypeNames.Length];
            for (int i = 0; i < m_AvailableProcedureTypeNames.Length; i++)
            {
                Type procedureType = Utility.Assembly.GetTypeWithinLoadedAssemblies(m_AvailableProcedureTypeNames[i]);
                if (procedureType == null)
                {
                    Log.Error("Can not find procedure type '{0}'.", m_AvailableProcedureTypeNames[i]);
                    yield break;
                }

                procedures[i] = (ProcedureBase)Activator.CreateInstance(procedureType);
                if (procedures[i] == null)
                {
                    Log.Error("Can not create procedure instance '{0}'.", m_AvailableProcedureTypeNames[i]);
                    yield break;
                }

                if (m_EntranceProcedureTypeName == m_AvailableProcedureTypeNames[i])
                {
                    m_EntranceProcedure = procedures[i];
                }
            }


            if (m_EntranceProcedure == null)
            {
                Log.Error("Entrance procedure is invalid.");
                yield break;
            }

            m_ProcedureManager.Initialize(GameFrameworkEntry.GetModule <IFsmManager>(), procedures);

            yield return(new WaitForEndOfFrame());

            m_ProcedureManager.StartProcedure(m_EntranceProcedure.GetType());
        }