示例#1
0
文件: Util.cs 项目: mezer123/EloBuddy
 public static Obj_AI_Base JungleClear(this Spell.Skillshot s, bool useCast = true, int numberOfHits = 1)
 {
     if (!s.IsReady() || numberOfHits <= 0) return null;
     var minions = EntityManager.MinionsAndMonsters.GetJungleMonsters(s.Source(), s.Range + s.Width).OrderBy(m => m.MaxHealth);
     if (!minions.Any() || minions.Count() < numberOfHits) return null;
     switch (s.Type)
     {
         case SkillShotType.Linear:
             var t = s.GetBestLineTarget(minions.ToList<Obj_AI_Base>());
             if (t.Item1 >= numberOfHits)
             {
                 if (useCast)
                 {
                     s.Cast(t.Item2);
                 }
                 return t.Item2;
             }
             break;
         case SkillShotType.Circular:
             var t2 = s.GetBestCircularTarget(minions.ToList<Obj_AI_Base>());
             if (t2.Item1 < numberOfHits) return null;
             if (useCast)
             {
                 s.Cast(t2.Item2);
             }
             return t2.Item2;
     }
     return null;
 }
示例#2
0
        public static bool Cast(this Spell.Skillshot spell, Obj_AI_Base target, int MinChance = 65, Vector3? From = null, bool UseICPred = false)
        {
            if (!UseICPred)
            {
                Prediction.Manager.PredictionSelected = "SDK Prediction";

                var SpellPred = Prediction.Position.PredictLinearMissile
                    (target, spell.Range, spell.Width, spell.CastDelay, spell.Speed, spell.AllowedCollisionCount, From.HasValue ? From.Value : Player.Instance.Position);

                if (SpellPred.HitChancePercent >= MinChance && spell.Cast(SpellPred.CastPosition)) return true;
            }
            else
            {
                Prediction.Manager.PredictionSelected = "SDK Beta Prediction";

                var SpellPred = Prediction.Manager.GetPrediction(new Prediction.Manager.PredictionInput
                {
                    Delay = (float)spell.CastDelay / 1000,
                    Radius = spell.Width,
                    Range = spell.Range,
                    Speed = spell.Speed,
                    Type = spell.Type,
                    Target = target,
                    From = From.HasValue ? From.Value : Player.Instance.Position
                });

                if (SpellPred.CollisionObjects.Count() <= spell.AllowedCollisionCount && SpellPred.HitChancePercent >= MinChance && spell.Cast(SpellPred.CastPosition)) return true;
            }

            return false;
        }
示例#3
0
 public static void Cast(this Spell.Skillshot spell, Obj_AI_Base target, bool value = true)
 {
     if (target != null && value && spell.IsReady() && target.IsKillable(spell.Range))
     {
         spell.Cast(spell.GetPrediction(target).CastPosition);
     }
 }
 public static Dictionary<string, string> ToDictionary
     (this NameValueCollection source)
 {
     return source.Cast<string>()
                  .Select(s => new { Key = s, Value = source[s] })
                  .ToDictionary(p => p.Key, p => p.Value);
 }
示例#5
0
      public static IEnumerable<XPathItem> ToXPathItems(this XdmValue value) {

         if (value == null)
            return Enumerable.Empty<XPathItem>();

         return ToXPathItems(value.Cast<XdmItem>());
      }
        /// <summary>
        /// Test if an exception is a fatal exception. 
        /// </summary>
        /// <param name="ex">Exception object.</param>
        public static bool IsFatal(this Exception ex)
        {
            if (ex is AggregateException)
            {
                return ex.Cast<AggregateException>().Flatten().InnerExceptions.Any(exception => exception.IsFatal());
            }

            if (ex.InnerException != null && ex.InnerException.IsFatal())
            {
                return true;
            }

            return
                ex is TypeInitializationException ||
                ex is AppDomainUnloadedException ||
                ex is ThreadInterruptedException ||
                ex is AccessViolationException ||
                ex is InvalidProgramException ||
                ex is BadImageFormatException ||
                ex is StackOverflowException ||
                ex is ThreadAbortException ||
                ex is OutOfMemoryException ||
                ex is SecurityException ||
                ex is SEHException;
        }
示例#7
0
        public static IEnumerable<XmlNode> GetSubnodes(this XmlNode node, string subNodeName)
        {
            Preconditions.NotNull(node, "node");
            Preconditions.NotNull(subNodeName, "subNodeName");

            return node.Cast<XmlNode>().Where(n => n.Name == subNodeName);
        }
示例#8
0
文件: Extensions.cs 项目: dfr0/moon
        internal static Type GetItemType(this IEnumerable list)
        {
            Type listType = list.GetType();
            Type itemType = null;

            // if it's a generic enumerable, we get the generic type

            // Unfortunately, if data source is fed from a bare IEnumerable, TypeHelper will report an element type of object,
            // which is not particularly interesting.  We deal with it further on.
            if (listType.IsEnumerableType())
            {
                itemType = listType.GetEnumerableItemType();
            }

            // Bare IEnumerables mean that result type will be object.  In that case, we try to get something more interesting
            if (itemType == null || itemType == typeof(object))
            {
                // We haven't located a type yet.. try a different approach.
                // Does the list have anything in it?

                itemType = list
                    .Cast<object>() // cast to convert IEnumerable to IEnumerable<object>
                    .Select(x => x.GetType()) // get the type
                    .FirstOrDefault(); // get only the first thing to come out of the sequence, or null if empty

                // 

            }

            // if we're null at this point, give up

            return itemType;
        }
示例#9
0
        internal static Spell.CastStates CastWithExtraTrapLogic(this Spell spell)
        {
            if (spell.isReadyPerfectly())
            {
                var Teleport = MinionManager.GetMinions(spell.Range).FirstOrDefault(x => x.HasBuff("teleport_target"));
                var Zhonya = HeroManager.Enemies.FirstOrDefault(x => ObjectManager.Player.Distance(x) <= spell.Range && x.HasBuff("zhonyasringshield"));

                if (Teleport != null)
                    return spell.Cast(Teleport);

                if (Zhonya != null)
                    return spell.Cast(Zhonya);

            }
            return Spell.CastStates.NotCasted;
        }
 public static List<SPField> AvailableSearchFields(this SPFieldCollection fields)
 {
     return fields.Cast<SPField>().Where(p => !p.Hidden &&
            (p.Type != SPFieldType.Computed || p.Id == SPBuiltInFieldId.ContentType) &&
            p.Title != "Predecessors" &&
            p.Title != "Related Issues").ToList();
 }
示例#11
0
        public static PolyCurve ToProtoType(this Autodesk.Revit.DB.CurveArray revitCurves)
        {
            if (revitCurves == null) throw new ArgumentNullException("revitCurves");

            var protoCurves = revitCurves.Cast<Autodesk.Revit.DB.Curve>().Select(x => x.ToProtoType());
            return PolyCurve.ByJoinedCurves(protoCurves.ToArray());
        }
示例#12
0
 private static IEnumerable<ICellLocation> AtPosition(this IEnumerable<ICellLocation> pattern, int x, int y)
 {
     return pattern
         .Cast<XYCellLocation>()
         .Select(cell =>
             new XYCellLocation(cell.X + x, cell.Y + y)).ToList();
 }
        public static bool HasSameItemsRegardlessOfSortOrder(this IEnumerable left, IEnumerable right)
        {
            var leftCollection = left.Cast<object>().ToList();
            var rightCollection = right.Cast<object>().ToList();

            return leftCollection.Except(rightCollection).Count() == 0;
        }
示例#14
0
 /// <summary>
 ///     Basit spell execute
 /// </summary>
 /// <param name="spell">Spell</param>
 public static void Execute(this Spell spell)
 {
     foreach (var enemy in HeroManager.Enemies.Where(o => o.LSIsValidTarget(spell.Range)))
     {
         spell.Cast(enemy);
     }
 }
 public static string ToIDString(this MatchCollection matches)
 {
     var match = matches.Cast<Match>().FirstOrDefault();
     return match != null
                ? match.Value.TrimStart('#')
                : string.Empty;
 }
示例#16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public static bool DoesNotContainsRestrictedChars(this string str)
 {
     // in PCL, string implements only IEnumerable, not IEnumerable<char>
     // https://stackoverflow.com/questions/11557690/
     var chars = str.Cast<char>();
     return !RestrictedCharacters.Any(chars.Contains);
 }
示例#17
0
        public static int IndexOfNextWhitespace(this string text)
        {
            Contract.Requires(text != null);
            Contract.Ensures(Contract.Result<int>() >= 0);

            return text.Cast<char>().TakeWhile(c => !char.IsWhiteSpace(c)).Count();
        }
        public static IEnumerable<MembershipUser> Search(this MembershipUserCollection m, string searchText)
        {
            var users = m.Cast<MembershipUser>().ToList();
            var profiles = users.Select(u => UserProfile.GetUserProfile(u.UserName)).ToList();
            var foundUserNames = profiles.Search(searchText).Select(p => p.UserName);

            return users.Where(u => foundUserNames.Contains(u.UserName)).ToList();
        }
示例#19
0
        /// <summary>
        /// Converts an IEnumerable to appropriate SqlDataRecords for TVP.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <returns>IEnumerable&lt;SqlDataRecord&gt;.</returns>
        public static IEnumerable<SqlDataRecord> ToDataRecords(this IEnumerable items)
        {
            if (items == null)
                return null;

            var enumerable = (items as IEnumerable<object> ?? items.Cast<object>());
            return !enumerable.Any() ? null : ToDataRecordsInternal(enumerable);
        }
示例#20
0
 public static void CastIfHitchanceGreaterOrEqual(this Spell spell, AIHeroClient t)
 {
     var nPrediction = spell.GetPrediction(t);
     var nHitPosition = nPrediction.CastPosition.LSExtend(ObjectManager.Player.Position, -130);
     if (nPrediction.Hitchance >= spell.GetHitchance())
     {
         spell.Cast(nHitPosition);
     }
 }
示例#21
0
 public static string Display(this Microsoft.AnalysisServices.AdomdClient.PropertyCollection collection)
 {
     StringBuilder sb = new StringBuilder();
     foreach (var item in collection.Cast<Property>())
     {
         sb.AppendFormat("{0}    {1} {2}", item.Name, item.Type.ToString(), item.Value == null ? " " : item.Value).AppendLine();
     }
     return sb.ToString();
 }
 public static Dictionary<string, string> ToAttributeDictionary(this MatchCollection matches)
 {
     return matches.Cast<Match>()
                   .Select(m => m.Value.Split('='))
                   .ToDictionary(s => s[0].Trim(new[] { '[', ']' }),
                                 s => s.Count() > 1
                                     ? s[1].ReplaceQuotes().Trim(']')
                                     : string.Empty);
 }
示例#23
0
        /// <summary>
        /// Convert a NameValueCollection into a KeyValue pair so it is a generic IEnumerable and accessible to Linq
        /// </summary>
        /// <param name="collection">A NameValueCollection</param>
        /// <returns></returns>
        /// <remarks>Source: http://stackoverflow.com/questions/391023/make-namevaluecollection-accessible-to-linq-query/396504#396504 </remarks>
        public static IEnumerable<KeyValuePair<string, string>> ToPairs(this NameValueCollection collection)
        {
            if (collection == null)
            {
                return null;
            }

            return collection.Cast<string>().Select(key => new KeyValuePair<string, string>(key, collection[key]));
        }
 public static ApiResponse AsApiResponse(this IPagedList source)
 {
     var totalPage = GetTotalPageCount(source.TotalItemCount, source.PageSize);
     return new ApiResponse()
     {
         data = source.Cast<object>(),
         hasMore = totalPage - source.CurrentPageIndex > 0
     };
 }
示例#25
0
        /// <summary>
        /// Converts the list of objects to an array of attributes, very easy to use during GetCustomAttribute reflection.
        /// </summary>
        /// <param name="objects">The object array, can be <c>null</c>.</param>
        /// <returns>Attribute array or empty array if <paramref name="objects"/> is <c>null</c>.</returns>
        public static Attribute[] ToAttributeArray(this object[] objects)
        {
            if (objects == null)
            {
                return new Attribute[] { };
            }

            return objects.Cast<Attribute>().ToArray();
        }
        public static ProjectItem GetItem(this ProjectItems projectItems, string name)
        {
            Contract.Requires(projectItems != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(name));

            return projectItems
                .Cast<ProjectItem>()
                .FirstOrDefault(
                    pi => string.Equals(pi.Name, name, StringComparison.OrdinalIgnoreCase));
        }
示例#27
0
 internal static void Shield(this Spell spell, float EffectRadius = 0f)
 {
     var SR = Math.Max(spell.Range, Player.AttackRange);
     if (ShieldTarget != null && ShieldTarget.Distance(Player.ServerPosition) <= SR && spell.IsReady()
     && AttackTime - Utils.GameTimeTickCount + 250 >= 0)
     {
         if (spell.IsSkillshot)
         { }
         else if (false == spell.IsSkillshot)
         {
             if (EffectRadius == 0f)
                 spell.Cast(ShieldTarget);
             else //차후 추가예정.
                 return;
         }
         else if (ShieldTarget.IsMe)
             spell.Cast();
     }
 }
        public static ProjectItem GetItem(this ProjectItems projectItems, string name)
        {
            DebugCheck.NotNull(projectItems);
            DebugCheck.NotEmpty(name);

            return projectItems
                .Cast<ProjectItem>()
                .FirstOrDefault(
                    pi => string.Equals(pi.Name, name, StringComparison.OrdinalIgnoreCase));
        }
示例#29
0
        public static bool HitChanceCast(this Spell.Skillshot spell, Obj_AI_Base target, HitChance chance)
        {
            var pred = spell.GetPrediction(target);

            if (pred.HitChance >= chance)
                if (spell.Cast(pred.CastPosition))
                    return true;

            return false;
        }
示例#30
0
        public static bool CastOKTW(this Spell spell, Obj_AI_Hero target, SebbyLib.Prediction.HitChance hitChance)
        {
            SebbyLib.Prediction.SkillshotType CoreType2 = SebbyLib.Prediction.SkillshotType.SkillshotLine;
            bool aoe2 = false;

            if (spell.Type == SkillshotType.SkillshotCircle)
            {
                CoreType2 = SebbyLib.Prediction.SkillshotType.SkillshotCircle;
                aoe2 = true;
            }

            if (spell.Width > 80 && !spell.Collision)
                aoe2 = true;

            var predInput2 = new SebbyLib.Prediction.PredictionInput
            {
                Aoe = aoe2,
                Collision = spell.Collision,
                Speed = spell.Speed,
                Delay = spell.Delay,
                Range = spell.Range,
                From = HeroManager.Player.ServerPosition,
                Radius = spell.Width,
                Unit = target,
                Type = CoreType2
            };
            var poutput2 = SebbyLib.Prediction.Prediction.GetPrediction(predInput2);

            if (spell.Speed != float.MaxValue && SebbyLib.OktwCommon.CollisionYasuo(HeroManager.Player.ServerPosition, poutput2.CastPosition))
                return false;

            if (poutput2.Hitchance >= SebbyLib.Prediction.HitChance.VeryHigh)
            {
                return spell.Cast(poutput2.CastPosition);
            }
            else if (predInput2.Aoe && poutput2.AoeTargetsHitCount > 1 && poutput2.Hitchance >= SebbyLib.Prediction.HitChance.High)
            {
                return spell.Cast(poutput2.CastPosition);
            }

            return false;
        }