Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private string[] GetOrientation(Map map, Address a)
- {
- string[] orientation = new string[2];
- orientation[0] = "Default";
- orientation[1] = "";
- /* Create list of tiles around centre tile
- N
- 0 1 2
- W 7 c 3 E
- 6 5 4
- S
- */
- string[] cellsaround = new string[8]; /* Holds the names of cell types around centre cell */
- /* Cell 0 */
- if( a.x-1 >= 0 && a.x-1 < map.size_X && a.y+1 >= 0 && a.y+1 < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[0] = map.cellsOnMap[a.x-1, a.y+1].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[0] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 1 */
- if( a.x >= 0 && a.x < map.size_X && a.y+1 >= 0 && a.y+1 < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[1] = map.cellsOnMap[a.x, a.y+1].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[1] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 2 */
- if( a.x+1 >= 0 && a.x+1 < map.size_X && a.y+1 >= 0 && a.y+1 < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[2] = map.cellsOnMap[a.x+1, a.y+1].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[2] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 3 */
- if( a.x+1 >= 0 && a.x+1 < map.size_X && a.y >= 0 && a.y < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[3] = map.cellsOnMap[a.x+1, a.y].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[3] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 4 */
- if( a.x+1 >= 0 && a.x+1 < map.size_X && a.y-1 >= 0 && a.y-1 < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[4] = map.cellsOnMap[a.x+1, a.y-1].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[4] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 5 */
- if( a.x >= 0 && a.x < map.size_X && a.y-1 >= 0 && a.y-1 < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[5] = map.cellsOnMap[a.x, a.y-1].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[5] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 6 */
- if( a.x-1 >= 0 && a.x-1 < map.size_X && a.y-1 >= 0 && a.y-1 < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[6] = map.cellsOnMap[a.x-1, a.y-1].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[6] = "OffMap"; /* Cell was off the map */
- }
- /* Cell 7 */
- if( a.x-1 >= 0 && a.x-1 < map.size_X && a.y >= 0 && a.y < map.size_Y ) { /* Make sure cell is within map bounds */
- cellsaround[7] = map.cellsOnMap[a.x-1, a.y].type; /* Grab the cell type from the map and store it */
- } else {
- cellsaround[7] = "OffMap"; /* Cell was off the map */
- }
- /* Rules list to determine what prefab type to place */
- string type = map.cellsOnMap[a.x,a.y].type;
- if( type == "Door" ) {
- /* Check if door should be vertical */
- if( cellsaround[1] == "Wall" && cellsaround[5] == "Wall" ) {
- orientation[0] = "Vertical"; orientation[1] = "Default";
- }
- /* Check if door should be horizontal */
- else if( cellsaround[3] == "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "Horizontal"; orientation[1] = "Default";
- }
- }
- else if( type == "Path" ) { /* Check what type of path tile should be used */
- orientation[0] = "Default"; /* No rules for floor tiles yet */
- }
- else if( type == "Wall" ) { /* Check what type of wall tile should be used */
- /* Core */
- if( cellsaround[1] == "Wall" && cellsaround[3] == "Wall" && cellsaround[5] == "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "Core"; orientation[1] = "Default";
- }
- /* Column */
- else if( cellsaround[1] == "Path" && cellsaround[3] == "Path" && cellsaround[5] == "Path" && cellsaround[7] == "Path" ) {
- orientation[0] = "Column"; orientation[1] = "Default";
- }
- /* Corner - North East */
- else if( cellsaround[1] == "Wall" && cellsaround[3] == "Wall" && cellsaround[5] != "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "Corner"; orientation[1] = "NE";
- }
- /* Corner - North West */
- else if( cellsaround[1] == "Wall" && cellsaround[3] != "Wall" && cellsaround[5] != "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "Corner"; orientation[1] = "NW";
- }
- /* Corner - South East */
- else if( cellsaround[1] != "Wall" && cellsaround[3] == "Wall" && cellsaround[5] == "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "Corner"; orientation[1] = "SE";
- }
- /* Corner - South West */
- else if( cellsaround[1] != "Wall" && cellsaround[3] != "Wall" && cellsaround[5] == "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "Corner"; orientation[1] = "SW";
- }
- /* Tip North */
- else if( cellsaround[1] != "Wall" && cellsaround[3] != "Wall" && cellsaround[5] == "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "Tip"; orientation[1] = "N";
- }
- /* Tip South */
- else if( cellsaround[1] == "Wall" && cellsaround[3] != "Wall" && cellsaround[5] != "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "Tip"; orientation[1] = "S";
- }
- /* Tip East */
- else if( cellsaround[1] != "Wall" && cellsaround[3] != "Wall" && cellsaround[5] != "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "Tip"; orientation[1] = "E";
- }
- /* Tip West */
- else if( cellsaround[1] != "Wall" && cellsaround[3] == "Wall" && cellsaround[5] != "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "Tip"; orientation[1] = "W";
- }
- /* One Sided North */
- else if( cellsaround[1] == "Wall" && cellsaround[3] == "Wall" && cellsaround[5] != "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "OneSided"; orientation[1] = "N";
- }
- /* One Sided South */
- else if( cellsaround[1] != "Wall" && cellsaround[3] == "Wall" && cellsaround[5] == "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "OneSided"; orientation[1] = "S";
- }
- /* One Sided East */
- else if( cellsaround[1] == "Wall" && cellsaround[3] == "Wall" && cellsaround[5] == "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "OneSided"; orientation[1] = "E";
- }
- /* One Sided West */
- else if( cellsaround[1] == "Wall" && cellsaround[3] != "Wall" && cellsaround[5] == "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "OneSided"; orientation[1] = "W";
- }
- /* Two Sided Vertical */
- else if( cellsaround[1] == "Wall" && cellsaround[3] != "Wall" && cellsaround[5] == "Wall" && cellsaround[7] != "Wall" ) {
- orientation[0] = "TwoSided"; orientation[1] = "V";
- }
- /* Two Sided Horizontal */
- else if( cellsaround[1] != "Wall" && cellsaround[3] == "Wall" && cellsaround[5] != "Wall" && cellsaround[7] == "Wall" ) {
- orientation[0] = "TwoSided"; orientation[1] = "V";
- }
- }
- return orientation; /* Return with what the tile prefab should be */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement