本文整理汇总了C#中OpenRA.Graphics.WorldRenderer.Position方法的典型用法代码示例。如果您正苦于以下问题:C# WorldRenderer.Position方法的具体用法?C# WorldRenderer.Position怎么用?C# WorldRenderer.Position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Graphics.WorldRenderer
的用法示例。
在下文中一共展示了WorldRenderer.Position方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
{
var pos = wr.ScreenPxPosition(self.CenterPosition);
var bounds = self.Bounds.Value;
bounds.Offset(pos.X, pos.Y);
var spaceBuffer = (int)(10 / wr.Viewport.Zoom);
var effectPos = wr.Position(new int2(pos.X, bounds.Y - spaceBuffer));
yield return new TextRenderable(font, effectPos, 0, color, name);
}
示例2: RenderAfterWorld
public void RenderAfterWorld(WorldRenderer wr, World world)
{
var position = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var topLeft = position - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
var rules = world.Map.Rules;
var actorInfo = rules.Actors[Building];
foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
dec.Render(wr, world, actorInfo, position.CenterPosition); /* hack hack */
var cells = new Dictionary<CPos, bool>();
// Linebuild for walls.
// Assumes a 1x1 footprint; weird things will happen for other footprints
if (rules.Actors[Building].Traits.Contains<LineBuildInfo>())
{
foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, Building, BuildingInfo))
cells.Add(t, BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, t));
}
else
{
if (!initialized)
{
var rbi = rules.Actors[Building].Traits.GetOrDefault<RenderBuildingInfo>();
if (rbi == null)
preview = new IRenderable[0];
else
{
var palette = rbi.Palette ?? (Producer.Owner != null ?
rbi.PlayerPalette + Producer.Owner.InternalName : null);
preview = rbi.RenderPreview(world, rules.Actors[Building], wr.Palette(palette));
}
initialized = true;
}
var offset = topLeft.CenterPosition + FootprintUtils.CenterOffset(BuildingInfo) - WPos.Zero;
foreach (var r in preview)
r.OffsetBy(offset).Render(wr);
var res = world.WorldActor.Trait<ResourceLayer>();
var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
foreach (var t in FootprintUtils.Tiles(rules, Building, BuildingInfo, topLeft))
cells.Add(t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null);
}
var pal = wr.Palette("terrain");
foreach (var c in cells)
{
var tile = c.Value ? buildOk : buildBlocked;
new SpriteRenderable(tile, c.Key.CenterPosition,
WVec.Zero, -511, pal, 1f, true).Render(wr);
}
}
示例3: Render
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (!self.IsInWorld)
yield break;
if (self.IsDead())
yield break;
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
yield break;
if (wr.world.FogObscures(self))
yield break;
var pos = wr.ScreenPxPosition(self.CenterPosition);
var bounds = self.Bounds.Value;
bounds.Offset(pos.X, pos.Y);
var offset = (int)(4 / wr.Viewport.Zoom);
var effectPos = wr.Position(new int2(bounds.Right - offset, bounds.Bottom - offset));
yield return new SpriteRenderable(anim.Image, effectPos, WVec.Zero, 0, wr.Palette("effect"), 1f / wr.Viewport.Zoom, true);
}
示例4: DrawZap
static IEnumerable<IRenderable> DrawZap(WorldRenderer wr, float2 from, float2 to, Sequence s, out float2 p, string palette)
{
var dist = to - from;
var q = new float2(-dist.Y, dist.X);
var c = -float2.Dot(from, q);
var rs = new List<IRenderable>();
var z = from;
var pal = wr.Palette(palette);
while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
{
var step = steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared)
.OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First();
var pos = wr.Position((z + new float2(step[2], step[3])).ToInt2());
rs.Add(new SpriteRenderable(s.GetSprite(step[4]), pos, WVec.Zero, 0, pal, 1f, true));
z += new float2(step[0], step[1]);
if (rs.Count >= 1000)
break;
}
p = z;
return rs;
}
示例5: RenderAfterWorld
public void RenderAfterWorld(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
foreach (var unit in power.UnitsInRange(xy))
wr.DrawSelectionBox(unit, Color.Red);
}
示例6: Render
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var pal = wr.Palette("terrain");
foreach (var t in world.FindTilesInCircle(xy, range))
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
}
示例7: RenderAfterWorld
public void RenderAfterWorld(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var targetUnits = power.UnitsInRange(xy);
foreach (var unit in targetUnits)
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility())
wr.DrawSelectionBox(unit, Color.Red);
}
示例8: Render
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var pal = wr.Palette("terrain");
// Source tiles
foreach (var t in world.FindTilesInCircle(sourceLocation, range))
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
// Destination tiles
foreach (var t in world.FindTilesInCircle(xy, range))
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
// Unit previews
foreach (var unit in power.UnitsInRange(sourceLocation))
{
var offset = (xy - sourceLocation).ToWVec();
if (manager.self.Owner.Shroud.IsTargetable(unit))
foreach (var r in unit.Render(wr))
yield return r.OffsetBy(offset);
}
// Unit tiles
foreach (var unit in power.UnitsInRange(sourceLocation))
{
if (manager.self.Owner.Shroud.IsTargetable(unit))
{
var targetCell = unit.Location + (xy - sourceLocation);
var canEnter = ((manager.self.Owner.Shroud.IsExplored(targetCell) || manager.self.Owner.HasFogVisibility()) &&
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell));
var tile = canEnter ? validTile : invalidTile;
yield return new SpriteRenderable(tile, targetCell.CenterPosition, WVec.Zero, -511, pal, 1f, true);
}
}
}