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


C# Unit.GetTurnTime方法代码示例

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


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

示例1: CastSpell

        private static void CastSpell(Unit hero, ExecuteOrderEventArgs args)
        {
            var spell = args.Ability;

            if (hero == null || spell == null || spell.ManaCost <= 25 || IgnoredSpells.Any(spell.Name.Contains))
                return;

            var powerTreads = hero.FindItem("item_power_treads");

            if (powerTreads == null)
                return;

            args.Process = false;

            var sleep = spell.FindCastPoint() * 1000 + 555;

            switch (args.Order) {
                case Order.AbilityTarget: {
                    var target = (Unit) args.Target;
                    if (target != null && target.IsAlive) {

                        var castRange = spell.GetCastRange() + 300;

                        if (hero.Distance2D(target) <= castRange) {
                            ChangePt(powerTreads, Attribute.Intelligence);
                            sleep += hero.GetTurnTime(target) * 1000;
                        }

                        spell.UseAbility(target);

                    }
                    break;
                }
                case Order.AbilityLocation: {
                    var castRange = spell.GetCastRange() + 300;

                    if (hero.Distance2D(Game.MousePosition) <= castRange) {
                        ChangePt(powerTreads, Attribute.Intelligence);
                        sleep += hero.GetTurnTime(Game.MousePosition) * 1000;
                    }

                    spell.UseAbility(Game.MousePosition);

                    break;
                }
                case Order.Ability: {
                    ChangePt(powerTreads, Attribute.Intelligence);
                    spell.UseAbility();
                    break;
                }
                case Order.ToggleAbility: {
                    ChangePt(powerTreads, Attribute.Intelligence);
                    spell.ToggleAbility();
                    break;
                }
            }

            Utils.Sleep(sleep, "delay");
        }
开发者ID:7ajlosh,项目名称:Ensage,代码行数:59,代码来源:Program.cs

示例2: GetCastDelay

        /// <summary>
        ///     Returns delay before ability is casted
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="source">
        ///     The source.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="abilityLevel">
        ///     The ability Level.
        /// </param>
        /// <param name="usePing">
        ///     The use Ping.
        /// </param>
        /// <param name="useCastPoint">
        ///     The use Cast Point.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <param name="useChannel">
        ///     The use Channel.
        /// </param>
        /// <returns>
        ///     The <see cref="double" />.
        /// </returns>
        public static double GetCastDelay(
            this Ability ability, 
            Unit source, 
            Unit target, 
            uint abilityLevel, 
            bool usePing = false, 
            bool useCastPoint = true, 
            string abilityName = null, 
            bool useChannel = false)
        {
            if (ability == null || !ability.IsValid)
            {
                return 0;
            }

            if (target == null || !target.IsValid || source == null || !source.IsValid)
            {
                return 0;
            }

            var level = abilityLevel != 0 ? abilityLevel : ability.Level;
            var name = abilityName ?? ability.StoredName();
            double delay;
            if (useCastPoint)
            {
                if (!delayDictionary.TryGetValue(name + " " + level, out delay))
                {
                    delay = Math.Max(ability.FindCastPoint(name), 0.07);
                    delayDictionary.Add(name + " " + level, delay);
                }

                if (name == "templar_assassin_meld")
                {
                    delay += UnitDatabase.GetAttackPoint(source) + Game.Ping / 500 + 0.1 + source.GetTurnTime(target);
                }

                if (name == "item_diffusal_blade" || name == "item_diffusal_blade_2")
                {
                    delay += 2;
                }
            }
            else
            {
                if (ability is Item)
                {
                    delay = 0;
                }
                else
                {
                    delay = 0.05;
                }
            }

            if (usePing)
            {
                delay += Game.Ping / 1000;
            }

            if (useChannel)
            {
                delay += ability.ChannelTime(level, name);
            }

            if (!ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                return Math.Max(delay + (!target.Equals(source) ? source.GetTurnTime(target) : 0), 0);
            }

            return Math.Max(delay, 0);
        }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:100,代码来源:AbilityExtensions.cs

示例3: GetAvailableTrees

 private IEnumerable<Tree> GetAvailableTrees(
     Unit hero,
     Vector3 target,
     float range,
     double time = 0,
     float speed = 1)
 {
     return
         allTrees.OrderBy(x => x.Distance2D(target))
             .Where(
                 x =>
                 x.Distance2D(hero) <= range && NavMesh.GetCellFlags(x.Position).HasFlag(NavMeshCellFlags.Tree)
                 && (time <= 0
                     || !unavailableTrees.Any(
                         z =>
                         z.Item1.Distance2D(x) <= z.Item2
                         && time + hero.GetTurnTime(x) + x.Distance2D(hero) / speed >= z.Item3)));
 }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:18,代码来源:TreeFactory.cs


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