Advertisement
Guest User

Room architect - Medium house

a guest
Oct 25th, 2017
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.15 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using RoomArchitectEngine;
  5.  
  6. public class SmallHouse : RoomArchitect
  7. {
  8.     public Room living1, living2, playroom, toilets, bathroom, garage, bedroom2;
  9.     public Roof balconyRoof;
  10.     public GameObject pillar;
  11.  
  12.     public override void buildTemplate()
  13.     {
  14.         generateChildren = true;
  15.         if (Random.Range(0, 100) > 50)
  16.             generateChildren = false;
  17.         int outdoorTexture = (Random.Range(0, 100) > 50 ? 4 : 7);
  18.         applyMaterialsToChildren();
  19.         setTextures(3, outdoorTexture, 2, 2, 2, 5, 1, 0, outdoorTexture, true);
  20.         living1 = addRoom(new Position(5, 0, 3), 5, 6);
  21.         living2 = addRoom(living1.BottomRight.offsetBy(-2, 0, -2), 5, 5);
  22.         mergeRooms(living1, living2);
  23.         setTextures(outdoorTexture: 3);
  24.         toilets = addRoom(living1.TopRight, new Position(living1.TopRight.x - 1, 0, living2.TopRight.z));
  25.         setTextures(outdoorTexture: outdoorTexture);
  26.         bathroom = addRoom(toilets.BottomRight, new Position(living2.TopRight.x, 0, living1.TopRight.z));
  27.  
  28.         Room bedroom1 = addRoom(living2.TopRight.offsetBy(0, 0, -2), bathroom.TopRight.offsetBy(4, 0, -1)); //BUGGY
  29.  
  30.         playroom = addRoom(new Position(living1.BottomLeft.x, 1, living2.BottomLeft.z), living2.TopRight.offsetBy(y: 1));
  31.         bool balconyEast = (Random.Range(0, 100) > 50 ? true : false);
  32.         updstairbedRoom(balconyEast);
  33.         addDoor(living1.BottomLeft.offsetBy(x: 1), Directions.EAST);
  34.         addDoor(toilets.BottomLeft, Directions.EAST);
  35.         addDoor(bathroom.BottomLeft, Directions.EAST);
  36.         addDoor(living2.TopRight, Directions.SOUTH);
  37.         addDoor(living1.TopLeft.offsetBy(1), Directions.EAST);
  38.         addWindow(toilets.TopLeft, Directions.EAST, 0.5f, false, 1);
  39.         addWindow(bathroom.TopLeft, Directions.EAST, 0.5f, false, 1);
  40.         addWindow(bathroom.TopRight.offsetBy(-1), Directions.EAST, 0.5f, false, 1);
  41.         addWindow(living1.TopLeft.offsetBy(2), Directions.EAST);
  42.         addWindow(living2.BottomLeft.offsetBy(1), Directions.EAST);
  43.         addWindow(living2.BottomLeft.offsetBy(3), Directions.EAST);
  44.         addWindow(living2.BottomLeft.offsetBy(1, 1), Directions.EAST);
  45.         addWindow(living2.BottomLeft.offsetBy(3, 1), Directions.EAST);
  46.         addWindow(bedroom1.BottomLeft.offsetBy(1), Directions.EAST);
  47.         addWindow(bedroom1.TopLeft.offsetBy(1), Directions.EAST);
  48.         addWindow(bedroom1.BottomRight.offsetBy(z: 2), Directions.NORTH);
  49.         addWindow(playroom.BottomLeft.offsetBy(1), Directions.EAST);
  50.         addWindow(playroom.BottomLeft.offsetBy(z: 2), Directions.NORTH);
  51.         addWindow(playroom.BottomRight.offsetBy(z: 2), Directions.NORTH);
  52.         addFloorEverywhere();
  53.         setStairStyle(RAILSTYLE.FULL, false);
  54.         addSingleStair(living2.TopRight.offsetBy(-1, 0, -4), living2.TopRight.offsetBy(y: 1, z: -1), 10, Directions.NORTH);
  55.         setStairStyle(RAILSTYLE.FULL, true);
  56.         addSingleStair(living2.BottomLeft.offsetBy(-2, 0, -1).toVector3(RealDimensionsVector) - new Vector3(0, elevation, -0.4f), living2.BottomLeft.offsetBy(-1).toVector3(RealDimensionsVector), 4, Directions.NORTH);
  57.         setStairStyle(RAILSTYLE.NONE, true);
  58.         addSingleStair(living1.TopLeft.offsetBy(1).toVector3(RealDimensionsVector) - new Vector3(0, elevation, 0), living1.TopLeft.offsetBy(2, 0, 1).toVector3(RealDimensionsVector) - new Vector3(0, 0, 0.6f), 4, Directions.SOUTH);
  59.         List<Roof> roofs = mapRoofs();
  60.         setRoofStyle(ROOFTYPE.DEFAULT);
  61.         for (int i = 0; i < roofs.Count; i++)
  62.         {
  63.             if (roofs[i].position.y == 1 && (roofs[i].BottomRight == bedroom2.BottomLeft || roofs[i].position == bedroom2.BottomRight))
  64.                 balconyRoof = roofs[i];
  65.             else
  66.             {
  67.                 buildRoof(roofs[i]);
  68.                 setTextures(roofTexture: 5);
  69.             }
  70.         }
  71.         balcony(balconyEast);
  72.         addFence(new Position(living1.BottomLeft.x, 0, living2.BottomLeft.z), 2, Directions.NORTH, 20);
  73.         addFence(new Position(living1.BottomLeft.x, 0, living2.BottomLeft.z), 1, Directions.EAST, 10);
  74.         addFence(new Position(living2.BottomLeft.x, 0, living2.BottomLeft.z), 1, Directions.WEST, 10);
  75.         addFence(living2.TopRight.offsetBy(-1, 1, -4), 1, Directions.EAST, 10);
  76.         addFence(living2.TopRight.offsetBy(-1, 1, -4), 3, Directions.NORTH, 30);
  77.  
  78.         addFloor(new Position(living1.BottomLeft.x, 0, living2.BottomLeft.z),
  79.                     new Position(living2.BottomLeft.x, 0, living1.BottomLeft.z));
  80.         GameObject pillarInstance = GameObject.Instantiate(pillar);
  81.         pillarInstance.transform.SetParent(objectHolder.transform, false);
  82.         pillarInstance.transform.localPosition = playroom.BottomLeft.toVector3(RealDimensionsVector) + new Vector3(0.2f, -VerticalScale, 0.2f);
  83.         pillarInstance.gameObject.SetActive(true);
  84.     }
  85.  
  86.     public void balcony(bool balconyEast)
  87.     {
  88.         setTextures(roofTexture: 6);
  89.         setRoofStyle(ROOFTYPE.FLAT);
  90.         buildRoof(balconyRoof);
  91.         if (balconyEast)
  92.             addFence(balconyRoof.BottomRight, balconyRoof.size.z, Directions.NORTH, balconyRoof.size.z * 10);
  93.         else
  94.             addFence(balconyRoof.BottomLeft, balconyRoof.size.z, Directions.NORTH, balconyRoof.size.z * 10);
  95.         addFence(balconyRoof.TopLeft, balconyRoof.size.x, Directions.EAST, balconyRoof.size.z * 10);
  96.         addWideEntrance(balconyRoof.BottomLeft.offsetBy(1), balconyRoof.BottomLeft.offsetBy(3), doorModels[1]);
  97.  
  98.     }
  99.  
  100.     public void updstairbedRoom(bool balconyEast)
  101.     {
  102.         if (balconyEast)
  103.             bedroom2 = addRoom(living1.TopLeft.upOneFloor(), toilets.BottomLeft.upOneFloor());
  104.         else
  105.             bedroom2 = addRoom(toilets.BottomLeft.upOneFloor(), bathroom.TopRight.upOneFloor());
  106.         addWindow(bedroom2.TopLeft.offsetBy(1), Directions.EAST);
  107.         addWindow(bedroom2.BottomLeft.offsetBy(z: 1), Directions.NORTH);
  108.         addWindow(bedroom2.BottomRight.offsetBy(z: 1), Directions.NORTH);
  109.         addDoor(bedroom2.BottomLeft, Directions.EAST);
  110.     }
  111.  
  112.     public void Start()
  113.     {
  114.         //Build();
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement