protected override void Run(ETModel.Session session, Actor_GameStart_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); //初始化玩家UI foreach (GamerCardNum gamerCardNum in message.GamersCardNum) { Gamer gamer = uiRoom.GetComponent <GamerComponent>().Get(gamerCardNum.UserID); GamerUIComponent gamerUI = gamer.GetComponent <GamerUIComponent>(); gamerUI.GameStart(); HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); if (handCards != null) { handCards.Reset(); } else { handCards = gamer.AddComponent <HandCardsComponent, GameObject>(gamerUI.Panel); } handCards.Appear(); if (gamer.UserID == gamerComponent.LocalGamer.UserID) { //本地玩家添加手牌 handCards.AddCards(message.HandCards); } 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(Session session, M2C_SetLandlord message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer != null) { HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); if (gamer.UserID == gamerComponent.LocalGamer.UserID) { //本地玩家添加手牌 handCards.AddCards(message.LordCards); } else { //其他玩家设置手牌数 handCards.SetHandCardsNum(20); } } foreach (var _gamer in gamerComponent.GetAll()) { HandCardsComponent handCardsComponent = _gamer.GetComponent <HandCardsComponent>(); GamerUIComponent gamerUIComponent = _gamer.GetComponent <GamerUIComponent>(); if (_gamer.UserID == message.UserID) { handCardsComponent.AccessIdentity = Identity.Landlord; gamerUIComponent.SetIdentity(Identity.Landlord); } else { handCardsComponent.AccessIdentity = Identity.Farmer; gamerUIComponent.SetIdentity(Identity.Farmer); } } //重置玩家UI提示 foreach (var _gamer in gamerComponent.GetAll()) { _gamer.GetComponent <GamerUIComponent>().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 <UIRoomComponent>().Interaction.GameStart(); }
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); }