本文整理汇总了C#中Unit.DamageTaken方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.DamageTaken方法的具体用法?C# Unit.DamageTaken怎么用?C# Unit.DamageTaken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.DamageTaken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SuicideKillSteal
private static void SuicideKillSteal(Unit hero)
{
if (!Utils.SleepCheck("suicide"))
{
return;
}
var pos = hero.Position;
if (hero.NetworkActivity == NetworkActivity.Move)
{
pos = Prediction.InFront(hero, (Game.Ping / 1000) * hero.MovementSpeed);
}
if (me.Distance2D(pos) > 100)
{
pos = (pos - me.Position) * 99 / pos.Distance2D(me) + me.Position;
}
if (!(pos.Distance2D(me) <= suicideAttackRadius))
{
return;
}
var dmg = hero.DamageTaken(suicideAttackDmg, DamageType.Physical, me, true);
//Console.WriteLine(dmg);
if (!(dmg >= hero.Health))
{
return;
}
suicideAttack.UseAbility(pos);
Utils.Sleep(500, "suicide");
}
示例2: CalculateDamage
/// <summary>
/// Calculates damage from given ability on given target
/// </summary>
/// <param name="ability"></param>
/// <param name="source"></param>
/// <param name="target"></param>
/// <param name="minusArmor"></param>
/// <param name="minusDamageResistancePerc"></param>
/// <param name="minusMagicResistancePerc"></param>
/// <param name="minusHealth"></param>
/// <returns></returns>
public static float CalculateDamage(
Ability ability,
Hero source,
Unit target,
double minusArmor = 0d,
double minusDamageResistancePerc = 0d,
double minusMagicResistancePerc = 0d,
float minusHealth = 0f)
{
var name = ability.StoredName();
var level = ability.Level;
if (ability.AbilityType.HasFlag(AbilityType.Ultimate) && level > 0 && source.AghanimState())
{
level += 1;
}
AbilityInfo data;
if (!DataDictionary.TryGetValue(ability, out data))
{
data = AbilityDatabase.Find(name);
if (data != null && data.IsNuke)
{
DataDictionary.Add(ability, data);
}
}
// var data = AbilityDatabase.Find(name);
if (data == null || !data.IsNuke)
{
return 0;
}
var outgoingDamage = 0f;
float bonusDamage = 0;
Hero hero;
double multi;
float tempDmg;
switch (name)
{
case "ember_spirit_sleight_of_fist":
outgoingDamage = source.MinimumDamage + source.BonusDamage;
if (!DamageDictionary.TryGetValue(ability, out bonusDamage))
{
bonusDamage = ability.GetAbilityData(data.BonusDamageString);
outgoingDamage += bonusDamage;
DamageDictionary.Add(ability, bonusDamage);
LevelDictionary.Add(ability, level);
}
else if (LevelDictionary[ability] != level)
{
LevelDictionary[ability] = level;
bonusDamage = ability.GetAbilityData(data.BonusDamageString);
DamageDictionary[ability] = bonusDamage;
outgoingDamage += bonusDamage;
}
else
{
outgoingDamage += bonusDamage;
}
outgoingDamage = target.DamageTaken(
outgoingDamage,
DamageType.Physical,
source,
true,
minusMagicResistancePerc: minusMagicResistancePerc);
break;
case "doom_bringer_lvl_death":
if (!DamageDictionary.TryGetValue(ability, out tempDmg))
{
tempDmg = ability.GetAbilityData(data.DamageString);
DamageDictionary.Add(ability, tempDmg);
LevelDictionary.Add(ability, level);
}
else if (LevelDictionary[ability] != level)
{
LevelDictionary[ability] = level;
tempDmg = ability.GetAbilityData(data.DamageString);
DamageDictionary[ability] = tempDmg;
}
var multiplier = ability.GetAbilityData("lvl_bonus_multiple");
bonusDamage = ability.GetAbilityData("lvl_bonus_damage");
var levelc = target.Level / multiplier;
if (levelc == Math.Floor(levelc) || target.Level == 25)
{
tempDmg += target.MaximumHealth * (bonusDamage / 100);
}
//.........这里部分代码省略.........
示例3: FindDetonatableBombs
private static Dictionary<int, Ability> FindDetonatableBombs(Unit hero, Vector3 pos, IEnumerable<Unit> bombs)
{
var possibleBombs = bombs.Where(x => x.Distance2D(pos) <= remoteMinesRadius);
var detonatableBombs = new Dictionary<int, Ability>();
var dmg = 0f;
foreach (var bomb in possibleBombs)
{
if (dmg > 0)
{
var takenDmg = hero.DamageTaken(dmg, DamageType.Magical, me, false);
if (takenDmg >= hero.Health)
{
break;
}
}
detonatableBombs[detonatableBombs.Count + 1] = bomb.Spellbook.Spell1;
dmg += remoteMinesDmg;
}
dmg = hero.DamageTaken(dmg, DamageType.Magical, me, false);
return dmg < hero.Health ? null : detonatableBombs;
}
示例4: CanKillSuic
private static string CanKillSuic(Unit target)
{
float s;
try
{
s = target.Health - target.DamageTaken(_currentSuicDamage, DamageType.Physical, _me, true);
}
catch
{
s = target.Health;
}
return (s <= 0) ? "Killable" : string.Format("need: {0:N}", s);
}
示例5: GetRemoteMineDamage
/// <summary>
/// The get remote mine damage.
/// </summary>
/// <param name="level">
/// The level.
/// </param>
/// <param name="handle">
/// The handle.
/// </param>
/// <param name="creep">
/// The creep.
/// </param>
/// <returns>
/// The <see cref="float" />.
/// </returns>
public float GetRemoteMineDamage(uint level, uint handle, Unit creep = null)
{
Dictionary<uint, float> dictionary;
if (!this.remoteMineDamageDictionary.TryGetValue(level, out dictionary))
{
var damage = Variables.Techies.AghanimState()
? Variables.RemoteMinesAbility.GetAbilityData("damage_scepter", level)
: Variables.RemoteMinesAbility.GetAbilityData("damage", level);
dictionary =
Heroes.GetByTeam(Variables.EnemyTeam)
.Where(x => x.IsValid && !x.IsIllusion)
.ToDictionary(
hero => hero.Handle,
hero => hero.DamageTaken(damage, DamageType.Magical, Variables.Techies));
}
if (!dictionary.ContainsKey(1) && creep != null)
{
handle = 1;
dictionary.Add(
1,
creep.DamageTaken(this.CurrentRemoteMineDamage, DamageType.Magical, Variables.Techies));
}
return !dictionary.ContainsKey(handle) ? 0 : dictionary[handle];
}
示例6: CalculateDamage
/// <summary>
/// Calculates damage from given ability on given target
/// </summary>
/// <param name="ability"></param>
/// <param name="source"></param>
/// <param name="target"></param>
/// <returns></returns>
public static float CalculateDamage(Ability ability, Hero source, Unit target)
{
var name = ability.Name;
var level = ability.Level;
AbilityInfo data;
if (!dataDictionary.TryGetValue(ability, out data))
{
data = AbilityDatabase.Find(name);
if (data != null && data.IsNuke)
{
dataDictionary.Add(ability, data);
}
}
//var data = AbilityDatabase.Find(name);
if (data == null || !data.IsNuke)
{
return 0;
}
var outgoingDamage = 0f;
float bonusDamage;
switch (name)
{
case "ember_spirit_sleight_of_fist":
outgoingDamage = source.MinimumDamage + source.BonusDamage;
if (!damageDictionary.TryGetValue(ability, out bonusDamage))
{
bonusDamage = ability.GetAbilityData(data.BonusDamageString);
outgoingDamage += bonusDamage;
damageDictionary.Add(ability, bonusDamage);
levelDictionary.Add(ability, ability.Level);
}
else if (levelDictionary[ability] != ability.Level)
{
levelDictionary[ability] = ability.Level;
bonusDamage = ability.GetAbilityData(data.BonusDamageString);
damageDictionary[ability] = bonusDamage;
outgoingDamage += bonusDamage;
}
else
{
outgoingDamage += bonusDamage;
}
outgoingDamage = target.DamageTaken(
outgoingDamage,
DamageType.Physical,
source,
data.MagicImmunityPierce);
break;
case "doom_bringer_lvl_death":
float tempDmg;
if (!damageDictionary.TryGetValue(ability, out tempDmg))
{
tempDmg = ability.GetAbilityData(data.DamageString);
damageDictionary.Add(ability, tempDmg);
levelDictionary.Add(ability, ability.Level);
}
else if (levelDictionary[ability] != ability.Level)
{
levelDictionary[ability] = ability.Level;
tempDmg = ability.GetAbilityData(data.DamageString);
damageDictionary[ability] = tempDmg;
}
var multiplier = ability.GetAbilityData("lvl_bonus_multiple");
bonusDamage = ability.GetAbilityData("lvl_bonus_damage");
var levelc = target.Level / multiplier;
if (levelc == Math.Floor(levelc) || target.Level == 25)
{
tempDmg += target.MaximumHealth * (bonusDamage / 100);
}
outgoingDamage = target.DamageTaken(tempDmg, DamageType.Magical, source, data.MagicImmunityPierce);
break;
case "phantom_assassin_phantom_strike":
var crit = source.Spellbook.SpellR;
if (crit.Level > 0)
{
float critMulti;
if (!damageDictionary.TryGetValue(crit, out critMulti))
{
critMulti = crit.GetAbilityData("crit_bonus");
damageDictionary.Add(crit, critMulti);
levelDictionary.Add(crit, crit.Level);
}
else if (levelDictionary[crit] != crit.Level)
{
levelDictionary[crit] = crit.Level;
critMulti = crit.GetAbilityData("crit_bonus");
damageDictionary[crit] = critMulti;
}
outgoingDamage = (source.MinimumDamage + source.BonusDamage) * (critMulti / 100);
}
outgoingDamage = target.DamageTaken(
//.........这里部分代码省略.........
示例7: CanKillSuic
private static bool CanKillSuic(Unit target)
{
float s;
try
{
s = target.Health - target.DamageTaken(_currentSuicDamage, DamageType.Physical, _me, true);
}
catch
{
//PrintError("ErrorLevel 4 (2)");
ErrorLevel[7]++;
s = 1;
}
return s <= 0;
}
示例8: DrawInfo
private static void DrawInfo(Unit unit, bool showCount)
{
var dPos = Drawing.WorldToScreen(unit.Position);
if (CanKill(unit)) Drawer.DrawCircle(dPos, 10, Color.Red, 10);
else
{
if (showCount)
{
var needStacks = 0;
for (int i = 0; i <= 19; i++)
{
var lvlDamage = _ShadowPoisonDamage[ShadowPoison.Level - 1];
var damage = needStacks * lvlDamage;
if (unit.DamageTaken(damage, DamageType.Magical, MyHero) < unit.Health) needStacks++;
else break;
}
Drawer.DrawShadowText(needStacks.ToString(), dPos.X - 5, dPos.Y - 5, Color.White);
}
Drawer.DrawCircle(dPos, 10, new ColorBGRA((Vector3)Color.Green, 120), 10);
}
}
示例9: CanKill
private static bool CanKill(Unit unit)
{
var shadowPoisonModifier = unit.Modifiers.FirstOrDefault(x => x.Name == "modifier_shadow_demon_shadow_poison");
if (shadowPoisonModifier != null)
{
var lvlDamage = _ShadowPoisonDamage[ShadowPoison.Level - 1];
var damage = shadowPoisonModifier.StackCount * lvlDamage;
if (unit.DamageTaken(damage, DamageType.Magical, MyHero) >= unit.Health)
return true;
}
return false;
}
示例10: CheckTarget
private static bool CheckTarget(Unit enemy, bool doubleOwnage = false) {
if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
return false;
if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
return false;
if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
return false;
return enemy.Health <
enemy.DamageTaken(DagonDamage[dagon.Level - 1] * (doubleOwnage ? 2 : 1), DamageType.Magical, hero);
}
示例11: GetRemoteMineDamage
/// <summary>
/// The get remote mine damage.
/// </summary>
/// <param name="level">
/// The level.
/// </param>
/// <param name="classId">
/// The class id.
/// </param>
/// <param name="creep">
/// The creep.
/// </param>
/// <returns>
/// The <see cref="float" />.
/// </returns>
public float GetRemoteMineDamage(uint level, ClassID classId, Unit creep = null)
{
Dictionary<ClassID, float> dictionary;
if (!this.remoteMineDamageDictionary.TryGetValue(level, out dictionary))
{
var damage = Variables.Techies.AghanimState()
? Variables.RemoteMinesAbility.GetAbilityData("damage_scepter", level)
: Variables.RemoteMinesAbility.GetAbilityData("damage", level);
dictionary = Heroes.GetByTeam(Variables.EnemyTeam)
.ToDictionary(
hero => hero.ClassID,
hero => hero.DamageTaken(damage, DamageType.Magical, Variables.Techies));
}
if (!dictionary.ContainsKey(classId)
&& (classId == ClassID.CDOTA_BaseNPC_Creep || classId == ClassID.CDOTA_BaseNPC_Creep_Lane
|| classId == ClassID.CDOTA_BaseNPC_Creep_Siege))
{
dictionary.Add(
classId,
creep.DamageTaken(this.currentRemoteMineDamage, DamageType.Magical, Variables.Techies));
}
return !dictionary.ContainsKey(classId) ? 0 : dictionary[classId];
}
示例12: CheckRazeDamage
private static float CheckRazeDamage(int number, Unit hero)
{
return hero.DamageTaken(shadowRazeDamage[number], DamageType.Magical, me, false);
}
示例13: GetCount
private static int GetCount(Unit v, uint health, float damage)
{
var n = 0;
float dmg = 0;
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (v == null || health == 0 || damage == 0) return 30;
try
{
do
{
n++;
dmg += damage;
} while (health - v.DamageTaken(dmg, DamageType.Magical, _me, false) > 0 && n < 30);
}
catch
{
ErrorLevel[5]++;
//PrintError("ErrorLevel 5");
// ignored
}
return n;
}
示例14: CheckBombDamage
private static float CheckBombDamage(Unit hero, Vector3 pos, IEnumerable<Unit> bombs)
{
var possibleBombs = bombs.Where(x => x.Distance2D(pos) <= remoteMinesRadius);
var dmg = remoteMinesDmg * possibleBombs.Count();
return hero.DamageTaken(dmg, DamageType.Magical, me, false);
}
示例15: CheckBombDamage
private static float CheckBombDamage(Unit hero, Vector3 pos, IEnumerable<KeyValuePair<Unit, float>> bombs)
{
var dmg =
bombs.Where(x => x.Key.Distance2D(pos) <= remoteMinesRadius).Sum(possibleBomb => possibleBomb.Value);
return hero.DamageTaken(dmg, DamageType.Magical, me);
}