Beispiel #1
0
    /// <summary>
    /// Reads and creates FurnitureAnimation from the prototype xml.
    /// </summary>
    private void ReadAnimationXml(XmlReader animationReader)
    {
        Animation = new FurnitureAnimation();
        while (animationReader.Read())
        {
            if (animationReader.Name == "Animation")
            {
                string state = animationReader.GetAttribute("state");
                float  fps   = 1;
                float.TryParse(animationReader.GetAttribute("fps"), out fps);
                bool looping = true;
                bool.TryParse(animationReader.GetAttribute("looping"), out looping);
                bool valueBased = false;
                bool.TryParse(animationReader.GetAttribute("valuebased"), out valueBased);

                // read frames
                XmlReader     frameReader       = animationReader.ReadSubtree();
                List <string> framesSpriteNames = new List <string>();
                while (frameReader.Read())
                {
                    if (frameReader.Name == "Frame")
                    {
                        framesSpriteNames.Add(frameReader.GetAttribute("name"));
                    }
                }

                Animation.AddAnimation(state, framesSpriteNames, fps, looping, valueBased);
            }
        }
    }
    /// <summary>
    /// Reads and creates FurnitureAnimation from the prototype xml.
    /// </summary>
    private void ReadAnimationXml(XmlReader animationReader)
    {
        Animation = new FurnitureAnimation();
        while (animationReader.Read())
        {
            if (animationReader.Name == "Animation")
            {
                string state   = animationReader.GetAttribute("state");
                float  fps     = float.Parse(animationReader.GetAttribute("fps"));
                bool   looping = bool.Parse(animationReader.GetAttribute("looping"));

                // read frames
                XmlReader     frameReader       = animationReader.ReadSubtree();
                List <string> framesSpriteNames = new List <string>();
                while (frameReader.Read())
                {
                    if (frameReader.Name == "Frame")
                    {
                        framesSpriteNames.Add(frameReader.GetAttribute("name"));
                    }
                }

                Animation.AddAnimation(state, framesSpriteNames, fps, looping);
            }
        }
    }