public void NeighbourLogic(TileDirections closestNeighbour, Wall currentWall, RandomeBackground backgroundScript, int x, int y) { if (currentWall != null) { //If its a edge tile this happens if (closestNeighbour.edge) { if (closestNeighbour.wallNeighbours == 4) { currentWall.innerWall = true; return; } if (closestNeighbour.downEdge) { currentWall.Rotate(1, true); } if (closestNeighbour.rightEdge) { currentWall.Rotate(2, true); } if (closestNeighbour.upEdge) { currentWall.Rotate(3, true); } if (closestNeighbour.leftEdge) { currentWall.Rotate(4, true); } return; } //This happens if you have three neighbours if (closestNeighbour.wallNeighbours == 3) { if (closestNeighbour.up) { currentWall.Rotate(1, true); } if (closestNeighbour.right) { currentWall.Rotate(2, true); } if (closestNeighbour.down) { currentWall.Rotate(3, true); } if (closestNeighbour.left) { currentWall.Rotate(4, true); } } //This is the logic for if you have 4 neighbours if (closestNeighbour.wallNeighbours == 4) { currentWall.innerWall = true; return; } //This happens if you have no neighbours if (closestNeighbour.wallNeighbours == 0) { currentWall.SoloWall(); } //This happens if you only have one neighbour if (closestNeighbour.wallNeighbours == 1) { //Pointing up if (closestNeighbour.left && closestNeighbour.up && closestNeighbour.right) { currentWall.EndWall(1); } //Pointing right if (closestNeighbour.up && closestNeighbour.right && closestNeighbour.down) { currentWall.EndWall(2); } //Pointing down if (closestNeighbour.right && closestNeighbour.down && closestNeighbour.left) { currentWall.EndWall(3); } //Pointing left if (closestNeighbour.down && closestNeighbour.left && closestNeighbour.up) { currentWall.EndWall(4); } } //This happens if you have 2 neighbours if (closestNeighbour.wallNeighbours == 2) { if (closestNeighbour.left && closestNeighbour.up) { //Top left corner currentWall.CornerLogic(1); } if (closestNeighbour.up && closestNeighbour.right) { //Top right corner currentWall.CornerLogic(2); } if (closestNeighbour.right && closestNeighbour.down) { //Bottom right corner currentWall.CornerLogic(3); } if (closestNeighbour.down && closestNeighbour.left) { //Bottom left corner currentWall.CornerLogic(4); } if (closestNeighbour.up && closestNeighbour.down) { //up and down is walls currentWall.CornerLogic(5); } if (closestNeighbour.right && closestNeighbour.left) { //left and right is walls currentWall.CornerLogic(6); } } } else { if (closestNeighbour.up) { backgroundScript.RoofSpikes(); } if (closestNeighbour.down) { backgroundScript.RandomPlant(); } if (closestNeighbour.up && !closestNeighbour.left && !closestNeighbour.right) { backgroundScript.canSpawnWater = true; waterSpawn.Add(backgroundScript); tmpX.Add(x); tmpY.Add(y); ceilSpawn.Add(new Vector3((-width / 2f + x + 0.5f), (-height / 2f + y), 0) * GameManager.globalScale); } } }
public void NeighbourLogic(TileDirections closestNeighbour, Wall currentWall, RandomeBackground backgroundScript) { if (currentWall != null) { //If its a edge tile this happens if (closestNeighbour.edge) { if (closestNeighbour.wallNeighbours == 4) { currentWall.innerWall = true; return; } if (closestNeighbour.downEdge) { currentWall.Rotate(1, true); } if (closestNeighbour.rightEdge) { currentWall.Rotate(2, true); } if (closestNeighbour.upEdge) { currentWall.Rotate(3, true); } if (closestNeighbour.leftEdge) { currentWall.Rotate(4, true); } return; } //This happens if you have three neighbours if (closestNeighbour.wallNeighbours == 3) { if (closestNeighbour.up) { currentWall.Rotate(1, true); } if (closestNeighbour.right) { currentWall.Rotate(2, true); } if (closestNeighbour.down) { currentWall.Rotate(3, true); } if (closestNeighbour.left) { currentWall.Rotate(4, true); } } //This is the logic for if you have 4 neighbours if (closestNeighbour.wallNeighbours == 4) { currentWall.innerWall = true; return; } //This happens if you have no neighbours if (closestNeighbour.wallNeighbours == 0) { currentWall.SoloWall(); } //This happens if you only have one neighbour if (closestNeighbour.wallNeighbours == 1) { //Pointing up if (closestNeighbour.left && closestNeighbour.up && closestNeighbour.right) { currentWall.EndWall(1); } //Pointing right if (closestNeighbour.up && closestNeighbour.right && closestNeighbour.down) { currentWall.EndWall(2); } //Pointing down if (closestNeighbour.right && closestNeighbour.down && closestNeighbour.left) { currentWall.EndWall(3); } //Pointing left if (closestNeighbour.down && closestNeighbour.left && closestNeighbour.up) { currentWall.EndWall(4); } } //This happens if you have 2 neighbours if (closestNeighbour.wallNeighbours == 2) { if (closestNeighbour.left && closestNeighbour.up) { //Top left corner currentWall.CornerLogic(1); } if (closestNeighbour.up && closestNeighbour.right) { //Top right corner currentWall.CornerLogic(2); } if (closestNeighbour.right && closestNeighbour.down) { //Bottom right corner currentWall.CornerLogic(3); } if (closestNeighbour.down && closestNeighbour.left) { //Bottom left corner currentWall.CornerLogic(4); } } } else { if (closestNeighbour.up) { backgroundScript.RoofSpikes(); } if (closestNeighbour.down) { backgroundScript.RandomPlant(); } } }