當前位置: 首頁>>代碼示例>>C#>>正文


C# BitStream.WriteFloat16方法代碼示例

本文整理匯總了C#中RakNet.BitStream.WriteFloat16方法的典型用法代碼示例。如果您正苦於以下問題:C# BitStream.WriteFloat16方法的具體用法?C# BitStream.WriteFloat16怎麽用?C# BitStream.WriteFloat16使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RakNet.BitStream的用法示例。


在下文中一共展示了BitStream.WriteFloat16方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main


//.........這裏部分代碼省略.........
            Console.WriteLine("SystemAddress");
            SystemAddress testSystemAddress = new SystemAddress("127.0.0.1", 60001);

            //RakNetGUID
            RakNetGUID testRakNetGUID = testClient.GetGuidFromSystemAddress(RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS);

            Console.WriteLine(testRakNetGUID);

            //AddressOrGUID
            Console.WriteLine("AddressOrGUID");
            AddressOrGUID testAddressOrGUIDAddress = new AddressOrGUID(testSystemAddress);

            Console.WriteLine(testAddressOrGUIDAddress.systemAddress);

            AddressOrGUID testAddressOrGUIDRakNetGUID = new AddressOrGUID(testRakNetGUID);

            Console.WriteLine(testAddressOrGUIDRakNetGUID.rakNetGuid);

            //BitStream
            Console.WriteLine("BitStream");
            BitStream testBitStream1 = new BitStream();
            BitStream testBitStream2 = new BitStream();
            byte[] testBuffer = new byte[999];
            byte[] writeArray = new byte[99];
            Packet bitStreamTestPacket = null;

            testBitStream1.Write((byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            testBitStream1.ResetWritePointer();
            testBitStream1.Write((byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM);

            writeArray[0] = (byte)127;
            testBitStream1.Write("xy");
            testBitStream1.WriteCompressed("xy");
            testBitStream1.WriteFloat16(23.5f, 0, 100);
            testBitStream1.WriteBits(writeArray, 7);
            testBitStream1.WriteAlignedBytesSafe(writeArray, 1, 1);
            testBitStream1.WriteAlignedBytes(writeArray, 1);
            testBitStream1.Write0();
            testBitStream1.Write1();
            int intForSerialization = 99;
            testBitStream1.Serialize(true, ref intForSerialization);

            testClient.Send(testBitStream1, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, new AddressOrGUID(RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS), true);

            while (bitStreamTestPacket == null || bitStreamTestPacket.data[0] != (byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM)
            {
                if (bitStreamTestPacket != null)
                {
                    testServer.DeallocatePacket(bitStreamTestPacket);
                }
                bitStreamTestPacket = testServer.Receive();
                testClient.Send(testBitStream1, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, new AddressOrGUID(RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS), true);
            }

            testBitStream2.Reset();
            testBitStream2 = new BitStream(bitStreamTestPacket.data, bitStreamTestPacket.length, true);

            testBitStream2.IgnoreBytes(1);
            testBitStream2.ResetReadPointer();
            testBitStream2.IgnoreBits(8);
            testBitStream2.ResetReadPointer();
            testBitStream2.ReadBits(testBuffer, 8);
            Console.WriteLine(testBuffer[0]);
            Console.WriteLine(DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            testBitStream2.ResetReadPointer();
            testBitStream2.ReadAlignedVar8(testBuffer);
開發者ID:0521guo,項目名稱:RakNet,代碼行數:67,代碼來源:TestMain.cs


注:本文中的RakNet.BitStream.WriteFloat16方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。