Ejemplo n.º 1
0
	private void placeWalls(Tile tile, FullRoom f)
	{
		List<GameObject> wallsToAdd = new List<GameObject>();
		List<Vector3> posToAdd = new List<Vector3>();
		List<Quaternion> rotToAdd = new List<Quaternion>();
		for (int i = 0; i < 4; ++i)
		{
			if (tile.getDoor (i))
			{
				Object temp = new Object();
				temp = walls[0];
				switch(i)
				{
				case 1:
				{
					if (!doorPlaced (tile, i))
					{
						GameObject wall = new GameObject();
						wall = temp as GameObject;
						posToAdd.Add (new Vector3(roomPos.x + 20.005f, 5, roomPos.z + 12.5f));
						wallsToAdd.Add (wall);
						rotToAdd.Add (new Quaternion());
						//Instantiate(temp, new Vector3(roomPos.x + 20.005f, 5, roomPos.z + 12.5f), new Quaternion());
						tile.setPlacedDoor(i);
					}
					break;
				}
				case 3:
				{
					if (!doorPlaced (tile, i))
					{
						GameObject wall = new GameObject();
						wall = temp as GameObject;
						posToAdd.Add(new Vector3(roomPos.x - 20.005f, 5, roomPos.z - 12.5f));
						wallsToAdd.Add (wall);
						rotToAdd.Add(new Quaternion());
						//Instantiate(temp, new Vector3(roomPos.x - 20.005f, 5, roomPos.z - 12.5f), new Quaternion());
						tile.setPlacedDoor(i);
					}
					break;
				}
				case 0:
				{
					if (!doorPlaced (tile, i))
					{
						GameObject g = new GameObject();
						g = temp as GameObject;
						g.transform.Rotate(90, 0, 0);
						posToAdd.Add(new Vector3(roomPos.x - 12.5f, 5, roomPos.z - 20.005f));
						wallsToAdd.Add (g);
						rotToAdd.Add(g.transform.rotation);
						//Instantiate(g, new Vector3(roomPos.x - 12.5f, 5, roomPos.z - 20.005f), g.transform.rotation);
						g.transform.Rotate(-90, 0, 0);
						tile.setPlacedDoor(i);
					}
					break;
				}
				case 2:
				{
					if (!doorPlaced (tile, i))
					{
						GameObject g = new GameObject();
						g = temp as GameObject;
						g.transform.Rotate(90, 0, 0);
						posToAdd.Add( new Vector3(roomPos.x + 12.5f, 5, roomPos.z + 20.005f));
						
						wallsToAdd.Add (g);
						rotToAdd.Add(g.transform.rotation);
						//Instantiate(g, new Vector3(roomPos.x + 12.5f, 5, roomPos.z + 20.005f), g.transform.rotation);
						g.transform.Rotate(-90, 0, 0);
						tile.setPlacedDoor(i);
					}
					break;
				}
				}
			}
			else
			{
				Object temp = new Object();
				temp = walls[1];
				switch(i)
				{
				case 1:
				{
					GameObject wall = temp as GameObject;
					posToAdd.Add(new Vector3(roomPos.x + 20.005f, 5, roomPos.z));
					wallsToAdd.Add (wall);
					rotToAdd.Add(new Quaternion());
					//Instantiate(temp, new Vector3(roomPos.x + 20.005f, 5, roomPos.z), new Quaternion());
					break;
				}
				case 3:
				{
					GameObject wall = temp as GameObject;
					posToAdd.Add(new Vector3(roomPos.x - 20.005f, 5, roomPos.z));
					wallsToAdd.Add (wall);
					rotToAdd.Add(new Quaternion());
					//Instantiate(temp, new Vector3(roomPos.x - 20.005f, 5, roomPos.z), new Quaternion());
					break;
				}
				case 0:
				{
					GameObject g = temp as GameObject;
					g.transform.Rotate(90, 0, 0);
					posToAdd.Add(new Vector3(roomPos.x, 5, roomPos.z - 20.005f));
					wallsToAdd.Add (g);
					rotToAdd.Add(g.transform.rotation);
					//Instantiate(g, new Vector3(roomPos.x, 5, roomPos.z - 20.005f), g.transform.rotation);
					g.transform.Rotate(-90, 0, 0);
					break;
				}
				case 2:
				{
					GameObject g = temp as GameObject;
					g.transform.Rotate(90, 0, 0);
					posToAdd.Add(new Vector3(roomPos.x, 5, roomPos.z + 20.005f));
					wallsToAdd.Add (g);
					rotToAdd.Add(g.transform.rotation);
					//Instantiate(g, new Vector3(roomPos.x, 5, roomPos.z + 20.005f), g.transform.rotation);
					g.transform.Rotate(-90, 0, 0);
					break;
				}
				}
			}
		}
		f.setWalls (wallsToAdd, posToAdd, rotToAdd);
	}