本文整理汇总了C#中Unit.Predict方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.Predict方法的具体用法?C# Unit.Predict怎么用?C# Unit.Predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.Predict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cast
public static bool Cast(Ability ability, Unit target, string name)
{
if (target.Modifiers.Any(x => x.Name == "modifier_item_blade_mail_reflect")
&& AbilityDamage.CalculateDamage(ability, AbilityMain.Me, target) > AbilityMain.Me.Health)
{
return false;
}
if (target.Modifiers.Any(x => x.Name == "modifier_nyx_assassin_spiked_carapace"))
{
return false;
}
if (ability.Name == "sniper_assassinate")
{
if (AbilityMain.Me.Distance2D(target) <= AbilityMain.Me.GetAttackRange() + 100)
{
return false;
}
}
if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && ability.Name != "lion_impale")
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
SoulRing.Cast(ability);
if (name == "omniknight_purification")
{
ability.UseAbility(AbilityMain.Me);
}
ability.UseAbility(target);
return true;
}
if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
|| ability.IsAbilityBehavior(AbilityBehavior.Point, name))
&& (Prediction.StraightTime(target) > 1000 || target.MovementSpeed < 200))
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
return ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
}
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
if (ability.Name == "templar_assassin_meld")
{
if (
!(target.Distance2D(MyHeroInfo.Position)
< (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking()
|| (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
> (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| !Utils.SleepCheck("GlobalCasting"))
{
return false;
}
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
DelayAction.Add(
new DelayActionItem(
(int)ability.GetCastDelay(AbilityMain.Me, target)*1000,
() =>
{
AbilityMain.Me.Attack(target);
},
CancellationToken.None));
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "casting");
Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "Ability.Move");
return true;
}
if (ability.Name.Contains("nevermore_shadowraze"))
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
return ability.CastSkillShot(target, name);
}
SoulRing.Cast(ability);
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
return true;
}
return false;
}
示例2: Cast
public static bool Cast(
Ability ability,
Unit target,
Unit buffTarget,
string name,
List<Modifier> modifiers,
bool togglearmlet = false)
{
if (name == "item_armlet")
{
if (buffTarget.Modifiers.Any(x => x.Name == "modifier_ice_blast"))
{
return false;
}
if (!togglearmlet && buffTarget.Distance2D(target) > Math.Max(target.GetAttackRange(), 500))
{
return false;
}
var armlettoggled = modifiers.Any(x => x.Name == "modifier_item_armlet_unholy_strength")
&& ability.IsToggled;
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
if (armlettoggled)
{
ability.ToggleAbility();
ability.ToggleAbility();
return true;
}
ability.ToggleAbility();
return true;
}
if (!(buffTarget.Distance2D(target) < MyHeroInfo.AttackRange() + 150))
{
return false;
}
SoulRing.Cast(ability);
if (ability.Name == "templar_assassin_refraction")
{
var meld = AbilityMain.Me.Spellbook.Spell2;
if (meld != null && meld.CanBeCasted())
{
if (
!(target.Distance2D(MyHeroInfo.Position)
< (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking()
|| (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
> (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
|| !Utils.SleepCheck("GlobalCasting"))
{
return false;
}
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
if (Nuke.Cast(meld, target, NameManager.Name(meld)))
{
DelayAction.Add(
new DelayActionItem(
(int)meld.GetCastDelay(AbilityMain.Me, target) * 1000 + 100,
() =>
{
AbilityMain.Me.Attack(target);
},
CancellationToken.None));
}
Utils.Sleep(meld.GetCastDelay(AbilityMain.Me,target)*1000, "GlobalCasting");
Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, "casting");
Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, ability.Handle.ToString());
return true;
}
}
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility();
return true;
}
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
ManageAutoAttack.AutoAttackDisabled = true;
ability.UseAbility(buffTarget);
return true;
}
示例3: OrbwalkOn
/// <summary>
/// The orbwalk.
/// </summary>
/// <param name="target">
/// The target.
/// </param>
/// <param name="movePosition">
/// The move Position.
/// </param>
/// <param name="bonusWindupMs">
/// The bonus windup ms.
/// </param>
/// <param name="bonusRange">
/// The bonus range.
/// </param>
/// <param name="attackmodifiers">
/// The attackmodifiers.
/// </param>
/// <param name="followTarget">
/// The follow target.
/// </param>
public void OrbwalkOn(
Unit target,
Vector3 movePosition,
float bonusWindupMs = 0,
float bonusRange = 0,
bool attackmodifiers = true,
bool followTarget = false)
{
if (this.Unit == null || !this.Unit.IsValid)
{
return;
}
var targetHull = 0f;
if (target != null)
{
targetHull = target.HullRadius;
}
float distance = 0;
if (target != null)
{
var pos = Prediction.InFront(
this.Unit,
(float)(Game.Ping / 1000 + this.Unit.GetTurnTime(target.Position) * this.Unit.MovementSpeed));
distance = pos.Distance2D(target) - this.Unit.Distance2D(target);
}
var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible;
var isAttackable = target != null && target.IsValid && !target.IsInvul() && !target.IsAttackImmune()
&& !target.HasModifiers(
new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" },
false)
&& target.Distance2D(this.Unit)
<= this.Unit.GetAttackRange() + this.Unit.HullRadius + 50 + targetHull + bonusRange
+ Math.Max(distance, 0);
if ((isValid && isAttackable)
|| (!isAttackable && target != null && target.IsValid && this.Unit.IsAttacking()
&& this.Unit.GetTurnTime(target.Position) < 0.1))
{
var canAttack = !this.IsAttackOnCoolDown(target, bonusWindupMs) && this.Unit.CanAttack();
if (canAttack && !this.attackSleeper.Sleeping && (!this.hero || Utils.SleepCheck("Orbwalk.Attack")))
{
this.attacker.Attack(target, attackmodifiers);
this.AttackOrder();
this.attackSleeper.Sleep(
(float)
(UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000
+ Game.Ping + 100));
this.moveSleeper.Sleep(
(float)
(UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + 50));
if (!this.hero)
{
return;
}
Utils.Sleep(
UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + Game.Ping
+ 100,
"Orbwalk.Attack");
Utils.Sleep(
UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + 50,
"Orbwalk.Move");
return;
}
if (canAttack && !this.attackSleeper2.Sleeping)
{
this.attacker.Attack(target, attackmodifiers);
this.AttackOrder();
this.attackSleeper2.Sleep(100);
return;
}
}
var userdelay = this.setUserDelayManually ? this.UserDelay : Orbwalking.UserDelay;
var canCancel = (this.CanCancelAttack(userdelay) && this.IsAttackOnCoolDown(target, bonusWindupMs))
|| ((!isValid || !isAttackable)
//.........这里部分代码省略.........