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); } }
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(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_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 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); }
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(); }
public void GamerReady(int[] seatIds) { for (int i = 0; i < seatIds.Length; i++) { UICowCow_GamerInfoComponent gc = GamerComponent.Get(seatIds[i]).GetComponent <UICowCow_GamerInfoComponent>(); if (gc.Status != UIGamerStatus.Ready) { gc.SetStatus(UIGamerStatus.Ready, UIGamerStatusString.Ready); } } }
protected override void Run(Session session, C2M_Trusteeship message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer.UserID == ClientComponent.Instance.LocalPlayer.UserID) { UIInteractionComponent interaction = uiRoom.GetComponent <UIRoomComponent>().Interaction; interaction.isTrusteeship = message.isTrusteeship; } }
protected override void Run(ETModel.Session session, Actor_Trusteeship_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer.UserID == ClientComponent.Instance.LocalPlayer.UserID) { LandlordsInteractionComponent interaction = uiRoom.GetComponent <LandlordsRoomComponent>().Interaction; interaction.isTrusteeship = message.isTrusteeship; } }
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(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); } }
protected override void Run(Session session, C2M_GamerGrabLandlordSelect message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.UserID); if (gamer != null) { if (gamer.UserID == gamerComponent.LocalGamer.UserID) { uiRoom.GetComponent <UIRoomComponent>().Interaction.EndGrab(); } gamer.GetComponent <GamerUIComponent>().SetGrab(message.IsGrab); } }
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 void Run(ETModel.Session session, Actor_GamerEnterRoom_Ntt message) { UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.LandlordsRoom); LandlordsRoomComponent landlordsRoomComponent = uiRoom.GetComponent <LandlordsRoomComponent>(); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); //从匹配状态中切换为准备状态 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); } } int localGamerIndex = message.Gamers.FindIndex(info => info.UserID == gamerComponent.LocalGamer.UserID); //添加未显示玩家 for (int i = 0; i < message.Gamers.Count; i++) { GamerInfo gamerInfo = message.Gamers[i]; if (gamerInfo.UserID == 0) { continue; } if (gamerComponent.Get(gamerInfo.UserID) == null) { Gamer gamer = GamerFactory.Create(gamerInfo.UserID, gamerInfo.IsReady); if ((localGamerIndex + 1) % 3 == i) { //玩家在本地玩家右边 landlordsRoomComponent.AddGamer(gamer, 2); } else { //玩家在本地玩家左边 landlordsRoomComponent.AddGamer(gamer, 0); } } } }
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); } }
public static void PlayCard(Actor_GamerPlayCard 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); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); Gamer gamer = gamerComponent.Get(message.Uid); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); HandCardsComponent cardsComponent = gamerComponent.LocalGamer.GetComponent <HandCardsComponent>(); if (PlayerInfoComponent.Instance.uid == message.Uid) { handCardsComponent.PlayCard(mahjongInfo, message.index, uiRoomComponent.currentItem); SoundsHelp.Instance.PlayCardSound(PlayerInfoComponent.Instance.GetPlayerInfo().PlayerSound, message.weight); } else { handCardsComponent.PlayOtherCard(mahjongInfo, uiRoomComponent.currentItem); SoundsHelp.Instance.PlayCardSound(gamer.PlayerInfo.PlayerSound, message.weight); } gamerComponent.LastPlayUid = message.Uid; SoundsHelp.Instance.playSound_ChuPai(); uiRoomComponent.CurrentMahjong = mahjongInfo; } catch (Exception e) { Log.Error(e); } }
protected override void Run(ETModel.Session session, Actor_GamerGrabLandlordSelect_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) { GamerUIComponent gamerUIComponent = gamer.GetComponent <GamerUIComponent>(); if (gamer.UserID == gamerComponent.LocalGamer.UserID) { uiRoom.GetComponent <LandlordsRoomComponent>().Interaction.EndGrab(); } if (message.IsGrab) { gamerUIComponent.SetGrab(GrabLandlordState.Grab); } else { gamerUIComponent.SetGrab(GrabLandlordState.UnGrab); } } }
protected override async void Run(ETModel.Session session, Actor_GamerChangeGold message) { try { Log.Info($"收到改变金币:" + message.Uid + "GoldAmount," + message.GoldAmount); UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); if (uiRoom == null) { Log.Warning("uiroom null"); return; } UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Gamer gamer = gamerComponent.Get(message.Uid); HandCardsComponent handCardsComponent = gamer.GetComponent <HandCardsComponent>(); handCardsComponent.ChangeGold(message.GoldAmount); } catch (Exception e) { Log.Error(e); } }
protected override async void Run(ETModel.Session session, Actor_GamerExitRoom message) { try { Log.Info($"收到退出"); UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); if (uiRoom == null) { return; } // UI uiReady = Game.Scene.GetComponent<UIComponent>().Get(UIType.UIReady); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); // UIReadyComponent uiReadyComponent = uiReady.GetComponent<UIReadyComponent>(); if (gamerComponent.LocalGamer.UserID == message.Uid) { CommonUtil.ShowUI(UIType.UIMain); GameUtil.Back2Main(); } else { Gamer gamer = gamerComponent.Get(message.Uid); gamer?.GetComponent <GamerUIComponent>()?.ResetReadyPanel(); uiRoomComponent.RemoveGamer(message.Uid); } SoundsHelp.Instance.playSound_LiKai(); } catch (Exception e) { Log.Error(e); } }
public void setData(Actor_GamerHuPai data, GamerComponent gamerComponent, int BeiLv) { this.huPaiNeedData = data; Gamer[] gamers = gamerComponent.GetAll(); Gamer huPaiGamer = gamerComponent.Get(data.Uid); for (int i = 0; i < gamers.Length; i++) { if (gamers[i] == null) { continue; } if (gamers[i].UserID == data.Uid) { playerList.Insert(i, winPlayer); } } int huaCount = 0; //设置胡牌的花数 List <int> dataHuPaiTypes = data.HuPaiTypes; for (int j = 0; j < dataHuPaiTypes.Count; j++) { Consts.HuPaiType huPaiType = (Consts.HuPaiType)dataHuPaiTypes[j]; int count; Logic_NJMJ.getInstance().HuPaiHuaCount.TryGetValue(huPaiType, out count); //胡牌花 huaCount += count; } //硬花 huaCount += data.YingHuaCount; //软花 huaCount += data.RuanHuaCount; huaCount += data.BixiaHuCount; //基数 huaCount += 20; //砸2 huaCount *= 2; //设置胡牌的人 for (int i = 0; i < gamers.Length; i++) { Gamer gamer = gamers[i]; GameObject gameObject = this.playerList[i]; Image headImage = gameObject.transform.Find("head").GetComponent <Image>(); Text nameText = gameObject.transform.Find("name").GetComponent <Text>(); Text goldText = gameObject.transform.Find("Text_gold").GetComponent <Text>(); //headImage.sprite = CommonUtil.getSpriteByBundle("playericon", gamer.PlayerInfo.Icon); HeadManager.setHeadSprite(headImage, gamer.PlayerInfo.Icon); nameText.text = gamer.PlayerInfo.Name + ""; //胡牌的ui if (gamer.UserID == data.Uid) { Text huaCountText = gameObject.Get <GameObject>("Text").GetComponent <Text>(); GameObject allhuashutype = gameObject.Get <GameObject>("Allhuashutype"); Text obj1 = allhuashutype.transform.GetChild(0).GetComponent <Text>(); Text obj2 = allhuashutype.transform.GetChild(1).GetComponent <Text>(); Text obj3 = allhuashutype.transform.GetChild(2).GetComponent <Text>(); obj1.gameObject.SetActive(true); obj2.gameObject.SetActive(true); obj3.gameObject.SetActive(true); obj1.text = $"硬花{data.YingHuaCount}"; obj2.text = $"软花{data.RuanHuaCount}"; obj3.text = $"基数{20}"; //胡牌类型 for (int j = 0; j < dataHuPaiTypes.Count; j++) { Consts.HuPaiType huPaiType = (Consts.HuPaiType)dataHuPaiTypes[j]; int count; string name; Logic_NJMJ.getInstance().HuPaiHuaCount.TryGetValue(huPaiType, out count); Logic_NJMJ.getInstance().HuPaiHuaName.TryGetValue(huPaiType, out name); Text obj = allhuashutype.transform.GetChild(j + 3).gameObject.GetComponent <Text>(); obj.gameObject.SetActive(true); obj.text = $"{name}{count}"; } if (data.BixiaHuCount > 0) { Text obj4 = allhuashutype.transform.GetChild(dataHuPaiTypes.Count + 3).GetComponent <Text>(); obj4.gameObject.SetActive(true); obj4.text = $"比下胡{data.BixiaHuCount}"; Text obj5 = allhuashutype.transform.GetChild(dataHuPaiTypes.Count + 4).GetComponent <Text>(); obj5.gameObject.SetActive(true); obj5.text = "砸2"; } else { Text obj4 = allhuashutype.transform.GetChild(dataHuPaiTypes.Count + 3).GetComponent <Text>(); obj4.gameObject.SetActive(true); obj4.text = "砸2"; } huaCountText.text = huaCount + ""; if (data.IsZiMo) { goldText.text = BeiLv * huaCount * 3 + ""; } else { goldText.text = BeiLv * huaCount + ""; } } else { if (data.IsZiMo) { if (BeiLv * huaCount == 0) { goldText.text = "0"; } else { goldText.text = "-" + BeiLv * huaCount + ""; } } else { if (gamer.UserID == data.FangPaoUid) { if (BeiLv * huaCount == 0) { goldText.text = "0"; } else { goldText.text = "-" + BeiLv * huaCount + ""; } nameText.color = Color.yellow; } } } } if (huPaiNeedData.IsZiMo) { winPlayer.transform.Find("hupaiType").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_gameresult", "gameresult_hu"); } SetHuPaiPlayerData(); }
public void SetPeng(int type, MahjongInfo mahjong, long operatedUid) { GameObject obj = null; if (type == 0) { obj = CommonUtil.getGameObjByBundle("Item_Peng_Card"); //更新手牌 for (int i = 0; i < 2; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } //明杠 else if (type == 1) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); //更新手牌 for (int i = 0; i < 3; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } //暗杆 else if (type == 4) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); for (int i = 0; i < 4; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } //碰刚 else if (type == 5) { obj = CommonUtil.getGameObjByBundle("Item_Gang_Card"); for (int i = 0; i < 1; i++) { int index = Logic_NJMJ.getInstance().GetIndex(this.handCards, mahjong); this.RemoveCard(index); } } UpdateCards(); //设置谁碰刚 UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); Log.Info("operatedUid:" + operatedUid); int gamerSeat = gamerComponent.Get(operatedUid).GetComponent <HandCardsComponent>().SeatIndex; int mySeat = SeatIndex; int offset = gamerSeat - mySeat; if (offset < 0) { offset += 4; } if (offset == 1) { offset = 3; } else if (offset == 3) { offset = 1; } Log.Info("offset:" + offset); //显示碰 GameObject gameObject = GameObject.Instantiate(obj, this.pengObj.transform); for (int i = 1; i < 4; i++) { Image image = gameObject.transform.Find("Item_" + i).GetComponent <Image>(); //暗杠显示 if (type == 4) { if (i == 2) { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_" + mahjong.weight); } else { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_back"); } } else { if (i == offset) { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_back"); } else { image.sprite = CommonUtil.getSpriteByBundle("Image_Top_Card", "card_" + mahjong.weight); } } } if (type == 0) { pengDic.Add(mahjong.weight, gameObject); } Vector3 localPosition = this.CardBottom.transform.localPosition; this.CardBottom.transform.localPosition = new Vector3(localPosition.x + (postionX) * 2f, localPosition.y + (postionY) * 2f, localPosition.z); }
private void OnBet(int n) { GamerComponent.Get(GamerComponent.LocalSeatID).GetComponent <UICowCow_GamerInfoComponent>().SeeSelfCards(n); this.ShowBetBtns(false); }
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); } }
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_GamerReconnet message) { try { Log.Info($"断线重连:"); SoundsHelp.Instance.IsOpenSound(false); GameObject mask = GameObject.Instantiate(CommonUtil.getGameObjByBundle("Image_Desk_Card", "RoomMask"), GameObject.Find("Global/UI/CommonCanvas").transform); //进入 List <GamerInfo> Gamers = new List <GamerInfo>(); foreach (var item in message.Gamers) { GamerInfo gamerInfo = new GamerInfo(); gamerInfo.UserID = item.UserID; gamerInfo.SeatIndex = item.SeatIndex; gamerInfo.IsReady = true; gamerInfo.playerInfo = item.playerInfo; Gamers.Add(gamerInfo); //将出的牌加入到手牌中 item.handCards.AddRange(item.playCards); foreach (var card in item.pengCards) { item.handCards.Add(card); item.handCards.Add(card); } foreach (var card in item.gangCards) { item.handCards.Add(card); item.handCards.Add(card); item.handCards.Add(card); } Logic_NJMJ.getInstance().SortMahjong(item.handCards); Log.Info($"{item.UserID} 手牌:{item.handCards.Count}"); } Actor_GamerEnterRoom actorGamerEnterRoom = new Actor_GamerEnterRoom() { Gamers = Gamers, RoomType = message.RoomType, }; if (message.RoomType == 3) { actorGamerEnterRoom.RoomId = message.RoomId; actorGamerEnterRoom.MasterUserId = message.MasterUserId; actorGamerEnterRoom.JuCount = message.JuCount; actorGamerEnterRoom.Multiples = message.Multiples; } await Actor_GamerEnterRoomHandler.GamerEnterRoom(actorGamerEnterRoom); //开始游戏 var actorStartGame = new Actor_StartGame(); actorStartGame.GamerDatas = message.Gamers; actorStartGame.restCount = message.RestCount; actorStartGame.RoomType = message.RoomType; if (actorStartGame.RoomType == 3) { actorStartGame.CurrentJuCount = message.CurrentJuCount; } Actor_StartGameHandler.StartGame(actorStartGame, true); //碰刚 foreach (var item in message.Gamers) { for (int i = 0; i < item.pengCards.Count; i++) { MahjongInfo card = item.pengCards[i]; Actor_GamerOperation gamerOperation = new Actor_GamerOperation(); gamerOperation.Uid = item.UserID; gamerOperation.weight = card.weight; gamerOperation.OperationType = 0; gamerOperation.OperatedUid = item.OperatedPengUserIds[i]; Actor_GamerOperateHandler.GamerOperation(gamerOperation, true); } for (int i = 0; i < item.gangCards.Count; i++) { MahjongInfo card = item.gangCards[i]; long operatedGangUserIds = item.OperatedGangUserIds[i]; Actor_GamerOperation gamerOperation = new Actor_GamerOperation(); gamerOperation.Uid = item.UserID; gamerOperation.weight = card.weight; gamerOperation.OperationType = 1; gamerOperation.OperatedUid = operatedGangUserIds; if (operatedGangUserIds == 0) { gamerOperation.OperationType = 4; } Actor_GamerOperateHandler.GamerOperation(gamerOperation, true); } } //打牌 foreach (var item in message.Gamers) { Log.Debug($"{item.UserID} 重连出牌"); for (int i = 0; i < item.playCards.Count; i++) { MahjongInfo card = item.playCards[i]; int index = Logic_NJMJ.getInstance().GetIndex(item.handCards, card); Actor_GamerPlayCard playCard = new Actor_GamerPlayCard(); playCard.Uid = item.UserID; playCard.weight = card.weight; playCard.index = index; // await ETModel.Game.Scene.GetComponent<TimerComponent>().WaitAsync(100); Actor_GamerPlayCardHandler.PlayCard(playCard); // item.handCards.RemoveAt(index); } } //托管恢复 UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>(); foreach (var item in message.Gamers) { if (item.IsTrusteeship) { if (item.UserID == PlayerInfoComponent.Instance.uid) { uiRoomComponent.ShowTrustship(); } else { GamerUIComponent gamerUIComponent = gamerComponent.Get(item.UserID).GetComponent <GamerUIComponent>(); gamerUIComponent.ShowTrust(); } } } await ETModel.Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000); int openSound = PlayerPrefs.GetInt("isOpenSound", 1); SoundsHelp.Instance.IsOpenSound(openSound == 1); GameObject.Destroy(mask); } catch (Exception e) { Log.Error(e); } }