本文整理汇总了C#中OpenRA.Graphics.WorldRenderer类的典型用法代码示例。如果您正苦于以下问题:C# WorldRenderer类的具体用法?C# WorldRenderer怎么用?C# WorldRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorldRenderer类属于OpenRA.Graphics命名空间,在下文中一共展示了WorldRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObserverProductionIconsWidget
public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer)
: base()
{
this.world = world;
this.worldRenderer = worldRenderer;
clocks = new Dictionary<ProductionQueue, Animation>();
}
示例2: RenderAfterWorld
public void RenderAfterWorld(WorldRenderer wr, Actor self)
{
Color trailStart = TrailColor;
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
trailStart.G, trailStart.B);
// LocalPlayer is null on shellmap
ShroudRenderer shroud = null;
if (self.World.LocalPlayer != null)
shroud = self.World.LocalPlayer.Shroud;
for (int i = positions.Count - 1; i >= 1; --i)
{
var conPos = positions[i];
var nextPos = positions[i - 1];
if (shroud == null ||
shroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) ||
shroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos)))
{
Game.Renderer.LineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd);
trailStart = trailEnd;
trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R,
trailStart.G, trailStart.B);
}
}
}
示例3: DrawInner
public override void DrawInner( WorldRenderer wr )
{
if (video == null)
return;
if (!(stopped || paused))
{
var nextFrame = (int)float2.Lerp(0, video.Frames, Sound.VideoSeekPosition*invLength);
if (nextFrame > video.Frames)
{
Stop();
return;
}
while (nextFrame > video.CurrentFrame)
{
video.AdvanceFrame();
if (nextFrame == video.CurrentFrame)
videoSprite.sheet.Texture.SetData(video.FrameData);
}
}
Game.Renderer.RgbaSpriteRenderer.DrawSprite(videoSprite, videoOrigin, videoSize);
if (DrawOverlay)
Game.Renderer.RgbaSpriteRenderer.DrawSprite(overlaySprite, videoOrigin, videoSize);
}
示例4: Draw
public void Draw( WorldRenderer wr, Viewport viewport )
{
int verticesPerRow = map.Bounds.Width * 4;
int visibleRows = (int)(viewport.Height * 1f / Game.CellSize / viewport.Zoom + 2);
int firstRow = (int)(viewport.Location.Y * 1f / Game.CellSize - map.Bounds.Top);
int lastRow = firstRow + visibleRows;
if (lastRow < 0 || firstRow > map.Bounds.Height)
return;
if (firstRow < 0) firstRow = 0;
if (lastRow > map.Bounds.Height) lastRow = map.Bounds.Height;
if (world.RenderedPlayer != null && !world.RenderedShroud.Disabled && world.RenderedShroud.Bounds.HasValue)
{
var r = world.RenderedShroud.Bounds.Value;
if (firstRow < r.Top - map.Bounds.Top)
firstRow = r.Top - map.Bounds.Top;
if (firstRow > r.Bottom - map.Bounds.Top)
firstRow = r.Bottom - map.Bounds.Top;
}
if( lastRow < firstRow ) lastRow = firstRow;
Game.Renderer.WorldSpriteRenderer.DrawVertexBuffer(
vertexBuffer, verticesPerRow * firstRow, verticesPerRow * (lastRow - firstRow),
PrimitiveType.QuadList, terrainSheet);
foreach (var r in world.WorldActor.TraitsImplementing<IRenderOverlay>())
r.Render( wr );
}
示例5: Render
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (!a.IsInWorld || a.World.FogObscures(a.Location))
return SpriteRenderable.None;
return anim.Render(a.CenterPosition, wr.Palette(palette));
}
示例6: ObserverSupportPowerIconsWidget
public ObserverSupportPowerIconsWidget(World world, WorldRenderer worldRenderer)
{
this.world = world;
this.worldRenderer = worldRenderer;
clocks = new Dictionary<string, Animation>();
icon = new Animation(world, "icon");
}
示例7: InitPalette
public void InitPalette( WorldRenderer wr )
{
var info = Rules.Info["player"].Traits.WithInterface<PlayerColorPaletteInfo>()
.First(p => p.BaseName == Info.PlayerPalette);
format = info.PaletteFormat;
wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette));
}
示例8: Render
public void Render(WorldRenderer wr)
{
// Need at least 4 points to smooth the contrail over
if (length - skip < 4)
return;
var wlr = Game.Renderer.WorldLineRenderer;
var oldWidth = wlr.LineWidth;
wlr.LineWidth = wr.Viewport.Zoom;
// Start of the first line segment is the tail of the list - don't smooth it.
var curPos = trail[Index(next - skip - 1)];
var curColor = color;
for (var i = 0; i < length - skip - 4; i++)
{
var j = next - skip - i - 2;
var nextPos = Average(trail[Index(j)], trail[Index(j - 1)], trail[Index(j - 2)], trail[Index(j - 3)]);
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
if (!world.FogObscures(curPos) && !world.FogObscures(nextPos))
wlr.DrawLine(wr.ScreenPosition(curPos), wr.ScreenPosition(nextPos), curColor, nextColor);
curPos = nextPos;
curColor = nextColor;
}
wlr.LineWidth = oldWidth;
}
示例9: IngameMenuLogic
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
{
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
{
onExit();
LeaveGame(world);
};
widget.Get<ButtonWidget>("SETTINGS").OnClick = () =>
{
widget.Visible = false;
Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs()
{
{ "onExit", () => widget.Visible = true },
{ "worldRenderer", worldRenderer },
});
};
widget.Get<ButtonWidget>("MUSIC").OnClick = () =>
{
widget.Visible = false;
Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", () => { widget.Visible = true; } } });
};
widget.Get<ButtonWidget>("RESUME").OnClick = () => onExit();
widget.Get<ButtonWidget>("SURRENDER").OnClick = () =>
{
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
onExit();
};
widget.Get("SURRENDER").IsVisible = () => world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
}
示例10: RenderAfterWorld
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
{
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
yield break;
var jamsMissiles = self.Info.TraitInfoOrDefault<JamsMissilesInfo>();
if (jamsMissiles != null)
{
yield return new RangeCircleRenderable(
self.CenterPosition,
jamsMissiles.Range,
0,
Color.FromArgb(128, Color.Red),
Color.FromArgb(96, Color.Black));
}
var jamsRadar = self.Info.TraitInfoOrDefault<JamsRadarInfo>();
if (jamsRadar != null)
{
yield return new RangeCircleRenderable(
self.CenterPosition,
jamsRadar.Range,
0,
Color.FromArgb(128, Color.Blue),
Color.FromArgb(96, Color.Black));
}
}
示例11: Render
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
{
var jamsMissiles = ai.TraitInfoOrDefault<JamsMissilesInfo>();
if (jamsMissiles != null)
{
yield return new RangeCircleRenderable(
centerPosition,
jamsMissiles.Range,
0,
Color.FromArgb(128, Color.Red),
Color.FromArgb(96, Color.Black));
}
var jamsRadar = ai.TraitInfoOrDefault<JamsRadarInfo>();
if (jamsRadar != null)
{
yield return new RangeCircleRenderable(
centerPosition,
jamsRadar.Range,
0,
Color.FromArgb(128, Color.Blue),
Color.FromArgb(96, Color.Black));
}
foreach (var a in w.ActorsWithTrait<RenderJammerCircle>())
if (a.Actor.Owner.IsAlliedWith(w.RenderPlayer))
foreach (var r in a.Trait.RenderAfterWorld(wr))
yield return r;
}
示例12: DoControlGroup
public void DoControlGroup(World world, WorldRenderer worldRenderer, int group, Modifiers mods, int MultiTapCount)
{
var addModifier = Platform.CurrentPlatform == PlatformType.OSX ? Modifiers.Meta : Modifiers.Ctrl;
if (mods.HasModifier(addModifier))
{
if (actors.Count == 0)
return;
if (!mods.HasModifier(Modifiers.Shift))
controlGroups[group].Clear();
for (var i = 0; i < 10; i++) /* all control groups */
controlGroups[i].RemoveAll(a => actors.Contains(a));
controlGroups[group].AddRange(actors.Where(a => a.Owner == world.LocalPlayer));
return;
}
var groupActors = controlGroups[group].Where(a => !a.IsDead() && !world.FogObscures(a));
if (mods.HasModifier(Modifiers.Alt) || MultiTapCount >= 2)
{
worldRenderer.Viewport.Center(groupActors);
return;
}
Combine(world, groupActors, mods.HasModifier(Modifiers.Shift), false);
}
示例13: TileSelectorLogic
public TileSelectorLogic(Widget widget, WorldRenderer worldRenderer, Ruleset modRules)
{
var tileset = modRules.TileSets[worldRenderer.World.Map.Tileset];
editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
panel = widget.Get<ScrollPanelWidget>("TILETEMPLATE_LIST");
itemTemplate = panel.Get<ScrollItemWidget>("TILEPREVIEW_TEMPLATE");
panel.Layout = new GridLayout(panel);
var tileCategorySelector = widget.Get<DropDownButtonWidget>("TILE_CATEGORY");
var categories = tileset.EditorTemplateOrder;
Func<string, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
{
var item = ScrollItemWidget.Setup(template,
() => tileCategorySelector.Text == option,
() => { tileCategorySelector.Text = option; IntializeTilePreview(widget, worldRenderer, tileset, option); });
item.Get<LabelWidget>("LABEL").GetText = () => option;
return item;
};
tileCategorySelector.OnClick = () =>
tileCategorySelector.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, categories, setupItem);
tileCategorySelector.Text = categories.First();
IntializeTilePreview(widget, worldRenderer, tileset, categories.First());
}
示例14: MapEditorTabsLogic
public MapEditorTabsLogic(Widget widget, WorldRenderer worldRenderer)
{
var tabContainer = widget.Get("MAP_EDITOR_TAB_CONTAINER");
var tilesTab = tabContainer.Get<ButtonWidget>("TILES_TAB");
tilesTab.IsHighlighted = () => menuType == MenuType.Tiles;
tilesTab.OnClick = () => { menuType = MenuType.Tiles; };
var overlaysTab = tabContainer.Get<ButtonWidget>("OVERLAYS_TAB");
overlaysTab.IsHighlighted = () => menuType == MenuType.Layers;
overlaysTab.OnClick = () => { menuType = MenuType.Layers; };
var actorsTab = tabContainer.Get<ButtonWidget>("ACTORS_TAB");
actorsTab.IsHighlighted = () => menuType == MenuType.Actors;
actorsTab.OnClick = () => { menuType = MenuType.Actors; };
var tileContainer = widget.Parent.Get<ContainerWidget>("TILE_WIDGETS");
tileContainer.IsVisible = () => menuType == MenuType.Tiles;
var layerContainer = widget.Parent.Get<ContainerWidget>("LAYER_WIDGETS");
layerContainer.IsVisible = () => menuType == MenuType.Layers;
var actorContainer = widget.Parent.Get<ContainerWidget>("ACTOR_WIDGETS");
actorContainer.IsVisible = () => menuType == MenuType.Actors;
}
示例15: ObserverProductionIconsWidget
public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer)
{
this.world = world;
this.worldRenderer = worldRenderer;
clocks = new Dictionary<ProductionQueue, Animation>();
timestep = world.IsReplay ? world.WorldActor.Trait<MapOptions>().GameSpeed.Timestep : world.Timestep;
}