Exemplo n.º 1
0
        // Constructor
        private Room(Dungeon dungeon, RoomType roomType, Coordinates coordinates, RoomPreset roomPreset)
        {
            this.dungeon  = dungeon;
            this.roomType = roomType;

            this.coordinates = coordinates;

            this.roomPreset = roomPreset;
        }
Exemplo n.º 2
0
        // On Player Enter Room
        public void OnEnterRoom(Room room)
        {
            // Check for Room
            if (room == null)
            {
                return;
            }

            // Generate Room Interior
            RoomPreset roomPreset = room.GetRoomPreset();

            if (roomPreset == null)
            {
                return;
            }
            List <RoomPresetObject> roomPresetObjects = roomPreset.GetRoomPresetObjects();

            // Clear GameObjects
            foreach (GameObject gameObject in gameObjects)
            {
                Destroy(gameObject);
            }
            gameObjects.Clear();

            Coordinates coordinates = room.GetCoordinates();

            int offsetx = coordinates.X * ((Room.WIDTH + Room.PADDING) * Tiles.TILE_SIZE);
            int offsety = coordinates.Y * ((Room.HEIGHT + Room.PADDING) * Tiles.TILE_SIZE);

            foreach (RoomPresetObject roomPresetObject in roomPresetObjects)
            {
                GameObject gameObject = roomPresetObject.GetGameObject();

                if (gameObject == null)
                {
                    continue;
                }
                int x = roomPresetObject.GetX() * Tiles.TILE_SIZE + offsetx;
                int y = roomPresetObject.GetY() * Tiles.TILE_SIZE + offsety;

                GameObject temp = Instantiate(gameObject, new Vector3(x, y, Settings.Depths.OBJECT_DEPTH), Quaternion.identity);

                // Assign to Container (if possible)
                if (temp != null && content != null)
                {
                    temp.transform.SetParent(content.transform);
                }
                gameObjects.Add(temp);
            }
        }
Exemplo n.º 3
0
 // Factory Create Method
 public static Room CreateRoom(Dungeon dungeon, RoomType roomType, Coordinates coordinates, RoomPreset roomPreset)
 {
     if (dungeon == null)
     {
         return(null);
     }
     return(new Room(dungeon, roomType, coordinates, roomPreset));
 }