//checks if room needs doors/walls public void SetDoors(RoomNode _node) { Doors doorScript = _node.self.GetComponent <Doors>(); doorScript.nodeData = _node; for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { //check all nodes left, right, up and down from the current node if (x == 1 && y == 0 || x == 0 && y == 1 || x == -1 && y == 0 || x == 0 && y == -1) { int checkX = _node.gridX + x; int checkY = _node.gridY + y; //check if coordinates are actually on grid if (checkX >= 0 && checkX < _gridReference.arraySizeX && checkY >= 0 && checkY < _gridReference.arraySizeY) { RoomNode NeighbournNode = _gridReference.roomNodeArray[checkX, checkY]; //check types of surrounding nodes and determine if there should be a wall if (NeighbournNode.type != 0) { if (x == 1 && y == 0) { //doorScript.hasDoorEast = true; doorScript.doorDirections[1] = 1; } if (x == -1 && y == 0) { //doorScript.hasDoorWest = true; doorScript.doorDirections[3] = 1; } if (x == 0 && y == 1) { //doorScript.hasDoorNorth = true; doorScript.doorDirections[0] = 1; } if (x == 0 && y == -1) { //doorScript.hasDoorSouth = true; doorScript.doorDirections[2] = 1; } } } } } } doorScript.SetDoors(); // doorScript.SetInterior(interiors[Random.Range(0, interiors.Length)]); }