本文整理汇总了C#中ISpriteBatch.DrawStringShaded方法的典型用法代码示例。如果您正苦于以下问题:C# ISpriteBatch.DrawStringShaded方法的具体用法?C# ISpriteBatch.DrawStringShaded怎么用?C# ISpriteBatch.DrawStringShaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISpriteBatch
的用法示例。
在下文中一共展示了ISpriteBatch.DrawStringShaded方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawSpawn
public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font)
{
var spawnArea = spawn.SpawnArea;
// Only draw if it does not cover the whole map
if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue)
return;
// Draw spawn area
Vector2 cameraOffset = map.Camera.Min;
Rectangle rect = spawnArea.ToRectangle(map);
rect.X -= (int)cameraOffset.X;
rect.Y -= (int)cameraOffset.Y;
RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2);
// Draw name
CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID];
if (charTemp != null)
{
string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID);
Vector2 textPos = new Vector2(rect.X, rect.Y);
textPos -= new Vector2(0, font.MeasureString(text).Y);
textPos = textPos.Round();
spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black);
}
}
示例2: DrawControl
/// <summary>
/// Draws the <see cref="Control"/>.
/// </summary>
/// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
protected override void DrawControl(ISpriteBatch spriteBatch)
{
base.DrawControl(spriteBatch);
// Draw the progress bar
float elapsedTime = TickCount.Now - _castStartTime;
var percent = elapsedTime / _currentCastTime;
var startDrawPos = ScreenPosition + new Vector2(Border.LeftWidth, Border.TopHeight);
var drawWidth = ClientSize.X * Math.Min(percent, 1);
var r = new Rectangle(startDrawPos.X, startDrawPos.Y, drawWidth, ClientSize.Y);
RenderRectangle.Draw(spriteBatch, r, new Color(255, 0, 0, 200));
// Draw the name
spriteBatch.DrawStringShaded(Font, Text, Position + _textOffset, ForeColor, Color.Black);
// Stop drawing if we hit 100%
if (percent >= 1.00f)
StopCasting();
}
示例3: DrawControl
/// <summary>
/// Draws the <see cref="Control"/>.
/// </summary>
/// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
protected override void DrawControl(ISpriteBatch spriteBatch)
{
base.DrawControl(spriteBatch);
var item = Item;
if (item == null)
return;
// Draw the item in the center of the slot
var offset = (_itemSize - item.Grh.Size) / 2f;
item.Draw(spriteBatch, ScreenPosition + offset.Round());
// Draw the amount
if (item.Amount > 1)
spriteBatch.DrawStringShaded(GUIManager.Font, item.Amount.ToString(), ScreenPosition, ItemAmountForeColor,
ItemAmountBackColor);
}
示例4: DrawName
/// <summary>
/// Draws the Character's name.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="font">The <see cref="Font"/> to use for the name text. May be null.</param>
protected virtual void DrawName(ISpriteBatch sb, Font font)
{
// Ensure we have a valid font and name first
if (font == null || string.IsNullOrEmpty(Name))
return;
// Get the size of the name
var nameSize = GetNameSize();
// Get the character's center
var namePos = DrawPosition;
// Center horizontally
namePos.X += Size.X / 2f; // Move the left side of the name to the center of the character
namePos.X -= (float)Math.Round(nameSize.X / 2f); // Move the center to the center of the character
// Move up above the character's head (height of the text, with a little extra offset)
namePos.Y -= nameSize.Y + 4f;
// Draw
sb.DrawStringShaded(font, Name, namePos, Color.Green, Color.Black);
}
示例5: DrawName
/// <summary>
/// Draws the Character's name.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="font">The <see cref="Font"/> to use for the name text. May be null.</param>
protected virtual void DrawName(ISpriteBatch sb, Font font)
{
// Ensure we have a valid font and name first
if (font == null || string.IsNullOrEmpty(Name))
return;
// Get the size of the name
var nameSize = GetNameSize();
// Get the character's center
var namePos = DrawPosition;
// Center horizontally
namePos.X += Size.X / 2f; // Move the left side of the name to the center of the character
namePos.X -= (float)Math.Round(nameSize.X / 2f); // Move the center to the center of the character
// Move below the character
namePos.Y -= 10 + (CharacterSprite.SpriteSize.Y - Size.Y);
// Draw
sb.DrawStringShaded(font, Name, namePos, Color.White, Color.Black);
}
示例6: DrawText
/// <summary>
/// Draws the text for the control.
/// </summary>
/// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="position">Position relative to the Control to draw the text.</param>
protected override void DrawText(ISpriteBatch spriteBatch, Vector2 position)
{
if (string.IsNullOrEmpty(Text) || Font == null)
return;
spriteBatch.DrawStringShaded(Font, Text, ScreenPosition + position, ForeColor, _textBorderColor);
}
示例7: HandleBeforeDrawMapGUI
/// <summary>
/// When overridden in the derived class, handles performing drawing before the GUI for a <see cref="IDrawableMap"/> has been draw.
/// </summary>
/// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to use to draw.</param>
/// <param name="imap">The <see cref="IDrawableMap"/> being drawn.</param>
protected override void HandleBeforeDrawMapGUI(ISpriteBatch spriteBatch, IDrawableMap imap)
{
base.HandleBeforeDrawMapGUI(spriteBatch, imap);
var map = imap as EditorMap;
if (map == null)
return;
var camera = map.Camera;
if (camera == null)
return;
// Only draw for the map under the cursor
if (map != _mouseOverMap)
return;
if (IsSelecting)
{
// Draw the selection area
var a = camera.ToScreen(_selectionStart);
var b = camera.ToScreen(_selectionEnd);
if (a.QuickDistance(b) > _minSelectionAreaDrawSize)
{
var rect = Rectangle.FromPoints(a, b);
RenderRectangle.Draw(spriteBatch, rect, _selectionAreaColorInner, _selectionAreaColorOuter);
}
}
else
{
// Draw the tooltip
var font = ToolTipFont;
if (_toolTipObject != null && _toolTip != null && font != null)
spriteBatch.DrawStringShaded(font, _toolTip, _toolTipPos, Color.White, Color.Black);
}
}
示例8: DrawMapGrhTooltip
public static bool DrawMapGrhTooltip(ISpriteBatch spriteBatch, IDrawableMap map, MapGrh mapGrh, Vector2 worldPos)
{
if (mapGrh == null || mapGrh.Grh == null || mapGrh.Grh.GrhData == null)
return false;
Vector2 drawPos = worldPos - map.Camera.Min;
var font = GlobalState.Instance.DefaultRenderFont;
string txt = mapGrh.Grh.GrhData.Categorization.ToString();
Vector2 txtSize = font.MeasureString(txt);
Vector2 txtPos = drawPos.Max(Vector2.Zero).Min(map.Camera.Size - txtSize);
spriteBatch.DrawStringShaded(font, txt, txtPos, Color.White, Color.Black);
return true;
}
示例9: DrawBackground
/// <summary>
/// Performs the default menu background drawing.
/// </summary>
/// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
protected virtual void DrawBackground(ISpriteBatch spriteBatch)
{
// Draw the background
if (_background != null)
{
var bgDest = new Rectangle(0, 0, (int)ScreenManager.ScreenSize.X, (int)ScreenManager.ScreenSize.Y);
_background.Draw(spriteBatch, bgDest);
}
// Draw the title
if (!string.IsNullOrEmpty(_title))
spriteBatch.DrawStringShaded(GameScreenHelper.DefaultMenuTitleFont, Title, _titlePosition, _titleColor,
_titleBorderColor);
}