Example #1
0
 public void Load(BinaryReader br, FileStream fs)
 {
     Header    = br.ReadInt32();
     Version   = br.ReadInt32();
     Reserved  = br.ReadInt32();
     AnimCount = br.ReadInt32();
     Anims     = new EanAnimation[AnimCount];
     for (var i = 0; i < AnimCount; i++)
     {
         Anims[i] = new EanAnimation();
         Anims[i].Load(br, fs);
     }
 }
Example #2
0
    public void BuildFromFile(string path, int index, float uvTime, Texture mainTex)
    {
        if (!File.Exists(path))
        {
            Debug.LogError("wrong ean file path!");
            return;
        }
        FileStream   fs  = new FileStream(path, FileMode.Open);
        BinaryReader br  = new BinaryReader(fs);
        EanFile      ean = new EanFile();

        ean.Load(br, fs);
        fs.Close();
        EanAnimation eanim = ean.Anims[index];

        frames       = new Vector2[eanim.TotalCount];
        UVDimensions = new Vector2[eanim.TotalCount];
        int cols      = eanim.TileCount;
        int rows      = (eanim.TotalCount + cols - 1) / cols;
        int cellCount = 0;


        int tWidth  = mainTex.width;
        int tHeight = mainTex.height;

        //Vector2 Oft = new Vector2((float)eanim.MipWidth / tWidth, (float)eanim.MipHeight / tHeight);

        for (int row = 0; row < rows; ++row)
        {
            for (int col = 0; col < cols && cellCount < eanim.TotalCount; ++col)
            {
                Vector2 cellSize = Vector2.zero;
                cellSize.x                = (float)eanim.Frames[cellCount].Width / tWidth;
                cellSize.y                = (float)eanim.Frames[cellCount].Height / tHeight;
                frames[cellCount].x       = (float)eanim.Frames[cellCount].X / tWidth;
                frames[cellCount].y       = 1f - (float)eanim.Frames[cellCount].Y / tHeight;
                UVDimensions[cellCount]   = cellSize;
                UVDimensions[cellCount].y = -UVDimensions[cellCount].y;
                ++cellCount;
            }
        }
    }
Example #3
0
    public void BuildFromFile(string path, int index, float uvTime, Texture mainTex)
    {
        if (!File.Exists(path))
        {
            Debug.LogError("wrong ean file path!");
            return;
        }
        FileStream   fileStream = new FileStream(path, FileMode.Open);
        BinaryReader br         = new BinaryReader(fileStream);
        EanFile      eanFile    = new EanFile();

        eanFile.Load(br, fileStream);
        fileStream.Close();
        EanAnimation eanAnimation = eanFile.Anims[index];

        frames       = new Vector2[eanAnimation.TotalCount];
        UVDimensions = new Vector2[eanAnimation.TotalCount];
        int tileCount = eanAnimation.TileCount;
        int num       = (eanAnimation.TotalCount + tileCount - 1) / tileCount;
        int num2      = 0;
        int width     = mainTex.width;
        int height    = mainTex.height;

        for (int i = 0; i < num; i++)
        {
            for (int j = 0; j < tileCount; j++)
            {
                if (num2 >= eanAnimation.TotalCount)
                {
                    break;
                }
                Vector2 zero = Vector2.zero;
                zero.x               = (float)(int)eanAnimation.Frames[num2].Width / (float)width;
                zero.y               = (float)(int)eanAnimation.Frames[num2].Height / (float)height;
                frames[num2].x       = (float)(int)eanAnimation.Frames[num2].X / (float)width;
                frames[num2].y       = 1f - (float)(int)eanAnimation.Frames[num2].Y / (float)height;
                UVDimensions[num2]   = zero;
                UVDimensions[num2].y = 0f - UVDimensions[num2].y;
                num2++;
            }
        }
    }
Example #4
0
 public void BuildFromFile(string path, int index, float uvTime, Texture mainTex)
 {
     if (!File.Exists(path))
     {
         Debug.LogError("wrong ean file path!");
     }
     else
     {
         FileStream   input = new FileStream(path, FileMode.Open);
         BinaryReader br    = new BinaryReader(input);
         EanFile      file  = new EanFile();
         file.Load(br, input);
         input.Close();
         EanAnimation animation = file.Anims[index];
         this.frames       = new Vector2[animation.TotalCount];
         this.UVDimensions = new Vector2[animation.TotalCount];
         int tileCount = animation.TileCount;
         int num2      = ((animation.TotalCount + tileCount) - 1) / tileCount;
         int num3      = 0;
         int width     = mainTex.width;
         int height    = mainTex.height;
         for (int i = 0; i < num2; i++)
         {
             for (int j = 0; j < tileCount; j++)
             {
                 if (num3 >= animation.TotalCount)
                 {
                     break;
                 }
                 Vector2 zero = Vector2.zero;
                 zero.x = ((float)animation.Frames[num3].Width) / ((float)width);
                 zero.y = ((float)animation.Frames[num3].Height) / ((float)height);
                 this.frames[num3].x       = ((float)animation.Frames[num3].X) / ((float)width);
                 this.frames[num3].y       = 1f - (((float)animation.Frames[num3].Y) / ((float)height));
                 this.UVDimensions[num3]   = zero;
                 this.UVDimensions[num3].y = -this.UVDimensions[num3].y;
                 num3++;
             }
         }
     }
 }
Example #5
0
    public void Load(BinaryReader br, FileStream fs)
    {
        Header = br.ReadInt32();
        Version = br.ReadInt32();
        Reserved = br.ReadInt32();
        AnimCount = br.ReadInt32();

        Anims = new EanAnimation[AnimCount];

        for (int i = 0; i < AnimCount; i++)
        {
            Anims[i] = new EanAnimation();
            Anims[i].Load(br, fs);
        }
    }