Exemple #1
0
        public static RoomFormat BuildRoomData()
        {
            RoomFormat room = new RoomFormat {
                main = new Dictionary <string, Dictionary <string, ArrayList> >(),
                bg   = new Dictionary <string, Dictionary <string, ArrayList> >(),
                fg   = new Dictionary <string, Dictionary <string, ArrayList> >(),
                obj  = new Dictionary <string, Dictionary <string, ArrayList> >()
            };

            return(room);
        }
Exemple #2
0
        public static void GenerateRoom(RoomScene room, LevelContent levelContent, byte roomId)
        {
            // NOTE: If room properties are NULL, the LevelFormat probably broke and it needs to be updated (or level data was invalid structure).
            RoomFormat roomData = levelContent.data.rooms[roomId];

            if (roomData.bg != null)
            {
                RoomGenerate.GenerateTileLayer(room, roomData.bg, LayerEnum.bg);
            }
            if (roomData.main != null)
            {
                RoomGenerate.GenerateTileLayer(room, roomData.main, LayerEnum.main);
            }
            if (roomData.obj != null)
            {
                RoomGenerate.GenerateObjectLayer(room, roomData.obj);
            }
            if (roomData.fg != null)
            {
                RoomGenerate.GenerateTileLayer(room, roomData.fg, LayerEnum.fg);
            }

            // Build "Barrier Wall" around Level. Designed to protect against objects crossing tile path.
            short maxX = (short)(room.tilemap.XCount + (byte)TilemapEnum.GapLeft + (byte)TilemapEnum.GapRight - 1);
            short maxY = (short)(room.tilemap.YCount + (byte)TilemapEnum.GapUp + (byte)TilemapEnum.GapDown - 1);

            for (short y = 0; y <= maxY; y++)
            {
                room.tilemap.SetMainTile(0, y, (byte)TileEnum.BarrierWall, 0);
                room.tilemap.SetMainTile(maxX, y, (byte)TileEnum.BarrierWall, 0);
            }

            for (short x = 0; x <= maxX; x++)
            {
                room.tilemap.SetMainTile(x, 0, (byte)TileEnum.BarrierWall, 0);
                room.tilemap.SetMainTile(x, maxY, (byte)TileEnum.BarrierWall, 0);
            }
        }
Exemple #3
0
        public static void DetectRoomSize(RoomFormat roomData, out short xCount, out short yCount)
        {
            // Prepare Minimum Width and Height for Level
            xCount = (byte)TilemapEnum.MinWidth;
            yCount = (byte)TilemapEnum.MinHeight;

            // Scan the full level to determine it's size:
            if (roomData.bg != null)
            {
                RoomGenerate.DetectLayerSize(roomData.bg, ref xCount, ref yCount);
            }
            if (roomData.main != null)
            {
                RoomGenerate.DetectLayerSize(roomData.main, ref xCount, ref yCount);
            }
            if (roomData.obj != null)
            {
                RoomGenerate.DetectLayerSize(roomData.obj, ref xCount, ref yCount);
            }
            if (roomData.fg != null)
            {
                RoomGenerate.DetectLayerSize(roomData.fg, ref xCount, ref yCount);
            }
        }
Exemple #4
0
        public void DeleteTileOnLayer(LayerEnum layerEnum, byte roomID, short gridX, short gridY)
        {
            RoomFormat roomData = this.data.rooms[roomID];

            string strX = gridX.ToString();
            string strY = gridY.ToString();

            if (layerEnum == LayerEnum.obj && roomData.obj.ContainsKey(strY))
            {
                roomData.obj[strY].Remove(strX);
            }
            else if (layerEnum == LayerEnum.main && roomData.main.ContainsKey(strY))
            {
                roomData.main[strY].Remove(strX);
            }
            else if (layerEnum == LayerEnum.fg && roomData.fg.ContainsKey(strY))
            {
                roomData.fg[strY].Remove(strX);
            }
            else if (layerEnum == LayerEnum.bg && roomData.bg.ContainsKey(strY))
            {
                roomData.bg[strY].Remove(strX);
            }
        }
Exemple #5
0
        public void DeleteTile(byte roomID, short gridX, short gridY)
        {
            RoomFormat roomData = this.data.rooms[roomID];

            string strX = gridX.ToString();
            string strY = gridY.ToString();

            if (roomData.obj.ContainsKey(strY))
            {
                roomData.obj[strY].Remove(strX);
            }
            if (roomData.main.ContainsKey(strY))
            {
                roomData.main[strY].Remove(strX);
            }
            if (roomData.fg.ContainsKey(strY))
            {
                roomData.fg[strY].Remove(strX);
            }
            if (roomData.bg.ContainsKey(strY))
            {
                roomData.bg[strY].Remove(strX);
            }
        }
Exemple #6
0
 public static Dictionary <string, Dictionary <string, ArrayList> > GetLayerData(RoomFormat roomData, LayerEnum layerEnum)
 {
     if (layerEnum == LayerEnum.main)
     {
         return(roomData.main);
     }
     if (layerEnum == LayerEnum.obj)
     {
         return(roomData.obj);
     }
     if (layerEnum == LayerEnum.bg)
     {
         return(roomData.bg);
     }
     if (layerEnum == LayerEnum.fg)
     {
         return(roomData.fg);
     }
     return(null);
 }