Example #1
0
 public CharacterSprite(Sprite2 sprite, CharacterData data)
 {
     this.Sprite = sprite;
     this.Data = data;
 }
Example #2
0
        private Dictionary<char, CharacterData> Parse(string fileName)
        {
            Dictionary<char, CharacterData> characterDictionary = new Dictionary<char, CharacterData>();
            string[] lines = File.ReadAllLines(fileName);

            int charCount = GetParameterValue(lines[3].Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1]);

            for (int i = _headerLines; i < (charCount + _headerLines); i++)
            {
                string line = lines[i];
                string[] parameters = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                CharacterData charData = new CharacterData
                {
                    Id          = GetParameterValue(parameters[1]),
                    X           = GetParameterValue(parameters[2]),
                    Y           = GetParameterValue(parameters[3]),
                    Width       = GetParameterValue(parameters[4]),
                    Height      = GetParameterValue(parameters[5]),
                    XOffset     = GetParameterValue(parameters[6]),
                    YOffset     = GetParameterValue(parameters[7]),
                    XAdvance    = GetParameterValue(parameters[8])
                };

                characterDictionary.Add((char)charData.Id, charData);
            }

            return characterDictionary;
        }