当前位置: 首页>>代码示例>>C#>>正文


C# BinaryWriter.WriteVarUInt32方法代码示例

本文整理汇总了C#中System.IO.BinaryWriter.WriteVarUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteVarUInt32方法的具体用法?C# BinaryWriter.WriteVarUInt32怎么用?C# BinaryWriter.WriteVarUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter.WriteVarUInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: doProcess

        public override bool doProcess(string[] args)
        {
            if (this.client.playerData.freeFuel)
            {
                client.sendCommandMessage("Sorry, you have already received free starter fuel on this server.");
                return false;
            }
            else if (!StarryboundServer.config.freeFuelForNewPlayers)
            {
                client.sendCommandMessage("Sorry, this server does not provide free starter fuel.");
                return false;
            }

            MemoryStream packet = new MemoryStream();
            BinaryWriter packetWrite = new BinaryWriter(packet);

            packetWrite.WriteStarString("solariumore");
            packetWrite.WriteVarUInt32(31); // Seems like it always gives 1 less than the amount entered, so we need 31 to give 30.
            packetWrite.Write((byte)0); //0 length Star::Variant
            client.sendClientPacket(Packet.GiveItem, packet.ToArray());
            client.sendCommandMessage("You have received 30 Solarium Ore as free starter fuel!");

            this.client.playerData.freeFuel = true;
            Users.SaveUser(this.client.playerData);

            return true;
        }
开发者ID:k0rd,项目名称:StarryboundServer,代码行数:27,代码来源:Fuel.cs

示例2: doProcess

        public override bool doProcess(string[] args)
        {
            if (player.receivedStarterKit)
            {
                client.sendCommandMessage("You have already received your starting items.");
                return false;
            }

            if (StarryboundServer.config.starterItems == null || StarryboundServer.config.starterItems.Length <= 0)
            {
                client.sendCommandMessage("Sorry! This server does not provide any starting items.");
                return false;
            }

            int awardedItems = 0;

            foreach (string item in StarryboundServer.config.starterItems)
            {
                if (String.IsNullOrEmpty(item) || String.IsNullOrWhiteSpace(item))
                {
                    continue;
                }
                string name;
                uint amount;
                if (item.Contains('*'))
                {
                    name = item.Split('*')[0];
                    amount = uint.Parse(item.Split('*')[1]);
                    if (amount <= 0) { continue; }
                }
                else
                {
                    name = item;
                    amount = 1;
                }

                MemoryStream packet = new MemoryStream();
                BinaryWriter packetWrite = new BinaryWriter(packet);

                packetWrite.WriteStarString(name);
                packetWrite.WriteVarUInt32(amount+1);
                packetWrite.Write((byte)0);
                client.sendClientPacket(Packet.GiveItem, packet.ToArray());

                awardedItems++;
            }

            if (awardedItems == 0)
            {
                client.sendCommandMessage("Sorry! This server does not provide any starting items.");
                return false;
            }

            client.sendCommandMessage("You have been given a few starting items to help you on your journey. Good luck!");
            this.client.playerData.receivedStarterKit = true;
            Users.SaveUser(this.client.playerData);

            return true;
        }
开发者ID:noxturno,项目名称:StarryboundServer,代码行数:59,代码来源:StarterItems.cs

示例3: onSend

        public override void onSend()
        {
            MemoryStream packet = new MemoryStream();
            BinaryWriter packetWrite = new BinaryWriter(packet);

            packetWrite.Write(false);
            packetWrite.WriteVarUInt32(0);
            packetWrite.WriteStarString((string)tmpArray["rejectReason"]);

            this.mClient.sendClientPacket(Packet.ConnectResponse, packet.ToArray());
        }
开发者ID:Gremlin13,项目名称:StarryboundServer,代码行数:11,代码来源:Packet2ConnectResponse.cs

示例4: doProcess

        public override bool doProcess(string[] args)
        {
            if (!hasPermission()) { permissionError(); return false; }

            if (args.Length < 2) { showHelpText(); return false; }

            string item = args[0];
            uint count = Convert.ToUInt32(args[1]) + 1;
            if (String.IsNullOrEmpty(item) || count < 1) { showHelpText(); return false; }

            MemoryStream packet = new MemoryStream();
            BinaryWriter packetWrite = new BinaryWriter(packet);

            packetWrite.WriteStarString(item);
            packetWrite.WriteVarUInt32(count);
            packetWrite.Write((byte)0); //0 length Star::Variant
            client.sendClientPacket(Packet.GiveItem, packet.ToArray());
            client.sendCommandMessage("Gave you " + (count - 1) + " " + item);

            return true;
        }
开发者ID:Gremlin13,项目名称:StarryboundServer,代码行数:21,代码来源:Item.cs


注:本文中的System.IO.BinaryWriter.WriteVarUInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。