public override void drawAsItem(Game game, Rectangle r, int count, int data, Color color, float depth) { if (renderType == RenderTypeNormal) { r.X += r.Width / 4; r.Y += r.Height / 4; r.Width /= 2; r.Height /= 2; Game.drawRectangle(Tile.TileSheet, r, Tile.getTileObject(data).getItemRect(data), color, depth); } }
public override void draw(Game game, World world) { byte a = (byte)MathHelper.Clamp(world.getLight((int)(position.X + (size.X / 2)) / World.tileSizeInPixels, (int)(position.Y + (size.Y / 2)) / World.tileSizeInPixels), 0, 255); if (tileDepth == World.TileDepth.wall) { Tile t = Tile.getTileObject(stack.getItem().index); a = (byte)Clamp(a - (255 - t.wallBrightness), 0, t.wallBrightness); } stack.drawNoCount(game, new Rectangle((int)position.X - world.viewOffset.X - (World.tileSizeInPixels / 2), (int)position.Y - world.viewOffset.Y - (World.tileSizeInPixels / 2), World.tileSizeInPixels * 2, World.tileSizeInPixels * 2), new Color(a, a, a), Game.RENDER_DEPTH_ENTITY_FALLING_SAND); }
public override string getDisplayName(int count, int data) { if (maxStack > 1) { Tile tile = Tile.getTileObject(data); return(count == 1 ? tile.displayName : (tile.displayNamePlural + " (" + formatNumber(count) + ")")); } else { return(name); } }
public override void init() { size = new Vector2(World.tileSizeInPixels * .75f, World.tileSizeInPixels * .75f); if (tileDepth == World.TileDepth.wall) { isSolid = false; } else { isSolid = index == 0 ? false : Tile.getTileObject(index).isSolid(); } }
public override void drawHover(Game game, int mouseTileX, int mouseTileY, ItemStack currentItem) { if (!Tile.getTileObject(currentItem.getData()).drawHover(game, mouseTileX, mouseTileY, currentItem)) { Tile tile = Tile.getTileObject(currentItem.getData()); bool tileGoesHere = tile.canBePlacedHere(game.currentWorld, mouseTileX, mouseTileY, World.TileDepth.tile); bool wallGoesHere = tile.canBePlacedHere(game.currentWorld, mouseTileX, mouseTileY, World.TileDepth.wall); if (tileGoesHere || wallGoesHere) { Game.drawRectangle(Tile.TileSheet, new Rectangle((mouseTileX * World.tileSizeInPixels) - game.currentWorld.viewOffset.X, (mouseTileY * World.tileSizeInPixels) - game.currentWorld.viewOffset.Y, World.tileSizeInPixels, World.tileSizeInPixels), Tile.getTileObject(currentItem.getData()).getTextureInfo(mouseTileX, mouseTileY, game.currentWorld, World.TileDepth.tile).rectangle, new Color(.5f, .5f, .5f, .5f), Game.RENDER_DEPTH_HOVER); } } }
public bool mine(Game game, ItemStack stack, int xTile, int yTile, int distance, World.TileDepth tileDepth) { int del = delay; Tile.Material mat = game.currentWorld.getTileObjectNoCheck(xTile, yTile, tileDepth).material; if (mat == Tile.Material.furniture) { del = 20; } int power = getPower(mat); if (power <= 0) { return(false); } game.inventory.t++; if (game.inventory.t >= del && distance <= reach) { game.inventory.t = 0; Tile tile = game.currentWorld.getTileObject(xTile, yTile, tileDepth); if (tile.index != Tile.TileAir.index) { SoundEffectPlayer.playSoundWithRandomPitch(SoundEffectPlayer.SoundTink); int m = ((int)game.currentWorld.getCrackNoCheck(xTile, yTile)); if (m == 0) { game.inventory.t = 0; } int n = m + power; int max = (Tile.getTileObject(tile.index)).toughness; if (n > max) { n = max; } game.currentWorld.setCrackNoCheck(xTile, yTile, (byte)n); if (n == max) { if (game.currentWorld.mineTile(xTile, yTile, this, tileDepth)) { game.currentWorld.setCrackNoCheck(xTile, yTile, 0); } } return(true); } } return(false); }
public string getDisplayName(bool extended) { string s = item.getDisplayName(count, data); if (extended) { s += "\n Reach: " + (item.reach / World.tileSizeInPixels); if (item is ItemTile) { s += "\n Placeable"; Tile tile = Tile.getTileObject(data); if (tile is TileDoor) { s += "\n Size: 1x3"; } else if (tile is TileFurniture) { TileFurniture furniture = (TileFurniture)tile; s += "\n Size: " + furniture.size.X + "x" + furniture.size.Y; } } else if (item is ItemPick) { ItemPick pick = (ItemPick)item; int p; p = pick.getPower(Tile.Material.stone); if (p > 0) { s += "\n Rock Power: " + Math.Ceiling(((p / 256.0) * 100)) + "%"; } p = pick.getPower(Tile.Material.dirt); if (p > 0) { s += "\n Soil Power: " + Math.Ceiling(((p / 256.0) * 100)) + "%"; } p = pick.getPower(Tile.Material.wood); if (p > 0) { s += "\n Wood Power: " + Math.Ceiling(((p / 256.0) * 100)) + "%"; } s += "\n Speed: " + Math.Max((20 - pick.getDelay()) * 5, 1) + "%"; } } return(s); }
public override ItemStack rightClick(Game game, ItemStack stack, int xTile, int yTile, int distance) { if (Tile.getTileObject(stack.getData()) != null && distance <= reach) { if (game.currentWorld.getTileIndex(xTile, yTile, World.TileDepth.wall) == Tile.TileAir.index) { if (Tile.getTileObject(stack.getData()).canBeWall) { if (Tile.getTileObject(stack.getData()).canBePlacedHere(game.currentWorld, xTile, yTile, World.TileDepth.wall)) { if (game.currentWorld.setTileWithUpdate(xTile, yTile, stack.getData(), World.TileDepth.wall)) { game.currentWorld.getTileObjectNoCheck(xTile, yTile, World.TileDepth.wall).justPlaced(game.currentWorld, xTile, yTile, World.TileDepth.wall); stack.setCount(stack.getCount() - 1); } } } } } return(stack); }
public Tile getTileObjectNoCheck(int x, int y, World.TileDepth tileDepth) { Tile t = Tile.getTileObject(getTileIndexNoCheck(x, y, tileDepth)); return(t != null ? t : Tile.TileAir); }