protected override void Run(ETModel.Session session, Actor_AuthorityPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { //重置玩家提示 gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); //当玩家为先手,清空出牌 if (message.IsFirst) { gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); } //显示出牌按钮 if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction; interaction.IsFirst = message.IsFirst; interaction.StartPlay(); } } }
protected override void Run(ETModel.Session session, Actor_Gameover_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); ReferenceCollector rc = uiRoom.GameObject.GetComponent <ReferenceCollector>(); //隐藏发牌桌 rc.Get <GameObject>("Desk").SetActive(false); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Identity localGamerIdentity = LandlordsRoomComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity; UI uiEndPanel = LandlordsEndFactory.Create(UIType.LandlordsEnd, uiRoom, message.Winner == (int)localGamerIdentity); LandlordsEndComponent landlordsEndComponent = uiEndPanel.GetComponent <LandlordsEndComponent>(); foreach (GamerScore gamerScore in message.GamersScore) { Gamer gamer = room.GetGamer(gamerScore.UserID); //更新玩家信息(金钱/头像) gamer.GetComponent <LandlordsGamerPanelComponent>().UpdatePanel(); //清空出牌 //gamer.GetComponent<HandCardsComponent>().ClearPlayCards(); gamer.GetComponent <HandCardsComponent>().Hide(); //根据GamersScore中玩家顺序进行排列 landlordsEndComponent.CreateGamerContent( gamer, localGamerIdentity, message.BasePointPerMatch, message.Multiples, gamerScore.Score); } room.Interaction.Gameover(); room.ResetMultiples(); }
protected override void Run(ETModel.Session session, Actor_GamerPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { gamer.GetComponent <LandlordsGamerPanelComponent>().ResetPrompt(); //本地玩家清空选中牌 关闭出牌按钮 if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().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); } }
protected override void Run(ETModel.Session session, Actor_GamerReconnect_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); //关闭准备按钮 uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false); foreach (GamerState gamerState in message.GamersState) { //遍历玩家状态 设置地主身份和头像 Gamer gamer = room.GetGamer(gamerState.UserID); HandCardsComponent gamerHandCards = gamer.GetComponent <HandCardsComponent>(); LandlordsGamerPanelComponent gamerUI = gamer.GetComponent <LandlordsGamerPanelComponent>(); Identity gamerIdentity = (Identity)gamerState.Identity; gamerHandCards.AccessIdentity = gamerIdentity; gamerUI.SetIdentity(gamerIdentity); //如果在牌局中 恢复上一个玩家的出牌行为(牌最大的玩家) //ID用于确认玩家 身份状态用于确认是否开始了牌局 if (message.BiggstGamer == gamer.UserID && gamerIdentity != Identity.None) { Card[] Tcards = new Card[message.DeskCards.Count]; for (int i = 0; i < message.DeskCards.Count; i++) { Tcards[i] = message.DeskCards[i]; } if (Tcards != null) { gamerHandCards.PopCards(Tcards); //本地出牌画面更新 } } else if (message.LordCards.Count == 0 && gamerState.GrabLandlordState) { //如果牌局在抢地主阶段 恢复抢地主状态 gamerUI.SetGrab(gamerState.GrabLandlordState); } } //初始化界面 room.SetMultiples(message.Multiples); //当抢完地主时才能显示托管按钮 if (message.LordCards.Count != 0) { room.Interaction.GameStart(); } //初始化地主牌 if (message.LordCards != null) { 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; } } }
protected override void Run(ETModel.Session session, Actor_Trusteeship_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction; interaction.isTrusteeship = message.IsTrusteeship; } }
protected override void Run(ETModel.Session session, Actor_GamerReady_Landlords message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); gamer.GetComponent <LandlordsGamerPanelComponent>().SetReady(); //本地玩家准备,隐藏准备按钮 if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false); } }
protected override void Run(ETModel.Session session, Actor_GamerGrabLandlordSelect_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.EndGrab(); } gamer.GetComponent <LandlordsGamerPanelComponent>().SetGrab(message.IsGrab); } }
protected override void Run(ETModel.Session session, Actor_GamerDontPlay_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { if (gamer.UserID == LandlordsRoomComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.EndPlay(); } gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); gamer.GetComponent <LandlordsGamerPanelComponent>().SetDiscard(); } }
protected override void Run(ETModel.Session session, Actor_SetLandlord_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent room = uiRoom.GetComponent <LandlordsRoomComponent>(); Gamer gamer = room.GetGamer(message.UserID); if (gamer != null) { HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); if (gamer.UserID == LandlordsRoomComponent.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; } //显示切换游戏模式按钮 uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.GameStart(); }
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_GamerEnterRoom_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>(); //从匹配状态中切换为准备状态 if (landlordsRoomComponent.Matching) { landlordsRoomComponent.Matching = false; GameObject matchPrompt = uiRoom.GameObject.Get <GameObject>("MatchPrompt"); if (matchPrompt.activeSelf) { matchPrompt.SetActive(false); uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(true); } } //服务端发过来3个GamerInfo 当前玩家为其中一个 //{"Parser":{},"UserID":382339254124924,"IsReady":false} int localGamerIndex = -1; for (int i = 0; i < message.Gamers.Count; i++) { if (message.Gamers[i].UserID == LandlordsRoomComponent.LocalGamer.UserID) { localGamerIndex = i; } } if (localGamerIndex == -1) { Log.Error("难道是旁观模式?"); } //添加未显示玩家 for (int i = 0; i < message.Gamers.Count; i++) { //如果服务端发来了默认空GamerInfo 跳过 //{"Parser":{},"UserID":0,"IsReady":false}]} GamerInfo gamerInfo = message.Gamers[i]; if (gamerInfo.UserID == 0) { continue; } //如果这个ID的玩家不在桌上 if (landlordsRoomComponent.GetGamer(gamerInfo.UserID) == null) { Gamer gamer = ETModel.ComponentFactory.Create <Gamer, long>(gamerInfo.UserID); //并没有判断玩家是否已准备 //localGamerIndex % 3可以理解为当前玩家在3个玩家(Gamers)中的顺序 //localGamerIndex + 1指当前玩家的下一个玩家的相对顺序 //如果本地玩家序列为2 localGamerIndex + 1) % 3=0 序列为0的玩家显示在2号位 if ((localGamerIndex + 1) % 3 == i) { //玩家在本地玩家右边 landlordsRoomComponent.AddGamer(gamer, 2); } else { //玩家在本地玩家左边 landlordsRoomComponent.AddGamer(gamer, 0); } } } }