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


C# ISkill.Use方法代码示例

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


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

示例1: UseSkill

        /// <summary>
        /// Calls a skill to be used, and applies the respective cooldown values.
        /// </summary>
        /// <param name="skill">The skill to be used.</param>
        /// <param name="target">The optional character to use the skill on. Can be null.</param>
        /// <param name="castedImmediately">True if this skill was casted immediately (that is, there was no delay before casting);
        /// false if the skill had a delay before casting.</param>
        void UseSkill(ISkill<SkillType, StatType, Character> skill, Character target, bool castedImmediately)
        {
            Debug.Assert(skill != null);
            Debug.Assert(castedImmediately || _currentCastingSkill == skill);
            Debug.Assert(castedImmediately || _castingSkillTarget == target);

            // Clear the casting status variables
            _currentCastingSkill = null;
            _castingSkillTarget = null;

            // Tell the caster that they stopped casting
            if (_character is INetworkSender)
            {
                using (var pw = ServerPacket.SkillStopCasting_ToUser())
                {
                    ((INetworkSender)_character).Send(pw, ServerMessageType.GUIUserStatus);
                }
            }

            // If the skill had a casting time, tell everyone that the casting stopped
            if (!castedImmediately)
            {
                using (var pw = ServerPacket.SkillStopCasting_ToMap(_character.MapEntityIndex))
                {
                    _character.Map.Send(pw, ServerMessageType.MapDynamicEntityProperty);
                }
            }

            // Actually use the skill
            var skillSuccessfullyUsed = skill.Use(_character, target);

            // If the skill was not used for whatever reason, then return
            if (!skillSuccessfullyUsed)
                return;

            // Only set the cooldown if it was successfully used
            _cooldownManager.SetCooldown(skill.CooldownGroup, skill.CooldownTime, _character.GetTime());

            // Update the character's skill cooldown
            if (_character is INetworkSender)
            {
                using (var pw = ServerPacket.SkillSetGroupCooldown(skill.CooldownGroup, skill.CooldownTime))
                {
                    ((INetworkSender)_character).Send(pw, ServerMessageType.GUIUserStatus);
                }
            }

            // Notify the clients on the map that the character used the skill
            var targetEntityIndex = target != null ? (MapEntityIndex?)target.MapEntityIndex : null;
            using (var pw = ServerPacket.SkillUse(_character.MapEntityIndex, targetEntityIndex, skill.SkillType))
            {
                _character.Map.Send(pw, ServerMessageType.MapDynamicEntityProperty);
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:61,代码来源:CharacterSkillCaster.cs


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