示例#1
0
        private static List<Encoder> InternalGetEncoders(GraphicsDevice device, BinaryFileReader reader)
        {
            List<Encoder> list = new List<Encoder>();
            int reader_count = reader.Read7BitEncodedInt();
            Regex regex = new Regex(@"\b([a-z0-9_]+)(,|$)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            for (int i = 0; i < reader_count; i++)
            {
                string reader_name = reader.ReadString();
                int reader_version = reader.ReadInt();
                string typeReaderShortName = regex.Match(reader_name).Groups[1].Value;
                if (typeReaderShortName.IndexOf("Reader") != -1)
                    typeReaderShortName = typeReaderShortName.Substring(0, typeReaderShortName.IndexOf("Reader"));
                bool isList = (reader_name.IndexOf("ListReader") != -1);

                Encoder encoder = new Encoder(typeReaderShortName, isList);
                list.Add(encoder);
            }

            return list;
        }
示例#2
0
 private static object InternalReadObject(GraphicsDevice device, BinaryFileReader reader, List<Encoder> encoders)
 {
     int encoder_index = reader.Read7BitEncodedInt();
     if (encoder_index <= 0)
         return null;
     Encoder encoder = encoders[encoder_index - 1];
     switch (encoder.Name)
     {
         case "SpriteFont":
             return InternalReadSpriteFont(device, reader, encoders);
         case "Texture2D":
             return InternalReadTexture(device, reader, encoders);
         case "Rectangle":
             if (encoder.IsList)
                 return InternalReadListRectangle(device, reader, encoders);
             else
                 return InternalReadRectangle(device, reader, encoders);
         case "Char":
             if (encoder.IsList)
                 return InternalReadListChar(device, reader, encoders);
             else
                 return InternalReadChar(device, reader, encoders);
         case "Vector3":
             if (encoder.IsList)
                 return InternalReadListVector3(device, reader, encoders);
             else
                 return InternalReadVector3(device, reader, encoders);
     }
     return null;
 }