コード例 #1
0
        private void LoadAudioConfiguration()
        {
            // Default settings
            fadeTime = 0;
            fadeOn   = false;

            if (!File.Exists(AudioConstants.GetResourcesPath()))
            {
                return;
            }

            XmlDocument xmlDocument = XmlParser.LoadFromResources(AudioConstants.GetReadableRuntimeResourcesPath());
            XmlNode     rootNode    = XmlDataParser.FindUniqueTag(xmlDocument, "AudioData");

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

            XmlNode configNode = XmlDataParser.FindUniqueTagInChild(rootNode, "AudioConfiguration");

            _generalAudioSettings.Load(configNode);
            fadeTime = float.Parse(configNode.Attributes ["fade"].Value);
            fadeOn   = bool.Parse(configNode.Attributes ["fadeOn"].Value);
        }
コード例 #2
0
        public bool LoadAudioBlock(string blockName)
        {
            if (audioBlock.name == blockName)
            {
                return(false);
            }

            XmlDocument xmlDocument = XmlParser.LoadFromResources(AudioConstants.GetReadableRuntimeResourcesPath());
            XmlNode     rootNode    = XmlParser.GetRootTag(xmlDocument, AudioConstants.XML_ROOT);

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

            foreach (XmlNode item in XmlDataParser.FindAllTagsInChild(rootNode, "AudioBlock"))
            {
                if (blockName == item.Attributes ["Name"].Value)
                {
                    audioBlock.LoadFromXml(item);
                    audioBlock.LoadAudioResources();
                    break;
                }
            }

            return(true);
        }
コード例 #3
0
        private void LoadRuntimeChangableAudioSettings()
        {
            XmlDocument xmlDocument;
            bool        needSave = false;

            // Check if exists runtime/resources data file and load xmlDocument
            if (!File.Exists(AudioConstants.GetCachePath()))
            {
                if (!File.Exists(AudioConstants.GetResourcesPath()))
                {
                    SaveRuntimeChangableAudioSettings();
                    xmlDocument = XmlParser.LoadFromFile(AudioConstants.GetCachePath());
                    Debug.LogError("Couldn't find configuration file in resources");
                }
                else
                {
                    xmlDocument = XmlParser.LoadFromResources(AudioConstants.GetReadableRuntimeResourcesPath());
                    needSave    = true;
                }
            }
            else
            {
                xmlDocument = XmlParser.LoadFromFile(AudioConstants.GetCachePath());
            }

            // Parsing audio data
            if (!XmlParser.IsExistRootTag(xmlDocument, AudioConstants.XML_ROOT))
            {
                Debug.Log("Couldn't find root tag");
                return;
            }
            XmlNode rootNode = XmlParser.GetRootTag(xmlDocument, AudioConstants.XML_ROOT);

            if (!XmlDataParser.IsAnyTagInChildExist(rootNode, AudioConstants.XML_RUNTIME_TAG))
            {
                Debug.Log(string.Format("{0} tag not founded", AudioConstants.XML_RUNTIME_TAG));
                return;
            }
            XmlNode audioNode = XmlDataParser.FindUniqueTagInChild(rootNode, AudioConstants.XML_RUNTIME_TAG);

            _runtimeAudioSettings.Load(audioNode);
            _runtimeAudioSettings.SoundVolume = _runtimeAudioSettings.SoundVolume;

            if (needSave)
            {
                SaveRuntimeChangableAudioSettings();
            }
        }