Exemple #1
0
        private void LoadAudioSettings()
        {
            XmlDocument xmlDocument;
            bool        needSave = false;

            if (!XmlDataParser.ExistsXmlFile(BaseEngineConstants.BaseSettingsPath, BaseEngineConstants.AudioSettingsShortFileName))
            {
                if (!XmlDataParser.ExistsInResourcesXmlFile(BaseEngineConstants.AudioResConfigurationPath, BaseEngineConstants.AudioConfigurationShortFileName))
                {
                    SaveAudioSettings();
                    xmlDocument = XmlDataParser.LoadXmlDocumentFromFile(BaseEngineConstants.BaseSettingsPath, BaseEngineConstants.AudioSettingsShortFileName);
                }
                else
                {
                    xmlDocument = XmlDataParser.LoadXmlDocumentFromResources(BaseEngineConstants.AudioResConfigurationPath, BaseEngineConstants.AudioConfigurationShortFileName);
                    needSave    = true;
                }
            }
            else
            {
                xmlDocument = XmlDataParser.LoadXmlDocumentFromFile(BaseEngineConstants.BaseSettingsPath, BaseEngineConstants.AudioSettingsShortFileName);
            }

            if (!XmlDataParser.IsAnyTagExist(xmlDocument, "AudioData"))
            {
                Debug.Log("AudioData not founded");
                return;
            }
            XmlNode rootNode = XmlDataParser.FindUniqueTag(xmlDocument, "AudioData");

            if (!XmlDataParser.IsAnyTagInChildExist(rootNode, "AudioSettings"))
            {
                Debug.Log("AudioSettings  not founded");
                return;
            }

            XmlNode audioNode = XmlDataParser.FindUniqueTagInChild(rootNode, "AudioSettings");

            isMusic      = bool.Parse(audioNode.Attributes ["useMusic"].Value);
            musicVolumme = AEngineTool.ParseFloat(audioNode.Attributes ["musicVolume"].Value, 1f);

            isSound      = bool.Parse(audioNode.Attributes ["useSound"].Value);
            soundVolumme = AEngineTool.ParseFloat(audioNode.Attributes ["soundVolume"].Value, 1f);

            if (needSave)
            {
                SaveAudioSettings();
            }
        }
        private static void Load()
        {
            XmlDocument xmlDocument = XmlDataParser.LoadXmlDocumentFromFile("", "GameSettings");
            XmlNode     rootNode    = XmlDataParser.FindUniqueTag(xmlDocument, "GameSettings");

            if (!XmlDataParser.IsAnyTagInChildExist(rootNode, "Item"))
            {
                return;
            }

            data.Clear();
            foreach (XmlNode item in XmlDataParser.FindAllTagsInChild(rootNode, "Item"))
            {
                data.Add(item.Attributes ["Key"].Value, item.Attributes ["Value"].Value);
            }
        }