void MoveRoom(Vector3 dir, float width, float length) { if (BuildingController.rooms > 0) { GameObject roomClone = (GameObject)Instantiate(room, new Vector3(xMod * 100, 0, zMod * 100), Quaternion.Euler(staticRot), this.transform.parent.transform.parent.transform.parent); roomClone.name = (gameObject.name + BuildingController.rooms); if (roomInRoom) { roomClone.GetComponent <RoomGenerate>().roomLength = roomProp.GetComponent <RoomGenerate>().roomLength; roomClone.GetComponent <RoomGenerate>().roomWidth = roomProp.GetComponent <RoomGenerate>().roomWidth; room.transform.position += direction * multiplier; } BuildingController.rooms--; BuildingController.AddRoom(roomClone); } else { BuildingController.PrintList(); } Destroy(gameObject); }
// Use this for initialization void Start() { GameObject northDoor = NorthDoor; GameObject eastDoor = EastDoor; GameObject southDoor = SouthDoor; GameObject westDoor = WestDoor; GameObject northWalker = NorthWalker; GameObject eastWalker = EastWalker; GameObject southWalker = SouthWalker; GameObject westWalker = WestWalker; destroyWalker = CheckRoomID(); switch (destroyWalker) { case 1: Object.Destroy(NorthWalker); break; case 2: Object.Destroy(WestWalker); break; case 3: Object.Destroy(SouthWalker); break; case 4: Object.Destroy(EastWalker); break; default: //do nothing break; } roomBox = GetComponent <BoxCollider>(); // if (roomWidth + roomLength == 0) // { // Debug.Log(gameObject.name + " is a room inside a room"); // roomWidth = Random.Range(lowerBounds, upperBounds); //roomLength = Random.Range(lowerBounds, upperBounds); // } // else // { // Debug.Log(gameObject.name + " branches off of "); roomWidth = Random.Range(lowerBounds, upperBounds); roomLength = Random.Range(lowerBounds, upperBounds); //} sMR.SetBlendShapeWeight(8, roomLength * 10); NDBlend.SetBlendShapeWeight(8, roomLength * 10); sMR.SetBlendShapeWeight(9, roomWidth * 10); EDBlend.SetBlendShapeWeight(9, roomWidth * 10); // Average Door Frames to center walker position for accurate walking behavior //northWalker.transform.position += (Vector3.forward * roomLength) * 10; //eastWalker.transform.position += (Vector3.right * roomWidth) * 10; //northWalker.transform.position = Vector3.forward * ((roomLength - 3.0f) * 10) + (Vector3.right * 7) + (Vector3.up * 0.55f); //eastWalker.transform.position = Vector3.right * ((roomWidth - 3.0f) * 10) + (Vector3.forward * 7) + (Vector3.up * 0.55f); northWalker.transform.position += new Vector3(0.0f, 0.0f, (roomLength * 10) - 0.02f); eastWalker.transform.position += new Vector3((roomWidth * 10) - 0.02f, 0.0f, 0.0f); northWalker.transform.position += new Vector3(0.0f, 0.0f, 0.0f); eastWalker.transform.position += new Vector3(0.0f, 0.0f, 0.0f); roomBox.size = new Vector3(0.14f + (roomWidth * 0.1f), 0.18f, 0.14f + (roomLength * 0.1f)); roomBox.center = new Vector3(-1 * (roomWidth * 0.05f) - 0.07f, 0.09f, -1 * (roomLength * 0.05f) + 0.07f); BuildingController.AddRoom(gameObject); }
void DetermineNextRoom(int i) { // GenerateRoom(0, 0, 0); // Previous Room Attach Script() // Room Type Assign Script() // Room Fit Script() if (BuildingController.rooms > 0) { //Debug.Log(direction + " * " + multiplier + " = " + (direction * multiplier)); GameObject roomClone = (GameObject)Instantiate(prefab, new Vector3(xMod, 0, zMod), Quaternion.Euler(staticRot), transform.parent.transform.parent); roomClone.name = (transform.parent.name + "_" + gameObject.name); float rmLngth = roomProp.GetComponent <RoomGenerate>().roomLength; float rmWdth = roomProp.GetComponent <RoomGenerate>().roomWidth; float rmCloneW = roomClone.GetComponent <RoomGenerate>().roomLength; float rmCloneL = roomClone.GetComponent <RoomGenerate>().roomWidth; if (xOffset) { roomClone.transform.position = transform.parent.position + Vector3.left * rmCloneW * 10; } if (yOffset) { roomClone.transform.position = transform.parent.position + Vector3.forward * rmCloneL * 10; } if (!xOffset || !yOffset) { switch (dir) { case CreateDir.North: roomClone.transform.position = transform.parent.position + Vector3.forward * (rmLngth + 1.4f) * 10; // Debug.Log("P:" + transform.parent.position + "C:" + roomClone.transform.position + "--" + rmCloneW); break; case CreateDir.East: roomClone.transform.position = transform.parent.position + Vector3.right * (rmWdth + 1.4f) * 10; break; default: roomClone.transform.position = transform.parent.position + Vector3.left * rmCloneW * 10; break; } } //roomClone.transform.localScale = Vector3.one * 100; //roomClone.transform.position -= direction * multiplier*100; // Debug.Log(roomProp.name + "_" + direction + " " + xMod + " " + zMod + " " + roomLength + "Long " + roomWidth + "Wide"); // Debug.Log(roomProp.name + "_" + rmLngth + " " + rmWdth); BuildingController.rooms--; BuildingController.AddRoom(roomClone); // MoveRoom(direction, rmWdth, rmLngth); } else { BuildingController.PrintList(); } Destroy(gameObject); }