本文整理汇总了C#中OpenRA.Graphics.Sheet类的典型用法代码示例。如果您正苦于以下问题:C# Sheet类的具体用法?C# Sheet怎么用?C# Sheet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sheet类属于OpenRA.Graphics命名空间,在下文中一共展示了Sheet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(Manifest m, Dictionary<string, string> info)
{
loadInfo = info;
// Avoid standard loading mechanisms so we
// can display loadscreen as early as possible
r = Game.Renderer;
if (r == null) return;
sheet = new Sheet(SheetType.BGRA, Platform.ResolvePath(loadInfo["Image"]));
var res = r.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height);
borderTop = new Sprite(sheet, new Rectangle(161, 128, 62, 33), TextureChannel.Alpha);
borderBottom = new Sprite(sheet, new Rectangle(161, 223, 62, 33), TextureChannel.Alpha);
borderLeft = new Sprite(sheet, new Rectangle(128, 161, 33, 62), TextureChannel.Alpha);
borderRight = new Sprite(sheet, new Rectangle(223, 161, 33, 62), TextureChannel.Alpha);
cornerTopLeft = new Sprite(sheet, new Rectangle(128, 128, 33, 33), TextureChannel.Alpha);
cornerTopRight = new Sprite(sheet, new Rectangle(223, 128, 33, 33), TextureChannel.Alpha);
cornerBottomLeft = new Sprite(sheet, new Rectangle(128, 223, 33, 33), TextureChannel.Alpha);
cornerBottomRight = new Sprite(sheet, new Rectangle(223, 223, 33, 33), TextureChannel.Alpha);
nodLogo = new Sprite(sheet, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
gdiLogo = new Sprite(sheet, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
evaLogo = new Sprite(sheet, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
nodPos = new float2(bounds.Width / 2 - 384, bounds.Height / 2 - 128);
gdiPos = new float2(bounds.Width / 2 + 128, bounds.Height / 2 - 128);
evaPos = new float2(bounds.Width - 43 - 128, 43);
brightBlock = new Sprite(sheet, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha);
dimBlock = new Sprite(sheet, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha);
versionText = m.Mod.Version;
}
示例2: Initialize
public override void Initialize(WidgetArgs args)
{
base.Initialize(args);
var width = world.Map.Bounds.Width;
var height = world.Map.Bounds.Height;
var size = Math.Max(width, height);
var rb = RenderBounds;
previewScale = Math.Min(rb.Width * 1f / width, rb.Height * 1f / height);
previewOrigin = new int2((int)(previewScale * (size - width) / 2), (int)(previewScale * (size - height) / 2));
mapRect = new Rectangle(previewOrigin.X, previewOrigin.Y, (int)(previewScale * width), (int)(previewScale * height));
// Only needs to be done once
using (var terrainBitmap = Minimap.TerrainBitmap(world.Map.Rules.TileSets[world.Map.Tileset], world.Map))
{
var r = new Rectangle(0, 0, width, height);
var s = new Size(terrainBitmap.Width, terrainBitmap.Height);
var terrainSheet = new Sheet(s, false);
terrainSheet.Texture.SetData(terrainBitmap);
terrainSprite = new Sprite(terrainSheet, r, TextureChannel.Alpha);
// Data is set in Tick()
customTerrainSprite = new Sprite(new Sheet(s, false), r, TextureChannel.Alpha);
actorSprite = new Sprite(new Sheet(s, false), r, TextureChannel.Alpha);
shroudSprite = new Sprite(new Sheet(s, false), r, TextureChannel.Alpha);
}
}
示例3: SheetBuilder
internal SheetBuilder(TextureChannel ch)
{
current = null;
rowHeight = 0;
channel = null;
initialChannel = ch;
}
示例4: DrawVertexBuffer
public void DrawVertexBuffer(IVertexBuffer<Vertex> buffer, int start, int length, PrimitiveType type, Sheet sheet)
{
shader.SetTexture("DiffuseTexture", sheet.Texture);
renderer.Device.SetBlendMode(BlendMode.Alpha);
shader.Render(() => renderer.DrawBatch(buffer, start, length, type));
renderer.Device.SetBlendMode(BlendMode.None);
}
示例5: GetImage
public static Sprite GetImage(Renderer renderer, string collection, string image)
{
// Cached sprite
if (cachedSprites.ContainsKey(collection) && cachedSprites[collection].ContainsKey(image))
return cachedSprites[collection][image];
MappedImage mi;
try { mi = collections[collection][image]; }
catch (KeyNotFoundException)
{
throw new InvalidOperationException(
"Collection `{0}` does not have an image `{1}`".F(collection, image));
}
// Cached sheet
Sheet sheet;
if (cachedSheets.ContainsKey(mi.Src))
sheet = cachedSheets[mi.Src];
else
{
sheet = new Sheet(renderer, mi.Src);
cachedSheets.Add(mi.Src, sheet);
}
// Cache the sprite
if (!cachedSprites.ContainsKey(collection))
cachedSprites.Add(collection, new Dictionary<string, Sprite>());
cachedSprites[collection].Add(image, mi.GetImage(renderer, sheet));
return cachedSprites[collection][image];
}
示例6: Init
public void Init(Manifest m, Dictionary<string, string> info)
{
var sheet = new Sheet("mods/modchooser/chrome.png");
var res = Game.Renderer.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height);
sprite = new Sprite(sheet, new Rectangle(0,0,1024,480), TextureChannel.Alpha);
}
示例7: TerrainSpriteLayer
public TerrainSpriteLayer(World world, WorldRenderer wr, Sheet sheet, BlendMode blendMode, PaletteReference palette, bool restrictToBounds)
{
worldRenderer = wr;
this.restrictToBounds = restrictToBounds;
Sheet = sheet;
BlendMode = blendMode;
paletteIndex = palette.TextureIndex;
map = world.Map;
rowStride = 4 * map.MapSize.X;
vertices = new Vertex[rowStride * map.MapSize.Y];
vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length);
emptySprite = new Sprite(sheet, Rectangle.Empty, TextureChannel.Alpha);
wr.PaletteInvalidated += () =>
{
paletteIndex = palette.TextureIndex;
// Everything in the layer uses the same palette,
// so we can fix the indices in one pass
for (var i = 0; i < vertices.Length; i++)
{
var v = vertices[i];
vertices[i] = new Vertex(v.X, v.Y, v.Z, v.U, v.V, paletteIndex, v.C);
}
for (var row = 0; row < map.MapSize.Y; row++)
dirtyRows.Add(row);
};
}
示例8: Init
public void Init(Manifest m, Dictionary<string, string> info)
{
var sheet = new Sheet(SheetType.BGRA, info["Image"]);
var res = Game.Renderer.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height);
sprite = new Sprite(sheet, new Rectangle(0, 0, 1024, 480), TextureChannel.Alpha);
}
示例9: SheetBuilder
public SheetBuilder(SheetType t, Func<Sheet> allocateSheet)
{
channel = TextureChannel.Red;
type = t;
current = allocateSheet();
this.allocateSheet = allocateSheet;
}
示例10: TerrainRenderer
public TerrainRenderer(World world, WorldRenderer wr)
{
this.world = world;
this.map = world.Map;
var tileSize = new Size( Game.CellSize, Game.CellSize );
var tileMapping = new Cache<TileReference<ushort,byte>, Sprite>(
x => Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize));
var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet;
int nv = 0;
var terrainPalette = wr.Palette("terrain").Index;
for( int j = map.Bounds.Top; j < map.Bounds.Bottom; j++ )
for( int i = map.Bounds.Left; i < map.Bounds.Right; i++ )
{
var tile = tileMapping[map.MapTiles.Value[i, j]];
// TODO: move GetPaletteIndex out of the inner loop.
Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size);
nv += 4;
if (tileMapping[map.MapTiles.Value[i, j]].sheet != terrainSheet)
throw new InvalidOperationException("Terrain sprites span multiple sheets");
}
vertexBuffer = Game.Renderer.Device.CreateVertexBuffer( vertices.Length );
vertexBuffer.SetData( vertices, nv );
}
示例11: SheetBuilder
public SheetBuilder(Renderer r, TextureChannel ch)
{
renderer = r;
current = null;
rowHeight = 0;
channel = null;
initialChannel = ch;
}
示例12: SetRenderStateForSprite
void SetRenderStateForSprite(Sprite s)
{
renderer.CurrentBatchRenderer = this;
if (s.BlendMode != currentBlend || s.Sheet != currentSheet || nv + 4 > renderer.TempBufferSize)
Flush();
currentBlend = s.BlendMode;
currentSheet = s.Sheet;
}
示例13: DrawSprite
public void DrawSprite(Sprite s, float2 location, string palette, float2 size)
{
if (s.sheet != currentSheet)
Flush();
currentSheet = s.sheet;
Util.FastCreateQuad(vertices, indices, location.ToInt2(), s, Game.world.WorldRenderer.GetPaletteIndex(palette), nv, ni, size);
nv += 4; ni += 6;
if (++sprites >= spritesPerBatch)
Flush();
}
示例14: Init
public void Init(ModData modData, Dictionary<string, string> info)
{
var res = Game.Renderer.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height);
using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
{
var sheet = new Sheet(SheetType.BGRA, stream);
sprite = new Sprite(sheet, new Rectangle(0, 0, 1024, 480), TextureChannel.Alpha);
}
}
示例15: Init
public void Init(Dictionary<string, string> info)
{
Info = info;
// Avoid standard loading mechanisms so we
// can display loadscreen as early as possible
r = Game.Renderer;
if (r == null) return;
var s = new Sheet("mods/d2k/uibits/loadscreen.png");
Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256);
LogoPos = new float2(Renderer.Resolution.Width/2 - 128, Renderer.Resolution.Height/2 - 128);
}