/// <summary> /// 创建玩家结算信息 /// </summary> /// <returns></returns> public GameObject CreateGamerContent(Gamer gamer, Identity winnerIdentity, long baseScore, int multiples, long score) { GameObject newContent = UnityEngine.Object.Instantiate(contentPrefab); newContent.transform.SetParent(gamerContent.transform, false); Identity gamerIdentity = gamer.GetComponent <HandCardsComponent>().AccessIdentity; Sprite identitySprite = CardHelper.GetCardSprite($"Identity_{Enum.GetName(typeof(Identity), gamerIdentity)}"); newContent.Get <GameObject>("Identity").GetComponent <Image>().sprite = identitySprite; string nickName = gamer.GetComponent <GamerUIComponent>().NickName; Text nickNameText = newContent.Get <GameObject>("NickName").GetComponent <Text>(); Text baseScoreText = newContent.Get <GameObject>("BaseScore").GetComponent <Text>(); Text multiplesText = newContent.Get <GameObject>("Multiples").GetComponent <Text>(); Text scoreText = newContent.Get <GameObject>("Score").GetComponent <Text>(); nickNameText.text = nickName; baseScoreText.text = baseScore.ToString(); multiplesText.text = multiples.ToString(); scoreText.text = score.ToString(); if (gamer.UserID == this.GetParent <UI>().GetParent <UI>().GetComponent <GamerComponent>().LocalGamer.UserID) { nickNameText.color = Color.red; baseScoreText.color = Color.red; multiplesText.color = Color.red; scoreText.color = Color.red; } return(newContent); }
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(Session session, M2C_AuthorityPlayCard message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer != null) { //重置玩家提示 gamer.GetComponent <GamerUIComponent>().ResetPrompt(); //当玩家为先手,清空出牌 if (message.IsFirst) { gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); } //显示出牌按钮 if (gamer.UserID == gamerComponent.LocalGamer.UserID) { UIInteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().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_Gameover_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Identity localGamerIdentity = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>().AccessIdentity; UI uiEndPanel = LandlordsEndFactory.Create(UIType.LandlordsEnd, uiRoom, (Identity)message.Winner == localGamerIdentity); LandlordsEndComponent landlordsEndComponent = uiEndPanel.GetComponent <LandlordsEndComponent>(); foreach (GamerScore gamerScore in message.GamersScore) { Gamer gamer = uiRoom.GetComponent <GamerComponent>().Get(gamerScore.UserID); gamer.GetComponent <GamerUIComponent>().UpdatePanel(); gamer.GetComponent <HandCardsComponent>().Hide(); landlordsEndComponent.CreateGamerContent( gamer, (Identity)message.Winner, message.BasePointPerMatch, message.Multiples, gamerScore.Score); } LandlordsRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>(); landlordsRoomComponent.Interaction.Gameover(); landlordsRoomComponent.ResetMultiples(); }
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_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); }
/// <summary> /// 添加玩家 /// </summary> /// <param name="gamer"></param> /// <param name="index"></param> public void AddGamer(Gamer gamer, int index) { try { GetParent <UI>().GetComponent <GamerComponent>().Add(gamer, index); gamer.GetComponent <GamerUIComponent>().SetPanel(this.GamersPanel[index], this.HeadPanel[index], index); HeadManager.setHeadSprite(gamer.GetComponent <GamerUIComponent>().head, gamer.PlayerInfo.Icon); } catch (Exception e) { Log.Error(e); } }
protected override void Run(ETModel.Session session, Actor_GamerReconnect_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); foreach (GamerState gamerState in message.GamersState) { Gamer gamer = gamerComponent.Get(gamerState.UserID); HandCardsComponent gamerHandCards = gamer.GetComponent <HandCardsComponent>(); GamerUIComponent gamerUI = gamer.GetComponent <GamerUIComponent>(); Identity gamerIdentity = gamerState.UserIdentity; gamerHandCards.AccessIdentity = gamerIdentity; gamerUI.SetIdentity(gamerIdentity); //初始化出牌 if (message.UserId == gamer.UserID && gamerIdentity != Identity.None) { if (message.Cards != null) { gamerHandCards.PopCards(message.Cards); } } else if (message.LordCards.count == 0) { gamer.GetComponent <GamerUIComponent>().SetGrab(gamerState.State); } } //初始化界面 LandlordsRoomComponent uiRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>(); //隐藏准备按钮,避免重连时还显示准备按钮 uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false); //设置倍率 uiRoomComponent.SetMultiples(message.Multiples); //当抢完地主时才能显示托管按钮 if (message.LordCards.count > 0) { uiRoomComponent.Interaction.GameStart(); } //初始化地主牌 if (message.LordCards.count > 0) { 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_GamerDontPlay_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer != null) { if (gamer.UserID == gamerComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.EndPlay(); } gamer.GetComponent <HandCardsComponent>().ClearPlayCards(); gamer.GetComponent <GamerUIComponent>().SetDiscard(); } }
protected override async void Run(ETModel.Session session, Actor_GamerTrusteeship message) { try { Log.Info($"玩家托管:" + message.Uid); UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); Gamer gamer = gamerComponent.Get(message.Uid); if (message.Uid == PlayerInfoComponent.Instance.uid) { uiRoomComponent.ShowTrustship(); } else { GamerUIComponent gamerUIComponent = gamer.GetComponent <GamerUIComponent>(); gamerUIComponent.ShowTrust(); } } catch (Exception e) { Log.Error(e); } }
protected override void Run(ETModel.Session session, Actor_GamerCheat message) { try { Log.Debug("收到作弊"); UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); if (handCardsComponent == null) { return; } handCardsComponent.DeleteAllItem(handCardsComponent.CardBottom); foreach (var card in message.handCards) { card.m_weight = (Consts.MahjongWeight)card.weight; } handCardsComponent.AddCards(message.handCards); } catch (Exception e) { Log.Error(e); } }
protected override async void Run(ETModel.Session session, Actor_GamerReady message) { try { Log.Info($"收到准备"); UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); UIReadyComponent uiReadyComponent = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIReady)?.GetComponent <UIReadyComponent>(); if (uiRoom == null) { return; } GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.Uid); if (gamer == null) { Log.Warning($"{message.Uid}玩家为空"); return; } GamerUIComponent gamerUiComponent = gamer.GetComponent <GamerUIComponent>(); gamerUiComponent.SetReady(); uiReadyComponent?.SetReady(message.Uid); SoundsHelp.Instance.playSound_ZhunBei(); } catch (Exception e) { Log.Error(e); } }
public static async void Start(this TrusteeshipComponent self) { //玩家所在房间 Room room = Game.Scene.GetComponent <RoomComponent>().Get(self.GetParent <Gamer>().RoomID); OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>(); Gamer gamer = self.GetParent <Gamer>(); bool isStartPlayCard = false; while (true) { await Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000); if (self.IsDisposed) { return; } if (gamer.UserID != orderController?.CurrentAuthority) { continue; } //自动出牌开关,用于托管延迟出牌 isStartPlayCard = !isStartPlayCard; if (isStartPlayCard) { continue; } //出牌 await gamer.GetComponent <HandCardsComponent>().PopCard(); } }
public void ShowOperation(int operationType) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); switch (operationType) { case 0: pengBtn.gameObject.SetActive(true); handCardsComponent.ShowHandCardCanPeng(CurrentMahjong.weight); break; case 1: case 4: case 5: gangBtn.gameObject.SetActive(true); handCardsComponent.ShowHandCardCanPeng(CurrentMahjong.weight); break; case 2: huBtn.gameObject.SetActive(true); break; case 3: break; } giveUpBtn.gameObject.SetActive(true); }
public static async void Start(this TrusteeshipComponent self) { //玩家所在房间 Room room = Game.Scene.GetComponent <RoomComponent>().Get(self.GetParent <Gamer>().RoomID); OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>(); Gamer gamer = self.GetParent <Gamer>(); bool isStartPlayCard = false; while (true) { await Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000); if (self.IsDisposed) { return; } if (gamer.UserID != orderController?.CurrentAuthority) { continue; } //自动出牌开关,用于托管延迟出牌 isStartPlayCard = !isStartPlayCard; if (isStartPlayCard) { continue; } ActorMessageSender actorProxy = Game.Scene.GetComponent <ActorMessageSenderComponent>().Get(gamer.Id); //当还没抢地主时随机抢地主 if (gamer.GetComponent <HandCardsComponent>().AccessIdentity == Identity.None) { int randomSelect = RandomHelper.RandomNumber(0, 2); actorProxy.Send(new Actor_GamerGrabLandlordSelect_Ntt() { IsGrab = randomSelect == 0 }); self.Playing = false; continue; } //自动提示出牌 Actor_GamerPrompt_Ack response = await actorProxy.Call(new Actor_GamerPrompt_Req()) as Actor_GamerPrompt_Ack; if (response.Error > 0 || response.Cards == null) { actorProxy.Send(new Actor_GamerDontPlay_Ntt()); } else { await actorProxy.Call(new Actor_GamerPlayCard_Req() { Cards = response.Cards }); } } }
/// <summary> /// 发牌 /// </summary> /// <param name="self"></param> /// <param name="chairID"></param> public static void DealTo(this GameControllerComponent self, ushort chairID) { Room room = self.GetParent <Room>(); byte[] cards = room.GetComponent <DeckComponent>().Deals(5); Gamer gamer = room.Get(chairID); gamer.GetComponent <HandCardsComponent>().AddCard(cards); }
public static void Send(this Room self, Gamer gamer, IActorMessage message) { if (gamer == null || gamer.IsOffline) { return; } ActorMessageSender actorProxy = gamer.GetComponent <GamerGateComponent>().GetActorMessageSender(); actorProxy.Send(message); }
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 async void Run(ETModel.Session session, Actor_GamerGrabCard message) { try { Log.Info($"收到抓拍"); MahjongInfo mahjongInfo = new MahjongInfo() { weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight }; UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); if (uiRoom == null) { return; } GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); Gamer gamer = gamerComponent.Get(message.Uid); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); if (PlayerInfoComponent.Instance.uid == message.Uid) { handCardsComponent.GrabCard(mahjongInfo); } else { handCardsComponent.GrabOtherCard(); } //当前出牌玩家 gamerComponent.CurrentPlayUid = message.Uid; gamerComponent.IsPlayed = false; //剩下的牌 uiRoomComponent.SetRestCount(); //显示黄色bg uiRoomComponent.ShowTurn(message.Uid); uiRoomComponent.ClosePropmtBtn(); SoundsHelp.Instance.playSound_MoPai(); uiRoomComponent.CurrentMahjong = mahjongInfo; Gamer currentGamer = gamerComponent.Get(PlayerInfoComponent.Instance.uid); HandCardsComponent currentGamerCard = currentGamer.GetComponent <HandCardsComponent>(); currentGamerCard.CloseHandCardCanPeng(); } catch (Exception e) { Log.Error(e); } }
public static void GamerBroadcast(this Room self, Gamer gamer, IActorMessage message) { if (gamer == null || gamer.isOffline) { return; } ActorMessageSenderComponent actorMessageSenderComponent = Game.Scene.GetComponent <ActorMessageSenderComponent>(); UnitGateComponent unitGateComponent = gamer.GetComponent <UnitGateComponent>(); actorMessageSenderComponent.GetWithActorId(unitGateComponent.GateSessionActorId).Send(message); }
protected override void Run(ETModel.Session session, Actor_GamerPlayCard_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer != null) { gamer.GetComponent <GamerUIComponent>().ResetPrompt(); if (gamer.UserID == gamerComponent.LocalGamer.UserID) { LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction; interaction.Clear(); interaction.EndPlay(); } HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); handCards.PopCards(message.Cards); } }
protected override async void Run(ETModel.Session session, Actor_GamerBuHua message) { try { Log.Info($"收到补花:{message.weight}"); MahjongInfo mahjongInfo = new MahjongInfo() { weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight }; UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); Gamer gamer = gamerComponent.Get(message.Uid); GamerUIComponent gamerUiComponent = gamer.GetComponent <GamerUIComponent>(); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); if (PlayerInfoComponent.Instance.uid == message.Uid) { handCardsComponent.BuHua(mahjongInfo, true); SoundsHelp.Instance.PlayBuHua(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound); } else { handCardsComponent.BuHua(mahjongInfo, false); SoundsHelp.Instance.PlayBuHua(gamer.PlayerInfo.PlayerSound); } //补花显示 gamerUiComponent.SetBuHua(message.weight); gamerUiComponent.ShowBuHua(); //剩下的牌 uiRoomComponent.SetRestCount(); } catch (Exception e) { Log.Error(e); } }
/// <summary> /// 游戏继续 /// </summary> /// <param name="self"></param> /// <param name="lastGamer"></param> public static void Continue(this GameControllerComponent self, Gamer lastGamer) { Room room = self.GetParent <Room>(); OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>(); //是否结束,当前出牌者手牌数为0时游戏结束 bool isEnd = lastGamer.GetComponent <HandCardsComponent>().CardsCount == 0; if (isEnd) { //当前最大出牌者为赢家 Identity winnerIdentity = room.Get(orderController.Biggest).GetComponent <HandCardsComponent>().AccessIdentity; List <GamerScore> gamersScore = new List <GamerScore>(); //游戏结束所有玩家摊牌 foreach (var gamer in room.GetAll()) { //取消托管 gamer.RemoveComponent <TrusteeshipComponent>(); //计算玩家积分 gamersScore.Add(new GamerScore() { UserID = gamer.UserID, Score = self.GetGamerScore(gamer, winnerIdentity) }); if (gamer.UserID != lastGamer.UserID) { //剩余玩家摊牌 Card[] _gamerCards = gamer.GetComponent <HandCardsComponent>().GetAll(); Actor_GamerPlayCard_Ntt gamerPlayCardMessage = new Actor_GamerPlayCard_Ntt() { UserID = gamer.UserID }; gamerPlayCardMessage.Cards.AddRange(gamer.GetComponent <HandCardsComponent>().GetAll()); room.Broadcast(gamerPlayCardMessage); } } self.GameOver(gamersScore, winnerIdentity); } else { //轮到下位玩家出牌 orderController.Biggest = lastGamer.UserID; orderController.Turn(); room.Broadcast(new Actor_AuthorityPlayCard_Ntt() { UserID = orderController.CurrentAuthority, IsFirst = false }); } }
protected override void Run(ETModel.Session session, A1006_PathfindingResult_M2C message) { Gamer gamer = ETModel.Game.Scene.GetComponent <GamerComponent>().Get(message.UserID); //如果本地玩家收到服务器转发自己的消息 不处理 if (gamer.UserID == GamerComponent.Instance.MyUser.UserID) { return; } gamer.GetComponent <GamerAnimatorComponent>().SetIntValue("Speed", 1); GamerPathComponent gamerPathComponent = gamer.GetComponent <GamerPathComponent>(); gamerPathComponent.StartMove(message).NoAwait(); GizmosDebug.Instance.Path.Clear(); GizmosDebug.Instance.Path.Add(new Vector3(message.X, message.Y, message.Z)); for (int i = 0; i < message.Xs.Count; ++i) { GizmosDebug.Instance.Path.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i])); } }
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(Session session, C2M_GamerReady message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); gamer.GetComponent <GamerUIComponent>().SetReady(); //本地玩家准备,隐藏准备按钮 if (gamer.UserID == gamerComponent.LocalGamer.UserID) { uiRoom.GetComponent <UIRoomComponent>().readyButton.SetActive(false); } }
protected override void Run(Session session, Actor_GamerReady_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); gamer.GetComponent <GamerUIComponent>().SetReady(); //本地玩家准备,隐藏准备按钮 if (gamer.UserID == gamerComponent.LocalGamer.UserID) { uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(false); } }
/// <summary> /// 计算玩家积分 /// </summary> /// <param name="self"></param> /// <param name="gamer"></param> /// <param name="winnerIdentity"></param> /// <returns></returns> public static long GetGamerScore(this GameControllerComponent self, Gamer gamer, Identity winnerIdentity) { HandCardsComponent handCards = gamer.GetComponent <HandCardsComponent>(); //积分计算公式:全场底分 * 全场倍率 * 身份倍率 long integration = self.BasePointPerMatch * self.Multiples * (int)handCards.AccessIdentity; //当玩家不是胜者,结算积分为负 if (handCards.AccessIdentity != winnerIdentity) { integration = -integration; } return(integration); }