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


C# BitStream.ReadByte方法代码示例

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


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

示例1: RecvDropInventoryItem

        void RecvDropInventoryItem(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadInventorySlot();
            var amount = r.ReadByte();

            User user;
            if ((user = TryGetUser(conn)) == null)
                return;

            if (user.IsPeerTrading)
                return;

            if (amount < 1)
                return;

            user.Inventory.Drop(slot, amount);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:17,代码来源:ServerPacketHandler.cs

示例2: RecvBuyFromShop

        void RecvBuyFromShop(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadShopItemIndex();
            var amount = r.ReadByte();

            User user;
            if ((user = TryGetUser(conn)) == null)
                return;

            if (user.IsPeerTrading)
                return;

            user.ShoppingState.TryPurchase(slot, amount);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:ServerPacketHandler.cs

示例3: RecvDeleteAccountCharacter

        void RecvDeleteAccountCharacter(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadByte();

            // Check for a valid account
            var account = TryGetAccount(conn);
            if (account == null)
            {
                const string errmsg =
                    "Connection `{0}` tried to delete account character but no account is associated with this connection.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, conn);
                return;
            }

            // Ensure the connection isn't logged in
            if (account.User != null)
            {
                const string errmsg = "User `{0}` tried to delete account character while already logged in.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, account.User);
                return;
            }

            // Get the character ID
            CharacterID charID;
            if (!account.TryGetCharacterID(slot, out charID))
            {
                const string errmsg = "Could not delete character in slot `{0}` - no character exists.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, slot);
                return;
            }

            // Delete
            var q = DbController.GetQuery<DeleteUserCharacterQuery>();
            q.Execute(charID);

            // Update
            account.LoadCharacterIDs();
            account.SendAccountCharacterInfos();
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:42,代码来源:ServerPacketHandler.cs

示例4: RecvSkillSetKnownAll

        void RecvSkillSetKnownAll(IIPSocket conn, BitStream r)
        {
            var count = r.ReadByte();
            var knownSkills = new List<SkillType>(count);

            // Read the known skills list
            for (var i = 0; i < count; i++)
            {
                var value = r.ReadEnum<SkillType>();
                knownSkills.Add(value);
            }

            Debug.Assert(knownSkills.Count == count);
            Debug.Assert(knownSkills.All(EnumHelper<SkillType>.IsDefined), "One or more known skills were unknown...");

            // Set the known skills
            UserInfo.KnownSkills.SetValues(knownSkills);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:18,代码来源:ClientPacketHandler.cs

示例5: RecvStartQuestChatDialog

        void RecvStartQuestChatDialog(IIPSocket conn, BitStream r)
        {
            var npcIndex = r.ReadMapEntityIndex();

            // Available quests
            var numAvailableQuests = r.ReadByte();
            var availableQuests = new QuestID[numAvailableQuests];
            for (var i = 0; i < availableQuests.Length; i++)
            {
                availableQuests[i] = r.ReadQuestID();
            }

            // Quests that can be turned in
            var numTurnInQuests = r.ReadByte();
            var turnInQuests = new QuestID[numTurnInQuests];
            for (var i = 0; i < turnInQuests.Length; i++)
            {
                turnInQuests[i] = r.ReadQuestID();
            }

            // For the quests that are available, make sure we set their status to not being able to be turned in (just in case)
            foreach (var id in availableQuests)
            {
                UserInfo.HasFinishQuestRequirements.SetRequirementsStatus(id, false);
            }

            // For the quests that were marked as being able to turn in, set their status to being able to be finished
            foreach (var id in turnInQuests)
            {
                UserInfo.HasFinishQuestRequirements.SetRequirementsStatus(id, true);
            }

            // Grab the descriptions for both the available quests and quests we can turn in
            var qds = availableQuests.Concat(turnInQuests).Distinct().Select(x => _questDescriptions.GetOrDefault(x)).ToArray();

            // Display the form
            GameplayScreen.AvailableQuestsForm.Display(qds, npcIndex);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:38,代码来源:ClientPacketHandler.cs

示例6: RecvSellInventoryToShop

        void RecvSellInventoryToShop(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadInventorySlot();
            var amount = r.ReadByte();

            User user;
            if ((user = TryGetUser(conn)) == null)
                return;

            user.ShoppingState.TrySellInventory(slot, amount);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:11,代码来源:ServerPacketHandler.cs

示例7: ReadSetGroup

        /// <summary>
        /// Handles <see cref="GroupInfoMessages.SetGroup"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadSetGroup(BitStream bs)
        {
            _members.Clear();
            _founder = null;

            var isInGroup = bs.ReadBool();

            if (isInGroup)
            {
                // Read the group members
                var numMembers = bs.ReadByte();
                var members = bs.ReadStrings(numMembers);
                _members.AddRange(members);

                // Read the founder's name
                _founder = bs.ReadString();
            }

            // Raise events
            OnGroupChanged();

            if (GroupChanged != null)
                GroupChanged.Raise(this, EventArgs.Empty);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:28,代码来源:UserGroupInformation.cs

示例8: RecvSetChatDialogPage

        void RecvSetChatDialogPage(IIPSocket conn, BitStream r)
        {
            var pageID = r.ReadNPCChatDialogItemID();
            var skipCount = r.ReadByte();

            var responsesToSkip = new byte[skipCount];
            for (var i = 0; i < skipCount; i++)
            {
                responsesToSkip[i] = r.ReadByte();
            }

            GameplayScreen.ChatDialogForm.SetPageIndex(pageID, responsesToSkip);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:13,代码来源:ClientPacketHandler.cs

示例9: RecvSetInventorySlot

        void RecvSetInventorySlot(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadInventorySlot();
            var hasGraphic = r.ReadBool();
            var graphic = hasGraphic ? r.ReadGrhIndex() : GrhIndex.Invalid;
            var amount = r.ReadByte();

            UserInfo.Inventory.Update(slot, graphic, amount, GetTime());
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:9,代码来源:ClientPacketHandler.cs

示例10: RecvSetCharacterMPPercent

        void RecvSetCharacterMPPercent(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var percent = r.ReadByte();

            var character = _objGrabber.GetDynamicEntity<Character>(mapEntityIndex);
            if (character == null)
                return;

            character.MPPercent = percent;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:11,代码来源:ClientPacketHandler.cs

示例11: RecvSetCharacterPaperDoll

        void RecvSetCharacterPaperDoll(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var count = r.ReadByte();

            var layers = new string[count];
            for (var i = 0; i < layers.Length; i++)
            {
                layers[i] = r.ReadString();
            }

            var character = _objGrabber.GetDynamicEntity<Character>(mapEntityIndex);
            if (character == null)
                return;

            character.CharacterSprite.SetPaperDollLayers(layers);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:17,代码来源:ClientPacketHandler.cs

示例12: RecvSendAccountCharacters

        void RecvSendAccountCharacters(IIPSocket conn, BitStream r)
        {
            var count = r.ReadByte();
            var charInfos = new AccountCharacterInfo[count];
            for (var i = 0; i < count; i++)
            {
                var charInfo = r.ReadAccountCharacterInfo();
                charInfos[charInfo.Index] = charInfo;
            }

            _accountCharacterInfos.SetInfos(charInfos);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:12,代码来源:ClientPacketHandler.cs

示例13: RecvNotifyGetItem

        void RecvNotifyGetItem(IIPSocket conn, BitStream r)
        {
            var name = r.ReadString();
            var amount = r.ReadByte();

            string msg;
            if (amount > 1)
                msg = string.Format("You got {0} {1}s", amount, name);
            else
                msg = string.Format("You got a {0}", name);

            GameplayScreen.InfoBox.Add(msg);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:13,代码来源:ClientPacketHandler.cs

示例14: RecvStartShopping

        void RecvStartShopping(IIPSocket conn, BitStream r)
        {
            var shopOwnerIndex = r.ReadMapEntityIndex();
            var canBuy = r.ReadBool();
            var name = r.ReadString();
            var itemCount = r.ReadByte();

            var items = new IItemTemplateTable[itemCount];
            for (var i = 0; i < itemCount; i++)
            {
                var value = new ItemTemplateTable();
                value.ReadState(r);
                items[i] = value;
            }

            var shopOwner = Map.GetDynamicEntity(shopOwnerIndex);
            var shopInfo = new ShopInfo<IItemTemplateTable>(shopOwner, name, canBuy, items);

            GameplayScreen.ShopForm.DisplayShop(shopInfo);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:20,代码来源:ClientPacketHandler.cs

示例15: RecvSelectAccountCharacter

        void RecvSelectAccountCharacter(IIPSocket conn, BitStream r)
        {
            ThreadAsserts.IsMainThread();

            var index = r.ReadByte();

            // Ensure the client is in a valid state to select an account character
            var userAccount = World.GetUserAccount(conn);
            if (userAccount == null)
                return;

            if (userAccount.User != null)
            {
                const string errmsg = "Account `{0}` tried to change characters while a character was already selected.";
                if (log.IsInfoEnabled)
                    log.InfoFormat(errmsg, userAccount);
                return;
            }

            // Get the CharacterID
            CharacterID characterID;
            if (!userAccount.TryGetCharacterID(index, out characterID))
            {
                const string errmsg = "Invalid account character index `{0}` given.";
                if (log.IsInfoEnabled)
                    log.InfoFormat(errmsg, characterID);
                return;
            }

            // Load the user
            userAccount.SetUser(World, characterID);


            var user = userAccount.User;
            if (user != null)
            {
                // Send the MOTD
                if (!string.IsNullOrEmpty(ServerSettings.Default.MOTD))
                {
                    using (var pw = ServerPacket.Chat(ServerSettings.Default.MOTD))
                    {
                        user.Send(pw, ServerMessageType.GUIChat);
                    }
                }

                // Send a notification to the world that the user joined
                var param = new object[] {user.Name};
                World.Send(GameMessage.UserJoinedWorld, ServerMessageType.GUIChat, param);

            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:51,代码来源:ServerPacketHandler.cs


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