本文整理汇总了C#中WDist类的典型用法代码示例。如果您正苦于以下问题:C# WDist类的具体用法?C# WDist怎么用?C# WDist使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WDist类属于命名空间,在下文中一共展示了WDist类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindUnitPathToRange
public List<CPos> FindUnitPathToRange(CPos source, SubCell srcSub, WPos target, WDist range, Actor self)
{
var mi = self.Info.TraitInfo<MobileInfo>();
var targetCell = world.Map.CellContaining(target);
// Correct for SubCell offset
target -= world.Map.OffsetOfSubCell(srcSub);
// Select only the tiles that are within range from the requested SubCell
// This assumes that the SubCell does not change during the path traversal
var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Length / 1024 + 1)
.Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= range.LengthSquared
&& mi.CanEnterCell(self.World, self, t));
// See if there is any cell within range that does not involve a cross-domain request
// Really, we only need to check the circle perimeter, but it's not clear that would be a performance win
var domainIndex = world.WorldActor.TraitOrDefault<DomainIndex>();
if (domainIndex != null)
{
var passable = mi.GetMovementClass(world.TileSet);
tilesInRange = new List<CPos>(tilesInRange.Where(t => domainIndex.IsPassable(source, t, (uint)passable)));
if (!tilesInRange.Any())
return EmptyPath;
}
using (var fromSrc = PathSearch.FromPoints(world, mi, self, tilesInRange, source, true))
using (var fromDest = PathSearch.FromPoint(world, mi, self, source, targetCell, true).Reverse())
return FindBidiPath(fromSrc, fromDest);
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:29,代码来源:PathFinder.cs
示例2: Repair
public Repair(Actor self, Actor host, WDist closeEnough)
{
this.host = Target.FromActor(host);
this.closeEnough = closeEnough;
repairsUnits = host.Info.TraitInfo<RepairsUnitsInfo>();
health = self.TraitOrDefault<Health>();
}
开发者ID:pchote,项目名称:OpenRA,代码行数:7,代码来源:Repair.cs
示例3: NukeLaunch
public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence,
WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
{
this.firedBy = firedBy;
this.weapon = weapon;
this.weaponPalette = weaponPalette;
this.downSequence = downSequence;
this.delay = delay;
turn = delay / 2;
this.flashType = flashType;
var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
ascendSource = launchPos;
ascendTarget = launchPos + offset;
descendSource = targetPos + offset;
descendTarget = targetPos;
anim = new Animation(firedBy.World, name);
anim.PlayRepeating(upSequence);
pos = launchPos;
if (weapon.Report != null && weapon.Report.Any())
Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), pos);
if (skipAscent)
ticks = turn;
}
开发者ID:OpenRA,项目名称:OpenRA,代码行数:27,代码来源:NukeLaunch.cs
示例4: FlyFollow
public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange)
{
this.target = target;
plane = self.Trait<Aircraft>();
this.minRange = minRange;
this.maxRange = maxRange;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:FlyFollow.cs
示例5: AreaBeam
public AreaBeam(AreaBeamInfo info, ProjectileArgs args, Color color)
{
this.info = info;
this.args = args;
this.color = color;
actorAttackBase = args.SourceActor.Trait<AttackBase>();
var world = args.SourceActor.World;
if (info.Speed.Length > 1)
speed = new WDist(world.SharedRandom.Next(info.Speed[0].Length, info.Speed[1].Length));
else
speed = info.Speed[0];
// Both the head and tail start at the source actor, but initially only the head is travelling.
headPos = args.Source;
tailPos = headPos;
target = args.PassiveTarget;
if (info.Inaccuracy.Length > 0)
{
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
var maxOffset = inaccuracy * (target - headPos).Length / args.Weapon.Range.Length;
target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
}
towardsTargetFacing = (target - headPos).Yaw.Facing;
// Update the target position with the range we shoot beyond the target by
// I.e. we can deliberately overshoot, so aim for that position
var dir = new WVec(0, -1024, 0).Rotate(WRot.FromFacing(towardsTargetFacing));
target += dir * info.BeyondTargetRange.Length / 1024;
length = Math.Max((target - headPos).Length / speed.Length, 1);
}
开发者ID:pchote,项目名称:OpenRA,代码行数:34,代码来源:AreaBeam.cs
示例6: FindActorsOnLine
/// <summary>
/// Finds all the actors of which their health radius is intersected by a line (with a definable width) between two points.
/// </summary>
/// <param name="world">The engine world the line intersection is to be done in.</param>
/// <param name="lineStart">The position the line should start at</param>
/// <param name="lineEnd">The position the line should end at</param>
/// <param name="lineWidth">How close an actor's health radius needs to be to the line to be considered 'intersected' by the line</param>
/// <returns>A list of all the actors intersected by the line</returns>
public static IEnumerable<Actor> FindActorsOnLine(this World world, WPos lineStart, WPos lineEnd, WDist lineWidth, WDist targetExtraSearchRadius)
{
// This line intersection check is done by first just finding all actors within a square that starts at the source, and ends at the target.
// Then we iterate over this list, and find all actors for which their health radius is at least within lineWidth of the line.
// For actors without a health radius, we simply check their center point.
// The square in which we select all actors must be large enough to encompass the entire line's width.
var xDir = Math.Sign(lineEnd.X - lineStart.X);
var yDir = Math.Sign(lineEnd.Y - lineStart.Y);
var dir = new WVec(xDir, yDir, 0);
var overselect = dir * (1024 + lineWidth.Length + targetExtraSearchRadius.Length);
var finalTarget = lineEnd + overselect;
var finalSource = lineStart - overselect;
var actorsInSquare = world.ActorMap.ActorsInBox(finalTarget, finalSource);
var intersectedActors = new List<Actor>();
foreach (var currActor in actorsInSquare)
{
var actorWidth = 0;
var healthInfo = currActor.Info.TraitInfoOrDefault<HealthInfo>();
if (healthInfo != null)
actorWidth = healthInfo.Shape.OuterRadius.Length;
var projection = MinimumPointLineProjection(lineStart, lineEnd, currActor.CenterPosition);
var distance = (currActor.CenterPosition - projection).HorizontalLength;
var maxReach = actorWidth + lineWidth.Length;
if (distance <= maxReach)
intersectedActors.Add(currActor);
}
return intersectedActors;
}
开发者ID:pchote,项目名称:OpenRA,代码行数:42,代码来源:WorldExtensions.cs
示例7: GetImpactType
public static ImpactType GetImpactType(World world, CPos cell, WPos pos)
{
// Missiles need a margin because they sometimes explode a little above ground
// due to their explosion check triggering slightly too early (because of CloseEnough).
// TODO: Base ImpactType on target altitude instead of explosion altitude.
var airMargin = new WDist(128);
var dat = world.Map.DistanceAboveTerrain(pos);
var isAir = dat.Length > airMargin.Length;
var isWater = dat.Length <= 0 && world.Map.GetTerrainInfo(cell).IsWater;
var isDirectHit = GetDirectHit(world, cell, pos);
if (isAir && !isDirectHit)
return ImpactType.Air;
else if (isWater && !isDirectHit)
return ImpactType.Water;
else if (isAir && isDirectHit)
return ImpactType.AirHit;
else if (isWater && isDirectHit)
return ImpactType.WaterHit;
else if (isDirectHit)
return ImpactType.GroundHit;
return ImpactType.Ground;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:25,代码来源:CreateEffectWarhead.cs
示例8: TryGetAlternateTargetInCircle
protected bool TryGetAlternateTargetInCircle(
Actor self, WDist radius, Action<Target> update, Func<Actor, bool> primaryFilter, Func<Actor, bool>[] preferenceFilters = null)
{
var diff = new WVec(radius, radius, WDist.Zero);
var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff)
.Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared })
.Where(p => p.Ls <= radius.LengthSquared).OrderBy(p => p.Ls).Select(p => p.Actor);
if (preferenceFilters != null)
foreach (var filter in preferenceFilters)
{
var preferredCandidate = candidates.FirstOrDefault(filter);
if (preferredCandidate == null)
continue;
target = Target.FromActor(preferredCandidate);
update(target);
return true;
}
var candidate = candidates.FirstOrDefault();
if (candidate == null)
return false;
target = Target.FromActor(candidate);
update(target);
return true;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:25,代码来源:Enter.cs
示例9: NukeLaunch
public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
{
this.firedBy = firedBy;
this.weapon = weapon;
this.delay = delay;
this.turn = delay / 2;
this.flashType = flashType;
var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
ascendSource = launchPos;
ascendTarget = launchPos + offset;
descendSource = targetPos + offset;
descendTarget = targetPos;
anim = new Animation(firedBy.World, weapon);
anim.PlayRepeating("up");
pos = launchPos;
var weaponRules = firedBy.World.Map.Rules.Weapons[weapon.ToLowerInvariant()];
if (weaponRules.Report != null && weaponRules.Report.Any())
Sound.Play(weaponRules.Report.Random(firedBy.World.SharedRandom), pos);
if (skipAscent)
ticks = turn;
}
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:25,代码来源:NukeLaunch.cs
示例10: RangeCircleRenderable
public RangeCircleRenderable(WPos centerPosition, WDist radius, int zOffset, Color color, Color contrastColor)
{
this.centerPosition = centerPosition;
this.radius = radius;
this.zOffset = zOffset;
this.color = color;
this.contrastColor = contrastColor;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:8,代码来源:RangeCircleRenderable.cs
示例11: Follow
public Follow(Actor self, Target target, WDist minRange, WDist maxRange)
{
this.target = target;
this.minRange = minRange;
this.maxRange = maxRange;
move = self.Trait<IMove>();
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:8,代码来源:Follow.cs
示例12: BeamRenderable
public BeamRenderable(WPos pos, int zOffset, WVec length, BeamRenderableShape shape, WDist width, Color color)
{
this.pos = pos;
this.zOffset = zOffset;
this.length = length;
this.shape = shape;
this.width = width;
this.color = color;
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:9,代码来源:BeamRenderable.cs
示例13: ContrailRenderable
ContrailRenderable(World world, WPos[] trail, WDist width, int next, int length, int skip, Color color, int zOffset)
{
this.world = world;
this.trail = trail;
this.width = width;
this.next = next;
this.length = length;
this.skip = skip;
this.color = color;
this.zOffset = zOffset;
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:11,代码来源:ContrailRenderable.cs
示例14: Attack
public Attack(Actor self, Target target, WDist minRange, WDist maxRange, bool allowMovement)
{
Target = target;
this.minRange = minRange;
this.maxRange = maxRange;
attack = self.Trait<AttackBase>();
facing = self.Trait<IFacing>();
positionable = self.Trait<IPositionable>();
move = allowMovement ? self.TraitOrDefault<IMove>() : null;
}
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:12,代码来源:Attack.cs
示例15: DetectionCircleRenderable
public DetectionCircleRenderable(WPos centerPosition, WDist radius, int zOffset,
int lineTrails, WAngle trailSeparation, WAngle trailAngle, Color color, Color contrastColor)
{
this.centerPosition = centerPosition;
this.radius = radius;
this.zOffset = zOffset;
trailCount = lineTrails;
this.trailSeparation = trailSeparation;
this.trailAngle = trailAngle;
this.color = color;
this.contrastColor = contrastColor;
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:12,代码来源:DetectionCircleRenderable.cs
示例16: AdjustAltitude
public static bool AdjustAltitude(Actor self, Helicopter helicopter, WDist targetAltitude)
{
var altitude = helicopter.CenterPosition.Z;
if (altitude == targetAltitude.Length)
return false;
var delta = helicopter.Info.AltitudeVelocity.Length;
var dz = (targetAltitude.Length - altitude).Clamp(-delta, delta);
helicopter.SetPosition(self, helicopter.CenterPosition + new WVec(0, 0, dz));
return true;
}
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:12,代码来源:HeliFly.cs
示例17: AdjustAltitude
public static bool AdjustAltitude(Actor self, Aircraft helicopter, WDist targetAltitude)
{
targetAltitude = new WDist(helicopter.CenterPosition.Z) + targetAltitude - self.World.Map.DistanceAboveTerrain(helicopter.CenterPosition);
var altitude = helicopter.CenterPosition.Z;
if (altitude == targetAltitude.Length)
return false;
var delta = helicopter.Info.AltitudeVelocity.Length;
var dz = (targetAltitude.Length - altitude).Clamp(-delta, delta);
helicopter.SetPosition(self, helicopter.CenterPosition + new WVec(0, 0, dz));
return true;
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:14,代码来源:HeliFly.cs
示例18: ProjectedCellsInRange
public static IEnumerable<PPos> ProjectedCellsInRange(Map map, WPos pos, WDist range)
{
// Account for potential extra half-cell from odd-height terrain
var r = (range.Length + 1023 + 512) / 1024;
var limit = range.LengthSquared;
// Project actor position into the shroud plane
var projectedPos = pos - new WVec(0, pos.Z, pos.Z);
var projectedCell = map.CellContaining(projectedPos);
foreach (var c in map.FindTilesInCircle(projectedCell, r, true))
if ((map.CenterOfCell(c) - projectedPos).HorizontalLengthSquared <= limit)
yield return (PPos)c.ToMPos(map);
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:14,代码来源:Shroud.cs
示例19: Missile
public Missile(MissileInfo info, ProjectileArgs args)
{
this.info = info;
this.args = args;
pos = args.Source;
hFacing = args.Facing;
gravity = new WVec(0, 0, -info.Gravity);
targetPosition = args.PassiveTarget;
rangeLimit = info.RangeLimit != WDist.Zero ? info.RangeLimit : args.Weapon.Range;
minLaunchSpeed = info.MinimumLaunchSpeed.Length > -1 ? info.MinimumLaunchSpeed.Length : info.Speed.Length;
maxLaunchSpeed = info.MaximumLaunchSpeed.Length > -1 ? info.MaximumLaunchSpeed.Length : info.Speed.Length;
maxSpeed = info.Speed.Length;
minLaunchAngle = info.MinimumLaunchAngle;
maxLaunchAngle = info.MaximumLaunchAngle;
var world = args.SourceActor.World;
if (info.Inaccuracy.Length > 0)
{
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024;
}
DetermineLaunchSpeedAndAngle(world, out speed, out vFacing);
velocity = new WVec(0, -speed, 0)
.Rotate(new WRot(WAngle.FromFacing(vFacing), WAngle.Zero, WAngle.Zero))
.Rotate(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(hFacing)));
if (world.SharedRandom.Next(100) <= info.LockOnProbability)
lockOn = true;
if (!string.IsNullOrEmpty(info.Image))
{
anim = new Animation(world, info.Image, () => renderFacing);
anim.PlayRepeating(info.Sequences.Random(world.SharedRandom));
}
if (info.ContrailLength > 0)
{
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset);
}
trailPalette = info.TrailPalette;
if (info.TrailUsePlayerPalette)
trailPalette += args.SourceActor.Owner.InternalName;
}
开发者ID:pchote,项目名称:OpenRA,代码行数:49,代码来源:Missile.cs
示例20: ActorsInCircle
public Actor[] ActorsInCircle(WPos location, WDist radius, LuaFunction filter = null)
{
var actors = Context.World.FindActorsInCircle(location, radius);
if (filter != null)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(Context)))
return f.First().ToBoolean();
});
}
return actors.ToArray();
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:15,代码来源:MapGlobal.cs
注:本文中的WDist类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论