/// <summary> /// Creates a basic collidable tile. /// </summary> /// <param name="tile">Structure of the tile.</param> /// <param name="position">Position of the tile.</param> /// <param name="rotation">Rotation of the tile.</param> /// <param name="tileSize">Size of the file.</param> /// <param name="density">Density of the tile.</param> /// <returns>The created collidable tile</returns> public ITile CreateCollidableTile(CollidableTileStructure tile, Vector2 position, float rotation, Rectangle tileSize, float density) { ITile returnTile; var frontTexture = LoadTexture(tile.Texture); returnTile = CreateCollidableTile(tile.CollidableType, frontTexture, position, tileSize, rotation, tile.Density); returnTile.TileID = tile.TileID; return(returnTile); }
/// <summary> /// Trys to find a Tile in the TilesNotInUse list. /// Creates a new Tile if there are none free exist. /// </summary> /// <returns></returns> public ITile GetTile(CollidableTileStructure tileStructure, Vector2 position, Rectangle rectangleSize) { var foundTile = TilesNotInUse.Find(tile => tile.TileID == tileStructure.TileID); if (foundTile == null) { return(m_tileFactory.CreateCollidableTile(tileStructure, position, 0f, rectangleSize, 1f)); } //Remove from the list so it wont' get re-used until it is free TilesNotInUse.Remove(foundTile); foundTile.Position = ConvertUnits.ToSimUnits(position); return(foundTile); }
/// <summary> /// Creates a basic collidable tile. /// </summary> /// <param name="tile">Structure of the tile.</param> /// <param name="position">Position of the tile.</param> /// <param name="rotation">Rotation of the tile.</param> /// <param name="tileSize">Size of the file.</param> /// <param name="density">Density of the tile.</param> /// <returns>The created collidable tile</returns> public ITile CreateCollidableTile(CollidableTileStructure tile, Vector2 position, float rotation, Rectangle tileSize, float density) { ITile returnTile; var frontTexture = LoadTexture(tile.Texture); returnTile = CreateCollidableTile(tile.CollidableType, frontTexture, position, tileSize, rotation, tile.Density); returnTile.TileID = tile.TileID; return returnTile; }
/// <summary> /// Trys to find a Tile in the TilesNotInUse list. /// Creates a new Tile if there are none free exist. /// </summary> /// <returns></returns> public ITile GetTile(CollidableTileStructure tileStructure, Vector2 position, Rectangle rectangleSize) { var foundTile = TilesNotInUse.Find(tile => tile.TileID == tileStructure.TileID); if (foundTile == null) { return m_tileFactory.CreateCollidableTile(tileStructure, position, 0f, rectangleSize, 1f); } //Remove from the list so it wont' get re-used until it is free TilesNotInUse.Remove(foundTile); foundTile.Position = ConvertUnits.ToSimUnits(position); return foundTile; }