本文整理汇总了C#中this.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# this.Cast方法的具体用法?C# this.Cast怎么用?C# this.Cast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.Cast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JungleClear
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: Cast
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: Cast
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);
}
}
示例4:
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: ToXPathItems
public static IEnumerable<XPathItem> ToXPathItems(this XdmValue value) {
if (value == null)
return Enumerable.Empty<XPathItem>();
return ToXPathItems(value.Cast<XdmItem>());
}
示例6: IsFatal
/// <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: GetSubnodes
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: GetItemType
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: CastWithExtraTrapLogic
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;
}
示例10: AvailableSearchFields
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: ToProtoType
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: AtPosition
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();
}
示例13: HasSameItemsRegardlessOfSortOrder
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: Execute
/// <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);
}
}
示例15: ToIDString
public static string ToIDString(this MatchCollection matches)
{
var match = matches.Cast<Match>().FirstOrDefault();
return match != null
? match.Value.TrimStart('#')
: string.Empty;
}