public override TextureInfo getTextureInfo(int x, int y, World world, World.TileDepth tileDepth) { if (renderType == RenderType.placed) { bool left = world.isTileSolid(x - 1, y, tileDepth); bool right = world.isTileSolid(x + 1, y, tileDepth); bool down = world.isTileSolid(x, y + 1, tileDepth); bool up = world.isTileSolid(x, y - 1, tileDepth); bool data = world.getTileData(x, y, tileDepth) != 0; Rectangle r; if (down) { r = get8(data?2:0, 0); } else if (left) { r = get8(data ? 3 : 1, 0); } else if (right) { r = get8(data ? 3 : 1, 1); } else if (up) { r = get8(data ? 2 : 0, 1); } else { r = get8(data ? 2 : 0, 0); } return(new TextureInfo(r, true)); } return(new TextureInfo(Game.OnexOneRect, true)); }
public override void updateNearChange(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileIndex(x, y + 1, tileDepth) == Tile.TileAir.index) { world.mineTile(x, y, Item.itemSupick, tileDepth); } }
public override void updateRandom(World world, int x, int y, World.TileDepth tileDepth) { if (Game.rand.Next(10) == 0) { world.setTileWithUpdate(x, y, Tile.TileAir.index, tileDepth); } }
public override void updateNearChange(World world, int x, int y, World.TileDepth tileDepth) { if (!world.isTileSolid(x + restOnX, y + restOnY, tileDepth)) { world.mineTile(x, y, Item.itemSupick, tileDepth); } }
internal void setTileForUpdate(int x, int y, World.TileDepth tileDepth) { if (inWorld(x, y)) { TileNeedsUpdateMatrix[x, y, (int)tileDepth] = true; } }
private void growTo(World world, int x, int y, World.TileDepth tileDepth) { bool grow = false; if (world.getTileObject(x - 1, y, tileDepth).transparent) { grow = true; } if (world.getTileObject(x + 1, y, tileDepth).transparent) { grow = true; } if (world.getTileObject(x, y - 1, tileDepth).transparent) { grow = true; } if (world.getTileObject(x, y + 1, tileDepth).transparent) { grow = true; } if (grow) { world.setTile(x, y, Tile.TileGrass, tileDepth); } }
public override void updateNearChange(World world, int x, int y, World.TileDepth tileDepth) { if (!(world.isTileSolid(x, y + 1, tileDepth) || world.getTileIndex(x, y + 1, tileDepth) == index)) { world.mineTile(x, y, Item.itemSupick, tileDepth); } }
public override TextureInfo getTextureInfo(int x, int y, World world, World.TileDepth tileDepth) { Rectangle r = get8(3, 3); int l = world.getTileDataNoCheck(x, y, tileDepth); int k = 1; bool kk = false; for (int i = 0; i < size.X; i++) { for (int j = size.Y - 1; j >= 0; j--) { if (k == l || k == -l) { r = get8(l < 0?(size.X - 1 - i):i, j); kk = true; break; } k++; } if (kk) { break; } } return(new TextureInfo(r, true, Point.Zero, l < 0, false)); }
public EntityFallingTile(int x, int y, int index, World.TileDepth tileDepth) : base(x, y) { this.index = index; this.tileDepth = tileDepth; stack = new ItemStack(Item.itemTile, 1, index); }
public int getTileIndex(int x, int y, World.TileDepth tileDepth) { if (inWorld(x, y)) { return(TileMatrix[x, y, (int)tileDepth]); } return(Tile.TileDirt.index); }
public int getTileData(int x, int y, World.TileDepth tileDepth) { if (inWorld(x, y)) { return(TileDataMatrix[x, y, (int)tileDepth]); } return(0); }
public override bool mustHaveTileBelow(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileData(x, y, tileDepth) == 0) { return(false); } return(true); }
public virtual bool canBePlacedHereOverridable(World world, int x, int y, World.TileDepth tileDepth) { if (renderType == RenderType.placed) { return((world.isTileSolid(x - 1, y, tileDepth) || world.isTileSolid(x + 1, y, tileDepth) || world.isTileSolid(x, y - 1, tileDepth) || world.isTileSolid(x, y + 1, tileDepth) || !world.getTileObject(x, y, tileDepth == World.TileDepth.wall ? World.TileDepth.tile : World.TileDepth.wall).isAir()) && world.getTileObject(x, y, tileDepth).isAir()); } return((!world.getTileObject(x - 1, y, tileDepth).isAir() || !world.getTileObject(x + 1, y, tileDepth).isAir() || !world.getTileObject(x, y - 1, tileDepth).isAir() || !world.getTileObject(x, y + 1, tileDepth).isAir() || !world.getTileObject(x, y, tileDepth == World.TileDepth.wall ? World.TileDepth.tile : World.TileDepth.wall).isAir()) && world.getTileObject(x, y, tileDepth).isAir()); }
public bool canBePlacedHere(World world, int x, int y, World.TileDepth tileDepth) { if (tileDepth == World.TileDepth.wall && !canBeWall) { return(false); } return(canBePlacedHereOverridable(world, x, y, tileDepth)); }
public bool canBeDestroyed(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileObject(x, y - 1, tileDepth).mustHaveTileBelow(world, x, y - 1, tileDepth)) { return(false); } return(true); }
public override int getLight(int x, int y, World.TileDepth tileDepth) { if (Game.instance.currentWorld == null) { return(0); } return(Game.instance.currentWorld.getTileData(x, y, tileDepth) == 0?base.getLight(x, y, tileDepth):0); }
public override void updateNearChange(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileIndex(x, y + 1, tileDepth) == Tile.TileAir.index) { world.setTile(x, y, Tile.TileAir, tileDepth); world.EntityAddingList.Add(new EntityFallingTile(x * World.tileSizeInPixels, y * World.tileSizeInPixels, index, tileDepth)); world.setTileForUpdate(x, y - 1, tileDepth); } }
public override TextureInfo getTextureInfo(int x, int y, World world, World.TileDepth tileDepth) { if (renderType == RenderType.custom) { return(new TextureInfo(get8(x8th, y8th), true)); } else { return(base.getTextureInfo(x, y, world, tileDepth)); } }
public void calculateTileFrame(Game game, int x, int y, World.TileDepth tileDepth) { if ((textureTileInfo) != null) { Tile tile = getTileObject(x, y, tileDepth); if (tile != null && inWorld(x, y)) { textureTileInfo[x, y, (int)tileDepth] = tile.getTextureInfo(x, y, this, tileDepth); } } }
public bool setTileWithUpdate(int x, int y, int index, World.TileDepth tileDepth) { if (setTile(x, y, index, tileDepth)) { TileNeedsUpdateMatrix[x, y, (int)tileDepth] = true; setTileForUpdate(x - 1, y, tileDepth); setTileForUpdate(x + 1, y, tileDepth); setTileForUpdate(x, y - 1, tileDepth); setTileForUpdate(x, y + 1, tileDepth); return(true); } return(false); }
public bool mineTileNoNearUpdate(int x, int y, ItemPick pick, World.TileDepth tileDepth) { Tile tile = getTileObject(x, y, tileDepth); int data = getTileDataNoCheck(x, y, tileDepth); if (setTile(x, y, Tile.TileAir.index, tileDepth)) { Entity e = new EntityItem(new Vector2((x) * World.tileSizeInPixels, (y) * World.tileSizeInPixels), tile.dropStack(this, pick, Game.rand, x, y, tileDepth)); tile.mine(this, x, y, data, pick, tileDepth); EntityAddingList.Add(e); return(true); } return(false); }
public override bool canBePlacedHereOverridable(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileIndex(x, y, tileDepth) != Tile.TileAir.index) { return(false); } for (int i = 0; i < restOns.Length; i++) { if (world.getTileObject(x + restOnX, y + restOnY, tileDepth).index == restOns[i].index) { return(true); } } return(false); }
public override void justPlaced(World world, int x, int y, World.TileDepth tileDepth) { bool right = Game.instance.currentWorld.player.facingRight; int k = 1; for (int i = 0; i < size.X; i++) { for (int j = size.Y - 1; j >= 0; j--) { world.setTileWithDataWithUpdate(x + i, y + j - (size.Y - 1), index, right?k:-k, tileDepth); k++; } } }
public override void justPlaced(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileDataNoCheck(x, y, tileDepth) != 0) { world.setTileWithDataWithUpdate(x, y, index, 0, tileDepth); world.setTileWithDataWithUpdate(x, y - 1, index, 0, tileDepth); world.setTileWithDataWithUpdate(x, y - 2, index, 0, tileDepth); } else { world.setTileWithDataWithUpdate(x, y - 1, index, 1, tileDepth); world.setTileWithDataWithUpdate(x, y - 2, index, 1, tileDepth); } updateDoor(Game.instance, stateClosed, x, y); }
public bool mineTile(int x, int y, ItemPick pick, World.TileDepth tileDepth) { if (!getTileObject(x, y, tileDepth).canBeDestroyed(this, x, y, tileDepth)) { return(false); } if (mineTileNoNearUpdate(x, y, pick, tileDepth)) { setTileForUpdate(x - 1, y, tileDepth); setTileForUpdate(x + 1, y, tileDepth); setTileForUpdate(x, y - 1, tileDepth); setTileForUpdate(x, y + 1, tileDepth); return(true); } return(false); }
public bool setTileWithData(int x, int y, int index, int data, World.TileDepth tileDepth) { if (inWorld(x, y)) { TileMatrix[x, y, (int)tileDepth] = index; TileDataMatrix[x, y, (int)tileDepth] = data; calculateTileFrame(Game.instance, x, y, tileDepth); calculateTileFrame(Game.instance, x + 1, y, tileDepth); calculateTileFrame(Game.instance, x - 1, y, tileDepth); calculateTileFrame(Game.instance, x, y + 1, tileDepth); calculateTileFrame(Game.instance, x, y - 1, tileDepth); setSkyTile(x); lightingNeedsUpdate = true; return(true); } return(false); }
public bool collisionCustom(World world, float x, float y, World.TileDepth tileDepth) { Rectangle r = new Rectangle((int)(position.X + x), (int)(position.Y + y), (int)size.X, (int)size.Y); for (int i = (r.Left / World.tileSizeInPixels); i < (r.Right / World.tileSizeInPixels) + 1; i++) { for (int j = (r.Top / World.tileSizeInPixels); j < (r.Bottom / World.tileSizeInPixels) + 1; j++) { Tile t = world.getTileObject(i, j, tileDepth); if (t != null) { if (t.isSolid(world, i, j)) { return(true); } } } } return(false); }
public override bool canBePlacedHereOverridable(World world, int x, int y, World.TileDepth tileDepth) { for (int i = 0; i < size.X; i++) { for (int j = size.Y - 1; j >= 0; j--) { if (!world.getTileObject(x + i, y + j - (size.Y - 1), tileDepth).isAir()) { return(false); } } } for (int i = 0; i < size.X; i++) { if (!world.isTileSolid(x + i, y + 1, tileDepth)) { return(false); } } return(true); }
public override void updateRandom(World world, int x, int y, World.TileDepth tileDepth) { if (world.getTileIndex(x - 1, y, tileDepth) == Tile.TileDirt.index) { growTo(world, x - 1, y, tileDepth); } if (world.getTileIndex(x + 1, y, tileDepth) == Tile.TileDirt.index) { growTo(world, x + 1, y, tileDepth); } if (world.getTileIndex(x, y - 1, tileDepth) == Tile.TileDirt.index) { growTo(world, x, y - 1, tileDepth); } if (world.getTileIndex(x, y + 1, tileDepth) == Tile.TileDirt.index) { growTo(world, x, y + 1, tileDepth); } if (world.getTileIndex(x - 1, y - 1, tileDepth) == Tile.TileDirt.index) { growTo(world, x - 1, y - 1, tileDepth); } if (world.getTileIndex(x + 1, y - 1, tileDepth) == Tile.TileDirt.index) { growTo(world, x + 1, y - 1, tileDepth); } if (world.getTileIndex(x + 1, y + 1, tileDepth) == Tile.TileDirt.index) { growTo(world, x + 1, y + 1, tileDepth); } if (world.getTileIndex(x - 1, y + 1, tileDepth) == Tile.TileDirt.index) { growTo(world, x - 1, y + 1, tileDepth); } }
public override void mine(World world, int x, int y, int data, ItemPick pick, World.TileDepth tileDepth) { int k = 1; int ii = 0; int jj = 0; bool kk = false; for (int i = 0; i < size.X; i++) { for (int j = size.Y - 1; j >= 0; j--) { if (k == data || k == -data) { ii = i; jj = j; kk = true; break; } k++; } if (kk) { break; } } for (int i = 0; i < size.X; i++) { for (int j = size.Y - 1; j >= 0; j--) { world.setTileWithUpdate(x + i - ii, y + j - jj, Tile.TileAir.index, tileDepth); } } }
public override bool isPlatform(World world, int x, int y, World.TileDepth tileDepth) { return(topIsPlatform && Math.Abs(world.getTileData(x, y, tileDepth)) % size.Y == 0); }