public void setup(GameObject _parent) { //reset the hash hash = 0; float xSize = _parent.GetComponent <Renderer>().bounds.size.x; float ySize = _parent.GetComponent <Renderer>().bounds.size.y; float zSize = _parent.GetComponent <Renderer>().bounds.size.z; //check for collisions with all other cells and calculate hash value of tile based of neighbours if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x - 1, (int)_parent.transform.position.z + 1) == 1) { hash += 1; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x, (int)_parent.transform.position.z + 1) == 1) { hash += 2; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x + 1, (int)_parent.transform.position.z + 1) == 1) { hash += 4; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x + 1, (int)_parent.transform.position.z) == 1) { hash += 16; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x + 1, (int)_parent.transform.position.z - 1) == 1) { hash += 128; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x, (int)_parent.transform.position.z - 1) == 1) { hash += 64; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x - 1, (int)_parent.transform.position.z - 1) == 1) { hash += 32; } if (worldGrid.getCellWorldSpace((int)_parent.transform.position.x - 1, (int)_parent.transform.position.z) == 1) { hash += 8; } }
private void setXFloors() { int rX = (int)pos.x; int rY = (int)pos.y; if (theLevel.getCellWorldSpace(rX, rY) != 1) { theLevel.setCellWorld(rX, rY, 1); createFloor(rX, rY); } if (theLevel.getCellWorldSpace(rX, rY + 1) != 1) { theLevel.setCellWorld(rX, rY + 1, 1); createFloor(rX, rY + 1); } if (theLevel.getCellWorldSpace(rX, rY - 1) != 1) { theLevel.setCellWorld(rX, rY - 1, 1); createFloor(rX, rY - 1); } }