Exemplo n.º 1
0
 private void Start()
 {
     if (gameStart != null)
     {
         gameStart.Start();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 启动本地代码
        /// </summary>
        public void LaunchLocal()
        {
            //寻找iGamestart
            foreach (var t in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (t.IsClass && t.GetInterface("IGameStart") != null)
                {
                    var attr = (GameStartAtrribute)t.GetCustomAttribute(typeof(GameStartAtrribute), false);
                    if (attr != null && attr.Index == 0)
                    {
                        mainStart = Activator.CreateInstance(t) as IGameStart;
                        //注册
                        mainStart.Start();

                        break;
                    }
                }
            }

            //类型注册
            List <Type> types = new List <Type>();

            types.AddRange(typeof(Button).Assembly.GetTypes());
            types.AddRange(typeof(IButton).Assembly.GetTypes());
            var uitype = typeof(UIBehaviour);

            foreach (var t in types)
            {
                //注册所有uiComponent
                if (t.IsSubclassOf(uitype))
                {
                    ILRuntimeHelper.UIComponentTypes[t.FullName] = t;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 启动本地代码
        /// </summary>
        public void LaunchLocal()
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();


            foreach (var t in types)
            {
                if (t.IsClass && t.GetInterface("IGameStart") != null)
                {
                    var attr = t.GetCustomAttribute(typeof(GameStartAtrribute), false);
                    if (attr != null)
                    {
                        mainStart = Activator.CreateInstance(t) as IGameStart;
                        //注册
                        mainStart.Start();
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 启动本地代码
        /// </summary>
        public void LaunchLocal()
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();


            foreach (var t in types)
            {
                if (t.IsClass && t.GetInterface("IGameStart") != null)
                {
                    var attr = (GameStartAtrribute)t.GetCustomAttribute(typeof(GameStartAtrribute), false);
                    if (attr != null && attr.Index == 0)
                    {
                        mainStart = Activator.CreateInstance(t) as IGameStart;
                        //注册
                        mainStart.Start();

                        break;
                    }
                }
            }

            #if UNITY_EDITOR
            if (Config.CodeRoot == AssetLoadPath.Editor)
            {
                foreach (var t in types)
                {
                    if (t.IsClass && t.GetInterface("IGameStart") != null)
                    {
                        var attr = (GameStartAtrribute)t.GetCustomAttribute(typeof(GameStartAtrribute), false);
                        if (attr != null && attr.Index == 1)
                        {
                            mainStart = Activator.CreateInstance(t) as IGameStart;
                            //注册
                            mainStart.Start();

                            break;
                        }
                    }
                }
            }
            #endif
        }
Exemplo n.º 5
0
    /// <summary>
    /// 这里注册整个游戏类型
    /// </summary>
    /// <param name="isILRMode"></param>
    static public void Start(bool isILRMode = false, bool isRefMode = false)
    {
        BDebug.Log("解释执行:" + isILRMode, "yellow");
        //组件加载
        List <Type> allTypes = new List <Type>();

        //编辑器环境下 寻找dll
        if (isILRMode)
        {
            var values = ILRuntimeHelper.AppDomain.LoadedTypes.Values.ToList();
            foreach (var v in values)
            {
                allTypes.Add(v.ReflectionType);
            }
        }
        else
        {
            //获取DLL ALLtype
            var assembly = Assembly.GetAssembly(typeof(BDLauncherBridge));
            if (assembly == null)
            {
                Debug.Log("当前dll is null");
            }

            allTypes = assembly.GetTypes().ToList();
        }

        //
        var mgrs = new List <IMgr>();

        var gsaType = typeof(GameStartAtrribute);

        //寻找所有的管理器
        allTypes = allTypes.Distinct().ToList();
        foreach (var t in allTypes)
        {
            if (t != null &&
                t.BaseType != null &&
                t.BaseType.FullName != null &&
                t.BaseType.FullName.Contains(".ManagerBase`2"))
            {
                BDebug.Log("加载管理器-" + t, "green");
                var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as IMgr;
                mgrs.Add(i);
                continue;
            }

            //游戏启动器
            //这里主要寻找
            if ((isILRMode || isRefMode) && hotfixStart == null)
            {
                var attrs = t.GetCustomAttributes(gsaType, false);
                if (attrs.Length > 0 && attrs[0] is GameStartAtrribute)
                {
                    hotfixStart = Activator.CreateInstance(t) as IGameStart;
                    BDebug.Log("找到hotfix启动器 :" + t.FullName, "red");
                }
            }
        }



        //类型注册
        foreach (var t in allTypes)
        {
            foreach (var iMgr in mgrs)
            {
                iMgr.CheckType(t);
            }
        }

        //管理器初始化
        foreach (var m in mgrs)
        {
            m.Init();
        }

        //game生命注册
        if (hotfixStart != null)
        {
            hotfixStart.Start();
            BDLauncher.OnUpdate     = hotfixStart.Update;
            BDLauncher.OnLateUpdate = hotfixStart.LateUpdate;
        }

        //所有管理器开始工作
        foreach (var m in mgrs)
        {
            m.Start();
        }

        BDebug.Log("管理器开始工作!");
    }
Exemplo n.º 6
0
    /// <summary>
    /// 这里注册整个游戏类型
    /// </summary>
    /// <param name="isILRMode"></param>
    static public void Start(bool isILRMode = false, bool isRefMode = false)
    {
        BDebug.Log("解释执行:" + isILRMode, "yellow");
        //组件加载
        List <Type> allTypes = new List <Type>();

        //编辑器环境下 寻找dll
        if (isILRMode)
        {
            allTypes = ILRuntimeHelper.GetHotfixTypes();
        }
        else
        {
            //获取DLL ALLtype
            var assembly = Assembly.GetAssembly(typeof(BDLauncherBridge));
            if (assembly == null)
            {
                Debug.Log("当前dll is null");
            }

            allTypes = assembly.GetTypes().ToList();
        }

        //
        var mgrs = new List <IMgr>();

        var gsaType = typeof(GameStartAtrribute);

        //寻找所有的管理器
        allTypes = allTypes.Distinct().ToList();
        foreach (var t in allTypes)
        {
            if (t != null &&
                t.BaseType != null &&
                t.BaseType.FullName != null &&
                t.BaseType.FullName.Contains(".ManagerBase`2"))
            {
                BDebug.Log("加载管理器-" + t, "green");
                var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as IMgr;
                mgrs.Add(i);
                continue;
            }

            //游戏启动器
            //这里主要寻找
            if (hotfixStart == null)
            {
                var attrs = t.GetCustomAttributes(gsaType, false);
                if (attrs.Length > 0 &&
                    attrs[0] is GameStartAtrribute &&
                    ((GameStartAtrribute)attrs[0]).Index == 1)
                {
                    hotfixStart = Activator.CreateInstance(t) as IGameStart;
                }
            }
        }



        //类型注册
        foreach (var t in allTypes)
        {
            foreach (var iMgr in mgrs)
            {
                iMgr.CheckType(t);
            }
        }

        //管理器初始化
        foreach (var m in mgrs)
        {
            m.Init();
        }

        //gamestart生命注册
        if (hotfixStart != null)
        {
            hotfixStart.Start();
            BDLauncher.OnUpdate     = hotfixStart.Update;
            BDLauncher.OnLateUpdate = hotfixStart.LateUpdate;
        }
        //执行框架初始化完成的测试
        BDLauncher.OnBDFrameInitialized?.Invoke();
        BDLauncher.OnBDFrameInitializedForTest?.Invoke();
        //所有管理器开始工作
        foreach (var m in mgrs)
        {
            m.Start();
        }


        IEnumeratorTool.WaitingForExec(5, () =>
        {
            //执行单元测试
            if (Config.Inst.Data.IsExcuteHotfixUnitTest && ILRuntimeHelper.IsRunning)
            {
                ILRuntimeTestRunner.RunHotfixUnitTest();
            }
        });
    }
Exemplo n.º 7
0
    /// <summary>
    /// 这里注册整个游戏类型
    /// </summary>
    /// <param name="isILRMode"></param>
    static public void Start(bool isILRMode = false)
    {
        BDebug.Log("解释执行:" + isILRMode, "yellow");
        //组件加载
        List <Type> allTypes = new List <Type>();

        //编辑器环境下 寻找dll
        if (isILRMode == false)
        {
            //当framework 是dll形式时候需要先获取当前dll里面的所有type
            var assembly = Assembly.GetAssembly(typeof(BDLauncherBridge));
            if (assembly == null)
            {
                Debug.Log("当前dll is null");
            }
            allTypes = assembly.GetTypes().ToList();
        }
        else
        {
            var values = ILRuntimeHelper.AppDomain.LoadedTypes.Values.ToList();
            foreach (var v in values)
            {
                allTypes.Add(v.ReflectionType);
            }
        }

        //
        var mgrs = new List <IMgr>();

        var gsaType = typeof(GameStartAtrribute);

        //寻找所有的管理器
        allTypes = allTypes.Distinct().ToList();
        foreach (var t in allTypes)
        {
            try
            {
                if (t != null && t.BaseType != null && t.BaseType.FullName != null && t.BaseType.FullName.Contains(".ManagerBase`2"))
                {
                    BDebug.Log("加载管理器-" + t, "green");
                    var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as  IMgr;
                    mgrs.Add(i);
                    continue;
                }
                //游戏启动器
                //这里主要寻找
                if (isILRMode && gameStart == null)
                {
                    var attrs = t.GetCustomAttributes(gsaType, false);
                    if (attrs.Length > 0)
                    {
                        if (attrs[0] is GameStartAtrribute)
                        {
                            gameStart = Activator.CreateInstance(t) as IGameStart;
                            BDebug.Log("找到启动器" + t.FullName, "red");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
        }

        BDebug.Log("管理器数量 =" + mgrs.Count);
        //类型注册
        foreach (var t in allTypes)
        {
            foreach (var iMgr in mgrs)
            {
                iMgr.CheckType(t);
            }
        }

        //管理器初始化
        foreach (var m in mgrs)
        {
            m.Init();
        }
        BDebug.Log("管理器注册完成!");

        //game生命注册
        if (gameStart != null)
        {
            gameStart.Start();
            //
            BDLauncher.OnUpdate     = gameStart.Update;
            BDLauncher.OnLateUpdate = gameStart.LateUpdate;
        }
        BDebug.Log("游戏生命周期准备完毕!");
        //所有管理器开始工作
        foreach (var m in mgrs)
        {
            m.Start();
        }
        BDebug.Log("管理器开始工作!");
    }
Exemplo n.º 8
0
    /// <summary>
    /// 这里注册整个游戏类型
    /// </summary>
    /// <param name="isCodeHotfix"></param>
    static public void Start(bool isCodeHotfix = false, bool isResourceHotfix = false)
    {
        BDebug.Log("资源热更:" + isResourceHotfix, "yellow");
        BDebug.Log("代码热更:" + isCodeHotfix, "yellow");
        //组件加载
        List <Type> allTypes = new List <Type>();

        //编辑器环境下 寻找dll
        if (isCodeHotfix == false)
        {
            //当framework 是dll形式时候需要先获取当前dll里面的所有type
            allTypes = Assembly.GetExecutingAssembly().GetTypes().ToList();

            //非源码形式 需要取game type
            if (Assembly.GetExecutingAssembly().GetName().Name != "Assembly-CSharp")
            {
                var assmblies    = new List <Assembly>(AppDomain.CurrentDomain.GetAssemblies());
                var logicAssmbly = assmblies.Find((a) => a.GetName().Name == "Assembly-CSharp");

                allTypes.AddRange(logicAssmbly.GetTypes());
            }
        }
        else
        {
            var values = ILRuntimeHelper.AppDomain.LoadedTypes.Values.ToList();
            foreach (var v in values)
            {
                allTypes.Add(v.ReflectionType);
            }
        }

        //
        var mgrs = new List <IMgr>();

        var gsaType = typeof(GameStartAtrribute);

        //寻找所有的管理器
        allTypes = allTypes.Distinct().ToList();
        foreach (var t in allTypes)
        {
            try
            {
                if (t != null && t.BaseType != null && t.BaseType.FullName != null && t.BaseType.FullName.Contains(".ManagerBase`2"))
                {
                    BDebug.Log("加载管理器-" + t, "green");
                    var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as  IMgr;
                    mgrs.Add(i);
                    continue;
                }
                //游戏启动器
                //这里主要寻找
                if (isCodeHotfix && gameStart == null)
                {
                    var attrs = t.GetCustomAttributes(gsaType, false);
                    if (attrs.Length > 0)
                    {
                        if (attrs[0] is GameStartAtrribute)
                        {
                            gameStart = Activator.CreateInstance(t) as IGameStart;
                            BDebug.Log("找到启动器" + t.FullName, "red");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
        }

        BDebug.Log("管理器数量 =" + mgrs.Count);
        //类型注册
        foreach (var t in allTypes)
        {
            foreach (var iMgr in mgrs)
            {
                iMgr.CheckType(t);
            }
        }

        //管理器初始化
        foreach (var m in mgrs)
        {
            m.Init();
        }
        BDebug.Log("管理器注册完成!");

        //game生命注册
        if (gameStart != null)
        {
            gameStart.Start();
            //
            BDLauncher.OnUpdate     += gameStart.Update;
            BDLauncher.OnLateUpdate += gameStart.LateUpdate;
        }
        BDebug.Log("游戏生命周期准备完毕!");
        //所有管理器开始工作
        foreach (var m in mgrs)
        {
            m.Start();
        }
        BDebug.Log("管理器开始工作!");
    }