static public int Dispose(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif ETModel.Session self = (ETModel.Session)checkSelf(l); self.Dispose(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int Send(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif ETModel.Session self = (ETModel.Session)checkSelf(l); SLua.ByteStringArray a1; checkType(l, 2, out a1); System.UInt16 a2; checkType(l, 3, out a2); self.Send(a1, a2); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int constructor(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif ETModel.Session o; ETModel.AChannel a1; checkType(l, 2, out a1); o = new ETModel.Session(a1); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
protected override void Run(ETModel.Session session, Actor_JoyLds_CanRobLanlord message) { EventMsgMgr.SendEvent(JoyLandlordsEventID.CanRobLanlord, message.SeatIndex); }
protected override void Run(ETModel.Session session, Actor_JoyLds_DontPlay message) { EventMsgMgr.SendEvent(JoyLandlordsEventID.DontPlay, message.SeatIndex); }
protected override void Run(ETModel.Session session, S2C_Exit msg) { Log.Info($"S2C_ExitHandler message: {msg.Name} RpcId= {msg.RpcId} Error= {msg.Error} Message= {msg.Message} "); }
public virtual async ETTask C2G_EnterMapHandler(ETModel.Session session, C2G_EnterMap request, G2C_EnterMap response, Action reply) { }
/// <summary> /// 点击注册按钮 /// </summary> private async void OnRegisterButton() { ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click); if (_isRequest) { Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.IsLoadingTip); return; } OnEndEditAccountInputField(accoutIF.text); OnEndEditPasswordInputField(passIF.text); OnEndEditCaptchaInputField(repeatIF.text); if (!_accountVertify || !_passwordVertify || !_captchaVertify) { return; } Game.PopupComponent.ShowLoadingLockUI(); _isRequest = true; try { // 创建一个ETModel层的Session ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>() .Create(GlobalConfigComponent.Instance.GlobalProto.Address); // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息 Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session); // 发送注册请求 R2C_Register_Res r2CRegisterRes = (R2C_Register_Res)await realmSession.Call( new C2R_Register_Req() { Account = this.accoutIF.text, Password = this.passIF.text }); if (r2CRegisterRes.Error != 0) { Game.PopupComponent.ShowMessageBox(r2CRegisterRes.Message); // GameHelper.ShowMessageBox(r2CRegisterRes.Message); } else if (r2CRegisterRes.Error == 0) { //注册上报 var openInstall = ETModel.Game.Scene.GetComponent <OpenInstallComponent>(); openInstall.reportRegister(); // 登录 GamePrefs.SetUserAccount(accoutIF.text); GamePrefs.SetUserPwd(passIF.text); // OnBackButton(); //this.GetParent<UILoginCpt>().RegisterLogin(); } Game.PopupComponent.CloseLoadingLockUI(); } catch (Exception e) { Game.PopupComponent.CloseLoadingLockUI(); Debug.LogError("无法连接到服务器: " + e.Message); Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ConnectServerFailTip); } finally { Game.PopupComponent.CloseLoadingLockUI(); _isRequest = false; } }
/// <summary> /// 普通账号游客登录 /// </summary> /// <param name="account"></param> /// <param name="pwd"></param> /// <param name="isGuest"></param> /// <returns></returns> public static async Task <int> OnLoginAsync(string account, string pwd, bool isGuest = false) { int errcode = -1; try { // 创建一个ETModel层的Session ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address); // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息 Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session); //向服务器申请了一个Key R2C_Login r2CLogin = (R2C_Login)await realmSession.Call(new C2R_Login() { Account = account, Password = pwd }); errcode = r2CLogin.Error; realmSession.Dispose(); if (r2CLogin.Error != 0) { if (isGuest && r2CLogin.Error == ErrorCode.ERR_AccountDoesnExist) { return(r2CLogin.Error); } Game.PopupComponent.ShowMessageBox(r2CLogin.Message); return(r2CLogin.Error); } GamePrefs.SetUserId(r2CLogin.UserId); // 创建一个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); //增加客户端断线处理组件 Game.Scene.GetComponent <SessionComponent>().Session.AddComponent <SessionOfflineComponent>(); G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate() { Key = r2CLogin.Key, UserId = r2CLogin.UserId }); errcode = g2CLoginGate.Error; if (g2CLoginGate.Error != 0) { Game.PopupComponent.ShowMessageBox(g2CLoginGate.Message); Game.Scene.GetComponent <SessionComponent>().Session.Dispose(); return(g2CLoginGate.Error); } if (Game.Scene.GetComponent <PingComponent>() == null) { Game.Scene.AddComponent <PingComponent, long, Session, Action>(3000, Game.Scene.GetComponent <SessionComponent>().Session, null); } return(g2CLoginGate.Error); } catch (Exception e) { // if (e.Message.Equals("ERR_AccountDoesnExist")) throw; Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.NotConnectGateTip); Log.Error("无法连接到网关服务器: " + e.Message); return(errcode); } }
protected override void Run(ETModel.Session session, Actor_FiveStar_SmallStartGame message) { CardFiveStarRoom.Ins.SmallStarGame(message); }
protected override void Run(ETModel.Session session, Actor_GameStart_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); //初始化玩家UI foreach (GamerCardNum gamerCardNum in message.GamersCardNum) { Gamer gamer = room.GetGamer(gamerCardNum.UserID); LandlordsGamerPanelComponent gamerUI = gamer.GetComponent <LandlordsGamerPanelComponent>(); gamerUI.GameStart(); HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); if (handCards != null) { handCards.Reset(); } else { //Log.Debug("没有可以复用的HandCardsComponent,创建一个。"); handCards = gamer.AddComponent <HandCardsComponent, GameObject>(gamerUI.Panel); } //显示牌背面或者手牌 handCards.Appear(); if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { //本地玩家添加手牌 Card[] Tcards = new Card[message.HandCards.Count]; for (int i = 0; i < message.HandCards.Count; i++) { Tcards[i] = message.HandCards[i]; } //Log.Debug("当前玩家手牌数量"+message.HandCards.array.Length.ToString()); //array的数量为32 与牌数不符合 handCards.AddCards(Tcards); } else { //设置其他玩家手牌数 handCards.SetHandCardsNum(gamerCardNum.Num); } } //显示牌桌UI GameObject desk = uiRoom.GameObject.Get <GameObject>("Desk"); desk.SetActive(true); GameObject lordPokers = desk.Get <GameObject>("LordPokers"); //重置地主牌 Sprite lordSprite = CardHelper.GetCardSprite("None"); for (int i = 0; i < lordPokers.transform.childCount; i++) { lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordSprite; } LandlordsRoomComponent uiRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>(); //清空选中牌 uiRoomComponent.Interaction.Clear(); //设置初始倍率 uiRoomComponent.SetMultiples(1); }
protected override void Run(ETModel.Session session, Actor_JoyLds_Deal message) { EventMsgMgr.SendEvent(JoyLandlordsEventID.Deal, message.Cards); }
protected abstract ETTask Run(ETModel.Session session, Message message);
protected override void Run(ETModel.Session session, Actor_JoyLds_StartGame message) { Game.Scene.GetComponent <JoyLdsGameRoom>()?.StartGame(message); }
protected override void Run(ETModel.Session session, Actor_FiveStar_ScoreChange message) { CardFiveStarRoom.Ins.ScoreChang(message.GetScore, message.NowScore); }
protected override void Run(ETModel.Session session, Actor_FiveStar_CanOperate message) { CardFiveStarRoom.Ins.PlayerCanOperate(message.SeatIndex, message.CanOperateLits, message.CanGangLits); }
protected override void Run(ETModel.Session session, G2C_StartGame message) { RunAsync(session, message).NoAwait(); }
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()); //等待服务端通知游戏计时开始 //等待服务端通知刷新第一波小兵 //等待服务端通知刷新普通野怪 //等待服务端通知刷新大龙 }
protected override void Run(ETModel.Session session, Actor_FiveStar_PlayCardResult message) { CardFiveStarRoom.Ins.PlayerPlayCard(message.SeatIndex, message.Card); }
protected override void Run(ETModel.Session session, Actor_RankUpdate message) { }
protected override async void Run(ETModel.Session session, A1010_NewArmyWave_M2C message) { //服务端通知客户端刷新一波士兵 1坦克 战士 1法师 TimerComponent timerComponent = ETModel.Game.Scene.GetComponent <TimerComponent>(); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); ConfigComponent config = Game.Scene.GetComponent <ConfigComponent>(); Moba5V5Component moba = Moba5V5Component.instance; //创建3个蓝方坦克 配置编号37-39 for (int i = 0; i < 3; i++) { //获取角色配置 Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 37); GameObject prefab = bundleGameObject.Get <GameObject>(moba5V5Config.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>(); 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组件 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; //默认导航线路 } //创建3个红方坦克 配置编号46-48 for (int i = 0; i < 3; i++) { //获取角色配置 Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 46); GameObject prefab = bundleGameObject.Get <GameObject>(moba5V5Config.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>(); 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组件 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; //默认导航线路 } await timerComponent.WaitAsync(1000); for (int i = 0; i < 3; i++) { //获取角色配置 Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 31); GameObject prefab = bundleGameObject.Get <GameObject>(moba5V5Config.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>(); 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组件 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; //默认导航线路 } for (int i = 0; i < 3; i++) { //获取角色配置 Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 40); GameObject prefab = bundleGameObject.Get <GameObject>(moba5V5Config.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>(); 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组件 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; //默认导航线路 } await timerComponent.WaitAsync(1000); //创建3个蓝方法师 配置编号34-36 for (int i = 0; i < 3; i++) { //获取角色配置 Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 34); GameObject prefab = bundleGameObject.Get <GameObject>(moba5V5Config.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>(); 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组件 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; //默认导航线路 } //创建3个红方法师 配置编号43-45 for (int i = 0; i < 3; i++) { //获取角色配置 Moba5V5Config moba5V5Config = (Moba5V5Config)config.Get(typeof(Moba5V5Config), i + 43); GameObject prefab = bundleGameObject.Get <GameObject>(moba5V5Config.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>(); 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组件 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; //默认导航线路 } }
protected override ETTask Run(ETModel.Session session, M2C_CommonAttack message) { UnitComponent.Instance.Get(message.AttackCasterId).GetComponent <CommonAttackComponent>() .CommonAttackStart(UnitComponent.Instance.Get(message.TargetUnitId)); return(ETTask.CompletedTask); }
protected override void Run(ETModel.Session session, G2C_RoomDetailInfo message) { RunAsync(session, message).NoAwait(); }
protected override void Run(ETModel.Session session, B2C_BattleEnd message) { RunAsync(session, message).NoAwait(); }
protected override void Run(ETModel.Session session, Actor_StartShowHand_Ntt message) { Game.Scene.GetComponent <GameDataComponent>().HideAllImg_Banker(); GameTools.GetRoomComponent().playerOperateComponent.ShowTanpai(); }
protected override ETTask Run(ETModel.Session session, M2C_SyncUnitAttribute message) { UnitComponent.Instance.Get(message.UnitId).GetComponent <HeroDataComponent>().NumericComponent[(NumericType)message.NumericType] = message.FinalValue; return(ETTask.CompletedTask); }
protected abstract void Run(ETModel.Session session, Message message);
protected override async ETTask Run(ETModel.Session session, G2C_TestHotfixMessage message) { Log.Debug(message.Info); await ETTask.CompletedTask; }
protected override void Run(ETModel.Session session, G2C_Gold message) { PlayerComponent.Instance.MyPlayer.Gold = message.Gold; Game.EventSystem.Run(EventIdType.GoldChange); }
protected override void Run(ETModel.Session session, Actor_JoyLds_DissolveRoom message) { EventMsgMgr.SendEvent(JoyLandlordsEventID.DissolveRoom); }