/// <summary>
        /// 抢地主的处理
        /// </summary>
        private void grabLandlord(ClientPeer client, bool result)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                if (userCache.IsOnline(client) == false)
                {
                    return;
                }
                //必须确保在线
                int userId = userCache.GetId(client);
                //if()
                FightRoom room = fightCache.GetRoomByUId(userId);

                if (result == true)
                {
                    //抢
                    room.SetLandlord(userId);
                    //给每一个客户端发一个消息  谁当了地主
                    //   第一个:地主id  第二个:三张底牌
                    GrabDto dto = new GrabDto(userId, room.TableCardList, room.GetUserCards(userId));
                    brocast(room, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRO, dto);
                    //发送一个出牌命令
                    brocast(room, OpCode.FIGHT, FightCode.TURN_DEAL_BRO, userId);
                }
                else
                {
                    //不抢
                    int nextUId = room.GetNextUId(userId);
                    brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, nextUId);
                }
            });
        }
Example #2
0
        /// <summary>
        /// 抢地主处理
        /// </summary>
        private void GrabLandLord(ClientPeer client, bool result)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                if (user.IsOnLine(client) == false)
                {
                    return;
                }

                int userId     = user.GetIdByClient(client);
                FightRoom room = fight.GetRoomByUid(userId);
                if (result == true)
                {
                    //抢
                    room.SetLandlord(userId);
                    GrabDto grab = new GrabDto(userId, room.TableCardList, room.GetPlayerCard(userId));
                    //广播  谁是地主  三张底牌
                    Brocast(room, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRO, grab);
                    //发送一个出牌的命令
                    Brocast(room, OpCode.FIGHT, FightCode.TURN_DEAL_BRO, userId);
                }
                else
                {
                    //不抢
                    int nextUid = room.GetNextUid(userId);
                    Brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB__BRO, nextUid);
                }
            });
        }
Example #3
0
        /// <summary>
        /// 抢地主
        /// </summary>
        /// <param name="client"></param>
        /// <param name="result"></param>
        private void grabLandlord(ClientPeer client, bool result)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!userCache.IsOnline(client))
                {
                    return;
                }
                int userId          = userCache.GetId(client);
                FightRoom fightRoom = fightCache.GetRoomByUId(userId);

                if (result == true)
                {
                    //抢
                    fightRoom.SetLandlord(userId);
                    //给每个客户端发送消息谁当了地主
                    GrabDto dto = new GrabDto(userId, fightRoom.TableCardList, fightRoom.getUserCards(userId));
                    Brocast(fightRoom, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRQ, dto);

                    Brocast(fightRoom, OpCode.FIGHT, FightCode.TURN_DEAL_BRO, userId);
                }
                else
                {
                    //不抢
                    int nextUId = fightRoom.GetNextUId(userId);
                    Brocast(fightRoom, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, nextUId);
                }
            });
        }
    /// <summary>
    /// 抢地主成功的处理
    /// </summary>
    private void grabLandlordBro(GrabDto dto)
    {
        //更改UI的身份显示
        Dispatch(AreaCode.UI, UIEvent.PLAYER_CHANGE_IDENTITY, dto.UserId);
        //播放抢地主的声音
        Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECT_AUDIO, "Fight/Woman_Order");
        //显示三张底牌
        Dispatch(AreaCode.UI, UIEvent.SET_TABLE_CARDS, dto.TableCardList);
        //给对应的地主玩家 添加手牌显示出来
        int eventCode = -1;

        if (dto.UserId == Models.GameModel.MatchRoomDto.LeftId)
        {
            eventCode = CharacterEvent.ADD_LEFT_CARD;
        }
        else if (dto.UserId == Models.GameModel.MatchRoomDto.RightId)
        {
            eventCode = CharacterEvent.ADD_RIGHT_CARD;
        }
        else if (dto.UserId == Models.GameModel.UserDto.Id)
        {
            eventCode = CharacterEvent.ADD_MY_CARD;
        }
        Dispatch(AreaCode.CHARACTER, eventCode, dto);
    }
    /// <summary>
    /// 有人抢地主的响应
    /// </summary>
    /// <param name="grabDto"></param>
    private void GrabLandBro(GrabDto grabDto)
    {
        int            landUid    = grabDto.Uid;
        List <CardDto> tableCards = grabDto.TableCards;

        //通知UI设置地主头像
        Dispatch(AreaCode.UI, UIEvent.CHANGE_IDENTITY, landUid);
        //显示底牌
        Dispatch(AreaCode.UI, UIEvent.SET_BOTTOM_CARD, grabDto.TableCards.ToArray());
        //播放抢地主的声音
        Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECTAUDIO, "Fight/Woman_Order");
        //给对应玩家发送底牌
        int eventCode = -1;

        if (grabDto.Uid == Caches.RoomDto.LeftId)
        {
            eventCode = CharacterEvent.LEFT_PLAYER_ADD_CARD;
        }
        else if (grabDto.Uid == Caches.RoomDto.RightId)
        {
            eventCode = CharacterEvent.RIGHT_PLAYER_ADD_CARD;
        }
        else
        {
            eventCode = CharacterEvent.MY_PLAYER_ADD_CARD;
        }
        Dispatch(AreaCode.CHARACTER, eventCode, grabDto);
    }
Example #6
0
        private void grabLandlord(ClientPeer client, bool result)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!userCache.IsOnline(client))
                {
                    return;
                }
                int userId          = userCache.GetId(client);
                FightRoom fightRoom = fightCache.GetRoomByUId(userId);

                if (result == true)
                {
                    fightRoom.SetLandlord(userId);
                    //send message to all client who was landlord
                    GrabDto dto = new GrabDto(userId, fightRoom.TableCardList, fightRoom.getUserCards(userId));
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BROADCAST, dto);

                    //enter deal phase
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.TURN_DEAL_BROADCAST, userId);
                }
                else
                {
                    //don't grab
                    int nextUserId = fightRoom.GetNextUserId(userId);
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.TURN_GRAB_BROADCAST, nextUserId);
                }
            });
        }
Example #7
0
    ///地主广播
    private void GrabLandLoardBro(GrabDto dto)
    {
        //改变身份
        Dispatch(AreaCode.UI, UIEvent.PLAYER_CHANGE_IDENTITY, dto.userId);
        //发出声音
        Dispatch(AreaCode.AUDIO, AudioEvent.PLAY_EFFECT_AUDIO, "Fight/Woman_Order");
        //显示卡牌
        Dispatch(AreaCode.UI, UIEvent.SET_TABLE_CARDS, dto.tableCarList);
        //增加地主底牌
        int eventCode = -1;

        if (dto.userId == Model.gameModel.matchRoomDto.leftId)
        {
            eventCode = CharacterEvent.ADD_LEFT_CARD;
        }
        else if (dto.userId == Model.gameModel.matchRoomDto.rightId)
        {
            eventCode = CharacterEvent.ADD_RIGHT_CARD;
        }
        else if (dto.userId == Model.gameModel.UserDto.id)
        {
            eventCode = CharacterEvent.ADD_MY_CARD;
        }
        Dispatch(AreaCode.CHARACTER, eventCode, dto);
    }
Example #8
0
 /// <summary>
 /// 抢地主的处理
 /// </summary>
 private void grabLandlord(ClientPeer client, bool result)
 {
     SingleExecute.Instance.Execute(
         delegate()
     {
         if (userCache.IsOnline(client) == false)
         {
             return;
         }
         //必须确保在线
         int userId     = userCache.GetId(client);
         FightRoom room = fightCache.GetRoomByUId(userId);
         if (result == true)
         {
             room.isMulti = true;
             //抢
             room.SetLandlord(userId);
             //给每一个客户发一个消息 谁当了地主
             GrabDto dto = new GrabDto(userId, room.TableCardList, room.GetUserCards(userId));
             brocast(room, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRO, dto);
             foreach (var player in room.PlayerList)
             {
                 if (player.Identity == Identity.FARMER)
                 {
                     //发送给平民翻倍命令
                     singleBrocast(room, OpCode.FIGHT, FightCode.MULTIPLE_BRO, 1, player.UserId);
                 }
                 else
                 {
                     singleBrocast(room, OpCode.FIGHT, FightCode.MULTIPLE_BRO, 2, player.UserId);
                 }
             }
         }
         else
         {
             //不抢
             int nextUId = room.GetNextUId(userId);
             brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, nextUId);
         }
     }
         );
 }
Example #9
0
    /// <summary>
    /// 添加底牌
    /// </summary>
    /// <param name="cardList"></param>
    private void AddTableCard(GrabDto dto)
    {
        List <CardDto> tableCards  = dto.TableCardList;
        List <CardDto> playerCards = dto.PlayerCardList;
        //复用之前创建的卡牌
        int index = 0;

        foreach (var item in cardCtrlsList)
        {
            item.gameObject.SetActive(true);
            item.Init(playerCards[index], index, true);
            index++;
        }
        //新增三张卡牌
        GameObject cardPrefab = Resources.Load <GameObject>("Card/MyCard");

        for (int i = index; i < playerCards.Count; i++)
        {
            CreateGo(cardPrefab, playerCards[i], i);
        }
    }
Example #10
0
    /// <summary>
    /// 添加底牌
    /// </summary>
    /// <param name="cardList"></param>
    private void addTableCard(GrabDto dto)
    {
        List <CardDto> tableCards  = dto.TableCardList;
        List <CardDto> playerCards = dto.PlayerCardList;

        //复用之前创建的卡牌
        int index = 0;

        foreach (var cardCtrl in cardCtrlList)
        {
            cardCtrl.gameObject.SetActive(true);
            cardCtrl.Init(playerCards[index], index, true);
            index++;
        }
        //在创建新的三张牌
        GameObject cardPrefab = Resources.Load <GameObject>("Card/MyCard");

        for (int i = index; i < playerCards.Count; i++)
        {
            createGo(playerCards[i], i, cardPrefab);
        }
    }
    /// <summary>
    /// 增加底牌
    /// </summary>
    /// <param name="grabDto">底牌</param>
    private void AddCard(GrabDto grabDto)
    {
        List <CardDto> tableCards  = grabDto.TableCards;
        List <CardDto> playerCards = grabDto.PlayerCards;

        int index = 0;

        foreach (var cardCtrl in cardCtrls)
        {
            cardCtrl.gameObject.SetActive(true);
            cardCtrl.Init(playerCards[index], index, true);
            index++;
        }
        //再创建三张卡牌
        for (int i = index; i < playerCards.Count; i++)
        {
            GameObject go = GameObject.Instantiate(CardPrefab, cardPoint);
            go.transform.localPosition += new Vector3(i * 35, 0, 0);
            CardCtrl cardCtrl = go.GetComponent <CardCtrl>();
            cardCtrl.Init(playerCards[i], i, true);
            cardCtrls.Add(cardCtrl);
        }
    }
Example #12
0
    private void grabLandlordBroadcast(GrabDto dto)
    {
        //update ui,set avatar to landlord
        Dispatch(AreaCode.UI, UIEvent.PLAY_CHANGE_IDENTITY, dto.userId);
        //show three table cards
        Dispatch(AreaCode.UI, UIEvent.SET_TABLE_CARD, dto.TableCardList);

        int eventCode = -1;

        if (dto.userId == Models.GameModel.MatchRoomDto.LeftId)
        {
            eventCode = CharacterEvent.ADD_LEFT_CARD;
        }
        else if (dto.userId == Models.GameModel.MatchRoomDto.RightId)
        {
            eventCode = CharacterEvent.ADD_RIGHT_CARD;
        }
        else if (dto.userId == Models.GameModel.UserDto.Id)
        {
            eventCode = CharacterEvent.ADD_MY_CARD;
        }
        Dispatch(AreaCode.CHARACTER, eventCode, dto);
    }
Example #13
0
 /// <summary>
 /// 抢地主
 /// </summary>
 /// <param name="client"></param>
 /// <param name="resulit"></param>
 private void GrabLandlord(ClientPeer client, bool resulit)
 {
     SingleExecute.Instance.Execute(() =>
     {
         if (UserCache.IsOnline(client) == false)
         {
             socketMsg.State = null;
             return;
         }
         //获取用户id
         int userId     = UserCache.GetClientUserId(client);
         FightRoom room = FightCache.GetRoomByUId(userId);
         if (resulit == true)
         {
             //抢地主
             room.SetLandlord(userId);
             //发放底牌
             GrabDto dto = new GrabDto
             {
                 UserId         = userId,
                 TableCardList  = room.TabkeCardList,
                 PlayerCardList = room.GetUserCard(userId)
             };
             socketMsg.SubCode = FightCode.Grab_Landlord_Bro;
             socketMsg.value   = dto;
             BroCast(room, socketMsg);
         }
         else
         {
             //不抢
             int nextUID       = room.GetNextUId(userId);
             socketMsg.SubCode = FightCode.Turn_Grab_Bro;
             socketMsg.value   = nextUID;
             BroCast(room, socketMsg);
         }
     });
 }
Example #14
0
    public override void Execute(int eventCode, object message)
    {
        switch (eventCode)
        {
        case UIEvent.Player_Hide_State:
            Invoke("HideUI", 0.5f);
            break;

        case UIEvent.Player_Ready:
            //显示准备文本框
            if (userCharacterDto == null)
            {
                break;
            }
            int userId = (int)message;
            if (userCharacterDto.Id == userId)
            {
                ReadyState(true);
            }
            break;

        case UIEvent.Player_Leave:
            if (userCharacterDto == null)
            {
                break;
            }
            //玩家离开隐藏面板
            int leaveUserId = (int)message;
            if (userCharacterDto.Id == leaveUserId)
            {
                ReadyState(false);
                SetPanelActive(false);
                userCharacterDto = null;
            }
            break;

        case UIEvent.Player_Enter:
            //玩家进入房间
            if (userCharacterDto == null)
            {
                break;
            }
            int enterUserId = (int)message;
            if (userCharacterDto.Id == enterUserId)
            {
                SetPanelActive(true);
            }
            break;

        case UIEvent.Player_Chat:
        {
            if (userCharacterDto == null)
            {
                break;
            }
            ChatDto chatDto = message as ChatDto;
            if (userCharacterDto.Id == chatDto.UserId)
            {
                var text = ConstantHelper.GetChatText(chatDto.Type);
                ShowChat(text);
            }
            break;
        }

        case UIEvent.Player_Change_Identity:
        {
            if (userCharacterDto == null)
            {
                break;
            }
            GrabDto dto = message as GrabDto;
            if (userCharacterDto.Id == dto.UserId)
            {
                SetIdentity(1);
            }
            break;
        }
        }
    }