Exemplo n.º 1
0
        private static void ImportSound(AtsMotorNoise motorNoise, string path, string sectionName)
        {
            var directoryName = Path.GetDirectoryName(path);
            var soundTxt      = AtsParser.ParseIni(path, a => AtsStorage.ReadText(a));

            var keyValuePairs = soundTxt[sectionName].GetPairArray();


            var motorTrackList = new List <AtsMotorNoise.MotorTrack>();


            foreach (var keyValuePair in keyValuePairs)
            {
                var index    = int.Parse(keyValuePair.Key);
                var filePath = Path.Combine(directoryName, keyValuePair.Value);


                if (!File.Exists(filePath))
                {
                    AtsDebug.LogError(string.Format("{0}: The file does not exist: {1}, {2}", typeof(AtsMotorNoiseImporter).Name, index, filePath));
                    return;
                }

                var audio = new AtsMotorNoise.MotorAudio(new StreamReader(filePath).BaseStream);


                motorTrackList.Add(new AtsMotorNoise.MotorTrack(index, filePath, audio));
            }

            motorNoise.SetMotorTracks(motorTrackList.ToArray());
        }
Exemplo n.º 2
0
        private static void ImportSound(AtsMotorNoise motorNoise, string path, string sectionName)
        {
            var directoryName = Path.GetDirectoryName(path);
            var soundTxt      = AtsParser.ParseIni(path, AtsStorage.ReadText);

            var keyValuePairs = soundTxt[sectionName].GetPairArray();


            var motorTrackList = new List <AtsMotorNoise.MotorTrack>();


            foreach (var keyValuePair in keyValuePairs)
            {
                var index    = int.Parse(keyValuePair.Key);
                var filePath = Path.Combine(directoryName, keyValuePair.Value);


                if (!File.Exists(filePath))
                {
                    throw new FileNotFoundException(string.Format("{0}: The file does not exist: {1}, {2}", typeof(AtsMotorNoiseImporter).Name, index, filePath));
                }

                var audio = new AtsMotorNoise.MotorAudio(new StreamReader(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)).BaseStream);


                motorTrackList.Add(new AtsMotorNoise.MotorTrack(index, filePath, audio));
            }

            motorNoise.SetMotorTracks(motorTrackList.ToArray());
        }