Example #1
0
 private void ChuPaiResponse(ChuPaiDto dto)
 {
     //给玩家发消息,你出牌了 可以把牌移除了
     Dispatch(AreaCode.CHARACTER, CharactorEvent.CHUPAI_SRES, dto);
     //告诉UI 把牌显示出来
     Dispatch(AreaCode.UI, UIEvent.CHUPAI_OPERATE, dto);
     //播放语音出了什么牌
     audioMsg.Set("Sound/Fight/", GetAudioName(dto));
     Dispatch(AreaCode.AUDIO, AudioEvent.EFFECTAUDIO, audioMsg);
 }
Example #2
0
    private string GetAudioName(ChuPaiDto dto)
    {
        string outStr = string.Empty;

        if (dto.type == CardsType.Boom || dto.type == CardsType.Joker_Boom)
        {
            return(dto.type.ToString());
        }


        if (!dto.isBiggest)
        {
            //不是最大者出的牌 直接返回 大你说这压死
            var rNum = Random.Range(1, 4);
            return("dani" + rNum);
        }

        //判断牌型
        if (dto.type == CardsType.Single)
        {
            outStr += (int)dto.weight + 3;
        }
        else if (dto.type == CardsType.Double)
        {
            outStr += "dui" + ((int)dto.weight + 3);
        }
        else if (dto.type == CardsType.Straight)
        {
            outStr += "shunzi";
        }
        else if (dto.type == CardsType.Double_Straight)
        {
            outStr += "liandui";
        }
        else if (dto.type == CardsType.Three_Straight || dto.type == CardsType.Three_Straight_One || dto.type == CardsType.Three_Straight_Two)
        {
            outStr += "feiji";
        }
        else if (dto.type == CardsType.Three)
        {
            outStr += "tuple" + ((int)dto.weight + 3);
        }
        else if (dto.type == CardsType.Three_One)
        {
            outStr += "sandaiyi";
        }
        else if (dto.type == CardsType.Three_Two)
        {
            outStr += "sandaiyidui";
        }

        return(outStr);
    }
Example #3
0
    /// <summary>
    /// 出牌结果的单独方法
    /// </summary>
    /// <param name="cards"></param>
    protected virtual void SetOperateResult(ChuPaiDto dto)
    {
        var flag = dto.userId == this.userDto.id;


        //是自己
        if (flag)
        {
            ShowChupaiResult(dto.cardsList);
            //chupaiResTxt.gameObject.SetActive(true);
            //string content = string.Empty;
            //foreach (var card in dto.cardsList)
            //{
            //    content += card.name;
            //}
            //chupaiResTxt.text = content;
        }
    }
Example #4
0
 /// <summary>
 /// 出的牌服务器来消息了 说明出牌成功了
 /// </summary>
 /// <param name="cards">玩家出的牌 由于是客户端发过去的。是已经排过顺序的</param>
 private void ChuPaiResonse(ChuPaiDto dto)
 {
     //将这些牌销毁(隐藏)
     //由于是广播。所以需要判断一下id
     if (dto.userId != Models.gameModel.UserDto.id)
     {
         return;
     }
     foreach (var card in dto.cardsList)
     {
         for (int i = 0; i < myCardsList.Count; i++)
         {
             if (myCardsList[i].CardInfo.name == card.name)
             {
                 myCardsList[i].IsSelect = false;
                 myCardsList[i].gameObject.SetActive(false);
                 break;
             }
         }
     }
 }
        private void ChuPai(ClientPeer client, ChuPaiDto dto)
        {
            SingleExecute.Instance.Execute(() => {
                if (!user.IsOnLine(client))
                {
                    return;
                }

                int userId = user.GetId(client);
                if (userId != dto.userId)
                {
                    throw new Exception("玩家作弊!客户端id与服务器保存的id 不一致");
                }
                var room = fight.GetRoom(userId);
                //玩家出牌
                //玩家不在
                if (room.leavePlayerIdList.Contains(userId))
                {
                    //直接换下家
                    Turn(room, FightCode.CHUPAI_TURN_BRO);
                }
                else
                {
                    var flag = room.ChuPai(dto);
                    if (flag)
                    {
                        //能管上
                        //client.StartSend(OpCode.FIGHT,FightCode.CHUPAI_SRES,1);
                        //广播,管上了
                        Brocast(room, OpCode.FIGHT, FightCode.CHUPAI_BRO, dto);
                        //检测手牌,小于1  就赢了
                        var cards = room.GetPlayerCards(userId);


                        if (cards.Count == 0)
                        {
                            //游戏结束
                            GameOver(room, userId);
                        }
                        else
                        {
                            //还有牌
                            //转换出牌
                            Turn(room, FightCode.CHUPAI_TURN_BRO);
                            if (cards.Count == 2)
                            {
                                Brocast(room, OpCode.FIGHT, FightCode.BAOJING_SRES, 2);
                            }
                            else if (cards.Count == 1)
                            {
                                Brocast(room, OpCode.FIGHT, FightCode.BAOJING_SRES, 1);
                            }
                        }
                    }
                    else
                    {
                        //管不上
                        client.StartSend(OpCode.FIGHT, FightCode.CHUPAI_SRES, null);
                    }
                }
            });
        }
Example #6
0
        /// <summary>
        /// 判断出的牌能不能管上
        /// </summary>
        /// <returns></returns>
        public bool ChuPai(ChuPaiDto dto)
        {
            bool result = false;

            //自己出牌
            //判断最大是不是自己
            if (dto.userId == round.currentBiggsetId)
            {
                //自己的牌,别人都不要
                //随便出
                //但是要符合规则
                if (dto.type != CardsType.None)
                {
                    result = true;

                    dto.Set(true);
                }
            }
            //管别人的牌
            //同类型比较
            else if (dto.type == round.lastCardsType)
            {
                //特殊的类型  还需要比长度
                if (dto.type == CardsType.Straight || dto.type == CardsType.Double_Straight)
                {
                    if (dto.length > round.lastCardsLength)
                    {
                        //判断权值
                        if (dto.weight > round.lastCardsWeight)
                        {
                            //可以出牌
                            result = true;
                        }
                    }
                }
                else  //普通的类型  只需要比权值
                {
                    if (dto.weight > round.lastCardsWeight)
                    {
                        result = true;
                    }
                }
            }
            else  //跨类型比较
            {
                //王炸
                if (dto.type == CardsType.Joker_Boom)
                {
                    result = true;
                }
                else if (dto.type == CardsType.Boom)//普通炸弹
                {
                    if (round.lastCardsType != CardsType.Joker_Boom)
                    {
                        result = true;
                    }
                }
            }

            //出牌
            if (result)
            {
                //移除手牌
                RemovePlayerCards(dto.userId, dto.cardsList);
                //可能翻倍
                if (dto.type == CardsType.Boom)
                {
                    this.multiple *= 2;
                }
                else if (dto.type == CardsType.Joker_Boom)
                {
                    this.multiple *= 8;
                }

                //改变回合信息
                round.ChangeBiggestId(dto.userId, dto.type, dto.length, dto.weight);
            }


            return(result);
        }