本文整理汇总了C#中Game.Draw2dTexture方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Draw2dTexture方法的具体用法?C# Game.Draw2dTexture怎么用?C# Game.Draw2dTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.Draw2dTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCompass
public void DrawCompass(Game game)
{
if (!CompassInActiveMaterials(game)) return;
if (compassid == -1)
{
compassid = game.GetTexture("compass.png");
needleid = game.GetTexture("compassneedle.png");
}
float size = 175;
float posX = game.Width() - 100;
float posY = 100;
float playerorientation = -((game.player.position.roty / (2 * Game.GetPi())) * 360);
compassvertex += (playerorientation - compassangle) / 50;
compassvertex *= (one * 9 / 10);
compassangle += compassvertex;
// compass
game.Draw2dTexture(compassid, posX - size / 2, posY - size / 2, size, size, null, 0, Game.ColorFromArgb(255, 255, 255, 255), false);
// compass needle
game.GLPushMatrix();
game.GLTranslate(posX, posY, 0);
game.GLRotate(compassangle, 0, 0, 90);
game.GLTranslate(-size / 2, -size / 2, 0);
game.Draw2dTexture(needleid, 0, 0, size, size, null, 0, Game.ColorFromArgb(255, 255, 255, 255), false);
game.GLPopMatrix();
}
示例2: DrawPlayerHealth
public void DrawPlayerHealth(Game game)
{
if (game.PlayerStats != null)
{
float progress = game.one * game.PlayerStats.CurrentHealth / game.PlayerStats.MaxHealth;
int posX = game.platform.FloatToInt(barDistanceToMargin * game.Scale());
int posY = game.platform.FloatToInt(game.Height() - barDistanceToMargin * game.Scale());
game.Draw2dTexture(game.WhiteTexture(), posX, posY - barSizeY * game.Scale(), barSizeX * game.Scale(), barSizeY * game.Scale(), null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
game.Draw2dTexture(game.WhiteTexture(), posX, posY - (progress * barSizeY * game.Scale()), barSizeX * game.Scale(), (progress) * barSizeY * game.Scale(), null, 0, Game.ColorFromArgb(255, 255, 0, 0), false);
}
//if (test) { d_The3d.Draw2dTexture(d_The3d.WhiteTexture(), 50, 50, 200, 200, null, Color.Red); }
}
示例3: DrawPlayerOxygen
public void DrawPlayerOxygen(Game game)
{
if (game.PlayerStats != null)
{
if (game.PlayerStats.CurrentOxygen < game.PlayerStats.MaxOxygen)
{
float progress = game.one * game.PlayerStats.CurrentOxygen / game.PlayerStats.MaxOxygen;
int posX = barDistanceToMargin + barOffset;
int posY = game.Height() - barDistanceToMargin;
game.Draw2dTexture(game.WhiteTexture(), posX, posY - barSizeY, barSizeX, barSizeY, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
game.Draw2dTexture(game.WhiteTexture(), posX, posY - (progress * barSizeY), barSizeX, (progress) * barSizeY, null, 0, Game.ColorFromArgb(255, 0, 0, 255), false);
}
}
}
示例4: DrawPlayerHealth
public void DrawPlayerHealth(Game game)
{
if (game.PlayerStats != null)
{
float progress = game.one * game.PlayerStats.CurrentHealth / game.PlayerStats.MaxHealth;
int InventoryStartX = game.Width() / 2 - 540 / 2;
int InventoryStartY = game.Height() - 110;
int posX = InventoryStartX + 10;
int posY = InventoryStartY + 10;
game.Draw2dTexture(game.GetTexture("hobars.png"), posX, posY - barSizeY, barSizeX, barSizeY, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
game.Draw2dTexture(game.GetTexture("hobars.png"), posX, posY - barSizeY, (progress) * barSizeX, barSizeY, null, 0, Game.ColorFromArgb(255, 255, 0, 0), false);
}
//if (test) { d_The3d.Draw2dTexture(d_The3d.WhiteTexture(), 50, 50, 200, 200, null, Color.Red); }
}
示例5: OnNewFrameDraw3d
public override void OnNewFrameDraw3d(Game game, float deltaTime)
{
float one = 1;
for (int i = 0; i < game.entitiesCount; i++)
{
Entity entity = game.entities[i];
if (entity == null) { continue; }
if (entity.sprite == null) { continue; }
Sprite b = entity.sprite;
game.GLMatrixModeModelView();
game.GLPushMatrix();
game.GLTranslate(b.positionX, b.positionY, b.positionZ);
Billboard(game);
game.GLScale((one * 2 / 100), (one * 2 / 100), (one * 2 / 100));
game.GLTranslate(0 - b.size / 2, 0 - b.size / 2, 0);
//d_Draw2d.Draw2dTexture(night ? moontexture : suntexture, 0, 0, ImageSize, ImageSize, null, Color.White);
IntRef n = null;
if (b.animationcount > 0)
{
float progress = one - (entity.expires.timeLeft / entity.expires.totalTime);
n = IntRef.Create(game.platform.FloatToInt(progress * (b.animationcount * b.animationcount - 1)));
}
game.Draw2dTexture(game.GetTexture(b.image), 0, 0, b.size, b.size, n, b.animationcount, Game.ColorFromArgb(255, 255, 255, 255), true);
game.GLPopMatrix();
}
}
示例6: DrawPlayerOxygen
public void DrawPlayerOxygen(Game game)
{
if (game.PlayerStats != null)
{
if (game.PlayerStats.CurrentOxygen < game.PlayerStats.MaxOxygen)
{
float progress = game.one * game.PlayerStats.CurrentOxygen / game.PlayerStats.MaxOxygen;
int InventoryStartX = game.Width() / 2 - 540 / 2;
int InventoryStartY = game.Height() - 140;
int posX = InventoryStartX + 10;
int posY = InventoryStartY + 10;
game.Draw2dTexture(game.GetTexture("hobars.png"), posX, posY - barSizeY, barSizeX, barSizeY, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
game.Draw2dTexture(game.GetTexture("hobars.png"), posX, posY - barSizeY, (progress) * barSizeX, barSizeY, null, 0, Game.ColorFromArgb(255, 0, 0, 255), false);
}
}
}
示例7: 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);
}
示例8: OnNewFrameDraw3d
public override void OnNewFrameDraw3d(Game game, float dt)
{
GamePlatform platform = game.platform;
game.GLMatrixModeModelView();
if (suntexture == -1)
{
suntexture = game.GetTexture("sun.png");
moontexture = game.GetTexture("moon.png");
}
UpdateSunMoonPosition(game, dt);
float posX;
float posY;
float posZ;
if (!game.isNight)
{
posX = game.sunPositionX;
posY = game.sunPositionY;
posZ = game.sunPositionZ;
}
else
{
posX = game.moonPositionX;
posY = game.moonPositionY;
posZ = game.moonPositionZ;
}
posX += game.player.position.x;
posY += game.player.position.y;
posZ += game.player.position.z;
game.GLPushMatrix();
game.GLTranslate(posX, posY, posZ);
ModDrawSprites.Billboard(game);
game.GLScale(one * 2 / 100, one * 2 / 100, one * 2 / 100);
//GL.Translate(-ImageSize / 2, -ImageSize / 2, 0);
game.Draw2dTexture(game.isNight ? moontexture : suntexture, 0, 0, ImageSize, ImageSize, null, 0, Game.ColorFromArgb(255, 255, 255, 255), false);
game.GLPopMatrix();
}
示例9: OnNewFrameDraw3d
public override void OnNewFrameDraw3d(Game game, float deltaTime)
{
if (ShouldDrawHand(game))
{
string img = HandImage2d(game);
if (img != null)
{
game.OrthoMode(game.Width(), game.Height());
if (lasthandimage != img)
{
lasthandimage = img;
byte[] file = game.GetFile(img);
BitmapCi bmp = game.platform.BitmapCreateFromPng(file, game.platform.ByteArrayLength(file));
if (bmp != null)
{
game.handTexture = game.platform.LoadTextureFromBitmap(bmp);
game.platform.BitmapDelete(bmp);
}
}
game.Draw2dTexture(game.handTexture, game.Width() / 2, game.Height() - 512, 512, 512, null, 0, Game.ColorFromArgb(255, 255, 255, 255), false);
game.PerspectiveMode();
}
}
}
示例10: OnNewFrameDraw2d
public override void OnNewFrameDraw2d(Game game_, float deltaTime)
{
game = game_;
if (dataItems == null)
{
dataItems = new GameDataItemsClient();
dataItems.game = game_;
controller = ClientInventoryController.Create(game_);
inventoryUtil = game.d_InventoryUtil;
}
if (game.guistate == GuiState.MapLoading)
{
return;
}
DrawMaterialSelector();
if (game.guistate != GuiState.Inventory)
{
return;
}
if (ScrollingUpTimeMilliseconds != 0 && (game.platform.TimeMillisecondsFromStart() - ScrollingUpTimeMilliseconds) > 250)
{
ScrollingUpTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
ScrollUp();
}
if (ScrollingDownTimeMilliseconds != 0 && (game.platform.TimeMillisecondsFromStart() - ScrollingDownTimeMilliseconds) > 250)
{
ScrollingDownTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
ScrollDown();
}
PointRef scaledMouse = PointRef.Create(game.mouseCurrentX, game.mouseCurrentY);
game.Draw2dBitmapFile("inventory.png", InventoryStartX(), InventoryStartY(), 1024, 1024);
//the3d.Draw2dTexture(terrain, 50, 50, 50, 50, 0);
//the3d.Draw2dBitmapFile("inventory_weapon_shovel.png", 100, 100, 60 * 2, 60 * 4);
//the3d.Draw2dBitmapFile("inventory_gauntlet_gloves.png", 200, 200, 60 * 2, 60 * 2);
//main inventory
for (int i = 0; i < game.d_Inventory.ItemsCount; i++)
{
Packet_PositionItem k = game.d_Inventory.Items[i];
if (k == null)
{
continue;
}
int screeny = k.Y - ScrollLine;
if (screeny >= 0 && screeny < CellCountInPageY)
{
DrawItem(CellsStartX() + k.X * CellDrawSize, CellsStartY() + screeny * CellDrawSize, k.Value_, 0, 0);
}
}
//draw area selection
if (game.d_Inventory.DragDropItem != null)
{
PointRef selectedInPage = SelectedCell(scaledMouse);
if (selectedInPage != null)
{
int x = (selectedInPage.X) * CellDrawSize + CellsStartX();
int y = (selectedInPage.Y) * CellDrawSize + CellsStartY();
int sizex = dataItems.ItemSizeX(game.d_Inventory.DragDropItem);
int sizey = dataItems.ItemSizeY(game.d_Inventory.DragDropItem);
if (selectedInPage.X + sizex <= CellCountInPageX
&& selectedInPage.Y + sizey <= CellCountInPageY)
{
int c;
IntRef itemsAtAreaCount = new IntRef();
PointRef[] itemsAtArea = inventoryUtil.ItemsAtArea(selectedInPage.X, selectedInPage.Y + ScrollLine, sizex, sizey, itemsAtAreaCount);
if (itemsAtArea == null || itemsAtAreaCount.value > 1)
{
c = Game.ColorFromArgb(100, 255, 0, 0); // red
}
else //0 or 1
{
c = Game.ColorFromArgb(100, 0, 255, 0); // green
}
game.Draw2dTexture(game.WhiteTexture(), x, y,
CellDrawSize * sizex, CellDrawSize * sizey,
null, 0, c, false);
}
}
IntRef selectedWear = SelectedWearPlace(scaledMouse);
if (selectedWear != null)
{
PointRef p = PointRef.Create(wearPlaceStart[selectedWear.value].X + InventoryStartX(), wearPlaceStart[selectedWear.value].Y + InventoryStartY());
PointRef size = wearPlaceCells[selectedWear.value];
int c;
Packet_Item itemsAtArea = inventoryUtil.ItemAtWearPlace(selectedWear.value, game.ActiveMaterial);
if (!dataItems.CanWear(selectedWear.value, game.d_Inventory.DragDropItem))
{
c = Game.ColorFromArgb(100, 255, 0, 0); // red
}
else //0 or 1
{
c = Game.ColorFromArgb(100, 0, 255, 0); // green
}
game.Draw2dTexture(game.WhiteTexture(), p.X, p.Y,
CellDrawSize * size.X, CellDrawSize * size.Y,
null, 0, c, false);
//.........这里部分代码省略.........
示例11: DrawCraftingRecipes
internal void DrawCraftingRecipes(Game game)
{
currentRecipes = new int[1024];
currentRecipesCount = 0;
for (int i = 0; i < craftingrecipes2Count; i++)
{
Packet_CraftingRecipe r = craftingrecipes2[i];
if (r == null)
{
continue;
}
bool next = false;
//can apply recipe?
for (int k = 0; k < r.IngredientsCount; k++)
{
Packet_Ingredient ingredient = r.Ingredients[k];
if (ingredient == null)
{
continue;
}
if (craftingblocksFindAllCount(craftingblocks, craftingblocksCount, ingredient.Type) < ingredient.Amount)
{
next = true;
break;
}
}
if (!next)
{
currentRecipes[currentRecipesCount++] = i;
}
}
int menustartx = game.xcenter(600);
int menustarty = game.ycenter(currentRecipesCount * 80);
if (currentRecipesCount == 0)
{
game.Draw2dText1(game.language.NoMaterialsForCrafting(), game.xcenter(200), game.ycenter(20), 12, null, false);
return;
}
for (int i = 0; i < currentRecipesCount; i++)
{
Packet_CraftingRecipe r = craftingrecipes2[currentRecipes[i]];
for (int ii = 0; ii < r.IngredientsCount; ii++)
{
int xx = menustartx + 20 + ii * 130;
int yy = menustarty + i * 80;
game.Draw2dTexture(game.d_TerrainTextures.terrainTexture(), xx, yy, 32, 32, IntRef.Create(game.TextureIdForInventory[r.Ingredients[ii].Type]), game.texturesPacked(), Game.ColorFromArgb(255, 255, 255, 255), false);
game.Draw2dText1(game.platform.StringFormat2("{0} {1}", game.platform.IntToString(r.Ingredients[ii].Amount), game.blocktypes[r.Ingredients[ii].Type].Name), xx + 50, yy, 12,
IntRef.Create(i == craftingselectedrecipe ? Game.ColorFromArgb(255, 255, 0, 0) : Game.ColorFromArgb(255, 255, 255, 255)), false);
}
{
int xx = menustartx + 20 + 400;
int yy = menustarty + i * 80;
game.Draw2dTexture(game.d_TerrainTextures.terrainTexture(), xx, yy, 32, 32, IntRef.Create(game.TextureIdForInventory[r.Output.Type]), game.texturesPacked(), Game.ColorFromArgb(255, 255, 255, 255), false);
game.Draw2dText1(game.platform.StringFormat2("{0} {1}", game.platform.IntToString(r.Output.Amount), game.blocktypes[r.Output.Type].Name), xx + 50, yy, 12,
IntRef.Create(i == craftingselectedrecipe ? Game.ColorFromArgb(255, 255, 0, 0) : Game.ColorFromArgb(255, 255, 255, 255)), false);
}
}
}
示例12: DrawBackground
void DrawBackground(Game game)
{
backgroundW = 512;
backgroundH = 512;
//Background tiling
int countX = game.platform.FloatToInt(Width / backgroundW) + 1;
int countY = game.platform.FloatToInt(Height / backgroundH) + 1;
for (int x = 0; x < countX; x++)
{
for (int y = 0; y < countY; y++)
{
game.Draw2dTexture(game.GetTexture("background.png"), x * backgroundW, y * backgroundH, backgroundW, backgroundH, null, 0, Game.ColorFromArgb(255, 255, 255, 255), false);
}
}
}
示例13: 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);
}
}
示例14: 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();
}
}
}
}
示例15: 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);
}