protected override async ETTask Run(ETModel.Session session, Actor_GamerPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); //本地玩家清空选中牌 关闭出牌按钮 if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { LandInteractionComponent interaction = uiRoom.GetComponent <LandRoomComponent>().Interaction; interaction.Clear(); interaction.EndPlay(); } //出牌后更新玩家手牌 HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); Card[] Tcards = new Card[message.Cards.Count]; for (int i = 0; i < message.Cards.Count; i++) { Tcards[i] = message.Cards[i]; } handCards.PopCards(Tcards); } await ETTask.CompletedTask; }
static StackObject *AssignFromStack_Session_0(ref object o, ILIntepreter __intp, StackObject *ptr_of_this_method, IList <object> __mStack) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; ETModel.Session @Session = (ETModel.Session) typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); ((ETModel.SessionComponent)o).Session = @Session; return(ptr_of_this_method); }
protected override async ETTask Run(ETModel.Session session, Actor_AuthorityPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { //重置玩家提示 gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); //当玩家为先手,清空出牌 if (message.IsFirst) { gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); } //显示出牌按钮 if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { LandInteractionComponent interaction = uiRoom.GetComponent <LandRoomComponent>().Interaction; interaction.IsFirst = message.IsFirst; interaction.StartPlay(); } } await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_SetLandlord_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { //如果本地玩家是地主添加地主牌 Card[] Tcards = new Card[message.LordCards.Count]; for (int i = 0; i < message.LordCards.Count; i++) { Tcards[i] = message.LordCards[i]; } handCards.AddCards(Tcards); } else { //其他玩家设置手牌数 handCards.SetHandCardsNum(20); } } //设置值玩家身份 foreach (var _gamer in room.gamers) { HandCardsComponent handCardsComponent = _gamer.GetComponent <HandCardsComponent>(); LandlordsGamerPanelComponent gamerUI = _gamer.GetComponent <LandlordsGamerPanelComponent>(); if (_gamer.UserID == message.UserID) { handCardsComponent.AccessIdentity = Identity.Landlord; gamerUI.SetIdentity(Identity.Landlord); } else { handCardsComponent.AccessIdentity = Identity.Farmer; gamerUI.SetIdentity(Identity.Farmer); } } //重置玩家UI提示 foreach (var _gamer in room.gamers) { _gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); } //切换地主牌精灵 GameObject lordPokers = uiRoom.GameObject.Get <GameObject>("Desk").Get <GameObject>("LordPokers"); for (int i = 0; i < lordPokers.transform.childCount; i++) { Sprite lordCardSprite = CardHelper.GetCardSprite(message.LordCards[i].GetName()); lordPokers.transform.GetChild(i).GetComponent <Image>().sprite = lordCardSprite; } await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_SetMultiples_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); uiRoom.GetComponent <LandRoomComponent>().SetMultiples(message.Multiples); await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_GamerEnterRoom_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent landRoomComponent = uiRoom.GetComponent <LandRoomComponent>(); //从匹配状态中切换为准备状态 if (landRoomComponent.Matching) { landRoomComponent.Matching = false; //进入房间取消匹配状态 //GameObject matchPrompt = uiRoom.GameObject.Get<GameObject>("MatchPrompt"); uiRoom.GameObject.Get <GameObject>("Ready").SetActive(true); } //服务端发过来3个GamerInfo 本地玩家进入房间的顺序 int localIndex = -1; for (int i = 0; i < message.Gamers.Count; i++) { if (message.Gamers[i].UserID == LandRoomComponent.LocalGamer.UserID) { //得出本地玩家是第几个进入房间,可能是0,1,2 localIndex = i; } } //添加进入房间的玩家,判定座位位置 for (int i = 0; i < message.Gamers.Count; i++) { //如果服务端发来了默认空GamerInfo 跳过 GamerInfo gamerInfo = message.Gamers[i]; if (gamerInfo.UserID == 0) { continue; } //如果这个ID的玩家不在桌上 if (landRoomComponent.GetGamer(gamerInfo.UserID) == null) { Gamer gamer = ETModel.ComponentFactory.Create <Gamer, long>(gamerInfo.UserID); // localIndex + 1 指本地玩家后进入的下一个玩家 // 不论本地玩家是第几个进入房间,都放在1号位(下边) if ((localIndex + 1) % 3 == i) { //玩家在本地玩家右边2号位 landRoomComponent.AddGamer(gamer, 2); } else { //玩家在本地玩家左边0号位 landRoomComponent.AddGamer(gamer, 0); } } } await ETTask.CompletedTask; }
private async void RPCTest() { ETModel.Session session = GameEntry.ETNetwork.CreateSession(GameEntry.ETNetwork.ServerIP); ETModel.R2C_RPCTest rpcTestResponse = (ETModel.R2C_RPCTest) await session.Call(new ETModel.C2R_RPCTest() { Text = "Hello ETServer" }); Log.Info("收到了服务端的RPC消息响应:" + rpcTestResponse.Text); }
static internal void Lua_OzNetClient_OnSessionClose(LuaFunction ld, ETModel.Session a1, int a2) { IntPtr l = ld.L; int error = pushTry(l); pushValue(l, a1); pushValue(l, a2); ld.pcall(2, error); LuaDLL.lua_settop(l, error - 1); }
protected override async ETTask Run(ETModel.Session session, Actor_AuthorityGrabLandlord_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); if (message.UserID == LandRoomComponent.LocalGamer.UserID) { //显示抢地主交互 uiRoom.GetComponent <LandRoomComponent>().Interaction.StartGrab(); } await ETTask.CompletedTask; }
public async Task OnLogin(BattleServerInfo serverInfo = null) { try { if (serverInfo == null) { Log.Error("onlogin failure"); return; } Log.Info("onlogin"); roomId = serverInfo.roomId; // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中 ETModel.Session gateSession = ETModel.Game.Scene.GetComponent <ETModel.NetOuterComponent>().Create(serverInfo.ipAndPort); ETModel.SessionComponent modelSession = ETModel.Game.Scene.GetComponent <ETModel.SessionComponent>(); if (modelSession == null) { modelSession = ETModel.Game.Scene.AddComponent <ETModel.SessionComponent>(); } modelSession.Session = gateSession; C2G_LoginGate c2G_LoginGate = new C2G_LoginGate() { Token = serverInfo.token, RoomId = serverInfo.roomId, PlayerId = playerUID }; G2C_LoginGate g2C_LoginGate = await modelSession.Session.Call(c2G_LoginGate) as G2C_LoginGate; if (g2C_LoginGate != null) { if (g2C_LoginGate.Error == ErrorCode.ERR_ConnectGateKeyError) { Game.EventSystem.Run(EventIdType.FightGameEnd); } } //if (funcs.UsingFrameSync && !func.IsPlayback) //{ // ETModel.WebSocketBenchmarkComponent testPing = ETModel.Game.Scene.GetComponent<ETModel.WebSocketBenchmarkComponent>(); // if (testPing == null) // testPing = ETModel.Game.Scene.AddComponent<ETModel.WebSocketBenchmarkComponent>(); // testPing.Session = gateSession; //} //testPing.UpdatePing(); //开始心跳 Log.Info("登陆gate成功!"); } catch (Exception e) { Log.Error(e); } }
static StackObject *get_Network_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ETModel.Session instance_of_this_method = (ETModel.Session) typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Network; return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *get_Error_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ETModel.Session instance_of_this_method = (ETModel.Session) typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Error; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
protected override async ETTask Run(ETModel.Session session, Actor_GamerGrabLandlordSelect_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandRoomComponent>().Interaction.EndGrab(); } gamer.GetComponent <LandlordsGamerPanelComponent>().SetGrab(message.IsGrab); } await ETTask.CompletedTask; }
static StackObject *Send_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ETModel.IMessage @message = (ETModel.IMessage) typeof(ETModel.IMessage).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); ETModel.Session instance_of_this_method = (ETModel.Session) typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Send(@message); return(__ret); }
protected override async ETTask Run(ETModel.Session session, Actor_GamerDontPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { if (gamer.UserID == LandRoomComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandRoomComponent>().Interaction.EndPlay(); } gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); gamer.GetComponent <LandlordsGamerPanelComponent>().SetDiscard(); } await ETTask.CompletedTask; }
static StackObject *Send_4(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object @message = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.UInt16 @opcode = (ushort)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 3); ETModel.Session instance_of_this_method = (ETModel.Session) typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Send(@opcode, @message); return(__ret); }
static StackObject *Call_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ETModel.IRequest @request = (ETModel.IRequest) typeof(ETModel.IRequest).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); ETModel.Session instance_of_this_method = (ETModel.Session) typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Call(@request); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/// <summary> /// 创建热更新层会话 /// </summary> public static Session CreateHotfixSession(ETModel.Session session) { return(ComponentFactory.Create <Session, ETModel.Session>(session)); }
protected override async ETTask Run(ETModel.Session session, Actor_GameStartHandCards_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(LandUIType.LandRoom); LandRoomComponent room = uiRoom.GetComponent <LandRoomComponent>(); //初始化玩家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 == LandRoomComponent.LocalGamer.UserID) { //本地玩家添加手牌 Card[] Tcards = new Card[message.HandCards.Count]; for (int i = 0; i < message.HandCards.Count; i++) { Tcards[i] = message.HandCards[i]; } 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; } LandRoomComponent uiRoomComponent = uiRoom.GetComponent <LandRoomComponent>(); //设置初始倍率 uiRoomComponent.SetMultiples(1); await ETTask.CompletedTask; }
protected override async ETTask Run(ETModel.Session session, Actor_LandMatcherPlusOne_NTT message) { Log.Debug("匹配玩家+1"); await ETTask.CompletedTask; }
static internal void Lua_OzNetClient_OnGetServerMessageCallback(LuaFunction ld, ETModel.Session a1, SLua.ByteStringArray a2, System.UInt16 a3) { IntPtr l = ld.L; int error = pushTry(l); pushValue(l, a1); pushValue(l, a2); pushValue(l, a3); ld.pcall(3, error); LuaDLL.lua_settop(l, error - 1); }