/// <summary> /// 服务端接收到计算机系协议 /// </summary> /// <param name="msgBase"></param> public void ProcessComputerScience(MsgComputerScience msg) { int paiIndex = msg.paiIndex; //牌在这个玩家的索引 int id = msg.id; //出牌的玩家id doSkillTime[msg.id]++; msg.canSkill = doSkillTime[msg.id] < maxSkillTime[msg.id] ? true : false; Broadcast(msg); MsgChuPai msgChuPai = new MsgChuPai(); msgChuPai.id = msg.id; msgChuPai.paiIndex = msg.paiIndex; Broadcast(msgChuPai); if (paiIndex == -1) { //服务端执行胡的操作,清空数据,写入数据库等 Over(msg.id, false); return; } int paiId = paiManager.ChuPai(paiIndex, id); MsgFaPai msgFaPai = new MsgFaPai(); turn = (turn + 1) % 4; msgFaPai = ProcessMsgFaPai(msgFaPai); //广播 Broadcast(msgFaPai); }
/// <summary> /// 客户端收到出牌的协议,进行同步 /// </summary> /// <param name="msgBase"></param> public void OnMsgChuPai(MsgBase msgBase) { MsgChuPai msg = (MsgChuPai)msgBase; Debug.Log("PlayerId: " + msg.id); gamePanel.PlayerStateText = "玩家" + msg.id + "出牌"; if (msg.paiIndex == -1)//胡的情况 { Gender gender = players[msg.id].gender; switch (gender) { case Gender.Female: Audio.PlayCue(Audio.audioHuFemale); break; case Gender.Male: Audio.PlayCue(Audio.audioHuMale); break; } Debug.Log("胡牌成功!"); PanelManager.Open <GameoverPanel>(msg.id, client_id, -1); PanelManager.Close("GamePanel"); } else { players[msg.id].DiscardPai(msg.paiIndex); gamePanel.HandPaiCount = new int[] { (int)gamePanel.numToDir[msg.id], players[msg.id].handPai.Count }; } }
/// <summary> /// 已经选择了出牌或者胡,将出牌的按钮隐藏,并发送ChuPai协议 /// </summary> /// <param name="index">pai的索引</param> protected void ChuPai_Hu(int index = -1) { gameManager.startTimeCount = false; if (index == -1) { Debug.Log("playerid: " + id + "胡了"); } else { Debug.Log("playerid: " + id + " 打出 " + Pai.int2name[handPai[index].GetComponent <Pai>().paiId]); } MsgChuPai msg = new MsgChuPai(); msg.id = id; msg.paiIndex = index; gamePanel.ChuPaiButton = false; gamePanel.HuButton = false; gameManager.isChuPai = false; NetManager.Send(msg); }
/// <summary> /// 判断是否触发了吃碰杠,如果触发了,就发送吃碰杠协议 /// 否则,发送发牌协议,并广播 /// </summary> /// <param name="paiIndex"></param> /// <param name="id"></param> public void ProcessMsgChuPai(MsgChuPai msg) { int paiIndex = msg.paiIndex; //牌在这个玩家的索引 int id = msg.id; //出牌的玩家id Broadcast(msg); //对客户端广播出牌协议,对出牌进行同步 if (paiIndex == -1) { //服务端执行胡的操作,清空数据,写入数据库等 Over(msg.id, false); return; } int paiId = paiManager.ChuPai(paiIndex, id); queueChiPengGang = paiManager.HasEvent(paiId, id); //检测是否有吃碰杠这件事 if (queueChiPengGang.Count != 0) //一直发送吃碰杠协议,直到发完或者有人同意吃碰杠为止 { Console.WriteLine("存在吃碰杠!"); foreach (MsgChiPengGang item in queueChiPengGang) { Console.WriteLine(item.ToString()); } MsgChiPengGang chiPengGang = queueChiPengGang.Dequeue(); Broadcast(chiPengGang);//广播吃碰杠协议 } else { MsgFaPai msgFaPai = new MsgFaPai(); turn = (turn + 1) % 4; msgFaPai = ProcessMsgFaPai(msgFaPai); //广播 Broadcast(msgFaPai); } }
public static void MsgChuPai(ClientState c, MsgBase msgBase) { MsgChuPai msg = (MsgChuPai)msgBase; Player player = c.player; if (player == null) { return; } Room room = RoomManager.GetRoom(player.roomId); if (room == null) { return; } GameManager gameManager = room.gameManager; if (gameManager == null) { return; } gameManager.ProcessMsgChuPai(msg); }