コード例 #1
0
        public Pig(string filename)
        {
            data = File.ReadAllBytes(filename);
            int ofs2 = Bits.GetInt32(data, 0);
            int ofs  = 4;

            if (ofs2 < 65536)
            { // classic pig
                ofs2 = 0;
                ofs  = 0;
            }
            int lvlTexCount = Bits.GetInt32(data, ofs);

            ofs      += 4;
            lvlTexIdx = new int[lvlTexCount];
            for (int i = 0; i < lvlTexCount; i++)
            {
                lvlTexIdx[i] = Bits.GetUInt16(data, ofs);
                ofs         += 2;
            }
            ofs         = ofs2;
            bitmapCount = Bits.GetInt32(data, ofs);
            Debug.WriteLine("bitmapCount " + bitmapCount);
            soundCount      = Bits.GetInt32(data, ofs + 4);
            ofs            += 8;
            dataOfs         = ofs + bitmapCount * 17 + soundCount * 20;
            bitmaps         = new PigBitmap[bitmapCount];
            bitmapIdxByName = new Dictionary <string, int>();
            for (int i = 0; i < bitmapCount; i++)
            {
                PigBitmap bitmap = new PigBitmap(data, ofs);
                ofs       += 17;
                bitmaps[i] = bitmap;
                //if ((bitmap.frame & 31) == 0)
                //    bitmapIdxByName.Add(bitmap.name, i);
            }
            sounds         = new PigSound[soundCount];
            soundIdxByName = new Dictionary <string, int>();
            for (int i = 0; i < soundCount; i++)
            {
                PigSound sound = new PigSound(data, ofs);
                ofs      += 20;
                sounds[i] = sound;
            }
        }
コード例 #2
0
 public void CopySound(PigSound sound, byte[] dest, int destOfs)
 {
     Array.Copy(data, dataOfs + sound.offset, dest, destOfs, sound.length);
 }