Example #1
0
        public Scene(Reader reader)
        {
            Title = reader.ReadRSDKString();
            //Console.WriteLine("Stage Name: " + Title);

            byte[] buffer = new byte[5];

            ActiveLayer0 = reader.ReadByte();
            ActiveLayer1 = reader.ReadByte();
            ActiveLayer2 = reader.ReadByte();
            ActiveLayer3 = reader.ReadByte();
            Midpoint     = reader.ReadByte();

            reader.Read(buffer, 0, 2); //Read Width

            width = 0; height = 0;


            // Map width in 128 pixel units
            // In RSDKv1, it's one byte long
            width  = buffer[0];
            height = buffer[1];

            MapLayout = new ushort[height][];
            for (int i = 0; i < height; i++)
            {
                MapLayout[i] = new ushort[width];
            }

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    // 128x128 Block number is 16-bit
                    // Big-Endian in RSDKv1 and RSDKv2
                    reader.Read(buffer, 0, 2); //Read size
                    MapLayout[y][x] = (ushort)(buffer[1] + (buffer[0] << 8));
                }
            }


            // Read number of object types, Only RSDKv1 and RSDKv2 support this feature
            int ObjTypeCount = reader.ReadByte();

            for (int n = 0; n < ObjTypeCount; n++)
            {
                string name = reader.ReadRSDKString();

                objectTypeNames.Add(name);
                //Console.WriteLine(name);
            }

            // Read object data
            int ObjCount = 0;

            // 2 bytes, big-endian, unsigned
            ObjCount  = reader.ReadByte() << 8;
            ObjCount |= reader.ReadByte();

            Object.cur_id = 0;

            for (int n = 0; n < ObjCount; n++)
            {
                // Add object
                objects.Add(new Object(reader));
            }
            reader.Close();
        }