private void btn_06() { List <GameObject> golist = new List <GameObject>(); //1.同步加载 var go = BResources.Load <GameObject>("AssetTest/Cube"); var load1 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("Test/Cube"); var load2 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("AssetTest/Particle"); var load3 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("Char/001"); var loadModel = GameObject.Instantiate(go); golist.Add(load1); golist.Add(load2); golist.Add(load3); golist.Add(loadModel); //2.异步加载单个 var id = BResources.AsyncLoad <GameObject>("Test/Cube", (o) => { var load4 = GameObject.Instantiate(o); golist.Add(load4); }); //3.异步加载多个 var list = new List <string>() { "AssetTest/Cube", "Test/Cube" }; BResources.AsyncLoad(list, (i, i2) => { //进度 Debug.Log(string.Format("进度 {0} / {1}", i, i2)); }, (map) => { BDebug.Log("加载全部完成,资源列表:"); foreach (var r in map) { BDebug.Log(string.Format("--> {0} : {1}", r.Key, r.Value.name)); var _go = GameObject.Instantiate(r.Value); golist.Add(_go as GameObject); } }); IEnumeratorTool.WaitingForExec(5, () => { foreach (var _go in golist) { GameObject.Destroy(_go); } }); }
/// <summary> /// 异步加载窗口 /// </summary> /// <param name="indexes"></param> /// <param name="loadProcessAction"></param> public void AsyncLoadWindows(List <int> indexes, Action <int, int> loadProcessAction) { int allCount = indexes.Count; int curTaskCount = 0; foreach (var i in indexes) { var index = i.GetHashCode(); if (windowMap.ContainsKey(index)) { var uvalue = windowMap[index]; if (uvalue.IsLoad) { Debug.LogError("已经加载过并未卸载" + index); //任务直接完成 { curTaskCount++; loadProcessAction(allCount, curTaskCount); } continue; } } else { //创建窗口 var win = CreateWindow(index); if (win == null) { Debug.LogErrorFormat("不存在UI:{0}", index); curTaskCount++; loadProcessAction(allCount, curTaskCount); } else { windowMap[index] = win; //开始窗口加载 win.AsyncLoad(() => { IEnumeratorTool.WaitingForExec(0.1f, () => { curTaskCount++; loadProcessAction(allCount, curTaskCount); if (win.Transform) { win.Transform.SetParent(this.Bottom, false); } //推送缓存的数据 PushCaheData(index); }); }); } } } }
public void BeginInit(Action <Exception> onInit, ScreenViewLayer layer) { this.IsLoad = true; //BDebug.Log("enter logo"); UIMgr.Inst.LoadWindows(0); UIMgr.Inst.ShowWindow(0); IEnumeratorTool.WaitingForExec(3, () => { ScreenViewMgr.Inst.BeginNav("Battle"); }); }
public void Do(IBattle battle, IHeroFSM selfFSM, IHeroFSM targetFSM) { var o = BResources.Load <GameObject>(this.se.StrParam0); effect = GameObject.Instantiate(o).transform; //在敌方阵营的特效 需要旋转 //父节点 Transform parent = null; if (se.DoubleParams0 == 1) //单体 { if (targetFSM.Camp == 2) { effect.eulerAngles = new Vector3(0, 180, 0); } parent = battle.World.GetPlayerRootTransform(targetFSM.ID); } else if (se.DoubleParams0 == 2) { parent = battle.World.GetPlayerRootTransform(targetFSM.Camp); } else if (se.DoubleParams0 == 3) //连接 { parent = battle.World.GetPlayerRootTransform(selfFSM.Camp); var mypos = battle.World.GetPlayerPos(selfFSM.ID); var tarpos = battle.World.GetPlayerPos(targetFSM.ID); //TODO 求两个向量夹角 var v1 = new Vector2(mypos.x, mypos.z); var v2 = new Vector2(tarpos.x, tarpos.z); var dir = (v2 - v1).normalized; effect.LookAt(dir); // float angle = Vector3.Angle(mypos, tarpos); // effect.eulerAngles += new Vector3(0,angle,0); } effect.SetParent(parent, false); if (se.DoubleParams1 > 0) { IEnumeratorTool.WaitingForExec((float)se.DoubleParams1, () => { BResources.Destroy(effect); }); } }
/// <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(); } }); }
public override void Init() { base.Init(); //增加覆盖测试 var service = DataListenerServer.Create(nameof(DataListenerEnum)); service.AddListener(DataListenerEnum.test, (o) => { Debug.Log(o.ToString()); }); //demo1: screenview 切换 //代码: //Game@hotfix/demo1 this.btn_01.onClick.AddListener(() => { ScreenViewManager.Inst.MainLayer.BeginNavTo(ScreenViewEnum.Demo1); }); //demo4 : uflux窗口 //代码: this.btn_04.onClick.AddListener(() => { //测试多个接口 var list = new List <WinEnum>() { WinEnum.Win_Demo6 }; UIManager.Inst.LoadWindows(list); UIManager.Inst.ShowWindow(WinEnum.Win_Demo6); BDebug.Log("加载成功!"); // }); //demo5: sqlite 查询 this.btn_05.onClick.AddListener(() => { //单条件查询 Debug.Log("普通查询:"); var ds = SqliteHelper.DB.GetTableRuntime().Where("id = 1").ToSearch <Hero>(); ds = SqliteHelper.DB.GetTableRuntime().Where("id = {0}", 1).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //多条件查询 Debug.Log("多条件查询:"); ds = SqliteHelper.DB.GetTableRuntime().Where("id > 1").Where("and id < 3").ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //批量查询 Debug.Log("Where or 批量查询:"); ds = SqliteHelper.DB.GetTableRuntime().WhereAnd("id", "=", 1, 2).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } //批量查询 Debug.Log("Where and 批量查询:"); ds = SqliteHelper.DB.GetTableRuntime().WhereOr("id", "=", 2, 3).ToSearch <Hero>(); foreach (var d in ds) { Debug.Log(JsonMapper.ToJson(d)); } }); //demo6:资源加载 this.btn_06.onClick.AddListener(() => { List <GameObject> golist = new List <GameObject>(); //1.同步加载 var go = BResources.Load <GameObject>("AssetTest/Cube"); var load1 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("Test/Cube"); var load2 = GameObject.Instantiate(go); go = BResources.Load <GameObject>("AssetTest/Particle"); var load3 = GameObject.Instantiate(go); golist.Add(load1); golist.Add(load2); golist.Add(load3); //2.异步加载单个 var id = BResources.AsyncLoad <GameObject>("Test/Cube", (o) => { var load4 = GameObject.Instantiate(o); golist.Add(load4); }); //3.异步加载多个 var list = new List <string>() { "AssetTest/Cube", "Test/Cube" }; BResources.AsyncLoad(list, (i, i2) => { Debug.Log(string.Format("进度 {0} / {1}", i, i2)); }, (map) => { BDebug.Log("加载全部完成,资源列表:"); foreach (var r in map) { BDebug.Log(string.Format("--> {0} : {1}", r.Key, r.Value.name)); var _go = GameObject.Instantiate(r.Value) as GameObject; golist.Add(_go); } }); IEnumeratorTool.WaitingForExec(5, () => { foreach (var _go in golist) { GameObject.Destroy(_go); } }); }); //代码: //Game@hotfix/demo_Manager_AutoRegister_And_Event this.btn_07.onClick.AddListener(() => { var path = Application.persistentDataPath; VersionContorller.Start(UpdateMode.Repair, "http://127.0.0.1", path, (i, j) => { Debug.LogFormat("资源更新进度:{0}/{1}", i, j); }, (error) => { Debug.LogError("错误:" + error); }); }); //发送消息机制 this.btn_08.onClick.AddListener(() => { DemoEventManager.Inst.Do(DemoEventEnum.TestEvent2); }); //图集 this.btn_09.onClick.AddListener(() => { UIManager.Inst.CloseWindow(WinEnum.Win_Main); UIManager.Inst.LoadWindow(WinEnum.Win_Demo5_Atlas); UIManager.Inst.ShowWindow(WinEnum.Win_Demo5_Atlas); }); //数据监听 this.btn_10.onClick.AddListener(() => { UIManager.Inst.LoadWindow(WinEnum.Win_Demo_Datalistener); UIManager.Inst.ShowWindow(WinEnum.Win_Demo_Datalistener); }); }