public TileCode(TileCodes code, string message = null) { Code = code; Message = message; }
public Tile GenerateTile(TileCodes tileCode, Point position) { return(new Tile(tileCode, position, ref levelAtlas, TileDefinitions[tileCode])); }
protected void TileOffset(int px, int py, Vector2 start, TileCodes type) { Vector2 assignedTexture = new Vector2(start.x, start.y); int bumps = 0; if (blocks [Mathf.Min(px + 1, gridWidth - 1), py] == (byte)type) { assignedTexture.x++; ++bumps; } if(blocks[Mathf.Max (px - 1, 0), py] == (byte)type){ assignedTexture.x--; ++bumps; } if(blocks[px, Mathf.Min (py + 1, gridHeight - 1)] == (byte)type){ assignedTexture.y++; ++bumps; } if(blocks[px, Mathf.Max (py - 1, 0)] == (byte)type){ assignedTexture.y--; ++bumps; } //if bumps == 0, it is either right where it is, or it is an inner corner //if bumps == 1 or 2, it should be right where it is //if bumps == 3, it is a corner surrounded on 3 sides by the border texture //if bumps == 4, it is a single tile surrounded on all sides by its border if (bumps == 0) { //check if it is an inner corner //if it is, move the y component up by 3. //this moves it to its "flipped" version 1 row higher //then bump it left/right/up/down as needed if(blocks[Mathf.Min (px + 1, gridWidth - 1), Mathf.Min (py + 1, gridHeight - 1)] != blocks[px, py]){ assignedTexture.y += 3; assignedTexture.x--; assignedTexture.y--; GenSquare (px, py, assignedTexture); return; } if(blocks[Mathf.Min (px + 1, gridWidth - 1), Mathf.Max (py - 1, 0) ] != blocks[px, py]){ assignedTexture.y += 3; assignedTexture.x--; assignedTexture.y++; GenSquare (px, py, assignedTexture); return; } if(blocks[Mathf.Max (px - 1, 0) , Mathf.Min (py + 1, gridHeight - 1)] != blocks[px, py]){ assignedTexture.y += 3; assignedTexture.x++; assignedTexture.y--; GenSquare (px, py, assignedTexture); return; } if(blocks[Mathf.Max (px - 1, 0) , Mathf.Max (py - 1, 0) ] != blocks[px, py]){ assignedTexture.y += 3; assignedTexture.x++; assignedTexture.y++; GenSquare (px, py, assignedTexture); return; } } GenSquare (px, py, assignedTexture); }