本文整理汇总了C#中OpenRA.Graphics.WorldRenderer.GetPaletteIndex方法的典型用法代码示例。如果您正苦于以下问题:C# WorldRenderer.GetPaletteIndex方法的具体用法?C# WorldRenderer.GetPaletteIndex怎么用?C# WorldRenderer.GetPaletteIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Graphics.WorldRenderer
的用法示例。
在下文中一共展示了WorldRenderer.GetPaletteIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawSprite
public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size)
{
DrawSprite(s, location, wr.GetPaletteIndex(palette), size);
}
示例2: DrawShroud
void DrawShroud( WorldRenderer wr, Rectangle clip, Sprite[,] s, string pal )
{
var shroudPalette = wr.GetPaletteIndex(pal);
for (var j = clip.Top; j < clip.Bottom; j++)
{
var starti = clip.Left;
var last = shadowBits[0x0f];
for (var i = clip.Left; i < clip.Right; i++)
{
if ((s[i, j] == shadowBits[0x0f] && last == shadowBits[0x0f])
|| (s[i, j] == shadowBits[0] && last == shadowBits[0]))
continue;
if (starti != i)
{
s[starti, j].DrawAt(
Game.CellSize * new float2(starti, j),
shroudPalette,
new float2(Game.CellSize * (i - starti), Game.CellSize));
starti = i + 1;
}
s[i, j].DrawAt(
Game.CellSize * new float2(i, j),
shroudPalette);
starti = i + 1;
last = s[i, j];
}
if (starti < clip.Right)
s[starti, j].DrawAt(
Game.CellSize * new float2(starti, j),
shroudPalette,
new float2(Game.CellSize * (clip.Right - starti), Game.CellSize));
}
}
示例3: RenderBeforeWorld
public void RenderBeforeWorld( WorldRenderer wr, World world )
{
var position = Game.viewport.ViewToWorld(Viewport.LastMousePos);
var topLeft = position - FootprintUtils.AdjustForBuildingSize( BuildingInfo );
var actorInfo = Rules.Info[Building];
foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
dec.Render(wr, world, actorInfo, Traits.Util.CenterOfCell(position)); /* hack hack */
var cells = new Dictionary<CPos, bool>();
// Linebuild for walls.
// Assumes a 1x1 footprint; weird things will happen for other footprints
if (Rules.Info[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
{
foreach (var r in Preview)
r.Sprite.DrawAt(topLeft.ToPPos().ToFloat2() + r.Pos,
wr.GetPaletteIndex(r.Palette),
r.Scale*r.Sprite.size);
var res = world.WorldActor.Trait<ResourceLayer>();
var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
foreach (var t in FootprintUtils.Tiles(Building, BuildingInfo, topLeft))
cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null );
}
foreach( var c in cells )
( c.Value ? buildOk : buildBlocked ).DrawAt(wr, c.Key.ToPPos().ToFloat2(), "terrain" );
}
示例4: DrawShroud
void DrawShroud( WorldRenderer wr, int minx, int miny, int maxx, int maxy, Sprite[,] s, string pal )
{
var shroudPalette = wr.GetPaletteIndex(pal);
for (var j = miny; j < maxy; j++)
{
var starti = minx;
for (var i = minx; i < maxx; i++)
{
if (s[i, j] == shadowBits[0x0f])
continue;
if (starti != i)
{
s[starti, j].DrawAt(
Game.CellSize * new float2(starti, j),
shroudPalette,
new float2(Game.CellSize * (i - starti), Game.CellSize));
starti = i + 1;
}
s[i, j].DrawAt(
Game.CellSize * new float2(i, j),
shroudPalette);
starti = i + 1;
}
if (starti < maxx)
s[starti, j].DrawAt(
Game.CellSize * new float2(starti, j),
shroudPalette,
new float2(Game.CellSize * (maxx - starti), Game.CellSize));
}
}
示例5: RenderBeforeWorld
public void RenderBeforeWorld( WorldRenderer wr, World world )
{
var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
var topLeft = position - FootprintUtils.AdjustForBuildingSize( BuildingInfo );
var cells = new Dictionary<int2, bool>();
// Linebuild for walls.
// Assumes a 1x1 footprint; weird things will happen for other footprints
if (Rules.Info[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
{
foreach (var r in Preview)
r.Sprite.DrawAt(Game.CellSize*topLeft + r.Pos,
wr.GetPaletteIndex(r.Palette ?? world.LocalPlayer.Palette),
r.Scale*r.Sprite.size);
var res = world.WorldActor.Trait<ResourceLayer>();
var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
foreach (var t in FootprintUtils.Tiles(Building, BuildingInfo, topLeft))
cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo.WaterBound) && res.GetResource(t) == null );
}
wr.uiOverlay.DrawGrid( wr, cells );
}
示例6: RenderBeforeWorld
public void RenderBeforeWorld(WorldRenderer wr, World world)
{
var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);
// Source tiles
foreach (var t in world.FindTilesInCircle(sourceLocation, range))
sourceTile.DrawAt( wr, t.ToPPos().ToFloat2(), "terrain" );
// Destination tiles
foreach (var t in world.FindTilesInCircle(xy, range))
sourceTile.DrawAt( wr, t.ToPPos().ToFloat2(), "terrain" );
// Unit previews
foreach (var unit in power.UnitsInRange(sourceLocation))
{
if (manager.self.Owner.Shroud.IsTargetable(unit)) {
var targetCell = unit.Location + (xy - sourceLocation);
foreach (var r in unit.Render())
r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(),
wr.GetPaletteIndex(r.Palette),
r.Scale*r.Sprite.size);
}
}
// 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;
tile.DrawAt( wr, targetCell.ToPPos().ToFloat2(), "terrain" );
}
}
}