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


C# BitStream.ReadEnum方法代码示例

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


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

示例1: RecvSkillStartCasting_ToUser

        void RecvSkillStartCasting_ToUser(IIPSocket conn, BitStream r)
        {
            var skillType = r.ReadEnum<SkillType>();
            var castTime = r.ReadUShort();

            GameplayScreen.SkillCastProgressBar.StartCasting(skillType, castTime);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:7,代码来源:ClientPacketHandler.cs

示例2: RecvSkillUse

        void RecvSkillUse(IIPSocket conn, BitStream r)
        {
            var casterEntityIndex = r.ReadMapEntityIndex();
            var hasTarget = r.ReadBool();
            MapEntityIndex? targetEntityIndex = null;
            if (hasTarget)
                targetEntityIndex = r.ReadMapEntityIndex();
            var skillType = r.ReadEnum<SkillType>();

            var casterEntity = _objGrabber.GetDynamicEntity<CharacterEntity>(casterEntityIndex);
            CharacterEntity targetEntity = null;
            if (targetEntityIndex.HasValue)
                targetEntity = _objGrabber.GetDynamicEntity<CharacterEntity>(targetEntityIndex.Value);

            if (casterEntity == null)
                return;

            // Get the SkillInfo for the skill being used
            var skillInfo = _objGrabber.GetSkillInfo(skillType);
            if (skillInfo == null)
                return;

            // If an ActionDisplay is available for this skill, display it
            if (skillInfo.CastActionDisplay.HasValue)
            {
                var ad = ActionDisplayScripts.ActionDisplays[skillInfo.CastActionDisplay.Value];
                if (ad != null)
                    ad.Execute(Map, casterEntity, targetEntity);
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:30,代码来源:ClientPacketHandler.cs

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

示例4: RecvSkillStartCasting_ToMap

        void RecvSkillStartCasting_ToMap(IIPSocket conn, BitStream r)
        {
            var casterEntityIndex = r.ReadMapEntityIndex();
            var skillType = r.ReadEnum<SkillType>();

            // Get the SkillInfo for the skill being used
            var skillInfo = _objGrabber.GetSkillInfo(skillType);
            if (skillInfo == null)
                return;

            // Get the entity
            var casterEntity = _objGrabber.GetDynamicEntity<Character>(casterEntityIndex);
            if (casterEntity == null)
                return;

            // If an ActionDisplay is available for this skill, display it
            if (skillInfo.StartCastingActionDisplay.HasValue)
            {
                var ad = ActionDisplayScripts.ActionDisplays[skillInfo.StartCastingActionDisplay.Value];
                if (ad != null)
                {
                    casterEntity.IsCastingSkill = true;
                    ad.Execute(Map, casterEntity, null);
                }
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:26,代码来源:ClientPacketHandler.cs

示例5: RecvUseSkill

        void RecvUseSkill(IIPSocket conn, BitStream r)
        {
            SkillType skillType;
            MapEntityIndex? targetIndex = null;

            // Get the SkillType to use
            try
            {
                skillType = r.ReadEnum<SkillType>();
            }
            catch (InvalidCastException)
            {
                const string errmsg = "Failed to read SkillType from stream.";
                if (log.IsWarnEnabled)
                    log.Warn(errmsg);
                Debug.Fail(errmsg);
                r.ReadBool();
                return;
            }

            // Check for a target
            var hasTarget = r.ReadBool();
            if (hasTarget)
                targetIndex = r.ReadMapEntityIndex();

            // Get the user
            User user;
            if ((user = TryGetUser(conn)) != null)
            {
                // Check that they know the skill
                if (!user.KnownSkills.Knows(skillType))
                    user.Send(GameMessage.SkillNotKnown, ServerMessageType.GUIChat);
                else
                {
                    // Use the skill
                    user.UseSkill(skillType, GetTargetCharacter(user, targetIndex));
                }
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:39,代码来源:ServerPacketHandler.cs

示例6: RecvRemoveStatusEffect

        void RecvRemoveStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();

            GameplayScreen.StatusEffectsForm.RemoveStatusEffect(statusEffectType);
            GameplayScreen.AppendToChatOutput(string.Format("Removed status effect {0}.", statusEffectType));
        }
开发者ID:wtfcolt,项目名称:game,代码行数:7,代码来源:ClientPacketHandler.cs

示例7: RecvEmote

        void RecvEmote(IIPSocket conn, BitStream r)
        {
            var mapEntityIndex = r.ReadMapEntityIndex();
            var emoticon = r.ReadEnum<Emoticon>();

            var entity = Map.GetDynamicEntity(mapEntityIndex);
            if (entity == null)
                return;

            EmoticonDisplayManager.Instance.Add(entity, emoticon, GetTime());
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:11,代码来源:ClientPacketHandler.cs

示例8: RecvRaiseStat

        void RecvRaiseStat(IIPSocket conn, BitStream r)
        {
            StatType statType;

            // Get the StatType
            try
            {
                statType = r.ReadEnum<StatType>();
            }
            catch (InvalidCastException)
            {
                const string errorMsg = "Received invaild StatType on connection `{0}`.";
                Debug.Fail(string.Format(errorMsg, conn));
                if (log.IsWarnEnabled)
                    log.WarnFormat(errorMsg, conn);
                return;
            }

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

            // Raise the user's stat
            user.RaiseStat(statType);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:26,代码来源:ServerPacketHandler.cs

示例9: RecvAddStatusEffect

        void RecvAddStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();
            var power = r.ReadUShort();
            var secsLeft = r.ReadUShort();

            var param = new string[] {User.Name, statusEffectType.ToString(), power.ToString()};
            var message = GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CombatStatusEffectGained, param);

            GameplayScreen.StatusEffectsForm.AddStatusEffect(statusEffectType, power, secsLeft);
            GameplayScreen.AppendToChatOutput(message);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:12,代码来源:ClientPacketHandler.cs

示例10: RecvCreateAccount

        void RecvCreateAccount(IIPSocket conn, BitStream r)
        {
            var successful = r.ReadBool();
            var errorMessage = string.Empty;

            if (!successful)
            {
                var failureGameMessage = r.ReadEnum<GameMessage>();
                errorMessage = GameMessageCollection.CurrentLanguage.GetMessage(failureGameMessage);
            }

            if (ReceivedCreateAccount != null)
                ReceivedCreateAccount.Raise(conn, new CreateAccountEventArgs(successful, errorMessage));
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:ClientPacketHandler.cs

示例11: RecvUpdateEquipmentSlot

        void RecvUpdateEquipmentSlot(IIPSocket conn, BitStream r)
        {
            var slot = r.ReadEnum<EquipmentSlot>();
            var hasValue = r.ReadBool();

            if (hasValue)
            {
                var graphic = r.ReadGrhIndex();
                UserInfo.Equipped.SetSlot(slot, graphic);
            }
            else
                UserInfo.Equipped.ClearSlot(slot);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:13,代码来源:ClientPacketHandler.cs

示例12: Read

        /// <summary>
        /// Reads the data from the server related to the user guild information. This should only be used by the client.
        /// </summary>
        /// <param name="bitStream">The <see cref="BitStream"/> containing the data.</param>
        public void Read(BitStream bitStream)
        {
            var id = bitStream.ReadEnum<GuildInfoMessages>();
            switch (id)
            {
                case GuildInfoMessages.SetGuild:
                    ReadSetGuild(bitStream);
                    return;

                case GuildInfoMessages.AddMember:
                    ReadAddMember(bitStream);
                    return;

                case GuildInfoMessages.RemoveMember:
                    ReadRemoveMember(bitStream);
                    return;

                case GuildInfoMessages.AddOnlineMember:
                    ReadAddOnlineMember(bitStream);
                    return;

                case GuildInfoMessages.RemoveOnlineMember:
                    ReadRemoveOnlineMember(bitStream);
                    return;

                case GuildInfoMessages.UpdateRank:
                    ReadUpdateRank(bitStream);
                    return;

                case GuildInfoMessages.UpdateNameTag:
                    ReadUpdateNameTag(bitStream);
                    return;

                default:
                    const string errmsg = "Unknown GuildInfoMessages value `{0}`. Could not parse!";
                    var err = string.Format(errmsg, id);
                    log.Fatal(err);
                    Debug.Fail(err);
                    return;
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:45,代码来源:UserGuildInformation.cs

示例13: Read

        /// <summary>
        /// Reads the data from the server related to the user group information. This should only be used by the client.
        /// </summary>
        /// <param name="bs">The <see cref="BitStream"/> containing the data.</param>
        public void Read(BitStream bs)
        {
            var id = bs.ReadEnum<GroupInfoMessages>();
            switch (id)
            {
                case GroupInfoMessages.AddMember:
                    ReadAddMember(bs);
                    break;

                case GroupInfoMessages.RemoveMember:
                    ReadRemoveMember(bs);
                    break;

                case GroupInfoMessages.SetGroup:
                    ReadSetGroup(bs);
                    break;

                default:
                    const string errmsg = "Unknown GroupInfoMessages value `{0}`. Could not parse!";
                    var err = string.Format(errmsg, id);
                    log.Fatal(err);
                    Debug.Fail(err);
                    return;
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:29,代码来源:UserGroupInformation.cs

示例14: RecvEmoticon

        void RecvEmoticon(IIPSocket conn, BitStream r)
        {
            var emoticon = r.ReadEnum<Emoticon>();

            if (!EnumHelper<Emoticon>.IsDefined(emoticon))
            {
                const string errmsg = "Attempted to use undefined emoticon `{0}`.";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, emoticon);
                return;
            }

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

            user.Emote(emoticon);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:18,代码来源:ServerPacketHandler.cs

示例15: RecvRemoveStatusEffect

        void RecvRemoveStatusEffect(IIPSocket conn, BitStream r)
        {
            var statusEffectType = r.ReadEnum<StatusEffectType>();

            var message = GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CombatStatusEffectWoreOff, statusEffectType.ToString());

            GameplayScreen.StatusEffectsForm.RemoveStatusEffect(statusEffectType);
            GameplayScreen.AppendToChatOutput(message);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:9,代码来源:ClientPacketHandler.cs


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