//public ITextureResource[] FramesTextureResources => this.framesTextureResources; /// <summary> /// Generate textures from atlas. /// </summary> /// <param name="textureAtlasResource">Texture atlas.</param> /// <param name="columns">(optional)</param> /// <param name="rowsCount">(optional)</param> /// <param name="autoInverse"> /// (optional) Enable this if you want to append reverse animation. Please note - first and last /// frame will be displayed twice. /// </param> /// <returns></returns> public static ITextureResource[] CreateAnimationFrames( ITextureAtlasResource textureAtlasResource, byte?columns = null, byte?rowsCount = null, byte?onlySpecificRow = null, bool autoInverse = false) { var atlasColumnsCount = columns ?? textureAtlasResource.AtlasSize.ColumnsCount; var atlasRowsCount = rowsCount ?? textureAtlasResource.AtlasSize.RowsCount; int chunksCount; if (onlySpecificRow.HasValue) { chunksCount = atlasColumnsCount; } else { chunksCount = atlasColumnsCount * atlasRowsCount; } var result = new ITextureResource[chunksCount * (autoInverse ? 2 : 1)]; if (onlySpecificRow.HasValue) { var row = onlySpecificRow.Value; for (byte column = 0; column < atlasColumnsCount; column++) { result[column] = textureAtlasResource.Chunk(column, row); } } else { for (byte row = 0; row < atlasRowsCount; row++) { for (byte column = 0; column < atlasColumnsCount; column++) { result[row * atlasColumnsCount + column] = textureAtlasResource.Chunk(column, row); } } } if (autoInverse) { for (var i = 0; i < chunksCount; i++) { result[chunksCount + i] = result[chunksCount - i - 1]; } } return(result); }
protected override ITextureResource PrepareDefaultTexture(Type thisType) { return(ExplosionGroundTextureAtlas.Chunk(7, 2)); }