Artemis.Engine.Graphics.Animation.LoadDirectoryReader.ReadElementAttributes C# (CSharp) Method

ReadElementAttributes() private method

private ReadElementAttributes ( XmlElement element ) : void
element System.Xml.XmlElement
return void
        private void ReadElementAttributes(XmlElement element)
        {
            Rectangle tile = new Rectangle(0, 0, 0, 0);
            foreach (XmlAttribute attrib in element.Attributes)
            {
                switch (attrib.Name)
                {
                    case NAME:
                        if (Tiles.ContainsKey(Path.GetFileNameWithoutExtension(attrib.Value)))
                        {
                            selectedImage = Path.GetFileNameWithoutExtension(attrib.Value);
                            tile.Width = Textures[selectedImage].Width;
                            tile.Height = Textures[selectedImage].Height;
                        }
                        else
                        {
                            LoadFromDirectory(attrib.Value);
                        }
                        break;

                    case TILE_GROUP:
                        GroupName = element.Value;
                        break;

                    case TOP_LEFT:
                        Match coords = Regex.Match(attrib.Value, INT_REGEX + SPACE_REGEX + INT_REGEX);

                        tile.X = Convert.ToInt32(coords.Groups[1].Value.Trim());
                        tile.Y = Convert.ToInt32(coords.Groups[5].Value.Trim());
                        break;

                    case DIMENSIONS:
                        Match dimensions = Regex.Match(attrib.Value, INT_REGEX + DIMENSIONS_SPECE_REGEX + INT_REGEX);

                        tile.Width = Convert.ToInt32(dimensions.Groups[1].Value.Trim());
                        tile.Height = Convert.ToInt32(dimensions.Groups[6].Value.Trim());
                        break;

                    default:
                        break;
                }
            }
            Tiles.Add(selectedImage, tile);
        }