/// <summary> /// 所有玩家 换3张成功后的数据处理 /// </summary> /// <param name="data"></param> public void UpdateHandCardsAfterAllChangeThree(MJoptInfoData data) { foreach (var item in data.cards) { if (item < 10) { MJGameModel.Inst.handCardsTiao.Add(item); } else if (item < 20) { MJGameModel.Inst.handCardsTong.Add(item); } else if (item < 30) { MJGameModel.Inst.handCardsWan.Add(item); } MJGameModel.Inst.mySelfCards.Add(item); } MJGameModel.Inst.mySelfCards.Sort(); List <int> allHand = MJGameModel.Inst.mySelfCards; if (MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].isHasCurrCard) { MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId] .currCard = allHand[allHand.Count - 1]; MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].currCard = allHand[allHand.Count - 1]; allHand.RemoveAt(allHand.Count - 1); } MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].handList = MJGameModel.Inst.mySelfCards; }
/// <summary> /// 设置玩家定缺 /// </summary> /// <param name="data"></param> private void SetOtherFixColor(MJoptInfoData data) { if (data.fixedList == null) { return; } int seatId; List <int> newHandCards = null; CardsInfoStruct mMJmyInfo; for (int i = 0; i < data.fixedList.Count; i++) { seatId = data.fixedList[i].seatId; mMJmyInfo = MJGameModel.Inst.allPlayersCardsInfoStruct[seatId]; newHandCards = MJGameModel.Inst.allPlayersCardsInfoStruct[seatId].handList; if (newHandCards != null && mMJmyInfo.currCard != 0) { newHandCards.Add(mMJmyInfo.currCard); } newHandCards = MJGameModel.Inst.ChangList(newHandCards, data.fixedList[i].type.GetHashCode()); mMJmyInfo.fixedType = data.fixedList[i].type.GetHashCode(); if (mMJmyInfo.currCard != 0)//如果有摸起来的牌就把手牌中的最后一张当作摸起来的牌 { mMJmyInfo.currCard = newHandCards[newHandCards.Count - 1]; newHandCards.RemoveAt(newHandCards.Count - 1); } MJGameModel.Inst.allPlayersCardsInfoStruct[seatId].handList = newHandCards; MJGameModel.Inst.AllPlayerEfixe[seatId] = MJGameModel.Inst.GetPlayerFixedType(data.fixedList[i].type); } }
/// <summary> /// 定缺成功 数据处理 /// </summary> public void UpdateHandCardsAfterFix(MJoptInfoData data) { MJGameModel.Inst.SetMyFixedType(data.type); CardsInfoStruct mMJmyInfo = MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId]; List <int> newHandCards = mMJmyInfo.handList; if (mMJmyInfo != null && mMJmyInfo.currCard != 0) { newHandCards.Add(mMJmyInfo.currCard); } mMJmyInfo.fixedType = data.type; newHandCards = MJGameModel.Inst.ChangList(newHandCards, data.type); for (int i = 0; i < newHandCards.Count; i++) { if (newHandCards[i] > MJGameModel.Inst.eFixe[0] && newHandCards[i] < MJGameModel.Inst.eFixe[1]) { MJGameModel.Inst.isHasFixeCard = true; break; } MJGameModel.Inst.isHasFixeCard = false; } if (MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].isHasCurrCard) { MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId] .currCard = newHandCards[newHandCards.Count - 1]; MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].currCard = newHandCards[newHandCards.Count - 1]; newHandCards.RemoveAt(newHandCards.Count - 1); } MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId] .handList = newHandCards; }
/// <summary> ///换3张 后的事件处理 /// </summary> public void InitSureChaneThree(MJoptInfoData data) { List <MjMyHandCard> newChangeThree = new List <MjMyHandCard>(); for (int i = 0; i < data.cards.Count; i++) { for (int j = 0; j < mAllHandCardList.Count; j++) { MjMyHandCard obj = mAllHandCardList[j] as MjMyHandCard; if (obj.mNum == data.cards[i] && !newChangeThree.Contains(obj)) { newChangeThree.Add(obj); break; } } } for (int i = 0; i < newChangeThree.Count; i++) { newChangeThree[i].SureChangeThree(); mHandCardList.Remove(newChangeThree[i]); mSureChangeThreeList.Add(newChangeThree[i]); } //mChangeThreeGrid.Reposition(); mHandGrid.Reposition(); }
private void ChangeThreeOver(MJoptInfoData data) { if (mGameUI != null) { mGameUI.PlayChangeThreeAnim(data); } //换三张完成 int seatid; int card; if (data.changeList == null) { return; } for (int i = 0; i < data.changeList.Length; i++) { seatid = data.changeList[i].seatId; for (int j = 0; j < data.changeList[i].inCards.Count; j++) { card = data.changeList[i].inCards[j]; MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].handList.Add(card);//从手牌中移除交换的牌 } MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].handList.Sort(); } }
/// <summary> /// 所有玩家 换3张成功后的数据处理 /// </summary> /// <param name="data"></param> private void UpdateHandCardsAfterAllChangeThree(MJoptInfoData data) { if (data.changeList == null) { return; } //拿出去三张 int seatid; int card; for (int i = 0; i < data.changeList.Length; i++) { seatid = data.changeList[i].seatId; for (int j = 0; j < data.changeList[i].outCards.Count; j++) { card = data.changeList[i].outCards[j]; if (MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].currCard > 0) { int ccard = MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].currCard; MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].handList.Add(ccard); MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].currCard = 0; } MJGameModel.Inst.allPlayersCardsInfoStruct[seatid].handList.Remove(card);//从手牌中移除交换的牌 } } ChangeThreeOver(data); }
/// <summary> /// 一炮多响 数据处理 /// </summary> /// <param name="data"></param> /// <returns></returns> public List <MJoptInfoData> YPDXData(MJoptInfoData data) { List <MJoptInfoData> dataList = new List <MJoptInfoData>(); List <int> newSeatIdList = new List <int>(); newSeatIdList = data.seatIdList; for (int i = 0; i < newSeatIdList.Count; i++) { MJoptInfoData newData = new MJoptInfoData(); newData.ins = eMJInstructionsType.YPDX; newData.otherSeatId = data.otherSeatId; newData.seatId = newSeatIdList[i]; newData.subType = data.subType; newData.thrType = data.thrType; newData.type = data.type; newData.cards = new List <int>(); newData.cards = data.cards; if (i == 0) { newData.huGl = false; } else { newData.huGl = true; } dataList.Add(newData); } return(dataList); }
private PengStruct AddPengCard(ref List <PengStruct> mycard, MJoptInfoData data, int lastoutcard) { //我牌里面加一组 if (mycard == null) { mycard = new List <PengStruct>(); } PengStruct chicard = new PengStruct(); chicard.cards = new List <int>(); chicard.otherSeatId = data.otherSeatId; //chicard.type = data.type; if (mHandCard != null && mHandCard.currCard > 0)//摸起来的牌加到手牌中并且去掉摸起来的牌 { mHandCard.cards.Add(mHandCard.currCard); mHandCard.currCard = 0; } else if (mOtherCard != null && mOtherCard.isHasCurrCard) { mOtherCard.cardsNum += 1; mOtherCard.isHasCurrCard = false; } //手牌中减去杠牌 if (data.ins == eMJInstructionsType.PENG) { int len = 2; for (int i = 0; i < len; i++) { if (mHandCard != null && data.seatId == MJGameModel.Inst.mMySeatId) { if (data.cards.Count == 1) { mHandCard.cards.Remove(data.cards[0]); } else { mHandCard.cards.Remove(data.cards[i]); } } else { mOtherCard.cardsNum--; } } chicard.cards.Add(data.cards[0]); } if (mHandCard != null) { //mHandCard.cards.Sort(); mycard.Add(chicard); } if (mHandCard != null && data.seatId == MJGameModel.Inst.mMySeatId) { mHandCard.currCard = mHandCard.cards[mHandCard.cards.Count - 1]; mHandCard.cards.RemoveAt(mHandCard.cards.Count - 1); } return(chicard); }
/// <summary> /// 设置特效显示 /// </summary> /// <param name="id">特效ID</param> /// <param name="seatId">座位号index,转换过后的</param> public void SetEffectShow(MJoptInfoData data, int seatId, int[] _type, int subtype) { if (data.ins == eMJInstructionsType.HU) //胡牌 { if (seatId != data.seatId) //不是主动操作的人 { return; } //先获取配置表 MJGameInsEffectConfig con = GetInsEffectConfig(data.ins); if (con == null) { return; } if ((eHuThrType)data.thrType != eHuThrType.NONE)//三级类型 { LoadAndShowEffect(con.thrTypeEffect[data.thrType], seatId); } else if ((eHuSubType)data.subType != eHuSubType.NONE)//二级类型 { LoadAndShowEffect(con.subTypeEffect[data.subType], seatId); } else if ((eHuType)data.type != eHuType.NONE)//一级类型 { LoadAndShowEffect(con.effect[data.type], seatId); } } else if (data.ins == eMJInstructionsType.YPDX || data.ins == eMJInstructionsType.PENG)//一炮多响、碰 { //先获取配置表 MJGameInsEffectConfig con = GetInsEffectConfig(data.ins); if (con == null) { return; } if (seatId == data.seatId)//主动操作的人 { LoadAndShowEffect(con.effect[0], seatId, data.ins == eMJInstructionsType.YPDX); } } else if (data.ins == eMJInstructionsType.GANG)//杠 { //先获取配置表 MJGameInsEffectConfig con = GetInsEffectConfig(data.ins); if (con == null) { return; } if (data.seatId != seatId)//不是主动操作的人就返回 { return; } int type = data.type; LoadAndShowEffect(con.subTypeEffect[type], seatId); } }
public CardsInfoStruct[] allPlayersCardsInfoStruct; //所有玩家的牌的数据 #region 主动操作牌 /// <summary> /// 主动操作牌 /// </summary> /// <param name="data"></param> public void InstructionsCard(MJoptInfoData data, ref int lastOutCard) { eMJInstructionsType _type = data.ins; CardsStruct chicard; switch (_type) { case eMJInstructionsType.GUO: //过 break; case eMJInstructionsType.GANG: //杠 chicard = AddGangCard(ref mPlayerInfo.gangList, data, lastOutCard); break; case eMJInstructionsType.PENG: //碰 chicard = AddPengCard(ref mPlayerInfo.pengList, data, lastOutCard); //chicard.card.Sort(); break; case eMJInstructionsType.HIT: //打牌 AddHitCard(ref mPlayerInfo.hitList, data); lastOutCard = data.cards[0]; break; case eMJInstructionsType.MO: //摸牌 //if (mHandCard != null)//摸起来的牌加到手牌中并且去掉摸起来的牌 MJGameModel.Inst.leaveCardNum--; MJGameModel.Inst.mStartGameData.startInfo.leaveCardNum--; if (data.seatId == MJGameModel.Inst.mMySeatId) { if (!MJGameModel.Inst.isHasFixeCard) { if (data.cards[0] > MJGameModel.Inst.eFixe[0] && data.cards[0] < MJGameModel.Inst.eFixe[1]) { MJGameModel.Inst.isHasFixeCard = true; } } mHandCard.currCard = data.cards[0]; } else if (mOtherCard != null) { mOtherCard.isHasCurrCard = true; } break; case eMJInstructionsType.YPDX: case eMJInstructionsType.HU: //胡 chicard = AddHuCard(ref mPlayerInfo.mHuCard, data, lastOutCard); if (data.seatId == MJGameModel.Inst.mMySeatId) { MJGameModel.Inst.isHu = mPlayerInfo.mHuCard != null; } break; } }
/// <summary> /// 播放 换牌动画 /// </summary> public void PlayChangeThreeAnim(MJoptInfoData data) { UpdataHandCardsAfterGetMsg(); SQDebug.Log("换牌动画"); SetPlayAnim(data); DelayRun(2.1f, () => { Global.Inst.GetController <MJGameController>().ExcuteOptInChange(); }); }
private PengStruct AddPengCard(ref List <PengStruct> mycard, MJoptInfoData data, int lastoutcard) { //我牌里面加一组 if (mycard == null) { mycard = new List <PengStruct>(); } PengStruct chicard = new PengStruct(); chicard.cards = new List <int>(); chicard.otherSeatId = data.otherSeatId; //chicard.type = data.type; if (handList != null && currCard > 0)//摸起来的牌加到手牌中并且去掉摸起来的牌 { handList.Add(currCard); currCard = 0; } else if (isHasCurrCard) { cardNum += 1; isHasCurrCard = false; } //手牌中减去杠牌 if (data.ins == eMJInstructionsType.PENG) { int len = 2; for (int i = 0; i < len; i++) { if (handList != null) { if (data.cards.Count == 1) { handList.Remove(data.cards[0]); } else { handList.Remove(data.cards[i]); } } else { cardNum--; } } chicard.cards.Add(data.cards[0]); } mycard.Add(chicard); if (handList != null) { currCard = handList[handList.Count - 1]; handList.RemoveAt(handList.Count - 1); } return(chicard); }
/// <summary> /// 所有人都定缺完成 /// </summary> public void SureAllFixeDcolor(MJoptInfoData data) { mMJFixeDcolor.gameObject.SetActive(false); for (int i = 0; i < data.fixedList.Count; i++) { bool isMy = data.fixedList[i].seatId == MJGameModel.Inst.mMySeatId; mAllPlayer[MJGameModel.Inst.mnewSeatToIndex[data.fixedList[i].seatId]].UpdataFixe(data.fixedList[i].type, isMy); } UpdataHandCardsAfterGetMsg();//刷新手牌 }
/// <summary> /// 分数 变化 /// </summary> /// <param name="data"></param> private void OnPlayerScoreIns(MJoptInfoData data) { List <ScoreStruct> scors = new List <ScoreStruct>(); scors = data.scoreList; foreach (var item in scors) { MJGameModel.Inst.mRoomPlayers[item.seatId].gold += item.score; mGameUI.SetScore(item.seatId, MJGameModel.Inst.mRoomPlayers[item.seatId].gold, item.score, data.type); } }
public void SetData(MJoptInfoData optList, List <int> info, CallBack <MJoptInfoData, List <int> > call) { mOpt = info; mOptInfo = optList; for (int i = 0; i < info.Count; i++) { mMesh[i].mesh = mRoot.mMeshs[info[i]]; } gameObject.SetActive(true); mSelectCall = call; }
/// <summary> /// 同步谁操作了什么指令 /// </summary> /// <param name="msg"></param> private void GetInstructionsACK(MessageData msg) { MJoptInfoData data = msg.Read <MJoptInfoData>(); if (MJGameModel.Inst.msgQueue.Count > 0 || mGameUI == null) { SQDebug.Log("消息加入队列!!!"); MJGameModel.Inst.msgQueue.Enqueue(data); return; } ChoiseIns(data); }
/// <summary> /// 被动接受的指令 /// </summary> /// <param name="data"></param> /// <param name="lastOutCard"></param> public void PassiveInstructionsCard(MJoptInfoData data, ref int lastOutCard) { eMJInstructionsType _type = data.ins; switch (_type) { case eMJInstructionsType.CHI: case eMJInstructionsType.PENG: if (mPlayerInfo.hitList != null) { mPlayerInfo.hitList.RemoveAt(mPlayerInfo.hitList.Count - 1); } lastOutCard = 0; break; case eMJInstructionsType.GANG: if (data.cards.Count <= 4) { if (mPlayerInfo.hitList != null) { mPlayerInfo.hitList.RemoveAt(mPlayerInfo.hitList.Count - 1); } lastOutCard = 0; } break; case eMJInstructionsType.HU: if (mPlayerInfo.hitList != null && lastOutCard != 0) { if (data.subType == (int)eHuSubType.QGH) { if (!data.huGl) { if (mHandCard != null && data.otherSeatId == mPlayerInfo.seatId) { if (mHandCard.cards != null) { mHandCard.cards.Remove(data.cards[0]); } else { mOtherCard.cardsNum--; } } } } mPlayerInfo.hitList.RemoveAt(mPlayerInfo.hitList.Count - 1); lastOutCard = 0; } break; } }
/// <summary> /// 碰 打 杠 摸 胡 操作 /// </summary> /// <param name="data"></param> private void OnPlayerInstructions(MJoptInfoData data) { int index = data.seatId - 1; mModel.mCurInsSeatId = data.seatId; //当前操作的玩家座位号 mModel.allPlayersCardsInfoStruct[data.seatId].InstructionsCard(data, ref mModel.mLastOutCard); if (data.otherSeatId != data.seatId && data.otherSeatId != 0) //被动操作的人数据 { mModel.allPlayersCardsInfoStruct[data.otherSeatId].PassiveInstructionsCard(data, ref mModel.mLastOutCard); } mGameUI.ServerWhoInstructions(data); }
public List <int> AddHitCard(ref List <int> mycard, MJoptInfoData data) { //我牌里面加一组 if (mycard == null) { mycard = new List <int>(); } List <int> icard = new List <int>(); //要操作的牌 if (handList != null && currCard > 0) //摸起来的牌加到手牌中并且去掉摸起来的牌 { handList.Add(currCard); currCard = 0; } else if (isHasCurrCard) { cardNum += 1; isHasCurrCard = false; } //手牌中减去打出去的牌 for (int i = 0; i < data.cards.Count; i++) { if (handList != null) { handList.Remove(data.cards[i]); } else { cardNum--; } mycard.Add(data.cards[i]); } if (handList != null) { handList = MJGameModel.Inst.ChangList(handList, this.fixedType); foreach (var item in handList) { if (item > MJGameModel.Inst.eFixe[0] && item < MJGameModel.Inst.eFixe[1]) { MJGameModel.Inst.isHasFixeCard = true; break; } MJGameModel.Inst.isHasFixeCard = false; } } return(mycard); }
public List <int> AddHitCard(ref List <int> mycard, MJoptInfoData data) { //我牌里面加一组 if (mycard == null) { mycard = new List <int>(); } List <int> icard = new List <int>(); //要操作的牌 if (mHandCard != null && mHandCard.currCard > 0) //摸起来的牌加到手牌中并且去掉摸起来的牌 { mHandCard.cards.Add(mHandCard.currCard); mHandCard.currCard = 0; } else if (mOtherCard != null && mOtherCard.isHasCurrCard) { mOtherCard.cardsNum += 1; mOtherCard.isHasCurrCard = false; } //手牌中减去打出去的牌 for (int i = 0; i < data.cards.Count; i++) { if (mHandCard != null && data.seatId == MJGameModel.Inst.mMySeatId) { mHandCard.cards.Remove(data.cards[i]); } else { mOtherCard.cardsNum--; } mycard.Add(data.cards[i]); } if (mHandCard != null && data.seatId == MJGameModel.Inst.mMySeatId) { mHandCard.cards = MJGameModel.Inst.ChangList(mHandCard.cards, (int)MJGameModel.Inst.eFixeType); foreach (var item in mHandCard.cards) { if (item > MJGameModel.Inst.eFixe[0] && item < MJGameModel.Inst.eFixe[1]) { MJGameModel.Inst.isHasFixeCard = true; break; } MJGameModel.Inst.isHasFixeCard = false; } } return(mycard); }
/// <summary> /// 执行指令 /// </summary> /// <param name="data"></param> public void ChoiseIns(MJoptInfoData data) { switch (data.ins) { case eMJInstructionsType.CHANGETHREE: //换3张 确定 //UpdateHandCardsAfterChangeThree(data);//数据处理 //mGameUI.SureChangeThreeUI(data); break; case eMJInstructionsType.ALLCHANGE: // 换3张 所有玩家都确定 UpdateHandCardsAfterAllChangeThree(data); //数据处理 break; case eMJInstructionsType.FIXEDCOLOR: // 定缺成功 mjController.UpdateHandCardsAfterFix(data); //数据处理 mGameUI.SureFixeDcolor(data); break; case eMJInstructionsType.ALLFIXED: // 所有人完成 定缺 SetOtherFixColor(data); mGameUI.SureAllFixeDcolor(data); MJGameModel.Inst.mState = eMJRoomStatus.STARTE; MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.START; //改变房间状态 break; case eMJInstructionsType.SCORE: // 分数 OnPlayerScoreIns(data); break; case eMJInstructionsType.YPDX: // 一炮的多项 List <MJoptInfoData> dataList = new List <MJoptInfoData>(); dataList = mjController.YPDXData(data); for (int i = 0; i < dataList.Count; i++) { OnPlayerInstructions(dataList[i]); } break; default: MJGameModel.Inst.mState = eMJRoomStatus.STARTE; MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.START; //改变房间状态 OnPlayerInstructions(data); break; } mjController.PlaySound(data); }
private HuStruct AddHuCard(ref List <HuStruct> mycard, MJoptInfoData data, int lastoutcard) { //我牌里面加一组 if (mycard == null) { mycard = new List <HuStruct>(); } HuStruct chicard = new HuStruct(); if (mHandCard != null && mHandCard.currCard > 0)//摸起来的牌加到手牌中并且去掉摸起来的牌 { mHandCard.cards.Add(mHandCard.currCard); mHandCard.currCard = 0; } else if (mOtherCard != null && mOtherCard.isHasCurrCard) { mOtherCard.cardsNum += 1; mOtherCard.isHasCurrCard = false; } if (data.ins == eMJInstructionsType.HU) { if (data.type == (int)eHuType.ZIMO) { if (mHandCard != null && data.seatId == MJGameModel.Inst.mMySeatId) { mHandCard.cards.RemoveAt(mHandCard.cards.Count - 1); mHandCard.currCard = 0; } else { mOtherCard.cardsNum--; } } chicard.card = data.cards[0]; chicard.isGl = data.huGl; } if (mHandCard != null) { mycard.Add(chicard); } return(chicard); }
/// <summary> /// 播放声音 /// </summary> /// <param name="data"></param> public void PlaySound(MJoptInfoData data) { switch (data.ins) { case eMJInstructionsType.PENG: case eMJInstructionsType.GANG: case eMJInstructionsType.HU: PlayInsVoice(data); break; case eMJInstructionsType.HIT: SoundProcess.PlaySound(VOICE_HITCARD); //播放打牌的声音 PlayCardVoice(data.cards[0], data.seatId); break; case eMJInstructionsType.MO: //摸牌 //SoundProcess.PlaySound(VOICE_GETCARD);//播放摸牌的声音 break; } }
private HuStruct AddHuCard(ref List <HuStruct> mycard, MJoptInfoData data, int lastoutcard) { //我牌里面加一组 if (mycard == null) { mycard = new List <HuStruct>(); } HuStruct chicard = new HuStruct(); if (handList != null && currCard > 0)//摸起来的牌加到手牌中并且去掉摸起来的牌 { handList.Add(currCard); currCard = 0; } else if (isHasCurrCard) { cardNum += 1; isHasCurrCard = false; } if (data.ins == eMJInstructionsType.HU || data.ins == eMJInstructionsType.YPDX) { if (data.type == (int)eHuType.ZIMO) { if (handList != null) { handList.RemoveAt(handList.Count - 1); currCard = 0; } else { cardNum--; } } chicard.card = data.cards[0]; chicard.isGl = data.huGl; chicard.huType = data.type; } mycard.Add(chicard); return(chicard); }
/// <summary> /// 换3张确定后的数据处理 /// </summary> /// <param name="data"></param> public void UpdateHandCardsAfterChangeThree(MJoptInfoData data) { foreach (var item in data.cards) { if (item < 10) { MJGameModel.Inst.handCardsTiao.Remove(item); } else if (item < 20) { MJGameModel.Inst.handCardsTong.Remove(item); } else if (item < 30) { MJGameModel.Inst.handCardsWan.Remove(item); } MJGameModel.Inst.mySelfCards.Remove(item); } MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].handList = MJGameModel.Inst.mySelfCards; MJGameModel.Inst.allPlayersCardsInfoStruct[MJGameModel.Inst.mMySeatId].currCard = 0; }
private void SetPlayAnim(MJoptInfoData data) { int seatid; int index; //三张牌摆出来 for (int i = 0; i < data.changeList.Length; i++) { seatid = data.changeList[i].seatId; index = MJGameModel.Inst.mnewSeatToIndex[seatid]; if (mAllPlayer[index] != null) { mAllPlayer[index].SetChangeThreeCardsNum(data.changeList[i].outCards);//显示换三张牌 mAllPlayer[index].ChangeThreeObj(true); } } DelayRun(1.5f, () => { RotaCards(data.type); }); DelayRun(3.5f, () => { for (int i = 0; i < MJGameModel.Inst.mRoomPlayers.Length; i++) { if (MJGameModel.Inst.mRoomPlayers[i] == null) { continue; } seatid = MJGameModel.Inst.mRoomPlayers[i].seatId; index = MJGameModel.Inst.mnewSeatToIndex[seatid]; if (mAllPlayer[index] != null) { mAllPlayer[index].ChangeThreeObj(false); mAllPlayer[index].RotaThreeObj(0, 0); } } UpdataHandCardsAfterGetMsg(); }); }
/// <summary> /// 谁操作了牌 /// </summary> /// <param name="data"></param> public void ServerWhoInstructions(MJoptInfoData data) { int index = data.seatId - 1; int index2 = data.otherSeatId - 1; if (data.ins == eMJInstructionsType.MO) { mMJSceneRoot.SetDeskCard(0, MJGameModel.Inst.mTouzi, false);//桌上的牌 SetLeftCardNum(MJGameModel.Inst.mStartGameData.startInfo.leaveCardNum, true); } if (data.seatId != MJGameModel.Inst.mMySeatId) { mSelfPlayer.ShowInstructions(null); } mSelfPlayer.mSpeciaInstructionRoot.SetActive(false); MJGameModel.Inst.mIsTing = false; //听牌 //主动操作的 { int k = MJGameModel.Inst.mnewSeatToIndex[data.seatId]; InitSelfPlayerCards(mAllPlayer[k], MJGameModel.Inst.mRoomPlayers[data.seatId], MJGameModel.Inst.allPlayersCardsInfoStruct[data.seatId], data); mMJSceneRoot.SetEffectShow(data, data.seatId, data.huType, data.subType); //特效 SetCurCardEffect(mAllPlayer[k], data.ins, mCurCardOffset); //打出的牌特效 } //轮到谁操作 mMJSceneRoot.SetLight(index + 1); SetAllPlayerCD(index + 1); //被动操作的 if (index != index2 && index2 >= 0) { int k = MJGameModel.Inst.mnewSeatToIndex[data.otherSeatId]; InitSelfPlayerCards(mAllPlayer[k], MJGameModel.Inst.mRoomPlayers[data.otherSeatId], MJGameModel.Inst.allPlayersCardsInfoStruct[data.otherSeatId], data); } InitAllHuTag(MJGameModel.Inst.allPlayersCardsInfoStruct);//刷新玩家 胡牌标记 }
public void ChoiseIns(MJoptInfoData data) { switch (data.ins) { case eMJInstructionsType.READY: //准备 MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.READY; mGameUI.ServerPlayerPre(data.seatId); break; case eMJInstructionsType.CHANGETHREE: //换3张 确定 UpdateHandCardsAfterChangeThree(data); //数据处理 mGameUI.SureChangeThreeUI(data); break; case eMJInstructionsType.ALLCHANGE: // 换3张 所有玩家都确定 UpdateHandCardsAfterAllChangeThree(data); //数据处理 mGameUI.PlayChangeThreeAnim(data); if (!MJGameModel.Inst.IsContainsDingque) //如果没有定缺,房间状态改为开始 { MJGameModel.Inst.mState = eMJRoomStatus.STARTE; MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.START; //改变房间状态 } break; case eMJInstructionsType.FIXEDCOLOR: // 定缺成功 UpdateHandCardsAfterFix(data); //数据处理 mGameUI.SureFixeDcolor(data); break; case eMJInstructionsType.ALLFIXED: // 所有人完成 定缺 mGameUI.SureAllFixeDcolor(data); MJGameModel.Inst.mState = eMJRoomStatus.STARTE; MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.START; //改变房间状态 break; case eMJInstructionsType.SCORE: // 分数 OnPlayerScoreIns(data); break; case eMJInstructionsType.CHATING: // 查胡 mGameUI.SetChaHu(data.canHuList); break; case eMJInstructionsType.YPDX: // 一炮的多项 List <MJoptInfoData> dataList = new List <MJoptInfoData>(); mGameUI.SetYPDXEffUI(data); //一炮多响特效显示 dataList = YPDXData(data); for (int i = 0; i < dataList.Count; i++) { OnPlayerInstructions(dataList[i]); } break; case eMJInstructionsType.EXITROOM: //退出房间,在线状态 MJGameModel.Inst.mRoomPlayers[data.seatId].onLineType = eMJOnlineState.leave.GetHashCode(); if (mGameUI != null) { mGameUI.ServerOnlineState(data.seatId, data.type); } break; case eMJInstructionsType.TG: //托管 if (mGameUI != null) { mGameUI.ServerPlayerTrustship(data.seatId, (eMJTrusteeshipType)data.type); } break; default: //mContrl.OnPlayerInstructCards(data); MJGameModel.Inst.mState = eMJRoomStatus.STARTE; MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.START; //改变房间状态 OnPlayerInstructions(data); break; } PlaySound(data); }
/// <summary> /// 播放操作声音 /// </summary> /// <param name="data"></param> private void PlayInsVoice(MJoptInfoData data) { if (data.ins == eMJInstructionsType.YPDX)//一炮多响 { if (data.seatIdList != null) { string ins = data.ins.GetHashCode().ToString(); for (int i = 0; i < data.seatIdList.Count; i++) { int sex = MJGameModel.Inst.mRoomPlayers[data.seatIdList[i]].sex;//性别 ConfigDada con = ConfigManager.GetConfigs <MJGameInsVoiceConfig>().Find(o => o.conIndex.Equals(ins)); MJGameInsVoiceConfig voiceCon = con as MJGameInsVoiceConfig; if (voiceCon == null || voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } int index = Random.Range(0, voiceCon.voice.Length); //随机选一个声音 if (sex == 1) //男 { SoundProcess.PlaySound(VOICE_INS_MAN + voiceCon.voice[index]); } else//女 { SoundProcess.PlaySound(VOICE_INS_WOMAN + voiceCon.voice[index]); } } } } else if (data.ins == eMJInstructionsType.PENG || data.ins == eMJInstructionsType.GANG)//碰和杠 { string ins = data.ins.GetHashCode().ToString(); int sex = MJGameModel.Inst.mRoomPlayers[data.seatId].sex;//性别 ConfigDada con = ConfigManager.GetConfigs <MJGameInsVoiceConfig>().Find(o => o.conIndex.Equals(ins)); MJGameInsVoiceConfig voiceCon = con as MJGameInsVoiceConfig; if (voiceCon == null || voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } int index = Random.Range(0, voiceCon.voice.Length); //随机选一个声音 if (sex == 1) //男 { SoundProcess.PlaySound(VOICE_INS_MAN + voiceCon.voice[index]); } else//女 { SoundProcess.PlaySound(VOICE_INS_WOMAN + voiceCon.voice[index]); } //if (data.ins == eMJInstructionsType.GANG)//杠要播放刮风和下雨的声音 //SoundProcess.PlaySound(VOICE_INS_OTHER + voiceCon.subTypeVoice[data.type]); } else if (data.ins == eMJInstructionsType.HU) { string ins = data.ins.GetHashCode().ToString(); int sex = MJGameModel.Inst.mRoomPlayers[data.seatId].sex;//性别 ConfigDada con = ConfigManager.GetConfigs <MJGameInsVoiceConfig>().Find(o => o.conIndex.Equals(ins)); MJGameInsVoiceConfig voiceCon = con as MJGameInsVoiceConfig; if (voiceCon == null || voiceCon.voice == null || voiceCon.voice.Length == 0) { return; } string str = sex == 1 ? VOICE_INS_MAN : VOICE_INS_WOMAN; if ((eHuThrType)data.thrType != eHuThrType.NONE && voiceCon.thrTypeVoice != null && voiceCon.thrTypeVoice.Length > data.thrType)//第三级类型 { SoundProcess.PlaySound(str + voiceCon.thrTypeVoice[data.thrType]); return; } if ((eHuSubType)data.subType != eHuSubType.NONE && voiceCon.subTypeVoice != null && voiceCon.subTypeVoice.Length > data.subType)//第二级类型 { SoundProcess.PlaySound(str + voiceCon.subTypeVoice[data.subType]); return; } if ((eHuType)data.type != eHuType.NONE && voiceCon.voice != null && voiceCon.voice.Length > data.type)//第一级类型 { SoundProcess.PlaySound(str + voiceCon.voice[data.type]); return; } } }
/// <summary> /// 初始化或刷新自己的牌 /// </summary> /// <param name="player"></param> /// <param name="info"></param> /// <param name="myinfo"></param> public void InitSelfPlayerCards(MJPlayerBase player, PlayerInfoStruct info, CardsInfoStruct myinfo, MJoptInfoData opt = null) { //手牌 SQDebug.Log(myinfo.currCard); InitOnePlayerHandCards(player, myinfo.handList, 0, myinfo.currCard); //打出的牌 InitOnePlayerCollectCards(player, myinfo); //碰的牌 InitOnePlayerPengCard(player, myinfo); //胡牌 if (opt != null) { bool zimo = false; if (opt.huType != null) { for (int i = 0; i < opt.huType.Length; i++) { if (opt.huType[i] == (int)eHuType.ZIMO) { zimo = true; } } } if (zimo) { InitHuCard(player, myinfo, (int)eHuType.ZIMO); } else { InitHuCard(player, myinfo); } } else { //胡牌 InitHuCard(player, myinfo); } }