本文整理汇总了C#中Game.Draw2dText方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Draw2dText方法的具体用法?C# Game.Draw2dText怎么用?C# Game.Draw2dText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.Draw2dText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawScreenshotFlash
internal void DrawScreenshotFlash(Game game)
{
game.Draw2dTexture(game.WhiteTexture(), 0, 0, game.platform.GetCanvasWidth(), game.platform.GetCanvasHeight(), null, 0, Game.ColorFromArgb(255, 255, 255, 255), false);
string screenshottext = "&0Screenshot";
IntRef textWidth = new IntRef();
IntRef textHeight = new IntRef();
game.platform.TextSize(screenshottext, 50, textWidth, textHeight);
FontCi font = new FontCi();
font.family = "Arial";
font.size = 50;
game.Draw2dText(screenshottext, font, game.xcenter(textWidth.value), game.ycenter(textHeight.value), null, false);
}
示例2: OnNewFrameDraw3d
public override void OnNewFrameDraw3d(Game game, float deltaTime)
{
for (int i = 0; i < game.entitiesCount; i++)
{
Entity e = game.entities[i];
if (e == null)
{
continue;
}
if (e.drawText == null)
{
continue;
}
if (e.networkPosition != null && (!e.networkPosition.PositionLoaded))
{
continue;
}
int kKey = i;
EntityDrawText p = game.entities[i].drawText;
float posX = - game.platform.MathSin(e.position.roty) * p.dx + e.position.x;
float posY = p.dy + e.position.y;
float posZ = game.platform.MathCos(e.position.roty) * p.dz + e.position.z;
//todo if picking
if ((game.Dist(game.player.position.x, game.player.position.y, game.player.position.z, posX, posY, posZ) < 20)
|| game.keyboardState[Game.KeyAltLeft] || game.keyboardState[Game.KeyAltRight])
{
string text = p.text;
{
float shadow = (game.one * game.GetLight(game.platform.FloatToInt(posX), game.platform.FloatToInt(posZ), game.platform.FloatToInt(posY))) / Game.maxlight;
game.GLPushMatrix();
game.GLTranslate(posX, posY, posZ);
game.GLRotate(180, 1, 0, 0);
game.GLRotate(e.position.roty * 360 / (2 * Game.GetPi()), 0, 1, 0);
float scale = game.one * 5 / 1000;
game.GLScale(scale, scale, scale);
FontCi font = new FontCi();
font.family = "Arial";
font.size = 14;
game.Draw2dText(text, font, -game.TextSizeWidth(text, 14) / 2, 0, IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), true);
game.GLPopMatrix();
}
}
}
}
示例3: OnNewFrameDraw2d
public override void OnNewFrameDraw2d(Game game, float deltaTime)
{
if (game.guistate != GuiState.MapLoading)
{
return;
}
GamePlatform platform = game.platform;
float one = 1;
Width = platform.GetCanvasWidth();
Height = platform.GetCanvasHeight();
DrawBackground(game);
string connecting = game.language.Connecting();
if (game.issingleplayer && (!platform.SinglePlayerServerLoaded()))
{
connecting = "Starting game...";
}
if (game.maploadingprogress.ProgressStatus != null)
{
connecting = game.maploadingprogress.ProgressStatus;
}
if (game.invalidVersionDrawMessage != null)
{
game.Draw2dText(game.invalidVersionDrawMessage, game.fontMapLoading, game.xcenter(game.TextSizeWidth(game.invalidVersionDrawMessage, 14)), Height / 2 - 50, null, false);
string connect = "Click to connect";
game.Draw2dText(connect, game.fontMapLoading, game.xcenter(game.TextSizeWidth(connect, 14)), Height / 2 + 50, null, false);
return;
}
IntRef serverNameWidth = new IntRef();
IntRef serverNameHeight = new IntRef();
platform.TextSize(game.ServerInfo.ServerName, 14, serverNameWidth, serverNameHeight);
game.Draw2dText(game.ServerInfo.ServerName, game.fontMapLoading, game.xcenter(serverNameWidth.value), Height / 2 - 150, null, false);
if (game.ServerInfo.ServerMotd != null)
{
IntRef serverMotdWidth = new IntRef();
IntRef serverMotdHeight = new IntRef();
platform.TextSize(game.ServerInfo.ServerMotd, 14, serverMotdWidth, serverMotdHeight);
game.Draw2dText(game.ServerInfo.ServerMotd, game.fontMapLoading, game.xcenter(serverMotdWidth.value), Height / 2 - 100, null, false);
}
IntRef connectingWidth = new IntRef();
IntRef connectingHeight = new IntRef();
platform.TextSize(connecting, 14, connectingWidth, connectingHeight);
game.Draw2dText(connecting, game.fontMapLoading, game.xcenter(connectingWidth.value), Height / 2 - 50, null, false);
string progress = platform.StringFormat(game.language.ConnectingProgressPercent(), platform.IntToString(game.maploadingprogress.ProgressPercent));
string progress1 = platform.StringFormat(game.language.ConnectingProgressKilobytes(), platform.IntToString(game.maploadingprogress.ProgressBytes / 1024));
if (game.maploadingprogress.ProgressPercent > 0)
{
IntRef progressWidth = new IntRef();
IntRef progressHeight = new IntRef();
platform.TextSize(progress, 14, progressWidth, progressHeight);
game.Draw2dText(progress, game.fontMapLoading, game.xcenter(progressWidth.value), Height / 2 - 20, null, false);
IntRef progress1Width = new IntRef();
IntRef progress1Height = new IntRef();
platform.TextSize(progress1, 14, progress1Width, progress1Height);
game.Draw2dText(progress1, game.fontMapLoading, game.xcenter(progress1Width.value), Height / 2 + 10, null, false);
float progressratio = one * game.maploadingprogress.ProgressPercent / 100;
int sizex = 400;
int sizey = 40;
game.Draw2dTexture(game.WhiteTexture(), game.xcenter(sizex), Height / 2 + 70, sizex, sizey, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
int red = Game.ColorFromArgb(255, 255, 0, 0);
int yellow = Game.ColorFromArgb(255, 255, 255, 0);
int green = Game.ColorFromArgb(255, 0, 255, 0);
int[] colors = new int[3];
colors[0] = red;
colors[1] = yellow;
colors[2] = green;
int c = InterpolationCi.InterpolateColor(platform, progressratio, colors, 3);
game.Draw2dTexture(game.WhiteTexture(), game.xcenter(sizex), Height / 2 + 70, progressratio * sizex, sizey, null, 0, c, false);
}
}
示例4: OnNewFrameDraw3d
public override void OnNewFrameDraw3d(Game game, float deltaTime)
{
for (int i = 0; i < game.entitiesCount; i++)
{
Entity e = game.entities[i];
if (e == null)
{
continue;
}
if (e.drawName == null)
{
continue;
}
if (i == game.LocalPlayerId)
{
continue;
}
if (e.networkPosition != null && (!e.networkPosition.PositionLoaded))
{
continue;
}
int kKey = i;
DrawName p = game.entities[i].drawName;
if (p.OnlyWhenSelected)
{
continue;
}
float posX = p.TextX + e.position.x;
float posY = p.TextY + e.position.y + e.drawModel.ModelHeight + game.one * 7 / 10;
float posZ = p.TextZ + e.position.z;
//todo if picking
if ((game.Dist(game.player.position.x, game.player.position.y, game.player.position.z, posX, posY, posZ) < 20)
|| game.keyboardState[Game.KeyAltLeft] || game.keyboardState[Game.KeyAltRight])
{
string name = p.Name;
{
float shadow = (game.one * game.GetLight(game.platform.FloatToInt(posX), game.platform.FloatToInt(posZ), game.platform.FloatToInt(posY))) / Game.maxlight;
//do not interpolate player position if player is controlled by game world
//if (EnablePlayerUpdatePositionContainsKey(kKey) && !EnablePlayerUpdatePosition(kKey))
//{
// posX = p.NetworkX;
// posY = p.NetworkY;
// posZ = p.NetworkZ;
//}
game.GLPushMatrix();
game.GLTranslate(posX, posY, posZ);
//if (p.Type == PlayerType.Monster)
//{
// GLTranslate(0, 1, 0);
//}
ModDrawSprites.Billboard(game);
float scale = game.one * 2 / 100;
game.GLScale(scale, scale, scale);
//Color c = Color.FromArgb((int)(shadow * 255), (int)(shadow * 255), (int)(shadow * 255));
//Todo: Can't change text color because text has outline anyway.
if (p.DrawHealth)
{
game.Draw2dTexture(game.WhiteTexture(), -26, -11, 52, 12, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
game.Draw2dTexture(game.WhiteTexture(), -25, -10, 50 * (game.one * p.Health), 10, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false);
}
FontCi font = new FontCi();
font.family = "Arial";
font.size = 14;
game.Draw2dText(name, font, -game.TextSizeWidth(name, 14) / 2, 0, IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), true);
// GL.Translate(0, 1, 0);
game.GLPopMatrix();
}
}
}
}
示例5: OnNewFrameDraw2d
public override void OnNewFrameDraw2d(Game game, float deltaTime)
{
float dt = deltaTime;
if (!visible)
{
return;
}
game.Draw2dTexture(game.WhiteTexture(), startX, startY, maxColumns * charSize, maxLines * charSize, null, 0, Game.ColorFromArgb(255, 100, 100, 100), false);
for (int i = 0; i < maxLines; i++)
{
game.Draw2dText(LineToString(buffer[i]), font, startX, startY + charSize * i, null, false);
}
int[] spaces = new int[maxColumns];
for (int i = 0; i < maxColumns; i++)
{
spaces[i] = 32;
}
spaces[cursorColumn] = 95; //_
string spacesString = game.platform.CharArrayToString(spaces, cursorColumn + 1);
game.Draw2dText(spacesString, font, startX, startY + cursorLine * charSize, null, false);
}
示例6: DrawLocalPosition
void DrawLocalPosition(Game game)
{
float one = 1;
if (game.ENABLE_DRAWPOSITION)
{
float heading = one * game.HeadingByte(game.player.position.rotx, game.player.position.roty, game.player.position.rotz);
float pitch = one * game.PitchByte(game.player.position.rotx, game.player.position.roty, game.player.position.rotz);
string postext = game.platform.StringFormat("X: {0}", game.platform.IntToString(game.MathFloor(game.player.position.x)));
postext = StringTools.StringAppend(game.platform, postext, ",\tY: ");
postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(game.player.position.z)));
postext = StringTools.StringAppend(game.platform, postext, ",\tZ: ");
postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(game.player.position.y)));
postext = StringTools.StringAppend(game.platform, postext, "\nHeading: ");
postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(heading)));
postext = StringTools.StringAppend(game.platform, postext, "\nPitch: ");
postext = StringTools.StringAppend(game.platform, postext, game.platform.IntToString(game.MathFloor(pitch)));
FontCi font = new FontCi();
font.family = "Arial";
font.size = Game.ChatFontSize;
game.Draw2dText(postext, font, 100, 460, null, false);
}
}
示例7: DrawDisconnected
void DrawDisconnected(Game game)
{
float one = 1;
float lagSeconds = one * (game.platform.TimeMillisecondsFromStart() - game.LastReceivedMilliseconds) / 1000;
if ((lagSeconds >= Game.DISCONNECTED_ICON_AFTER_SECONDS && lagSeconds < 60 * 60 * 24)
&& game.invalidVersionDrawMessage == null && !(game.issingleplayer && (!game.platform.SinglePlayerServerLoaded())))
{
game.Draw2dBitmapFile("disconnected.png", game.Width() - 100, 50, 50, 50);
FontCi font = new FontCi();
font.family = "Arial";
font.size = 12;
game.Draw2dText(game.platform.IntToString(game.platform.FloatToInt(lagSeconds)), font, game.Width() - 100, 50 + 50 + 10, null, false);
game.Draw2dText("Press F6 to reconnect", font, game.Width() / 2 - 200 / 2, 50, null, false);
}
}
示例8: DrawEnemyHealthUseInfo
internal void DrawEnemyHealthUseInfo(Game game, string name, float progress, bool useInfo)
{
int y = useInfo ? 55 : 35;
game.Draw2dTexture(game.WhiteTexture(), game.xcenter(300), 40, 300, y, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
game.Draw2dTexture(game.WhiteTexture(), game.xcenter(300), 40, 300 * progress, y, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false);
FontCi font = new FontCi();
font.family = "Arial";
font.size = 14;
IntRef w = new IntRef();
IntRef h = new IntRef();
game.platform.TextSize(name, 14, w, h);
game.Draw2dText(name, font, game.xcenter(w.value), 40, null, false);
if (useInfo)
{
name = game.platform.StringFormat(game.language.PressToUse(), "E");
game.platform.TextSize(name, 10, w, h);
FontCi font2 = new FontCi();
font2.family = "Arial";
font2.size = 10;
game.Draw2dText(name, font2, game.xcenter(w.value), 70, null, false);
}
}
示例9: DrawAmmo
internal void DrawAmmo(Game game)
{
Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
if (item != null && item.ItemClass == Packet_ItemClassEnum.Block)
{
if (game.blocktypes[item.BlockId].IsPistol)
{
int loaded = game.LoadedAmmo[item.BlockId];
int total = game.TotalAmmo[item.BlockId];
string s = game.platform.StringFormat2("{0}/{1}", game.platform.IntToString(loaded), game.platform.IntToString(total - loaded));
FontCi font = new FontCi();
font.family = "Arial";
font.size = 18;
game.Draw2dText(s, font, game.Width() - game.TextSizeWidth(s, 18) - 50,
game.Height() - game.TextSizeHeight(s, 18) - 50, loaded == 0 ? IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)) : IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), false);
if (loaded == 0)
{
font.size = 14;
string pressR = "Press R to reload";
game.Draw2dText(pressR, font, game.Width() - game.TextSizeWidth(pressR, 14) - 50,
game.Height() - game.TextSizeHeight(s, 14) - 80, IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)), false);
}
}
}
}