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 GamerOperation(Actor_GamerOperation message, bool isReconnect) { try { Log.Info($"收到有人碰杠胡"); 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); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); uiRoomComponent.ClosePropmtBtn(); uiRoomComponent.ShowTurn(message.Uid); MahjongInfo mahjongInfo = new MahjongInfo() { weight = (byte)message.weight, m_weight = (Consts.MahjongWeight)message.weight }; if (message.OperationType == 0) { SoundsHelp.Instance.PlayPeng(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound); } else { SoundsHelp.Instance.PlayGang(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound); } if (PlayerInfoComponent.Instance.uid == message.Uid) { if (message.OperationType == 0) { gamerComponent.CurrentPlayUid = message.Uid; gamerComponent.IsPlayed = false; } //碰刚 if (message.OperationType == 5) { handCardsComponent.SetPengGang(message.OperationType, mahjongInfo, message.OperatedUid); } else { handCardsComponent.SetPeng(message.OperationType, mahjongInfo, message.OperatedUid, isReconnect); } //隐藏碰杠 handCardsComponent.CloseHandCardCanPeng(); } else { //碰刚 if (message.OperationType == 5) { handCardsComponent.SetOtherPengGang(message.OperationType, mahjongInfo, message.OperatedUid, message.Uid); } else { handCardsComponent.SetOtherPeng(message.OperationType, mahjongInfo, message.OperatedUid, message.Uid); } } //显示碰刚动画 handCardsComponent.ShowOperateAnimAsync(message.OperationType); if (isReconnect) { return; } //碰和碰刚删除出的牌 if (message.OperationType == 0 || message.OperationType == 1) { Gamer currentGamer = gamerComponent.Get(gamerComponent.LastPlayUid); HandCardsComponent currentCards = currentGamer.GetComponent <HandCardsComponent>(); GameObject.Destroy(currentCards.currentPlayCardObj); currentCards.cardDisplayObjs.Remove(currentCards.currentPlayCardObj); } } catch (Exception e) { Log.Error(e); } }
protected override async void Run(ETModel.Session session, Actor_GamerHuPai message) { try { Log.Info($"收到胡:"); 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>(); SoundsHelp.Instance.PlayHuSound(gamer.PlayerInfo.PlayerSound); if (PlayerInfoComponent.Instance.uid == message.Uid) { SoundsHelp.Instance.playSound_Win(); } else { SoundsHelp.Instance.playSound_Fail(); } if (message.IsZiMo) { handCardsComponent.ShowOperateAnimAsync((int)GamerOpearteType.zimo); } else { handCardsComponent.ShowOperateAnimAsync((int)GamerOpearteType.Hu); } uiRoomComponent.exitBtn.gameObject.SetActive(false); await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(1500); uiRoomComponent.exitBtn.gameObject.SetActive(true); if (gamerComponent.GetGamerCount() < 4) { return; } UIGameResultComponent gameResultComponent = Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGameResult).GetComponent <UIGameResultComponent>(); RoomConfig roomConfig; if (uiRoomComponent.RoomType == 3) { roomConfig = uiRoomComponent.RoomConfig; gameResultComponent.SetFriendRoom(); gameResultComponent.startTimer(5); } else { roomConfig = ConfigHelp.Get <RoomConfig>(uiRoomComponent.RoomType); gameResultComponent.startTimer(20); } gameResultComponent.setData(message, gamerComponent, roomConfig.Multiples); UIRoomComponent.ISGaming = false; uiRoomComponent.ClosePropmtBtn(); } catch (Exception e) { Log.Error(e); } }