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);
            }
        }
Esempio n. 2
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);
            }
        }
        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;
                }
            }
        }