public void BuildRoom() { // Game Objects this.objects = new Dictionary <byte, Dictionary <int, GameObject> > { [(byte)LoadOrder.Platform] = new Dictionary <int, GameObject>(), [(byte)LoadOrder.Enemy] = new Dictionary <int, GameObject>(), [(byte)LoadOrder.Item] = new Dictionary <int, GameObject>(), [(byte)LoadOrder.TrailingItem] = new Dictionary <int, GameObject>(), [(byte)LoadOrder.Character] = new Dictionary <int, GameObject>(), [(byte)LoadOrder.Projectile] = new Dictionary <int, GameObject>() }; // Object Coordination and Cleanup this.markedForAddition = new List <GameObject>(); this.markedForRemoval = new List <GameObject>(); // Build Tilemap with Correct Dimensions short xCount, yCount; RoomGenerate.DetectRoomSize(Systems.handler.levelContent.data.rooms[roomID], out xCount, out yCount); this.tilemap = new TilemapLevel(xCount, yCount); // Additional Components this.colors = new ColorToggles(); this.trackSys = new TrackSystem(); this.roomExits = new RoomExits(); this.queueEvents = new QueueEvent(this); // Generate Room Content (Tiles, Objects) RoomGenerate.GenerateRoom(this, Systems.handler.levelContent, roomID); // Prepare the Full Track System this.trackSys.SetupTrackSystem(); }
// Check if an exact coordinate has a Blocking Square (Ground, BlockTile, HorizontalWall, etc.) public static bool IsBlockingCoord(TilemapLevel tilemap, int posX, int posY, DirCardinal dir) { short gridX = (short)(posX / (byte)TilemapEnum.TileWidth); short gridY = (short)(posY / (byte)TilemapEnum.TileHeight); return(CollideTile.IsBlockingSquare(tilemap, gridX, gridY, dir)); }
// Check if Grid Square is a Blocking Square (Ground, BlockTile, HorizontalWall, etc.) public static bool IsBlockingSquare(TilemapLevel tilemap, short gridX, short gridY, DirCardinal dir) { // Verify that a tile exists at the given location: byte[] tileData = tilemap.GetTileDataAtGrid(gridX, gridY); // If the tile was removed, never existed, or the main layer has no content: if (tileData == null || tileData[0] == 0) { return(false); } TileObject tileObj = Systems.mapper.TileDict[tileData[0]]; // Make sure the tile exists and collides, otherwise there's no point in testing any further: if (tileObj == null || !tileObj.collides) { return(false); } // Check if the Tile is Blocking: if (tileObj is Ground || tileObj is BlockTile || tileObj is HorizontalWall || tileObj is ButtonFixed || tileObj is SpringFixed || tileObj is Cannon || tileObj is Placer) { return(true); } if (tileObj is Ledge) { return(dir == DirCardinal.Down); } // Tile may be blocking against specific directions: if (dir == DirCardinal.Down) { if (tileObj is PlatformFixedUp) { return(true); } } return(false); }