public async ETVoid RunAsync()
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            // 加载场景资源

            await resourcesComponent.LoadBundleAsync(AssetBundleName.Unit);

            await resourcesComponent.LoadBundleAsync(AssetBundleName.Battle);



            // 切换到Battle场景
            using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent <SceneChangeComponent>())
            {
                await sceneChangeComponent.ChangeSceneAsync(SceneType.Battle);
            }



            C2B_LoadAssetFinish msg = new C2B_LoadAssetFinish();

            ETModel.SessionComponent.Instance.Session.Send(msg);
        }
Ejemplo n.º 2
0
        public static async ETVoid EnterMainAsync()
        {
            try
            {
                //1.获取资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync("unit.unity3d");

                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("main.unity3d");

                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Main);

                    Log.Debug("场景加载进度:" + sceneChangeComponent.Process);
                }

                Game.Scene.AddComponent <MainComponent>();

                Game.EventSystem.Run(EventIdType.EnterMainFinish);
            }
            catch (System.Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 3
0
        public static async ETVoid EnterOutSpaceAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

                // 加载场景资源
                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("outspace.unity3d");

                // 切换到outspace场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.OutSpace);
                }

                G2C_EnterOutSpace g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterOutSpace()) as G2C_EnterOutSpace;

                PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.ShipId;

                Game.Scene.AddComponent <OutSpaceComponent>();

                Game.EventSystem.Run(EventIdType.LobbyFinish);
                Game.EventSystem.Run(EventIdType.Init_UI_OutSpace);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 4
0
        public static async ETVoid EnterMapAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"player.unity3d");

                // 加载场景资源
                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("map.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Map);
                }

                Game.Scene.AddComponent <OperaComponent>();
                Game.Scene.AddComponent <PlatformComponent>();

                Player          player          = PlayerFactory.Create(IdGenerater.GenerateId());
                PlayerComponent playerComponent = Game.Scene.GetComponent <PlayerComponent>();
                playerComponent.MyPlayer = player;

                Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 联网demo的切换场景
        /// </summary>
        /// <returns></returns>
        public static async ETVoid EnterMyGameAsync()
        {
            try
            {
                // 获取加载ResourcesComponent组件   加载Unit资源(放一些模型)
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");   //异步加载

                // 加载map场景资源
                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("mygame.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.MyGame);
                }

                //发送消息到服务器
                G2C_EnterMyGame g2CEnterMyGame = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMyGame()) as G2C_EnterMyGame;

                //把自己的ID设置为刚生成传过来的ID
                PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMyGame.UnitId;

                Game.Scene.AddComponent <OperaComponent>();

                Game.EventSystem.Run(EventIdType.ChoiceCharacterFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 6
0
        private async ETVoid EnterMapAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

                // 加载场景资源
                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("map.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Map);
                }

                G2C_EnterMap g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMap()) as G2C_EnterMap;

                PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId;

                Game.Scene.AddComponent <OperaComponent>();
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILobby);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 7
0
        private static async ETVoid EnterBattleAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

                // 加载场景资源
                await resourcesComponent.LoadBundleAsync("battle.unity3d");

                // 切换到Battle场景
                using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Battle);

                    Game.EventSystem.Run(EventIdType.EnterBattlefieldFinish);
                }

                Game.EventSystem.Run(EventIdType.GMCreateTank, 10000);

                // G2C_EnterMap g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMap()) as G2C_EnterMap;
                // PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId;
                //
                // Game.Scene.AddComponent<OperaComponent>();
                //
                // // 逻辑层不应该去调用UI,逻辑层只关心逻辑并且抛出事件,由UI层自己去订阅事件
                // Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 进入地图
        /// </summary>
        /// <returns></returns>
        public static async ETVoid EnterMapAsync(int MapSizeX, int MapSizeY)
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

                // 加载场景资源
                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("etdemomap.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync("ETDemoMap");
                }

                Game.Scene.AddComponent <MapGridOperaComponent>();
                Game.EventSystem.Run(ETDemoEventIdType.EnterMapFinish, MapSizeX, MapSizeY);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 9
0
        public static async ETVoid EnterMapAsync(string sceneName)
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = DCET.Model.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

                // 加载场景资源
                await DCET.Model.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("map.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = DCET.Model.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(sceneName);
                }

                G2C_EnterMap g2CEnterMap = await DCET.Model.SessionComponent.Instance.Session.Call(new C2G_EnterMap()) as G2C_EnterMap;

                PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId;

                Game.Scene.AddComponent <OperaComponent>();

                Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 10
0
        public static async ETVoid LoadUnitAsync()
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            await resourcesComponent.LoadBundleAsync($"unit.unity3d");

            Game.EventSystem.Run(EventIdType.UnitLoadFinished);

            // resourcesComponent.UnloadBundle("unit.unity3d");
        }
Ejemplo n.º 11
0
        public async Task <UI> LoadBundleAsync(string type)
        {
            Type typeComponent = UIType.GetComponentTypeByString(type);
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            await resourcesComponent.LoadBundleAsync($"ui/{type}.unity3d");

            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"ui/{type}.unity3d", $"{type}");
            GameObject go = UnityEngine.Object.Instantiate(bundleGameObject);

            go.layer = LayerMask.NameToLayer(LayerNames.UI);
            UI ui = ComponentFactory.Create <UI, GameObject>(go);

            ui.AddUiComponent(typeComponent);
            return(ui);
        }
Ejemplo n.º 12
0
        public async void Awake()
        {
            Instance     = this;
            audioManager = AudioManager.Instance;
            // 项目音效资源少,直接加载全部。
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            // resourcesComponent.LoadBundle("sound.unity3d");
            await resourcesComponent.LoadBundleAsync("sound.unity3d");

            GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("sound.unity3d", "Sound");
            GameObject sound            = UnityEngine.Object.Instantiate(bundleGameObject);

            sound.name             = "SoundComponent";
            sound.transform.parent = GameObject.Find("Global").transform;
            rc = sound.GetComponent <ReferenceCollector>();
        }
Ejemplo n.º 13
0
        protected async ETVoid RunAsync(ETModel.Session session, B2C_BattleEnd message)
        {
            ETModel.Game.Scene.GetComponent <TankComponent>().RemoveAll();

            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            // 加载场景资源
            await resourcesComponent.LoadBundleAsync("start.unity3d");

            using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent <SceneChangeComponent>())
            {
                await sceneChangeComponent.ChangeSceneAsync(SceneType.Start);
            }

            await FUIFactory.Create <CombatSettlementViewComponent, B2C_BattleEnd>(FUIType.CombatSettlement, message);
        }
Ejemplo n.º 14
0
        public async Task <UI> CreateAsync(Scene scene, string type, GameObject parent)
        {
            try
            {
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"{type}.unity3d");

                GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}");
                GameObject club             = UnityEngine.Object.Instantiate(bundleGameObject);
                club.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI ui = ComponentFactory.Create <UI, GameObject>(club);
                ui.AddUIBaseComponent <UILogin_ForgetComponent>();
                AddSubComponent(ui);
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
Ejemplo n.º 15
0
        public static async ETVoid EnterMapAsync()
        {
            try
            {
                // 加载Unit资源
                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"unit.unity3d");

                // 加载场景资源
                await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("map.unity3d");

                // 切换到map场景
                using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
                {
                    await sceneChangeComponent.ChangeSceneAsync(SceneType.Map);
                }

                Player       player      = ETModel.Game.Scene.GetComponent <PlayerComponent>().MyPlayer;
                G2C_EnterMap g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMap()
                {
                    PlayerId = player.Id
                }) as G2C_EnterMap;

                //PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId;
                player.UnitId = g2CEnterMap.UnitId;

                Debug.Log(" MapHelper-player.Id/player.UnitId: " + player.Id + " / " + player.UnitId);

                ///20190721 取消合并到Move里了
                //Game.Scene.AddComponent<OperaComponent>();

                Game.EventSystem.Run(EventIdType.EnterMapFinish);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 16
0
        public async Task OnLoginPhone(string phone, string code, string token)
        {
            Session sessionWrap = null;

            try
            {
                UINetLoadingComponent.showNetLoading();

                //IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address);

                IPEndPoint      connetEndPoint = ToIPEndPointWithYuMing(NetConfig.getInstance().getServerPort());
                ETModel.Session session        = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                sessionWrap = ComponentFactory.Create <Session, ETModel.Session>(session);
                R2C_PhoneLogin r2CLogin = (R2C_PhoneLogin)await sessionWrap.Call(new C2R_PhoneLogin()
                {
                    Phone = phone, Code = code, Token = token, MachineId = PlatformHelper.GetMacId(), ChannelName = PlatformHelper.GetChannelName(), ClientVersion = PlatformHelper.GetVersionName()
                });

                //R2C_PhoneLogin r2CLogin = (R2C_PhoneLogin)await sessionWrap.Call(new C2R_PhoneLogin() { Phone = phone, Code = code, Token = token, MachineId = "1234", ChannelName = "jav", ClientVersion = "1.1.0" });
                sessionWrap.Dispose();

                UINetLoadingComponent.closeNetLoading();

                if (r2CLogin.Error != ErrorCode.ERR_Success)
                {
                    ToastScript.createToast(r2CLogin.Message);

                    if (r2CLogin.Error == ErrorCode.ERR_TokenError)
                    {
                        PlayerPrefs.SetString("Phone", "");
                        PlayerPrefs.SetString("Token", "");

                        panel_phoneLogin.transform.localScale = new Vector3(1, 1, 1);
                    }

                    if (r2CLogin.Message.CompareTo("用户不存在") == 0)
                    {
                        panel_phoneLogin.transform.localScale = new Vector3(1, 1, 1);
                    }

                    return;
                }

                UINetLoadingComponent.showNetLoading();


                //connetEndPoint = NetworkHelper.ToIPEndPoint(r2CLogin.Address);
                //connetEndPoint = NetConfig.getInstance().ToIPEndPointWithYuMing();
                string[] temp = r2CLogin.Address.Split(':');
                connetEndPoint = ToIPEndPointWithYuMing(Convert.ToInt32(temp[1]));
                ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint);
                Game.Scene.GetComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(session);
                ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>().Session = gateSession;

                G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
                {
                    Key = r2CLogin.Key
                });

                UINetLoadingComponent.closeNetLoading();

                ToastScript.createToast("登录成功");
                //挂心跳包
                Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <HeartBeatComponent>();
                UINetLoadingComponent.closeNetLoading();
                await getAllData();

                isLoginSuccess = true;

                {
                    // 保存Phone
                    PlayerPrefs.SetString("Phone", phone);

                    // 保存Token
                    PlayerPrefs.SetString("Token", r2CLogin.Token);
                }

                Game.Scene.GetComponent <PlayerInfoComponent>().uid = g2CLoginGate.Uid;

                PlayerInfoComponent.Instance.SetShopInfoList(g2CLoginGate.ShopInfoList);
                PlayerInfoComponent.Instance.SetBagInfoList(g2CLoginGate.BagList);
                PlayerInfoComponent.Instance.ownIcon = g2CLoginGate.ownIcon;

                ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
                await resourcesComponent.LoadBundleAsync($"UIMain.unity3d");

                await resourcesComponent.LoadBundleAsync($"Image_Main.unity3d");

                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIMain);
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UILogin);
            }
            catch (Exception e)
            {
                sessionWrap?.Dispose();
                Log.Error(e);
            }
        }
Ejemplo n.º 17
0
        public async Task AddPackageAsync(string packageName)
        {
            if (Define.IsUseAddressable)
            {
                // TextAsset descPkg = null;
                // Texture resTexturePkg = null;

                await Game.Scene.GetComponent <AdsResComponent>().LoadFairyGUIPackage(packageName);

                // await Game.Scene.GetComponent<AdsResComponent>().LoadAssetListAsyncByLabel<Object>(
                //     $"{FUI_NAME_PREFIX}_{packageName}", null, onCompleteAssetList =>
                //     {
                //         for (int i = 0; i < onCompleteAssetList.Count; i++)
                //         {
                //             var asset = onCompleteAssetList[i];
                //             var isTextAsset = asset is TextAsset;
                //             var isTexture2D = asset is Texture;
                //
                //             if (isTextAsset)
                //             {
                //                 descPkg = asset as TextAsset;
                //             }
                //             else if (isTexture2D)
                //             {
                //                 resTexturePkg = asset as Texture;
                //             }
                //         }
                //     });
                // UIPackage.AddPackage(descPkg.bytes, packageName, (name, extension, type, item) =>
                // {
                //     if (type == typeof(Texture))
                //     {
                //         item.owner.SetItemAsset(item, resTexturePkg, DestroyMethod.Custom);
                //     }
                // });
            }
            else
            {
                if (!Define.IsAsync)
                {
                    await Task.CompletedTask;

                    UIPackage uiPackage = UIPackage.AddPackage($"{FUI_PACKAGE_DIR}/{packageName}");

                    packages.Add(packageName, uiPackage);
                }

                else
                {
                    string             uiBundleDesName    = AssetBundleHelper.StringToAB($"{packageName}_fui");
                    string             uiBundleResName    = AssetBundleHelper.StringToAB(packageName);
                    ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
                    await resourcesComponent.LoadBundleAsync(uiBundleDesName);

                    await resourcesComponent.LoadBundleAsync(uiBundleResName);

                    // AssetBundle desAssetBundle = resourcesComponent.GetAssetBundle(uiBundleDesName);
                    // AssetBundle resAssetBundle = resourcesComponent.GetAssetBundle(uiBundleResName);

                    // packages.Add(type, uiPackage);
                }
            }
        }
Ejemplo n.º 18
0
        public static async ETVoid Login(LoginViewComponent self, string account, string password)
        {
            #region 客户端给服务器发送登陆信息
            // 创建一个ETModel层的Session
            ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);

            Log.Info("服务器地址 : " + GlobalConfigComponent.Instance.GlobalProto.Address);
            // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
            Session   realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);
            R2C_Login r2CLogin     = (R2C_Login)await realmSession.Call(new C2R_Login()
            {
                Account = account, Password = password
            });

            realmSession.Dispose();

            #endregion

            if (r2CLogin.Error != ErrorCode.ERR_Success)
            {
                SetErrorPrompt(self, Message.Get(r2CLogin.ErrorMessageId));
                return;
            }


            #region 客户端根据服务器下发的网关地址连接网关

            Log.Info("服务器下发的网关地址 : " + r2CLogin.Address);
            Log.Info("服务器下发的网关验证码 : " + r2CLogin.Key);

            // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中
            ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(r2CLogin.Address);
            ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>().Session = gateSession;

            // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中
            Game.Scene.AddComponent <SessionComponent>().Session = ComponentFactory.Create <Session, ETModel.Session>(gateSession);



            G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate()
            {
                Key = r2CLogin.Key
            });

            Log.Info("登陆gate成功!");

            #endregion

            // 创建Player
            Player player = ETModel.ComponentFactory.CreateWithId <Player>(g2CLoginGate.PlayerId);

            PlayerComponent playerComponent = ETModel.Game.Scene.GetComponent <PlayerComponent>();

            playerComponent.MyPlayer = player;

            // 测试消息有成员是class类型
            G2C_PlayerInfo g2CPlayerInfo = (G2C_PlayerInfo)await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo());


            // 加载Unit资源
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();

            // 加载场景资源
            await resourcesComponent.LoadBundleAsync("start.unity3d");

            // 切换到Battle场景
            using (SceneChangeComponent sceneChangeComponent = Game.Scene.AddComponent <SceneChangeComponent>())
            {
                await sceneChangeComponent.ChangeSceneAsync(SceneType.Start);
            }

            // 逻辑层不应该去调用UI,逻辑层只关心逻辑并且抛出事件,由UI层自己去订阅事件,而且注意事件名字
            // 很多人容易把这个事件取名成LoginFinishiCreateLobbyUI,这是不对的,事件抛出去不可能知道谁订阅了这个事件,
            // 也不会知道别人订阅这个事件是干什么的,这里只知道我Login Finish
            //Game.EventSystem.Run(EventIdType.LoginFinish);
            Game.EventSystem.Run(EventIdType.LoginHasFinish);
        }
        protected override async void Run(ETModel.Session session, A1004_CreateMoba5V5Secene_M2C message)
        {
            //开启加载界面 切换UI
            UIComponent uiComponent = Game.Scene.GetComponent <UIComponent>();
            UI          ui          = uiComponent.Get(UIType.SekiaLobby);

            if (ui == null)
            {
                return;
            }
            if (ui.GetComponent <SekiaLobbyComponent>().isMatching == false)
            {
                return;
            }
            uiComponent.Create(UIType.Moba5V5UI);
            uiComponent.Remove(UIType.SekiaLobby);

            //切换场景
            using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>())
            {
                await sceneChangeComponent.ChangeSceneAsync(SceneType.Moba5V5Map);
            }

            //加载配置
            ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>();
            await resourcesComponent.LoadBundleAsync($"unit.unity3d");

            GameObject       bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit");
            ConfigComponent  config           = Game.Scene.GetComponent <ConfigComponent>();
            Moba5V5Component moba             = Game.Scene.AddComponent <Moba5V5Component>();

            //创建空气墙 编号73和74
            for (int i = 0; i < 2; i++)
            {
                Moba5V5Config qiang       = (Moba5V5Config)config.Get(typeof(Moba5V5Config), 73 + i);
                GameObject    qiangPrefab = bundleGameObject.Get <GameObject>(qiang.Prefab);
                qiangPrefab.transform.position    = new Vector3((float)qiang.Position[0], (float)qiang.Position[1], (float)qiang.Position[2]);
                qiangPrefab.transform.eulerAngles = new Vector3(0, qiang.Rotation, 0);
                qiangPrefab.name = $"Qiang{(i + 1).ToString()}";
                UnityEngine.Object.Instantiate(qiangPrefab).transform.SetParent(GameObject.Find($"/Global/Unit").transform, false);
            }

            //创建10个英雄的GameObject和Gamer MobaID编号1-10
            for (int i = 0; i < message.Gamers.Count; i++)
            {
                //获取英雄配置 角色配置 技能配置
                HeroConfig    heroConfig    = (HeroConfig)config.Get(typeof(HeroConfig), message.Gamers[i].HeroID);
                Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 1);
                GameObject    prefab        = bundleGameObject.Get <GameObject>(heroConfig.Prefab);
                prefab.transform.position    = new Vector3((float)moba5V5Config.Position[0], (float)moba5V5Config.Position[1], (float)moba5V5Config.Position[2]);
                prefab.transform.eulerAngles = new Vector3(0, moba5V5Config.Rotation, 0);

                //创建角色
                Gamer gamer = ETModel.ComponentFactory.Create <Gamer, long>(message.Gamers[i].UserID);
                gamer.GameObject = UnityEngine.Object.Instantiate(prefab);
                gamer.GameObject.transform.SetParent(GameObject.Find($"/Global/Unit").transform, false);
                int mobaID = moba.MobaID;             //获取ID
                moba.mobaIDGamers.Add(mobaID, gamer); //添加到词典

                //添加Unity组件
                NavMeshAgent navMeshAgent = gamer.GameObject.AddComponent <NavMeshAgent>();
                navMeshAgent.radius                = 0.2f;
                navMeshAgent.height                = 0.8f;
                navMeshAgent.angularSpeed          = 360f;
                navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;

                //添加ET组件
                GamerAnimatorComponent anime = gamer.AddComponent <GamerAnimatorComponent>();
                gamer.AddComponent <GamerMoveComponent>();
                gamer.AddComponent <GamerTurnComponent>();
                gamer.AddComponent <GamerPathComponent>();

                //设置角色
                CharacterComponent character = gamer.AddComponent <CharacterComponent>();
                character.mobaID = mobaID;
                character.group  = moba5V5Config.Group; //阵营
                character.type   = moba5V5Config.Type;  //类型
                character.route  = moba5V5Config.Route; //默认导航线路
                character.anime  = anime;

                //确认本地玩家
                if (gamer.UserID == GamerComponent.Instance.MyUser.UserID)
                {
                    gamer.AddComponent <GamerCameraComponent>();
                    moba.myGamer = gamer;
                }
            }

            //创建攻击类建筑 MobaID编号11-30
            for (int i = 0; i < 20; i++)
            {
                //获取角色配置
                Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 11);

                //创建角色
                Gamer gamer = ETModel.ComponentFactory.Create <Gamer>();
                gamer.GameObject = GameObject.Find($"/World/5v5_Map/mobaTower{i+1}");
                gamer.GameObject.transform.SetParent(GameObject.Find($"/Global/Unit").transform, false);
                int mobaID = moba.MobaID;             //获取ID
                moba.mobaIDGamers.Add(mobaID, gamer); //添加到词典

                //添加ET组件
                gamer.AddComponent <GamerAnimatorComponent>();
                CharacterComponent character = gamer.AddComponent <CharacterComponent>();

                //设置角色
                character.mobaID = mobaID;
                character.group  = moba5V5Config.Group; //阵营
                character.type   = moba5V5Config.Type;  //类型
            }

            //初始加载完成
            SessionComponent.Instance.Session.Send(new A1007_GamerReadyMoba5V5_C2M());
            //等待服务端通知游戏计时开始
            //等待服务端通知刷新第一波小兵
            //等待服务端通知刷新普通野怪
            //等待服务端通知刷新大龙
        }