/// <summary>
        /// 发单摸结果
        /// </summary>
        /// <param name="secondCommand"></param>
        /// <param name="roomInfo"></param>
        /// <param name="cardIndex">所摸牌在桌牌中的下标</param>
        /// <param name="card">所摸牌</param>
        void ForeachSendDraw(int secondCommand, RoomInfo roomInfo, int cardIndex, BaseCard card)
        {
            byte[] data_1 = BitConverter.GetBytes(cardIndex);
            byte[] data_3;
            if (card == null)
            {
                data_3 = new byte[0];
            }
            else
            {
                data_3 = DataDo.Object2Json(card);
            }
            byte[] datas = new byte[data_1.Length + data_3.Length];
            Buffer.BlockCopy(data_1, 0, datas, 0, 4);
            Buffer.BlockCopy(data_3, 0, datas, 4, data_3.Length);
            Conn conn;

            Console.WriteLine("----roomInfo.member.Count:" + roomInfo.member.Count);
            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, secondCommand, datas);
                conn.SendBts(data);
            }
        }
        /// <summary>
        /// 发牌
        /// </summary>
        //void Deal(RoomInfo roomInfo)
        //{
        //    int cards = 0;
        //    if (roomInfo.member.Count == 3 || roomInfo.member.Count == 2)
        //    {
        //        cards = 4;
        //    }
        //    else if (roomInfo.member.Count == 4)
        //    {
        //        cards = 3;
        //    }

        //    if (cards == 4 || cards == 3)
        //    {
        //        BaseCard card;
        //        roomInfo.playersCards = new List<BaseCard>();
        //        for (int i = 1; i <= roomInfo.member.Count; i++)//人员
        //        {
        //            for (int j = 1; j <= cards; j++)//牌数
        //            {
        //                card = roomInfo.cardsLibrary[0];
        //                card.CardBelongTo = (CardBelongTo)i;//为每个玩家发牌 0是牌库
        //                Console.WriteLine("手牌:" + card.CardName);
        //                roomInfo.playersCards.Add(card);
        //                roomInfo.cardsLibrary.Remove(card);
        //            }
        //        }
        //        Console.WriteLine("手牌数:" + roomInfo.playersCards.Count + " 牌库:  " + roomInfo.cardsLibrary.Count);
        //    }
        //}
        #endregion

        /// <summary>
        /// 公布自选牌
        /// </summary>
        void OpenSelfSelectCard()
        {
            byte[]     content    = Decode.DecodeSecondContendBtyes(bytes);
            SingleDraw singleDraw = DataDo.Json2Object <SingleDraw>(content);
            RoomInfo   roomInfo   = GetRoom(singleDraw.roomNum);

            //找到自己在成员列表所对应的下标
            if (roomInfo == null)
            {
                return;
            }

            Next(roomInfo);
            Console.WriteLine("Next-------------OpenSelfSelectCard");


            //广播成员
            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, (int)SecondCommands.SelectMyCardToOpen, content);
                conn.SendBts(data);
            }
        }
Esempio n. 3
0
        void ReturnRoom()
        {
            Info     info     = DataDo.Json2Object <Info>(Decode.DecodeSecondContendBtyes(bytes));
            RoomInfo roomInfo = GameCommand.GetRoom(info.roomId);

            if (roomInfo != null)
            {
                PersonalInfo personal = roomInfo.member.Find(it => {
                    if (it.id == info.myId)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });
                if (personal != null)
                {
                    personal.IsInWaitRoom = true;
                }
                //在房间的都知道

                conn.SendBts(Incode.IncodeSecondaryCommand(type, (int)SecondCommands.TurnBackROOM, DataDo.Object2Json(roomInfo)));
                Conn _conn;
                for (int i = 0; i < roomInfo.member.Count; i++)
                {
                    if (roomInfo.member[i].id != info.myId)
                    {
                        Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out _conn);
                        _conn.SendBts(Incode.IncodeSecondaryCommand(type, (int)SecondCommands.JOINROOM, DataDo.Object2Json(roomInfo)));
                    }
                }
            }
        }
Esempio n. 4
0
    /// <summary>
    /// 发送单摸结果
    /// </summary>
    public static void SendLineCardIndexs(List <LineCardMoveInfo> lineCardMoveInfos)
    {
        Info info = new Info(DataDo.Object2Json(lineCardMoveInfos));

        byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.MoveLineCardInFirstDraw, DataDo.Object2Json(info));
        NetStart.SendContend(byt);
        Debug.Log("--------SendLineCardIndexs---------");
    }
Esempio n. 5
0
 /// <summary>
 /// 发送自己的id
 /// </summary>
 public static void SendMyID(int secondCommand)
 {
     byte[] data_1 = BitConverter.GetBytes(NetStart.myInfo.id);
     byte[] data_2 = System.Text.Encoding.UTF8.GetBytes(currentRoom.roomID); //BitConverter.GetBytes(int.Parse(currentRoom.roomID));
     byte[] datas  = new byte[data_1.Length + data_2.Length];
     Buffer.BlockCopy(data_1, 0, datas, 0, 4);
     Buffer.BlockCopy(data_2, 0, datas, 4, data_2.Length);
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, secondCommand, datas);
     NetStart.SendContend(byt);
 }
        /// <summary>
        /// 遍历房间成员发送猜错命令
        /// </summary>
        void ForeachSendGuess(int secondCommand, RoomInfo roomInfo, byte[] guess)
        {
            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, secondCommand, guess);
                conn.SendBts(data);
            }
        }
Esempio n. 7
0
    /// <summary>
    /// 退出房间
    /// </summary>
    /// <param name="roomNum">房间号</param>
    public static void ExitRoom(string roomNum, int peopleId)
    {
        RoomMsg roomMsg = new RoomMsg
        {
            roomNum = roomNum,
            otherId = peopleId,
        };

        byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.EXITROOM, DataDo.Object2Json(roomMsg));
        NetStart.SendContend(byt);
    }
Esempio n. 8
0
    /// <summary>
    /// 加入房间
    /// </summary>
    /// <param name="roomNum">房间号</param>
    public static void JoinRoom(string roomNum, PersonalInfo my)
    {
        RoomMsg roomMsg = new RoomMsg
        {
            roomNum = roomNum,
            my      = my,
        };

        byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.JOINROOM, DataDo.Object2Json(roomMsg));
        NetStart.SendContend(byt);
    }
Esempio n. 9
0
        /// <summary>
        /// 遍历房间成员发送房间命令
        /// </summary>
        /// <param name="byt">内容</param>
        /// <param name="secondCommand">二级命令</param>
        public static void ForeachSendRoom(int secondCommand, RoomInfo roomInfo)
        {
            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                //Console.WriteLine();
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                conn.SendBts(Incode.IncodeSecondaryCommand(type, secondCommand, DataDo.Object2Json(roomInfo)));
            }
        }
Esempio n. 10
0
    /// <summary>
    /// 战斗结束后返回房间界面
    /// </summary>
    /// <param name="roomNum">房间号</param>
    public static void TurnBackCurrRoom(string roomNum)
    {
        Info info = new Info
        {
            myId    = NetStart.myInfo.id,
            roomId  = roomNum,
            content = new byte[0]
        };

        byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.TurnBackROOM, DataDo.Object2Json(info));
        NetStart.SendContend(byt);
    }
        /// <summary>
        /// 遍历房间成员发送公布玩家手牌  命令
        /// </summary>
        /// <param name="byt">内容</param>
        /// <param name="secondCommand">二级命令</param>
        static void ForeachSendOneOpen(int secondCommand, RoomInfo roomInfo, byte[] id)
        {
            if (id == null)
            {
                id = new byte[0];
            }
            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, secondCommand, id);
                conn.SendBts(data);
            }
        }
        /// <summary>
        /// 遍历房间成员发送出牌者  命令
        /// </summary>
        /// <param name="byt">内容</param>
        /// <param name="secondCommand">二级命令</param>
        public static void ForeachSendForthgoer(int secondCommand, RoomInfo roomInfo, int[] diceIndex)
        {
            byte[] datas  = new byte[8];
            byte[] dice_1 = BitConverter.GetBytes(diceIndex[0]);
            byte[] dice_2 = BitConverter.GetBytes(diceIndex[1]);
            Buffer.BlockCopy(dice_1, 0, datas, 0, 4);
            Buffer.BlockCopy(dice_2, 0, datas, 4, 4);
            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, secondCommand, datas);
                conn.SendBts(data);
            }
        }
        /// <summary>
        /// 广播
        /// </summary>
        /// <param name="roomInfo"></param>
        /// <param name="secondCommand"></param>
        /// <param name="content"></param>
        void Broadcast(RoomInfo roomInfo, SecondCommands secondCommand, byte[] content)
        {
            if (roomInfo == null)
            {
                Console.WriteLine("该房间不存在");
                return;
            }
            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, (int)secondCommand, content);
                conn.SendBts(data);
            }
        }
        /// <summary>
        /// 初始化命令
        /// </summary>
        /// <param name="_1stDrawTime">首摸时间</param>
        /// <param name="_SingleDrawTime">单摸时间</param>
        /// <param name="roomInfo">房间</param>
        void Initialize(RoomInfo roomInfo)
        {
            Dictionary <string, int> times = new Dictionary <string, int>();

            times.Add("_1stDrawTime", (int)Time._1stDrawTime - 1);
            times.Add("_SingleDrawTime", (int)Time._SingleDrawTime);
            times.Add("_DiceTime", (int)Time._DiceTime);
            times.Add("_SelectMyselfCardTime", (int)Time._SelectMyselfCardTime);
            times.Add("_ExtraTime", (int)Time._ExtraTime);
            times.Add("_ClickThinkingTime", (int)Time._ClickThinkingTime);
            times.Add("_MoveCardTime", (int)Time._MoveCardTime);

            Conn conn;

            for (int i = 0; i < roomInfo.member.Count; i++)
            {
                roomInfo.member[i].IsInWaitRoom = false;
                Server.connMap.TryGetValue(roomInfo.member[i].id.ToString(), out conn);
                byte[] data = Incode.IncodeSecondaryCommand(type, (int)SecondCommands.INITIALIZE, DataDo.Object2Json(times));
                conn.SendBts(data);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// 踢出房间(与退出房间一个事件)
 /// </summary>
 public static void RemoveFromRoom(string roomNum, int people)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.EXITROOM, System.Text.Encoding.UTF8.GetBytes(roomNum));
     NetStart.SendContend(byt);
 }
Esempio n. 16
0
 /// <summary>
 /// 发送猜错了创建自选计时器//正在自选要公布的手牌
 /// </summary>
 public static void SelectMyCardTimer()
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.CreateSelectMyCardTimer, System.Text.Encoding.UTF8.GetBytes(currentRoom.roomID));
     NetStart.SendContend(byt);
 }
Esempio n. 17
0
 /// <summary>
 /// 发送猜牌时的结果
 /// </summary>
 public static void SendGuessCard(GuessInfo guessInfo)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.GUESS, DataDo.Object2Json(guessInfo));
     NetStart.SendContend(byt);
 }
Esempio n. 18
0
 /// <summary>
 /// 发送单摸结果
 /// </summary>
 public static void SendSingleDrow(int secondCommands, SingleDraw singleDraw)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, secondCommands, DataDo.Object2Json(singleDraw));
     NetStart.SendContend(byt);
 }
Esempio n. 19
0
 /// <summary>
 /// 发送手牌选择(开局首摸)
 /// </summary>
 public static void SendSeletFirstHandCards(SelectCards selectCards)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.DEAL, DataDo.Object2Json(selectCards));
     NetStart.SendContend(byt);
 }
Esempio n. 20
0
 public static void Already(string roomNum)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.Already, System.Text.Encoding.UTF8.GetBytes(roomNum));
     NetStart.SendContend(byt);
 }
Esempio n. 21
0
 public static void Send(MessageInfo message)
 {
     NetStart.SendContend(Incode.IncodeSecondaryCommand(TYPE, PrivateChat, DataDo.Object2Json(message)));
 }
Esempio n. 22
0
 /// <summary>
 /// 断线重连
 /// </summary>
 public static void ReLink()
 {
     NetStart.SendContend(Incode.IncodeSecondaryCommand(TYPE, _ReLink, System.BitConverter.GetBytes(NetStart.myInfo.id)));
     Debug.Log("----------发送重连命令");
 }
Esempio n. 23
0
 /// <summary>
 /// 获取所有闲置房间的列表
 /// </summary>
 public static void SelectRooms()
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.SELECTROOM, System.Text.Encoding.UTF8.GetBytes(""));
     NetStart.SendContend(byt);
 }
Esempio n. 24
0
 /// <summary>
 /// 发送单纯的信号
 /// </summary>
 /// <param name="secondCommand"></param>
 public static void SendSign(int secondCommand)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, secondCommand, System.Text.Encoding.UTF8.GetBytes(currentRoom.roomID));
     NetStart.SendContend(byt);
 }
Esempio n. 25
0
 /// <summary>
 /// 邀请加入
 /// </summary>
 public static void InviteToRoom(string roomNum, PersonalInfo my, int otherId)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.EXITROOM, System.Text.Encoding.UTF8.GetBytes(roomNum));
     NetStart.SendContend(byt);
 }
Esempio n. 26
0
 /// <summary>
 /// 房主转让
 /// </summary>
 public static void HostTransfer(string roomNum, int otherId)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.EXITROOM, System.Text.Encoding.UTF8.GetBytes(roomNum));
     NetStart.SendContend(byt);
 }
Esempio n. 27
0
 /// <summary>
 /// 开房
 /// </summary>
 /// <param name="room"></param>
 public static void CreatRoom(RoomInfo room)
 {
     byte[] byt = Incode.IncodeSecondaryCommand(TYPE, (int)SecondCommands.CREATEROOM, DataDo.Object2Json(room));
     NetStart.SendContend(byt);
 }
Esempio n. 28
0
 /// <summary>
 /// 心跳命令发送
 /// </summary>
 public static void Heartbeat_Send()
 {
     NetStart.SendContend(Incode.IncodeSecondaryCommand(TYPE, _HeartBeat, System.BitConverter.GetBytes(NetStart.myInfo.id)));
     //Debug.Log("发送心跳命令");
 }
Esempio n. 29
0
 /// <summary>
 /// 发送房间命令给自己
 /// </summary>
 /// <param name="byt">内容</param>
 /// <param name="secondCommand">二级命令</param>
 void SendRoom(byte[] byt, int secondCommand)
 {
     byte[] data = Incode.IncodeSecondaryCommand(type, secondCommand, byt);
     conn.SendBts(data);
 }