Ejemplo n.º 1
0
        /// <summary>
        /// 处理非指令卡
        /// </summary>
        /// <param name="clientPeer"></param>
        /// <param name="cardDto"></param>
        private void processOtherCard(ClientPeer clientPeer, CardDto cardDto)
        {
            SingleExecute.Instance.processSingle(() =>
            {
                if (!UserCache.Instance.IsOnline(clientPeer))
                {
                    return;
                }

                int uid             = UserCache.Instance.GetId(clientPeer);
                FightRoom fightRoom = FightRoomCache.Instance.GetRoomByUid(uid);


                switch (cardDto.Race)
                {
                case RaceType.ORC:
                    switch (cardDto.Name)
                    {
                    case OrcOtherCardType.Ancestor_Helmets:        //先祖头盔
                        fightRoom.Broadcast(OpCode.FIGHT, FightCode.USE_OTHERCARD_SBOD, cardDto, clientPeer);

                        //在服务器上移除玩家相应非指令卡
                        fightRoom.RemoveCard(uid, cardDto);

                        break;

                    case OrcOtherCardType.Totem_summon:        //召唤图腾
                        List <CardDto> cardDtos = fightRoom.DispathCard(uid, CardType.ARMYCARD);

                        if (cardDtos.Count > 0)
                        {
                            //给玩家发送发牌消息
                            //fightRoom.Broadcast(OpCode.FIGHT, FightCode.ADD_CARD_SRES, cardlist);
                            clientPeer.StartSend(OpCode.FIGHT, FightCode.ADD_CARD_SRES, cardDtos);
                            //给房间内除其他玩家发送发牌消息
                            fightRoom.Broadcast(OpCode.FIGHT, FightCode.ADD_CARD_SBOD, cardDtos.Count, clientPeer);
                        }
                        else
                        {
                            //牌库内没有其他中高阶单位
                            clientPeer.StartSend(OpCode.FIGHT, FightCode.USE_OTHERCARD_SRES, cardDto);
                        }
                        break;
                    }
                    break;
                }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理下一回合请求
        /// </summary>
        /// <param name="clientPeer"></param>
        private void processNextTurn(ClientPeer clientPeer)
        {
            SingleExecute.Instance.processSingle(
                () =>
            {
                if (!UserCache.Instance.IsOnline(clientPeer))
                {
                    return;
                }

                int uid = UserCache.Instance.GetId(clientPeer);
                //获得战斗房间
                FightRoom fightRoom = FightRoomCache.Instance.GetRoomByUid(uid);

                int nextuid = -1;    //下一回合的玩家ID
                foreach (var item in fightRoom.playerDtos)
                {
                    if (item.UserID != uid)
                    {
                        nextuid = item.UserID;
                        break;
                    }
                }
                //下一回玩家的套接字连接对象
                ClientPeer nextClientpeer = UserCache.Instance.GetClientPeer(nextuid);

                //广播通知下一回合玩家
                fightRoom.Broadcast(OpCode.FIGHT, FightCode.NEXT_TURN_SBOD, nextuid);
                //给下一回合的玩家发牌
                List <CardDto> cardlist = fightRoom.DispathCard(nextuid);
                //给玩家发送发牌消息
                //fightRoom.Broadcast(OpCode.FIGHT, FightCode.ADD_CARD_SRES, cardlist);
                nextClientpeer.StartSend(OpCode.FIGHT, FightCode.ADD_CARD_SRES, cardlist);
                //给房间内除了下一回合的玩家发送发牌消息
                fightRoom.Broadcast(OpCode.FIGHT, FightCode.ADD_CARD_SBOD, cardlist.Count, nextClientpeer);
            }
                );
        }