Пример #1
0
        public static Frame[] GetAnimation(int body, int action, int direction, int hue, bool preserveHue)
        {
            if (preserveHue)
            {
                Animations.Translate(ref body);
            }
            else
            {
                Animations.Translate(ref body, ref hue);
            }
            FileIndex fileIndex;
            int       num1;

            switch (BodyConverter.Convert(ref body))
            {
            case 2:
                fileIndex = Animations.m_FileIndex2;
                num1      = body >= 200 ? 22000 + (body - 200) * 65 : body * 110;
                break;

            case 3:
                fileIndex = Animations.m_FileIndex3;
                num1      = body >= 300 ? (body >= 400 ? 35000 + (body - 400) * 175 : 33000 + (body - 300) * 110) : body * 65;
                break;

            default:
                fileIndex = Animations.m_FileIndex;
                num1      = body >= 200 ? (body >= 400 ? 35000 + (body - 400) * 175 : 22000 + (body - 200) * 65) : body * 110;
                break;
            }
            int    num2   = num1 + action * 5;
            int    index1 = direction > 4 ? num2 + (direction - (direction - 4) * 2) : num2 + direction;
            int    length1;
            int    extra;
            bool   patched;
            Stream input = fileIndex.Seek(index1, out length1, out extra, out patched);

            if (input == null)
            {
                return((Frame[])null);
            }
            bool         flip = direction > 4;
            BinaryReader bin  = new BinaryReader(input);

            ushort[] palette = new ushort[256];
            for (int index2 = 0; index2 < 256; ++index2)
            {
                palette[index2] = (ushort)((uint)bin.ReadUInt16() ^ 32768U);
            }
            int num3    = (int)bin.BaseStream.Position;
            int length2 = bin.ReadInt32();

            int[] numArray = new int[length2];
            for (int index2 = 0; index2 < length2; ++index2)
            {
                numArray[index2] = num3 + bin.ReadInt32();
            }
            bool onlyHueGrayPixels = (hue & 32768) == 0;

            hue = (hue & 16383) - 1;
            Hue hue1 = (Hue)null;

            if (hue >= 0 && hue < Hues.List.Length)
            {
                hue1 = Hues.List[hue];
            }
            Frame[] frameArray = new Frame[length2];
            for (int index2 = 0; index2 < length2; ++index2)
            {
                bin.BaseStream.Seek((long)numArray[index2], SeekOrigin.Begin);
                frameArray[index2] = new Frame(palette, bin, flip);
                if (hue1 != null)
                {
                    hue1.ApplyTo(frameArray[index2].Bitmap, onlyHueGrayPixels);
                }
            }
            return(frameArray);
        }