public ObjTile[] RenderScreenTiles(int[] tiles, int width) { if (tiles is null) { throw new ArgumentNullException(nameof(tiles)); } if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if ((tiles.Length % width) != 0) { throw new ArgumentException(); } var height = tiles.Length / width; var result = new ObjTile[tiles.Length * 4]; for (var y = 0; y < height; y++) { var rowIndex = y * width; var rowIndex2 = rowIndex << 2; for (var x = 0; x < width; x++) { var x2 = x << 1; var index = rowIndex + x; var tileIndex = (byte)tiles[index]; var tile = Map16Data[tileIndex]; if (tileIndex == 0x56 || tileIndex == 0x57) { if (x > 0 && ((byte)tiles[index - 1]) == 0) { tile.TopLeft += 4; tile.BottomLeft += 4; } if (x + 1 < width && ((byte)tiles[index + 1]) == 0) { tile.TopRight += 4; tile.BottomRight += 4; } } result[rowIndex2 + x2] = tile.TopLeft; result[rowIndex2 + x2 + 1] = tile.TopRight; result[rowIndex2 + (width << 1) + x2] = tile.BottomLeft; result[rowIndex2 + (width << 1) + x2 + 1] = tile.BottomRight; } } return(result); }
public void RemoveEntity(WorldLocation _WorldLocation) { ObjTile Tile = W.chunkManager.GetTile(_WorldLocation); if (Tile.Entity == -1) { // do nothing } else { ObjChunk Chunk = W.chunkManager.GetChunk(_WorldLocation); Chunk.Entities.Remove(Tile.Entity); Tile.Entity = -1; } }
public void initTile(int x, int y) { objMap[x,y] = new ObjTile(); }
public ObjTile[] RenderBg2Tiles(int[] tiles, int width) { if (tiles is null) { throw new ArgumentNullException(nameof(tiles)); } if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if ((tiles.Length % width) != 0) { throw new ArgumentException(); } var height = (tiles.Length / width) + 2; var result = new ObjTile[width * height * 4]; for (var x = 0; x < width; x++) { var x2 = x << 1; var tile = Map16Data[0x100]; result[x2] = tile.TopLeft; result[x2 + 1] = tile.BottomLeft; result[(width << 1) + x2] = tile.TopRight; result[(width << 1) + x2 + 1] = tile.BottomRight; } for (var s = 0; s < 8; s++) { var screenIndex = s * 0x100; var screenIndex2 = s * 0x20; for (var y = 0; y < 0x0E; y++) { var rowIndex = screenIndex + (y * 0x10); var rowIndex2 = screenIndex2 + (((y + 1) << 1) * (width << 1)); for (var x = 0; x < 0x10; x++) { var x2 = x << 1; var index = rowIndex + x; var tileIndex = (byte)tiles[index]; if (tileIndex == 0xFF && index + 1 < tiles.Length) { if (index > 0 && (byte)tiles[index + 1] == 0xFF) { return(result); } } var tile = Map16Data[0x100 + tileIndex]; result[rowIndex2 + x2] = tile.TopLeft; result[rowIndex2 + x2 + 1] = tile.BottomLeft; result[rowIndex2 + (width << 1) + x2] = tile.TopRight; result[rowIndex2 + (width << 1) + x2 + 1] = tile.BottomRight; } } } return(result); }