Ejemplo n.º 1
0
        void MakePacket(int packetID, object str)
        {
            DefinedStructure.PacketInfo packet;
            packet._id   = packetID;
            packet._data = new byte[1024];

            if (str != null)
            {
                byte[] temp = ConvertPacket.StructureToByteArray(str);
                for (int n = 0; n < temp.Length; n++)
                {
                    packet._data[n] = temp[n];
                }
                packet._totalSize = temp.Length;
            }
            else
            {
                packet._totalSize = packet._data.Length;
            }

            _data     = ConvertPacket.StructureToByteArray(packet);
            _dataSize = _data.Length;
        }
Ejemplo n.º 2
0
        void TurnAI(int roomNum, CardBattleAI ai, int index)
        {
            int[] select;

            if (!ai.Check(_iconIndexesDic[roomNum], out select))
            {
                Random rd = new Random();
                select = new int[2];

                do
                {
                    select[0] = rd.Next(0, _cardCount);
                }while (_isClickableDic[roomNum][select[0]]);

                do
                {
                    select[1] = rd.Next(0, _cardCount);
                }while (select[0] == select[1] || _isClickableDic[roomNum][select[1]]);
            }

            DefinedStructure.Packet_ChooseCard pChooseCard;
            pChooseCard._UUID       = 0;
            pChooseCard._roomNumber = roomNum;
            pChooseCard._cardIdx1   = select[0];
            pChooseCard._cardIdx2   = select[1];
            pChooseCard._slotIndex  = index;

            DefinedStructure.PacketInfo packetInfo;
            packetInfo._id        = (int)DefinedProtocol.eFromClient.ChooseCard;
            packetInfo._data      = ConvertPacket.StructureToByteArray(pChooseCard);
            packetInfo._totalSize = packetInfo._data.Length;

            PacketClass packet = new PacketClass(packetInfo._id, packetInfo._data, packetInfo._totalSize);

            _fromClientQueue.Enqueue(packet);
        }