本文整理汇总了C#中RenderTarget.ConvertCoords方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget.ConvertCoords方法的具体用法?C# RenderTarget.ConvertCoords怎么用?C# RenderTarget.ConvertCoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderTarget
的用法示例。
在下文中一共展示了RenderTarget.ConvertCoords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBufferToTarget
/// <summary>
/// Gets the buffer then draws it to a <see cref="RenderTarget"/>.
/// </summary>
/// <param name="target">The <see cref="RenderTarget"/> to draw to.</param>
/// <param name="camera">The <see cref="ICamera2D"/> to use when drawing.</param>
/// <returns>True if the buffer was successfully drawn to the <paramref name="target"/>; otherwise false.</returns>
protected bool DrawBufferToTarget(RenderTarget target, ICamera2D camera)
{
// Get the buffer
var bufferImage = GetBuffer(camera);
if (bufferImage == null)
return false;
// Set up the sprite
_drawToTargetSprite.Image = bufferImage;
_drawToTargetSprite.Width = bufferImage.Width;
_drawToTargetSprite.Height = bufferImage.Height;
_drawToTargetSprite.Position = target.ConvertCoords(0, 0).Round();
_drawToTargetSprite.SubRect = new IntRect(0, 0, (int)bufferImage.Width, (int)bufferImage.Height);
PrepareDrawToTargetSprite(_drawToTargetSprite, target);
// Draw to the target
HandleDrawBufferToTarget(bufferImage, _drawToTargetSprite, target, camera);
return true;
}
示例2: Draw
public void Draw(RenderTarget rt, int layer)
{
Vector2f origin = rt.ConvertCoords(0, 0);
Shape fog = Shape.Rectangle(new FloatRect(origin.X, origin.Y, rt.DefaultView.Size.X, rt.DefaultView.Size.Y), new Color(100, 149, 237, 150));
int layerIndex = 0;
foreach (List<Cube> cubeList in cubeLists) {
if (layerIndex > layer)
break;
foreach (Cube c in cubeList)
c.Draw(rt);
foreach (Player p in playerList)
if (p.Layer == layerIndex)
p.Draw(rt);
if (layerIndex < layer)
rt.Draw(fog);
layerIndex++;
}
}
示例3: Render
public override void Render(RenderTarget target)
{
//Setting view to camera position
View view = target.GetView();
view.Center = new Vector2f((int) CameraPosition.X, (int) CameraPosition.Y);
target.SetView(view);
var screenBounds = new FloatRect
{
Left = view.Center.X - (view.Size.X / 2),
Top = view.Center.Y - (view.Size.Y / 2),
Width = view.Size.X,
Height = view.Size.Y
};
//Drawing map/tiles
map.Render(target, screenBounds, Fog);
RenderRallypoints(target);
//Draw selected unit circles
const float selectCircleRadius = 20;
var selectedCircle = new CircleShape(selectCircleRadius);
selectedCircle.OutlineColor = new Color(100, 255, 100, 200);
selectedCircle.OutlineThickness = 5;
selectedCircle.FillColor = new Color(0, 0, 0, 0);
selectedCircle.Origin = new Vector2f(selectCircleRadius, selectCircleRadius);
if (selectedUnits != null)
{
foreach (EntityBase entityBase in selectedUnits)
{
selectedCircle.Position = entityBase.Position;
target.Draw(selectedCircle);
}
}
var debugHPText = new Text();
debugHPText.Scale = new Vector2f(.6f, .6f);
debugHPText.Color = new Color(255, 255, 255, 100);
var readOnly = new Dictionary<ushort, EntityBase>(entities);
foreach (EntityBase entityBase in readOnly.Values)
{
if (entityBase.GetBounds().Intersects(screenBounds))
{
if (Fog != null)
{
var coords = map.ConvertCoords(entityBase.Position);
entityBase.Render(target, Fog.Grid[(int) coords.X, (int) coords.Y].CurrentState);
if (Fog.Grid[(int)coords.X, (int)coords.Y].CurrentState == FOWTile.TileStates.CurrentlyViewed)
{
entityBase.HasBeenViewed = true;
}
debugHPText.Color = new Color(255, 255, 255, 200);
debugHPText.DisplayedString = "HP: " + entityBase.Health.ToString();
debugHPText.Origin = new Vector2f(debugHPText.GetGlobalBounds().Width/2,
debugHPText.GetGlobalBounds().Height);
debugHPText.Position = entityBase.Position;
target.Draw(debugHPText);
if (entityBase is BuildingBase)
{
var buildingCast = (BuildingBase) entityBase;
if (buildingCast.IsProductingUnit)
{
debugHPText.Color = new Color(255, 255, 0, 100);
debugHPText.DisplayedString = buildingCast.UnitBuildCompletePercent.ToString();
debugHPText.Position += new Vector2f(0, 50);
target.Draw(debugHPText);
}
}
}
}
}
var readOnlyEffect = new List<EffectBase>(Effects);
foreach (EffectBase effectBase in readOnlyEffect)
{
effectBase.Render(target);
}
if (releaseSelect)
{
var rect = new FloatRect(controlBoxP1.X, controlBoxP1.Y, controlBoxP2.X - controlBoxP1.X,
controlBoxP2.Y - controlBoxP1.Y);
var rectangle = new RectangleShape(new Vector2f(rect.Width, rect.Height));
rectangle.Position = new Vector2f(rect.Left, rect.Top);
rectangle.FillColor = new Color(100, 200, 100, 100);
target.Draw(rectangle);
}
//Draw Alerts
const int ALERTXOFFSET = 10;
const int ALERTYMULTIPLE = 60;
const int ALERTYOFFSET = 20;
for (int i = 0; i < alerts.Count; i++)
{
HUDAlert alert = alerts[i];
//.........这里部分代码省略.........
示例4: Render
public override void Render(RenderTarget target)
{
var renderName = new Text(PlayerName);
renderName.Position = target.ConvertCoords(new Vector2i(10, 10));
renderName.Scale = new Vector2f(.6f, .6f);
target.Draw(renderName);
var gameName = new Text("MY LITTLE GLUE FACTORY");
gameName.Scale = new Vector2f(1, 1);
gameName.Origin = new Vector2f(gameName.GetGlobalBounds().Width/2, gameName.GetGlobalBounds().Height/2);
gameName.Position = target.ConvertCoords(new Vector2i((int) target.Size.X/2, 10));
target.Draw(gameName);
for(var i = 0; i < options.Count; i++)
{
if(selectedOption == i)
{
target.Draw(options[i][1]);
}
else
{
target.Draw(options[i][0]);
}
}
}