Exemplo n.º 1
0
        private static void LoadFromElement(AnimationChainListSave toReturn, System.Xml.Linq.XElement element)
        {
            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "FileRelativeTextures":
                    toReturn.FileRelativeTextures = AsBool(subElement);
                    break;

                case "TimeMeasurementUnit":
                    toReturn.TimeMeasurementUnit =
                        (TimeMeasurementUnit)Enum.Parse(typeof(TimeMeasurementUnit), subElement.Value, true);
                    break;


                case "CoordinateType":
                    toReturn.CoordinateType =
                        (TextureCoordinateType)Enum.Parse(typeof(TextureCoordinateType), subElement.Value, true);
                    break;

                case "AnimationChain":
                    toReturn.AnimationChains.Add(AnimationChainSave.FromXElement(subElement));
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private static AnimationChainListSave DeserializeManually(string fileName)
        {
            AnimationChainListSave toReturn = new AnimationChainListSave();

            System.Xml.Linq.XDocument xDocument = null;

            using (var stream = FileManager.GetStreamForFile(fileName))
            {
                xDocument = System.Xml.Linq.XDocument.Load(stream);
            }

            System.Xml.Linq.XElement foundElement = null;

            foreach (var element in xDocument.Elements())
            {
                if (element.Name.LocalName == "AnimationChainArraySave")
                {
                    foundElement = element;
                    break;
                }
            }

            LoadFromElement(toReturn, foundElement);

            return(toReturn);
        }
        public static AnimationChainListSave ReadAnimationChainListSave(ContentReader input)
        {
            FlatRedBall.Content.AnimationChain.AnimationChainListSave newObject = new FlatRedBall.Content.AnimationChain.AnimationChainListSave();
            newObject.FileRelativeTextures = input.ReadBoolean();
            newObject.TimeMeasurementUnit  = (FlatRedBall.TimeMeasurementUnit)Enum.ToObject(typeof(FlatRedBall.TimeMeasurementUnit), (int)input.ReadInt32());
            int AnimationChainsCount = input.ReadInt32();

            for (int i = 0; i < AnimationChainsCount; i++)
            {
                newObject.AnimationChains.Add(ObjectReader.ReadObject <FlatRedBall.Content.AnimationChain.AnimationChainSave>(input));
            }
            return(newObject);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a "save" object from a regular animation chain list
        /// </summary>
        public static AnimationChainListSave FromAnimationChainList(AnimationChainList chainList)
        {
            AnimationChainListSave achlist = new AnimationChainListSave();

            achlist.FileRelativeTextures = chainList.FileRelativeTextures;
            achlist.TimeMeasurementUnit  = chainList.TimeMeasurementUnit;
            achlist.mFileName            = chainList.Name;

            List <AnimationChainSave> newChains = new List <AnimationChainSave>(chainList.Count);

            for (int i = 0; i < chainList.Count; i++)
            {
                AnimationChainSave ach = AnimationChainSave.FromAnimationChain(chainList[i], achlist.TimeMeasurementUnit);
                newChains.Add(ach);
            }
            achlist.AnimationChains = newChains;

            return(achlist);
        }
Exemplo n.º 5
0
        public static AnimationChainListSave FromFile(string fileName)
        {
            AnimationChainListSave toReturn = null;

            if (ManualDeserialization)
            {
                toReturn = DeserializeManually(fileName);
            }
            else
            {
                toReturn =
                    FileManager.XmlDeserialize <AnimationChainListSave>(fileName);
            }

            if (FileManager.IsRelative(fileName))
            {
                fileName = FileManager.MakeAbsolute(fileName);
            }

            toReturn.mFileName = fileName;

            return(toReturn);
        }