コード例 #1
0
    private byte[] GetTile(byte[] tileset, byte[] mapData, int index)
    {
        var(pal, hFlip, vFlip, tile) = LzTilemapRun.ReadTileData(mapData, index, 32);
        var result = new byte[64];

        pal <<= 4;
        var tileStart = tile * 32;
        var pixels    = SpriteRun.GetPixels(tileset, tileStart, 1, 1, 4);

        for (int yy = 0; yy < 8; yy++)
        {
            for (int xx = 0; xx < 8; xx++)
            {
                var inX = hFlip ? 7 - xx : xx;
                var inY = vFlip ? 7 - yy : yy;
                result[yy * 8 + xx] = (byte)(pixels[inX, inY] + pal);
            }
        }
        return(result);
    }
コード例 #2
0
        public static RunStrategy GetStrategy(string format)
        {
            RunStrategy strategy;

            if (format == PCSRun.SharedFormatString)
            {
                strategy = new PCSRunContentStrategy();
            }
            else if (format.StartsWith(AsciiRun.SharedFormatString))
            {
                strategy = new AsciiRunContentStrategy();
            }
            else if (format == EggMoveRun.SharedFormatString)
            {
                strategy = new EggRunContentStrategy();
            }
            else if (format == PIERun.SharedFormatString)
            {
                strategy = new PIERunContentStrategy();
            }
            else if (format == PLMRun.SharedFormatString)
            {
                strategy = new PLMRunContentStrategy();
            }
            else if (format == XSERun.SharedFormatString)
            {
                strategy = new XseRunContentStrategy();
            }
            else if (format == BSERun.SharedFormatString)
            {
                strategy = new BseRunContentStrategy();
            }
            else if (format == ASERun.SharedFormatString)
            {
                strategy = new AseRunContentStrategy();
            }
            else if (format.StartsWith(OverworldSpriteListRun.SharedFormatString.Substring(0, OverworldSpriteListRun.SharedFormatString.Length - 1)))
            {
                strategy = new OverworldSpriteListContentStrategy(format);
            }
            else if (format == TrainerPokemonTeamRun.SharedFormatString)
            {
                strategy = new TrainerPokemonTeamRunContentStrategy();
            }
            else if (LzSpriteRun.TryParseSpriteFormat(format, out var spriteFormat))
            {
                strategy = new LzSpriteRunContentStrategy(spriteFormat);
            }
            else if (LzPaletteRun.TryParsePaletteFormat(format, out var paletteFormat))
            {
                strategy = new LzPaletteRunContentStrategy(paletteFormat);
            }
            else if (TilesetRun.TryParseTilesetFormat(format, out var tilesetFormat))
            {
                strategy = new TilesetRunContentStrategy(tilesetFormat);
            }
            else if (LzTilesetRun.TryParseTilesetFormat(format, out var lzTilesetFormat))
            {
                strategy = new LzTilesetRunContentStrategy(lzTilesetFormat);
            }
            else if (LzTilemapRun.TryParseTilemapFormat(format, out var tilemapFormat))
            {
                strategy = new LzTilemapRunContentStrategy(tilemapFormat);
            }
            else if (TilemapRun.TryParseTilemapFormat(format, out var tilemapFormat1))
            {
                strategy = new TilemapRunContentStrategy(tilemapFormat1);
            }
            else if (SpriteRun.TryParseSpriteFormat(format, out var spriteFormat1))
            {
                strategy = new SpriteRunContentStrategy(spriteFormat1);
            }
            else if (PaletteRun.TryParsePaletteFormat(format, out var paletteFormat1))
            {
                strategy = new PaletteRunContentStrategy(paletteFormat1);
            }
            else if (format.IndexOf("[") >= 0 && format.IndexOf("[") < format.IndexOf("]"))
            {
                strategy = new TableStreamRunContentStrategy();
            }
            else
            {
                return(null);
            }

            strategy.Format = format;
            return(strategy);
        }