예제 #1
0
 public Level(int levelWidth, int levelHeight, List<Vector2> layout, Room[,] rooms)
 {
     this.levelWidth = levelWidth;
     this.levelHeight = levelHeight;
     this.layout = layout;
     this.rooms = rooms;
 }
예제 #2
0
        private void generateRoom(Room room)
        {
            int width = room.Width;
            int height = room.Height;
            Vector2 position = room.getPosition ();

            GameObject roomTransformObject = new GameObject ("Room" + roomIndice);
            Transform roomTransform = roomTransformObject.GetComponent<Transform> ();
            roomTransform.SetParent (environment);

            foreach (Facing facing in room.getFacings()) {
                int i, j;
                i = j = 0;

                switch (facing) {
                case Facing.EAST:
                    i = width;
                    goto case Facing.WEST;

                case Facing.WEST:
                    for (j = 0; j < height; j++) {
                        Transform wallInstance = (Transform)Instantiate (wall, new Vector3 (i + position.x, j + position.y, 0), Quaternion.identity);
                        wallInstance.SetParent (roomTransform);
                    }
                    break;

                case Facing.NORTH:
                    j = height;
                    goto case Facing.SOUTH;

                case Facing.SOUTH:
                    for (i = 0; i < width; i++) {
                        Transform wallInstance = (Transform)Instantiate (wall, new Vector3 (i + position.x, j + position.y, 0), Quaternion.identity);
                        wallInstance.SetParent (roomTransform);
                    }
                    break;

                }
            }

            roomIndice++;
        }
 private void addRoomToLayout(int x, int y)
 {
     layout.Add (new Vector2 (x, y));
     rooms [x, y] = new Room (new Vector2 (x * 10, y * 10));
 }