void DrawHearts() { Model.ModelCache cache = game.ModelCache; int index = 0, health = game.LocalPlayer.Health; int inner = (int)(7 * game.GuiHotbarScale); int middle = (int)(8 * game.GuiHotbarScale); int outer = (int)(9 * game.GuiHotbarScale); int selBlockSize = (int)(23 * game.GuiHotbarScale); int offset = middle - inner; int y = Y + (Height - selBlockSize - outer); for (int heart = 0; heart < 10; heart++) { Texture tex = new Texture(0, X + middle * heart, y, outer, outer, backRec); IGraphicsApi.Make2DQuad(ref tex, PackedCol.White, cache.vertices, ref index); if (health <= 0) { continue; } TextureRec rec = (health >= 2) ? fullRec : halfRec; tex = new Texture(0, X + middle * heart + offset, y + offset, inner, inner, rec); IGraphicsApi.Make2DQuad(ref tex, PackedCol.White, cache.vertices, ref index); health -= 2; } game.Graphics.BindTexture(game.Gui.IconsTex); game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index); }
public virtual void RenderHotbarItems() { Model.ModelCache cache = game.ModelCache; for (int i = 0; i < Inventory.BlocksPerRow; i++) { BlockID block = game.Inventory[i]; if (BlockInfo.Draw[block] != DrawType.Sprite) { continue; } int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2); int y = (int)(Y + (Height - barHeight)); int lower = (int)(3 * game.GuiHotbarScale); int side = (int)(8 * game.GuiHotbarScale); int outer = (int)(16 * game.GuiHotbarScale); y += lower; x -= side; if (BlockInfo.Draw[block] == DrawType.Sprite) { int texLoc = BlockInfo.GetTextureLoc(block, Side.Right); TextureRec rec = TerrainAtlas1D.GetTexRec(texLoc, 1, out texIndex); Texture tex = new Texture(0, (int)x, (int)y, outer, outer, rec); IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index); game.Graphics.BindTexture(TerrainAtlas1D.TexIds[texIndex]); game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index); } } index = 0; texIndex = 0; }
void DrawHearts() { Model.ModelCache cache = game.ModelCache; int index = 0, health = game.LocalPlayer.Health; int damage = this.damage; int inner = (int)(7 * game.GuiHotbarScale); int middle = (int)(8 * game.GuiHotbarScale); int outer = (int)(9 * game.GuiHotbarScale); int selBlockSize = (int)(23 * game.GuiHotbarScale); int offset = middle - inner; int y = Y + (Height - selBlockSize - outer); bool flash = false; if (damageTime <= 10 && damageTime >= 8 || damageTime >= 14 && damageTime <= 17) { flash = true; } TextureRec rec2 = flash ? backRecHurt : backRec; for (int heart = 0; heart < 10; heart++) { Texture tex = new Texture(0, X + middle * heart, y, outer, outer, rec2); IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index); if (damage > 0 && health <= 1 && flash) { if (health == 1) { damage += 1; } TextureRec rec3 = (damage >= 2) ? fullRecHurt : halfRecHurt; tex = new Texture(0, X + middle * heart + offset, y + offset, inner, inner, rec3); IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index); damage -= 2; } if (health <= 0) { continue; } TextureRec rec = (health >= 2) ? fullRec : halfRec; tex = new Texture(0, X + middle * heart + offset, y + offset, inner, inner, rec); IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index); health -= 2; } game.Graphics.BindTexture(game.Gui.IconsTex); game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index); }
void DrawBubbles() { Model.ModelCache cache = game.ModelCache; int index = 0, air = Utils.Ceil(((float)game.LocalPlayer.Air / 30f)); int damage = this.damage; int inner = (int)(7 * game.GuiHotbarScale); int middle = (int)(8 * game.GuiHotbarScale); int outer = (int)(9 * game.GuiHotbarScale); int selBlockSize = (int)(23 * game.GuiHotbarScale); //int offset = middle - inner; //int offset = (int)(101 * game.GuiHotbarScale); int y = Y + (Height - selBlockSize - outer * 2); if (air > 0) { drowning = false; } if ((float)game.LocalPlayer.Air / 30 == air && !drowning) { this.pop = 3; if (air == 0) { drowning = true; } } bool pop = (this.pop > 0); TextureRec rec2 = BubbleRec; for (int heart = 0; heart < 10; heart++) { if (air <= 0 && !pop) { continue; } if (pop && air == 0) { rec2 = PoppedRec; pop = false; } Texture tex = new Texture(0, X + middle * heart, y, outer, outer, rec2); IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, cache.vertices, ref index); air -= 1; } game.Graphics.BindTexture(game.Gui.IconsTex); game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index); }
void RenderHotbarBlocks() { Model.ModelCache cache = game.ModelCache; drawer.BeginBatch(game, cache.vertices, cache.vb); for (int i = 0; i < Inventory.BlocksPerRow; i++) { BlockID block = game.Inventory[i]; int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2); int y = (int)(Y + (Height - barHeight / 2)); float scale = (elemSize * 13.5f / 16f) / 2f; drawer.DrawBatch(block, scale, x, y); } drawer.EndBatch(); }
public override void Render(double delta) { RenderHotbar(); Model.ModelCache cache = game.ModelCache; drawer.BeginBatch(game, cache.vertices, cache.vb); for (int i = 0; i < hotbarCount; i++) { byte block = (byte)game.Inventory.Hotbar[i]; int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2); int y = (int)(game.Height - barHeight / 2); float scale = (elemSize * 13.5f / 16f) / 2f; drawer.DrawBatch(block, scale, x, y); } drawer.EndBatch(); }
public override void RenderHotbarBlocks() { Model.ModelCache cache = game.ModelCache; drawer.BeginBatch(game, cache.vertices, cache.vb); for (int i = 0; i < Inventory.BlocksPerRow; i++) { if (game.SurvInv.ItemList[i] == null) { continue; } BlockID block = (BlockID)game.SurvInv.ItemList[i].id; int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2); int y = (int)(Y + (Height - barHeight / 2)); float scale = (elemSize * 13.5f / 16f) / 2f; if (BlockInfo.Draw[block] != DrawType.Sprite) { drawer.DrawBatch(block, scale, x, y); } } drawer.EndBatch(); }