本文整理汇总了C#中Unit.StoredName方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.StoredName方法的具体用法?C# Unit.StoredName怎么用?C# Unit.StoredName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.StoredName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dispose
public static void Dispose(Unit target)
{
ParticleEffect effect;
if (_effectDictinary.TryGetValue(target, out effect))
{
effect.Dispose();
_effectDictinary.Remove(target);
var hero = target as Hero;
Printer.Print(hero != null ? $"[Dispose]: {hero.GetRealName()}" : $"[Dispose]: {target.StoredName()}");
}
}
示例2: GetHitDelay
/// <summary>
/// Checks all aspects and returns full delay before target gets hit by given ability
/// </summary>
/// <param name="ability">
/// The ability.
/// </param>
/// <param name="target">
/// The target.
/// </param>
/// <param name="abilityName">
/// The ability Name.
/// </param>
/// <returns>
/// The <see cref="double" />.
/// </returns>
public static double GetHitDelay(this Ability ability, Unit target, string abilityName = null)
{
if (ability == null || !ability.IsValid)
{
return 0;
}
if (target == null || !target.IsValid)
{
return 0;
}
var name = abilityName ?? ability.StoredName();
var owner = ability.Owner as Unit;
var n = name + owner.StoredName() + target.StoredName();
double storedDelay;
var found = hitDelayDictionary.TryGetValue(n, out storedDelay);
if (!found)
{
hitDelayDictionary.Add(n, 0);
}
if (found && !Utils.SleepCheck(n))
{
return storedDelay;
}
var data = ability.CommonProperties();
var delay = ability.GetCastDelay(owner as Hero, target, true, abilityName: name);
if (data != null)
{
delay += data.AdditionalDelay;
}
var speed = ability.GetProjectileSpeed(name);
var radius = ability.GetRadius(name);
if (!ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name) && speed < 6000 && speed > 0)
{
var xyz = ability.GetPrediction(target, abilityName: name);
delay += Math.Max((int)(owner.Distance2D(xyz) - radius / 2), 100) / speed;
}
if (name == "tinker_heat_seeking_missile")
{
var xyz = ability.GetPrediction(target, abilityName: name);
delay += Math.Max(owner.Distance2D(xyz), 100) / speed;
}
hitDelayDictionary[n] = delay;
Utils.Sleep(40, n);
return delay;
}
示例3: DrawItems
private static void DrawItems(Unit v)
{
var pos = HUDInfo.GetHPbarPosition(v);
if (pos.IsZero)
return;
List<Item> items;
try
{
if (!Members.ItemDictionary.TryGetValue(v.Handle, out items))
{
return;
}
}
catch (Exception)
{
Printer.Print("[ItemOverlay][DrawItems][Courier]: " + v.StoredName());
return;
}
var count = 0;
var itemBoxSizeY = (float)(_defSize / 1.24);
var newSize = new Vector2(_defSize, itemBoxSizeY);
var halfSize = HUDInfo.GetHPBarSizeX() / 2;
var maxSizeX = Math.Max((float)items.Count / 2 * newSize.X + _defSize / (float)2.6, halfSize);
pos -= new Vector2(-halfSize + maxSizeX, _defSize + _defSize / Extra);
foreach (var item in items)
{
try
{
var tex = Textures.GetItemTexture(item.StoredName());
var extraPos = new Vector2(_defSize * count, 0);
var itemPos = pos + extraPos;
var normalSize = newSize + new Vector2(4, _defSize / (float)2.6 + 4);
var normalPos = itemPos - new Vector2(2, 2);
Drawing.DrawRect(normalPos, newSize + new Vector2(4, _defSize / (float)2.6 + 4), Color.Black);
Drawing.DrawRect(itemPos, newSize + _defSize / (float)2.6, tex);
DrawState(item, normalPos, normalSize, v.Mana);
count++;
}
catch (Exception)
{
// ignored
}
}
}
示例4: DoShit
/**
* DoShit takes in a unit and makes the unit do pushing related actions:
* 1) boots of travel to creep furthest away from unit
* 2) push the current lane
* 3) attack tower with shield if nearby
* 4) attack creeps if nearby
* 5) if enemy creeps are nearby, use mjollnir and necronomicon
* args hero: unit to control
* args isTempest: passed to easily distinguish between clone unit and other units
**/
private static void DoShit(Unit hero, bool isTempest=false)
{
if (!hero.IsAlive)
return;
// setting variables
var handle = hero.Handle;
var items = isTempest ? hero.Inventory.Items.ToList() : null;
var travelBoots = isTempest?
items.FirstOrDefault(
x =>
(x.Name == "item_travel_boots" ||
x.Name == "item_travel_boots_2") && x.CanBeCasted() &&
Utils.SleepCheck("Tempest.Travels.Cd" + handle)) : null;
var autoPushItems =isTempest ?
items.Where(
x =>
AutoPushItems.Contains(x.Name) && x.CanBeCasted() &&
Utils.SleepCheck("Tempest.AutoPush.Cd" + handle + x.Name)) : null;
var myCreeps = Objects.LaneCreeps.GetCreeps().Where(x => x.Team == hero.Team).ToList();
var enemyCreeps = Objects.LaneCreeps.GetCreeps().Where(x => x.Team != hero.Team).ToList();
var creepWithEnemy =
myCreeps.FirstOrDefault(
x => x.MaximumHealth * 65 / 100 < x.Health && enemyCreeps.Any(y => y.Distance2D(x) <= 1000));
var isChannel = isTempest && hero.IsChanneling();
// code for using boots of travel
// note: chooses creep furthest away from unit to TP to
if (travelBoots != null && !enemyCreeps.Any(x => x.Distance2D(hero) <= 1000) && !isChannel && Menu.Item("AutoPush.Travels").GetValue<bool>())
{
var mod = hero.FindModifier("modifier_kill");
if (mod == null || mod.RemainingTime >= 10)
{
if (creepWithEnemy == null)
{
creepWithEnemy = myCreeps.OrderByDescending(x => x.Distance2D(hero)).FirstOrDefault();
}
if (creepWithEnemy != null)
{
travelBoots.UseAbility(creepWithEnemy);
Utils.Sleep(500, "Tempest.Travels.Cd" + handle);
return;
}
}
}
if (isChannel) return;
var nearestTower =
Objects.Towers.GetTowers()
.Where(x => x.Team == hero.GetEnemyTeam())
.OrderBy(y => y.Distance2D(hero))
.FirstOrDefault() ?? Objects.Fountains.GetEnemyFountain();
var fountain = Objects.Fountains.GetAllyFountain();
var curlane = GetCurrentLane(hero);
var clospoint = GetClosestPoint(curlane);
var useThisShit = clospoint.Distance2D(fountain) - 250 > hero.Distance2D(fountain);
// useThisShit will return true if unit is closer to the fountain than the clospoint
if (nearestTower != null)
{
var pos = (curlane == "mid" || !useThisShit) ? nearestTower.Position : clospoint;
// if unit is at mid or clospoint is closer than the unit to the fountain, push the nearest tower
// otherwise, push the closest point
// if unit is a tempest and is close to the tower, use shield and attack tower
if (nearestTower.Distance2D(hero) <= 900 && isTempest)
{
if (Utils.SleepCheck("Tempest.Attack.Tower.Cd" + handle))
{
var spell = hero.Spellbook.Spell2;
if (spell != null && IsAbilityEnable(spell.StoredName(), calcForPushing: true) &&
spell.CanBeCasted() && Utils.SleepCheck("shield" + handle))
// handle used to uniquely identify the current hero's cooldowns
{
spell.UseAbility(Prediction.InFront(hero, 100));
Utils.Sleep(1500, "shield" + handle);
}
else if (!hero.IsAttacking())
{
hero.Attack(nearestTower);
}
Utils.Sleep(1000, "Tempest.Attack.Tower.Cd" + handle);
}
}
// make the unit issue an attack command at the position pos
else if (Utils.SleepCheck("Tempest.Attack.Cd" + handle) && !hero.IsAttacking() && isTempest)
{
hero.Attack(pos);
Utils.Sleep(1000, "Tempest.Attack.Cd" + handle);
}
// smart attack for necrobook (unaggro under tower)
//.........这里部分代码省略.........
示例5: SmartAttack
private static void SmartAttack(Unit me, List<Unit> myCreeps, Unit nearestTower, Vector3 pos)
{
var name = me.StoredName();
if (Menu.Item("AutoPush.UnAggro.Enable").GetValue<bool>() &&
myCreeps.Any(x => x.Distance2D(nearestTower) <= 800) && me.Distance2D(nearestTower) <= 1000)
{
var hpwasChanged = CheckForChangedHealth(me);
if (hpwasChanged)
{
var allyCreep = myCreeps.OrderBy(x => x.Distance2D(me)).First();
if (allyCreep != null)
{
var towerPos = nearestTower.Position;
var ang = allyCreep.FindAngleBetween(towerPos, true);
var p = new Vector3((float) (allyCreep.Position.X - 250*Math.Cos(ang)),
(float) (allyCreep.Position.Y - 250*Math.Sin(ang)), 0);
me.Move(p);
me.Attack(allyCreep, true);
Utils.Sleep(1200, name + "attack");
}
else
{
var towerPos = nearestTower.Position;
var ang = me.FindAngleBetween(towerPos, true);
var p = new Vector3((float) (me.Position.X - 1000*Math.Cos(ang)),
(float) (me.Position.Y - 1000*Math.Sin(ang)), 0);
me.Move(p);
Utils.Sleep(500, name + "attack");
}
}
else
{
me.Attack(pos);
Utils.Sleep(500, name + "attack");
}
}
else
{
me.Attack(pos);
Utils.Sleep(500, name + "attack");
}
}
示例6: GetProjectileSpeed
/// <summary>
/// Returns units projectile speed
/// </summary>
/// <param name="unit">
/// The unit.
/// </param>
/// <returns>
/// The <see cref="double" />.
/// </returns>
public static double GetProjectileSpeed(Unit unit)
{
var hero = unit as Hero;
if (hero != null)
{
return GetProjectileSpeed(hero);
}
if (unit == null || !unit.IsRanged)
{
return double.MaxValue;
}
var name = unit.StoredName();
try
{
double projSpeed;
if (!ProjSpeedDictionary.TryGetValue(unit.Handle, out projSpeed))
{
projSpeed = Game.FindKeyValues(name + "/ProjectileSpeed", KeyValueSource.Unit).IntValue;
}
return projSpeed;
}
catch (KeyValuesNotFoundException)
{
if (!Utils.SleepCheck("Ensage.Common.DemoModeWarning"))
{
return double.MaxValue;
}
Utils.Sleep(10000, "Ensage.Common.DemoModeWarning");
Console.WriteLine(@"[[Please do not use demo mode for testing assemblies]]");
return double.MaxValue;
}
}
示例7: GetAttackSpeed
/// <summary>
/// Gets the attack speed.
/// </summary>
/// <param name="unit">
/// The unit.
/// </param>
/// <returns>
/// The <see cref="float" />.
/// </returns>
public static float GetAttackSpeed(Unit unit)
{
var hero = unit as Hero;
if (hero != null)
{
return GetAttackSpeed(hero);
}
try
{
double attackBaseTime;
if (!AttackRateDictionary.TryGetValue(unit.Handle, out attackBaseTime))
{
attackBaseTime =
Game.FindKeyValues(unit.StoredName() + "/AttackRate", KeyValueSource.Unit).FloatValue;
AttackRateDictionary.Add(unit.Handle, attackBaseTime);
}
var attackSpeed = Math.Min(unit.AttackSpeedValue, 600);
return (float)attackSpeed;
}
catch (KeyValuesNotFoundException)
{
if (!Utils.SleepCheck("Ensage.Common.DemoModeWarning"))
{
return 0;
}
Utils.Sleep(10000, "Ensage.Common.DemoModeWarning");
Console.WriteLine(@"[[Please do not use demo mode for testing assemblies]]");
return 0;
}
}
示例8: GetAttackPoint
/// <summary>
/// Gets the attack point.
/// </summary>
/// <param name="unit">
/// The unit.
/// </param>
/// <returns>
/// The <see cref="double" />.
/// </returns>
public static double GetAttackPoint(Unit unit)
{
var hero = unit as Hero;
if (hero != null)
{
return GetAttackPoint(hero);
}
if (unit == null)
{
return 0;
}
try
{
var name = unit.StoredName();
double attackAnimationPoint;
if (!AttackPointDictionary.TryGetValue(unit.Handle, out attackAnimationPoint))
{
attackAnimationPoint =
Game.FindKeyValues(name + "/AttackAnimationPoint", KeyValueSource.Unit).FloatValue;
AttackPointDictionary.Add(unit.Handle, attackAnimationPoint);
}
var attackSpeed = GetAttackSpeed(unit);
return attackAnimationPoint / (1 + (attackSpeed - 100) / 100);
}
catch (KeyValuesNotFoundException)
{
if (!Utils.SleepCheck("Ensage.Common.DemoModeWarning"))
{
return 0;
}
Utils.Sleep(10000, "Ensage.Common.DemoModeWarning");
Console.WriteLine(@"[[Please do not use demo mode for testing assemblies]]");
return 0;
}
}