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


C# BitStream.ReadQuestID方法代码示例

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


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

示例1: ReadRemoveActiveQuest

        /// <summary>
        /// Handles <see cref="QuestInfoMessages.RemoveActiveQuest"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadRemoveActiveQuest(BitStream bs)
        {
            var questID = bs.ReadQuestID();

            // Ensure the quest is in the active list
            int index;
            if ((index = _activeQuests.BinarySearch(questID)) < 0)
                return;

            Debug.Assert(_activeQuests[index] == questID);

            // Remove
            _activeQuests.RemoveAt(index);

            // Raise events
            OnActiveQuestRemoved(questID);

            if (ActiveQuestRemoved != null)
                ActiveQuestRemoved.Raise(this, EventArgsHelper.Create(questID));
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:24,代码来源:UserQuestInformation.cs

示例2: ReadAddCompletedQuest

        /// <summary>
        /// Handles <see cref="QuestInfoMessages.AddCompletedQuest"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadAddCompletedQuest(BitStream bs)
        {
            var questID = bs.ReadQuestID();

            // Ensure the quest isn't already in the completed list
            if (_completedQuests.BinarySearch(questID) >= 0)
                return;

            // Add
            _completedQuests.Add(questID);
            _completedQuests.Sort();

            // Raise events
            OnCompletedQuestAdded(questID);

            if (CompletedQuestAdded != null)
                CompletedQuestAdded.Raise(this, EventArgsHelper.Create(questID));
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:22,代码来源:UserQuestInformation.cs

示例3: ReadLoadInitialValues

        /// <summary>
        /// Handles <see cref="QuestInfoMessages.LoadInitialValues"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadLoadInitialValues(BitStream bs)
        {
            _completedQuests.Clear();
            _activeQuests.Clear();

            // Read completed quests
            var count = bs.ReadByte();
            for (var i = 0; i < count; i++)
            {
                _completedQuests.Add(bs.ReadQuestID());
            }

            // Read Active quests
            count = bs.ReadByte();
            for (var i = 0; i < count; i++)
            {
                _activeQuests.Add(bs.ReadQuestID());
            }

            // Raise events
            OnLoaded();

            if (Loaded != null)
                Loaded.Raise(this, EventArgs.Empty);
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:29,代码来源:UserQuestInformation.cs

示例4: RecvAcceptOrTurnInQuest

        void RecvAcceptOrTurnInQuest(IIPSocket conn, BitStream r)
        {
            var providerIndex = r.ReadMapEntityIndex();
            var questID = r.ReadQuestID();

            // Get the user
            User user;
            if ((user = TryGetUser(conn)) == null || user.Map == null)
                return;

            if (user.IsPeerTrading)
                return;

            // Get the provider
            var npc = user.Map.GetDynamicEntity<Character>(providerIndex);
            var provider = npc as IQuestProvider<User>;
            if (provider == null)
                return;

            // Check the distance and state
            if (user.Map != npc.Map || user.Map == null || !npc.IsAlive || npc.IsDisposed ||
                user.GetDistance(npc) > GameData.MaxNPCChatDistance)
                return;

            // Get the quest
            var quest = _questManager.GetQuest(questID);
            if (quest == null)
                return;

            // Ensure this provider even provides this quest
            if (!provider.Quests.Contains(quest))
                return;

            // If the user already has the quest, try to turn it in
            if (user.ActiveQuests.Contains(quest))
            {
                // Quest already started, try to turn in
                var success = user.TryFinishQuest(quest);
                using (var pw = ServerPacket.AcceptOrTurnInQuestReply(questID, success, false))
                {
                    user.Send(pw, ServerMessageType.GUI);
                }
            }
            else
            {
                // Quest not started yet, try to add it
                var success = user.TryAddQuest(quest);
                using (var pw = ServerPacket.AcceptOrTurnInQuestReply(questID, success, true))
                {
                    user.Send(pw, ServerMessageType.GUI);
                }
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:53,代码来源:ServerPacketHandler.cs

示例5: ReadAddActiveQuest

        /// <summary>
        /// Handles <see cref="QuestInfoMessages.AddActiveQuest"/>.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> to read from.</param>
        void ReadAddActiveQuest(BitStream bs)
        {
            var questID = bs.ReadQuestID();

            // Ensure the quest isn't already in the active list
            if (_activeQuests.BinarySearch(questID) >= 0)
                return;

            // Add
            _activeQuests.Add(questID);
            _activeQuests.Sort();

            // Raise events
            OnActiveQuestAdded(questID);

            if (ActiveQuestAdded != null)
                ActiveQuestAdded.Raise(this, EventArgsHelper.Create(questID));
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:22,代码来源:UserQuestInformation.cs

示例6: RecvHasQuestStartRequirements

        void RecvHasQuestStartRequirements(IIPSocket conn, BitStream r)
        {
            var questID = r.ReadQuestID();

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

            var quest = _questManager.GetQuest(questID);
            var hasRequirements = false;

            if (quest == null)
            {
                const string errmsg = "User `{0}` sent request for invalid quest ID `{1}`.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, user, questID);
            }
            else
            {
                if (quest.StartRequirements != null)
                    hasRequirements = quest.StartRequirements.HasRequirements(user);
            }

            using (var pw = ServerPacket.HasQuestStartRequirements(questID, hasRequirements))
            {
                user.Send(pw, ServerMessageType.GUI);
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:28,代码来源:ServerPacketHandler.cs

示例7: 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

示例8: RecvSetProvidedQuests

        void RecvSetProvidedQuests(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var count = r.ReadByte();
            var questIDs = new QuestID[count];
            for (var i = 0; i < count; i++)
            {
                questIDs[i] = r.ReadQuestID();
            }

            var character = _objGrabber.GetDynamicEntity<Character>(mapEntityIndex);
            if (character != null)
                character.ProvidedQuests = questIDs;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:ClientPacketHandler.cs

示例9: RecvHasQuestStartRequirementsReply

        void RecvHasQuestStartRequirementsReply(IIPSocket conn, BitStream r)
        {
            var questID = r.ReadQuestID();
            var hasRequirements = r.ReadBool();

            UserInfo.HasStartQuestRequirements.SetRequirementsStatus(questID, hasRequirements);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:7,代码来源:ClientPacketHandler.cs

示例10: RecvAcceptOrTurnInQuestReply

        void RecvAcceptOrTurnInQuestReply(IIPSocket conn, BitStream r)
        {
            var questID = r.ReadQuestID();
            var successful = r.ReadBool();
#pragma warning disable 168
            var accepted = r.ReadBool();
#pragma warning restore 168

            if (successful)
            {
                // Remove the quest from the available quests list
                var aqf = GameplayScreen.AvailableQuestsForm;
                if (aqf.IsVisible)
                {
                    aqf.AvailableQuests = aqf.AvailableQuests.Where(x => x.QuestID != questID).ToArray();
                }
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:18,代码来源:ClientPacketHandler.cs


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