public void RebuildRoom(RoomData room) { if (m_backgroundTiles == null) { m_backgroundTiles = new TileGridWidget(m_backgroundGroup, "BackgroundTiles", Screen.width, Screen.height, 3, 0.0f, 0.0f); } if (m_wallTiles == null) { m_wallTiles = new TileGridWidget(m_backgroundGroup, "WallTiles", Screen.width, Screen.height, 2, 0.0f, 0.0f); } if (m_backgroundObjectTiles == null) { m_backgroundObjectTiles = new TileGridWidget(m_backgroundGroup, "BackgroundObjects", Screen.width, Screen.height, 1, 0.0f, 0.0f); } if (m_foregroundObjectTiles == null) { m_foregroundObjectTiles = new TileGridWidget(m_foregroundGroup, "ForegroundObjects", Screen.width, Screen.height, 0, 0.0f, 0.0f); } // Covert the tile IDs over to sprite sheet indices RoomTemplate roomTemplate = room.StaticRoomData.RoomTemplate; TileGridTemplate floorGrid = roomTemplate.FloorGridTemplate; m_backgroundTiles.LoadMap( floorGrid.TileIndices, floorGrid.RowCount, floorGrid.ColomnCount, floorGrid.TileSetImageName, floorGrid.TileWidth, floorGrid.TileHeight); TileGridTemplate wallGrid = roomTemplate.WallGridTemplate; m_wallTiles.LoadMap( wallGrid.TileIndices, wallGrid.RowCount, wallGrid.ColomnCount, wallGrid.TileSetImageName, wallGrid.TileWidth, wallGrid.TileHeight); TileGridTemplate backgroundObjGrid = roomTemplate.BackgroundObjectsTemplate; m_backgroundObjectTiles.LoadMap( backgroundObjGrid.TileIndices, backgroundObjGrid.RowCount, backgroundObjGrid.ColomnCount, backgroundObjGrid.TileSetImageName, backgroundObjGrid.TileWidth, backgroundObjGrid.TileHeight); TileGridTemplate foregroundObjGroup = roomTemplate.BackgroundObjectsTemplate; m_foregroundObjectTiles.LoadMap( foregroundObjGroup.TileIndices, foregroundObjGroup.RowCount, foregroundObjGroup.ColomnCount, foregroundObjGroup.TileSetImageName, foregroundObjGroup.TileWidth, foregroundObjGroup.TileHeight); //TODO: rebuildRoom: Use animated tile entities from the room template /*var tileIdGrid:Array = room.staticRoomData.backgroundTileGrid; * var tileIndices:Array = new Array(); * for (var listIndex:uint = 0; listIndex < tileIdGrid.length; listIndex++) * { * var tileId:uint = tileIdGrid[listIndex]; * var tileDescriptor:TileDescriptor= currentTileSet.getTileDescriptorById(tileId); * var sheetIndex:int = tileDescriptor.sheetIndex; * * // Create an animated tile for any tile that has more than one frame * if (tileDescriptor.frameCount > 1) * { * var tileColomn:uint = listIndex % room.staticRoomData.tileColomns; * var tileRow:uint = uint(listIndex / room.staticRoomData.tileColomns); * var tileX:Number = Number(tileColomn) * currentTileSet.TileWidth; * var tileY:Number = Number(tileRow) * currentTileSet.TileHeight; * * new AnimatedTileWidget(m_backgroundGroup, currentTileSet, tileDescriptor, tileX, tileY); * } * * tileIndices.push(sheetIndex); * }*/ }