本文整理汇总了C#中WVec.Rotate方法的典型用法代码示例。如果您正苦于以下问题:C# WVec.Rotate方法的具体用法?C# WVec.Rotate怎么用?C# WVec.Rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WVec
的用法示例。
在下文中一共展示了WVec.Rotate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawRangeCircle
public static void DrawRangeCircle(WorldRenderer wr, WPos centerPosition, WDist radius,
float width, Color color, float contrastWidth, Color contrastColor)
{
var wcr = Game.Renderer.WorldRgbaColorRenderer;
var offset = new WVec(radius.Length, 0, 0);
for (var i = 0; i < RangeCircleSegments; i++)
{
var a = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleStartRotations[i]));
var b = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleEndRotations[i]));
if (contrastWidth > 0)
wcr.DrawLine(a, b, contrastWidth / wr.Viewport.Zoom, contrastColor);
if (width > 0)
wcr.DrawLine(a, b, width / wr.Viewport.Zoom, color);
}
}
示例2: Tick
public void Tick(World world)
{
ticks++;
if (anim != null)
anim.Tick();
// Switch from freefall mode to homing mode
if (ticks == info.HomingActivationDelay + 1)
{
state = States.Homing;
speed = velocity.Length;
// Compute the vertical loop radius
loopRadius = LoopRadius(speed, info.VerticalRateOfTurn);
}
// Switch from homing mode to freefall mode
if (info.RangeLimit != 0 && ticks == info.RangeLimit + 1)
{
state = States.Freefall;
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)));
}
// Check if target position should be updated (actor visible & locked on)
var newTarPos = targetPosition;
if (args.GuidedTarget.IsValidFor(args.SourceActor) && lockOn)
newTarPos = args.GuidedTarget.CenterPosition
+ new WVec(WDist.Zero, WDist.Zero, info.AirburstAltitude);
// Compute target's predicted velocity vector (assuming uniform circular motion)
var fac1 = OpenRA.Traits.Util.GetFacing(tarVel, hFacing);
tarVel = newTarPos - targetPosition;
var fac2 = OpenRA.Traits.Util.GetFacing(tarVel, hFacing);
predVel = tarVel.Rotate(WRot.FromFacing(fac2 - fac1));
targetPosition = newTarPos;
// Compute current distance from target position
var tarDistVec = targetPosition + offset - pos;
var relTarDist = tarDistVec.Length;
var relTarHorDist = tarDistVec.HorizontalLength;
WVec move;
if (state == States.Freefall)
move = FreefallTick();
else
move = HomingTick(world, tarDistVec, relTarHorDist);
renderFacing = WAngle.ArcTan(move.Z - move.Y, move.X).Angle / 4 - 64;
// Move the missile
pos += move;
// Create the smoke trail effect
if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated))
{
world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.TrailImage, trailPalette, info.TrailSequence)));
ticksToNextSmoke = info.TrailInterval;
}
if (info.ContrailLength > 0)
contrail.Update(pos);
var cell = world.Map.CellContaining(pos);
// NOTE: High speeds might cause the missile to miss the target or fly through obstacles
// In that case, big moves should probably be decomposed into multiple smaller ones with hit checks
var height = world.Map.DistanceAboveTerrain(pos);
var shouldExplode = (height.Length < 0) // Hit the ground
|| (relTarDist < info.CloseEnough.Length) // Within range
|| (info.ExplodeWhenEmpty && info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel
|| (info.Blockable && BlocksProjectiles.AnyBlockingActorAt(world, pos)) // Hit a wall or other blocking obstacle
|| !world.Map.Contains(cell) // This also avoids an IndexOutOfRangeException in GetTerrainInfo below.
|| (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.Map.GetTerrainInfo(cell).Type != info.BoundToTerrainType) // Hit incompatible terrain
|| (height.Length < info.AirburstAltitude.Length && relTarHorDist < info.CloseEnough.Length); // Airburst
if (shouldExplode)
Explode(world);
}
示例3: Tick
public void Tick(World world)
{
ticks++;
if (anim != null)
anim.Tick();
// Switch from freefall mode to homing mode
if (ticks == info.HomingActivationDelay + 1)
{
state = States.Homing;
speed = velocity.Length;
// Compute the vertical loop radius
loopRadius = LoopRadius(speed, info.VerticalRateOfTurn);
}
// Switch from homing mode to freefall mode
if (info.RangeLimit != 0 && ticks == info.RangeLimit + 1)
{
state = States.Freefall;
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)));
}
// Check if target position should be updated (actor visible & locked on)
var newTarPos = targetPosition;
if (args.GuidedTarget.IsValidFor(args.SourceActor) && lockOn)
newTarPos = args.GuidedTarget.CenterPosition
+ new WVec(WDist.Zero, WDist.Zero, info.AirburstAltitude);
// Compute target's predicted velocity vector (assuming uniform circular motion)
var yaw1 = tarVel.HorizontalLengthSquared != 0 ? tarVel.Yaw : WAngle.FromFacing(hFacing);
tarVel = newTarPos - targetPosition;
var yaw2 = tarVel.HorizontalLengthSquared != 0 ? tarVel.Yaw : WAngle.FromFacing(hFacing);
predVel = tarVel.Rotate(WRot.FromYaw(yaw2 - yaw1));
targetPosition = newTarPos;
// Compute current distance from target position
var tarDistVec = targetPosition + offset - pos;
var relTarDist = tarDistVec.Length;
var relTarHorDist = tarDistVec.HorizontalLength;
WVec move;
if (state == States.Freefall)
move = FreefallTick();
else
move = HomingTick(world, tarDistVec, relTarHorDist);
renderFacing = new WVec(move.X, move.Y - move.Z, 0).Yaw.Facing;
// Move the missile
var lastPos = pos;
pos += move;
// Check for walls or other blocking obstacles
var shouldExplode = false;
WPos blockedPos;
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, lastPos, pos, info.Width,
info.TargetExtraSearchRadius, out blockedPos))
{
pos = blockedPos;
shouldExplode = true;
}
// Create the smoke trail effect
if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated))
{
world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, renderFacing, info.TrailImage, trailPalette, info.TrailSequence)));
ticksToNextSmoke = info.TrailInterval;
}
if (info.ContrailLength > 0)
contrail.Update(pos);
var cell = world.Map.CellContaining(pos);
var height = world.Map.DistanceAboveTerrain(pos);
shouldExplode |= height.Length < 0 // Hit the ground
|| relTarDist < info.CloseEnough.Length // Within range
|| (info.ExplodeWhenEmpty && info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel
|| !world.Map.Contains(cell) // This also avoids an IndexOutOfRangeException in GetTerrainInfo below.
|| (!string.IsNullOrEmpty(info.BoundToTerrainType) && world.Map.GetTerrainInfo(cell).Type != info.BoundToTerrainType) // Hit incompatible terrain
|| (height.Length < info.AirburstAltitude.Length && relTarHorDist < info.CloseEnough.Length); // Airburst
if (shouldExplode)
Explode(world);
}
示例4: DrawRangeCircle
public void DrawRangeCircle(WPos pos, WRange range, Color c)
{
var offset = new WVec(range.Range, 0, 0);
for (var i = 0; i < 32; i++)
{
var pa = pos + offset.Rotate(WRot.FromFacing(8 * i));
var pb = pos + offset.Rotate(WRot.FromFacing(8 * i + 6));
Game.Renderer.WorldLineRenderer.DrawLine(ScreenPosition(pa), ScreenPosition(pb), c, c);
}
}
示例5: DrawRangeCircle
public void DrawRangeCircle(WPos pos, WDist range, Color c)
{
var offset = new WVec(range.Length, 0, 0);
for (var i = 0; i < RangeCircleSegments; i++)
{
var pa = pos + offset.Rotate(RangeCircleStartRotations[i]);
var pb = pos + offset.Rotate(RangeCircleEndRotations[i]);
Game.Renderer.WorldLineRenderer.DrawLine(ScreenPosition(pa), ScreenPosition(pb), c);
}
}