Пример #1
0
        public void Save(SaveLoadParameters parameters)
        {
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding = System.Text.Encoding.UTF8;
            xmlSettings.Indent   = true;

            using (XmlWriter writer = CreateXmlWriter(xmlSettings))
            {
                writer.WriteStartDocument(true);
                writer.WriteStartElement("Input");
                writer.WriteAttributeString("playerOneDefault", parameters.playerOneDefault);
                writer.WriteAttributeString("playerTwoDefault", parameters.playerTwoDefault);
                writer.WriteAttributeString("playerThreeDefault", parameters.playerThreeDefault);
                writer.WriteAttributeString("playerFourDefault", parameters.playerFourDefault);
                foreach (InputConfiguration inputConfig in parameters.inputConfigurations)
                {
                    WriteInputConfiguration(inputConfig, writer);
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

#if UNITY_WINRT && !UNITY_EDITOR
            if (_filename != null && _outputStream != null && (_outputStream is MemoryStream))
            {
                UnityEngine.Windows.File.WriteAllBytes(_filename, ((MemoryStream)_outputStream).ToArray());
                _outputStream.Dispose();
            }
#endif
        }
Пример #2
0
        public SaveLoadParameters Load()
        {
            SaveLoadParameters parameters = new SaveLoadParameters();
            XmlDocument        doc        = CreateXmlDocument();

            if (doc != null)
            {
                parameters.playerOneDefault   = ReadAttribute(doc.DocumentElement, "playerOneDefault");
                parameters.playerTwoDefault   = ReadAttribute(doc.DocumentElement, "playerTwoDefault");
                parameters.playerThreeDefault = ReadAttribute(doc.DocumentElement, "playerThreeDefault");
                parameters.playerFourDefault  = ReadAttribute(doc.DocumentElement, "playerFourDefault");

                var inputConfigNodes = doc.DocumentElement.SelectNodes("InputConfiguration");
                foreach (XmlNode node in inputConfigNodes)
                {
                    parameters.inputConfigurations.Add(ReadInputConfiguration(node));
                }
            }

            return(parameters);
        }