Exemplo n.º 1
0
        public static AvlTree<CharacterData> Parse(string filePath)
        {
            AvlTree<CharacterData> charDictionary = new AvlTree<CharacterData>();

              string[] lines = File.ReadAllLines(filePath);

              for (int i = HeaderSize; i < lines.Length; i += 1)
              {
            string firstLine = lines[i];
            string[] typesAndValues = firstLine.Split(" ".ToCharArray(),
            StringSplitOptions.RemoveEmptyEntries);

            // All the data comes in a certain order,
            // used to make the parser shorter
            CharacterData charData = new CharacterData
            {
              Id = GetValue(typesAndValues[1]),
              X = GetValue(typesAndValues[2]),
              Y = GetValue(typesAndValues[3]),
              Width = GetValue(typesAndValues[4]),
              Height = GetValue(typesAndValues[5]),
              XOffset = GetValue(typesAndValues[6]),
              YOffset = GetValue(typesAndValues[7]),
              XAdvance = GetValue(typesAndValues[8])
            };
            charDictionary.Add(((char)charData.Id).ToString(), charData);
              }
              return charDictionary;
        }
Exemplo n.º 2
0
 public CharacterSprite(Sprite sprite, CharacterData data)
 {
     Data = data;
       Sprite = sprite;
 }