public DDZCard SetReflexPai(int index) { DDZCard card = new DDZCard(); switch (index) { case 0: card = ChaiFen(roomBehaiorCpt.ddzDistributeCpt.player1Pokers); break; case 1: card = ChaiFen(roomBehaiorCpt.ddzDistributeCpt.player2Pokers); break; case 2: card = ChaiFen(roomBehaiorCpt.ddzDistributeCpt.player3Pokers); break; case 3: card = ChaiFen(roomBehaiorCpt.ddzDistributeCpt.dpPokers); break; default: break; } return(card); }
/// <summary> /// 显示手牌 /// </summary> /// <param name="handCard"></param> public async void ShowHandCard(DDZCard handCard, bool hasAni = false) { if (handCard == null) { return; } this.ReSelect(); this.HideHandCard(); if (hasAni) { SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.DDZ_sound_dealcard); } horizontalLayoutGroup.spacing = handCard.Card.Length > 17 ? DDZGameConfigComponent.Instance.handCardSortWidth : DDZGameConfigComponent.Instance.handCardNormalSortWidth; for (int i = 0; i < handCard.Card.Length; i++) { var cardValue = handCard.Card[i]; DDZPokerItem item = handCardDic[i]; if (hasAni) { await Task.Delay(100); } int realId = DDZGameHelper.ChangeSeat(DDZGameConfigComponent.Instance.LordID); item.GetComponent <DDZPokerItemUIComponent>().SetPokerImageSprite(cardValue, realId == 0); } }
/// <summary> /// 请求出牌 /// </summary> /// <param name="_PlayCardStatue">出牌状态 0-出牌 1-要不起</param> /// <param name="_PlayCard">要出的牌数组</param> public async void RequestPlayCard(int _PlayCardStatue, DDZCard _PlayCard) { var resp = (G2C_DDZPlayCard_Res)await SessionComponent.Instance.Session.Call( new C2G_DDZPlayCard_Req() { GameId = DDZGameHelper.CurrentGameInfo.GameId, AreaId = GameHelper.AreaList[DDZGameHelper.CurrentGameInfo.GameId][0].AreaId, UserId = GamePrefs.GetUserId(), RoomId = DDZGameHelper.RoomId, PlayCardStatue = _PlayCardStatue, PlayCard = _PlayCard }); //由于服务器修正了,这里还是走DDZOutCardError事件 if (resp.Error != 0 && resp.Error != 200225) { Game.PopupComponent.ShowMessageBox(resp.Message); this.DDZHandCardPlugin.ReSelect(); return; } if (resp.Error == 200225) { return; } //隐藏掉交互界面 this.DDZInteractivePlugin.Hide(); //刷新最新的手牌 if (resp.Card != null) { DDZGameConfigComponent.Instance.myHandCard = resp.Card; //修改:用服务器返回的数据刷新 //this.DDZHandCardPlugin.ShowHandCard(resp.Card); } //根据出的牌,将牌隐藏掉,如果是不出,则不移。 if (_PlayCardStatue != 1) { this.DDZHandCardPlugin.RemoveCard2();//临时 } else { this.DDZHandCardPlugin.ReSelect(); } //刷新倍数 DDZGameConfigComponent.Instance.Times = resp.Times; this.DDZTopPlugin.SetBeiSu(); //播放语音 this.PlayOutCardSound(resp.PlayCard); }
public void setSelectCards() { for (int i = 0; i < transform.childCount; i++) { DDZCard tempCard = transform.GetChild(i).GetComponent <DDZCard> (); if (tempCard.BSelect) { DDZRules.instance.dapaiCardsList.Add(tempCard); } } }
/// <summary> /// 重置参数 /// </summary> public void Clear() { this.GameState = (int)DDZ_GameState.NoStart; this.ActiveChairId = -1; this.PreCallScore = -1; this.DPCard = null; this.LordID = -1; this.myHandCard = null; this.preOutCard = null; this.ActiveOpTime = 0; }
public DDZCard ChaiFen(List <byte> pokers) { DDZCard card = new DDZCard(); if (pokers == null) { return(card); } for (int i = 0; i < pokers.Count; i++) { var num = PokerCardsHelper.GetPokerNum(pokers[i]); card.Points = num.ToString() + "点"; card.Value = num; } card.Card = (ByteString.CopyFrom(pokers.ToArray())); return(card); }
/// <summary> /// 从手牌移除掉牌 /// </summary> public void RemoveCard(DDZCard ddzCard) { for (int i = 0; i < ddzCard.Card.Length; i++) { var cardValue = ddzCard.Card[i]; foreach (var item in handCardDic) { var ui = item.Value.GetComponent <DDZPokerItemUIComponent>(); if (ui.pokerId == cardValue && ui.Panel.activeSelf) { ui.Hide(); } } } this.ReSelect(); }
/// <summary> /// 显示底牌 /// </summary> /// <param name="diPaiCard"></param> public async void ShowDP(DDZCard diPaiCard, bool hasAni = false) { if (diPaiCard == null) { return; } DiPai.SetActive(true); for (int i = 0; i < diPaiCard.Card.Length; i++) { var cardValue = diPaiCard.Card[i]; if (hasAni) { await Task.Delay(100); } this.dpDic[i].GetComponent <DDZPokerItemUIComponent>().SetPokerImageSprite(cardValue); } }
/// <summary> /// 结束,摊牌 /// </summary> /// <param name="list"></param> public void ShowHand(List <DDZCard> list) { for (int i = 0; i < list.Count; i++) { DDZCard cardData = list[i]; var vo = DataCenterComponent.Instance.userInfo.getUserByUserID(cardData.UserId); if (vo != null && cardData != null) { int realSeatID = DDZGameHelper.ChangeSeat(vo.seatID); this.PlayCardBySeatID(realSeatID, cardData); //重回时,赋值上一手的出牌.临时 if (realSeatID == 2 && cardData != null) { DDZGameConfigComponent.Instance.preOutCard = cardData; } } } }
/// <summary> /// 将出的牌绘制出来 /// </summary> /// <param name="seatID"></param> /// <param name="_card"></param> public void PlayCardBySeatID(int seatID, DDZCard _card) { if (_card.Card == null) { return; } var curOutList = this.outCardDic[seatID]; this.ClearOutList(curOutList); for (int i = 0; i < _card.Card.Length; i++) { var cardValue = _card.Card[i]; DDZPokerItem item = curOutList[i]; int lordID = DDZGameHelper.ChangeSeat(DDZGameConfigComponent.Instance.LordID); item.GetComponent <DDZPokerItemUIComponent>().SetPokerImageSprite(cardValue, lordID == seatID); } }
/// <summary> /// 播放出牌语音 /// </summary> /// <param name="resp"></param> public void PlayOutCardSound(DDZCard card, int chairID = 0) { int px = card.PaiXing; if (px == (int)DDZ_POKER_TYPE.DDZ_PASS) { Log.Debug("过牌,不出"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_pass + ETModel.RandomHelper.RandomNumber(1, 3)); } else if (px == (int)DDZ_POKER_TYPE.Single) { Log.Debug("单张"); //特殊处理大小王 if (card.Value == 15) { card.Value = 18; } if (card.Value == 16) { card.Value = 19; } //特殊处理2 if (card.Value == 2) { card.Value = 15; } SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_prefix + card.Value); } else if (px == (int)DDZ_POKER_TYPE.TWIN) { Log.Debug("对儿"); //特殊处理2 if (card.Value == 2) { card.Value = 15; } SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_double_prefix + (card.Value)); } else if (px == (int)DDZ_POKER_TYPE.TRIPLE) { Log.Debug("数值相同的三张牌(如三个J)"); //特殊处理2 if (card.Value == 2) { card.Value = 15; } SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_triple_prefix + (card.Value)); } else if (px == (int)DDZ_POKER_TYPE.TRIPLE_WITH_SINGLE) { Log.Debug("数值相同的三张牌 + 一张单牌或一对牌。例如:333+6 或 444+99"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_sandaiyi); } else if (px == (int)DDZ_POKER_TYPE.TRIPLE_WITH_TWIN) { Log.Debug("三带二"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_sandaiyidui); } else if (px == (int)DDZ_POKER_TYPE.STRAIGHT_SINGLE) { Log.Debug("单顺 五张或更多的连续单牌(如:45678 或 78910JQK)。不包括 2 点和双王"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_shunzi); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.ShunZi, chairID); } else if (px == (int)DDZ_POKER_TYPE.STRAIGHT_TWIN) { Log.Debug("双顺 三对或更多的连续对牌(如:334455 、77 88 99 1010 JJ)。不包括 2 点和双王"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_liandui); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.LianDui, chairID); } else if (px == (int)DDZ_POKER_TYPE.PLANE_PURE) { Log.Debug("飞机 二个或更多的连续三张牌(如:333444 、 555 666 777 888)。不包括 2 点和双王。"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_feiji); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.Plane, chairID); } else if (px == (int)DDZ_POKER_TYPE.PLANE_WITH_SINGLE) { Log.Debug("飞机带单"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_feiji); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.Plane, chairID); } else if (px == (int)DDZ_POKER_TYPE.PLANE_WITH_TWIN) { Log.Debug("飞机带双"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_feiji); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.Plane, chairID); } else if (px == (int)DDZ_POKER_TYPE.FOUR_WITH_SINGLE) { Log.Debug("四带两单"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_sidaier); } else if (px == (int)DDZ_POKER_TYPE.FOUR_WITH_TWIN) { Log.Debug("四带对"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_sidaier); } else if (px == (int)DDZ_POKER_TYPE.FOUR_BOMB) { Log.Debug("炸弹"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_zhadan); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.Bomb, chairID); } else if (px == (int)DDZ_POKER_TYPE.KING_BOMB) { Log.Debug("火箭"); SoundComponent.Instance.PlayClip(soundInfo.DDZ_male_wangzha); this.DDZFXLayerPlugin.PlayFX(DDZ_FX_TYPE.WangFire, chairID); } else { Log.Error("异常:未知牌型"); } }
public DDZInteractivePlugin Awake(GameObject panel) { this.panel = panel; _rf = this.panel.GetComponent <ReferenceCollector>(); Clock = _rf.Get <GameObject>("Clock"); Num = _rf.Get <GameObject>("Num").GetComponent <Text>(); TipBtn = _rf.Get <GameObject>("TipBtn").GetComponent <Button>(); Clock.SetActive(false); clockComponent = AddComponent <DDZClockComponent>().Awake(Num.gameObject); ButtonHelper.RegisterButtonEvent(_rf, "NotOutBtn", () => { Game.PopupComponent.SetClickLock(); SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click); DDZConfig.GameScene.RequestPlayCard(1, new DDZCard()); }); ButtonHelper.RegisterButtonEvent(_rf, "ReSetBtn", () => { SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click); DDZConfig.GameScene.DDZHandCardPlugin.ReSelect(); }); ButtonHelper.RegisterButtonEvent(_rf, "TipBtn", () => { Game.PopupComponent.SetClickLock(); SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click); DDZConfig.GameScene.DDZHandCardPlugin.ReSelect(); var tipCardDic = DDZConfig.GameScene.DDZAIComponent.GetTipCards(); if (tipCardDic != null && tipCardDic.Count > 0) { Log.Debug("获得的提示长度是:" + tipCardDic.Count); if (tipCardIndex == -1) { tipCardIndex = 0; } if (tipCardIndex > tipCardDic.Count - 1) { tipCardIndex = 0; } List <int> tipCards = tipCardDic[tipCardIndex]; DDZConfig.GameScene.DDZHandCardPlugin.SelectTipCard(tipCards); tipCardIndex++; } else { Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.NoTipCardsTip); } }); ButtonHelper.RegisterButtonEvent(_rf, "OutBtn", () => { Game.PopupComponent.SetClickLock(); SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click); DDZCard _data = new DDZCard(); List <byte> outCardList = DDZConfig.GameScene.DDZHandCardPlugin.GetOutCardList(); _data.Card = PbHelper.CopyFrom(outCardList); foreach (var item in outCardList) { Log.Debug("牌值:" + PokerCardsHelper.GetPokerOfInt(item)); Log.Debug("中文牌:" + PokerCardsHelper.GetPokerString(item)); } _data.CardsNum = outCardList.Count; Log.Debug("出牌的长度:" + _data.CardsNum); //增加判断:出牌是否为空 if (_data.CardsNum <= 0) { DDZConfig.GameScene.DDZMaskPlugin.Show(2); } else { DDZConfig.GameScene.RequestPlayCard(0, _data); } }); this.Reset(); return(this); }