Exemple #1
0
 private void _PlayEffect(string song, float volume, float delta, string key)
 {
     if (this._rc.effects.ContainsKey(song))
     {
         SoundElement se   = null;
         AudioClip    clip = this._rc.effects[song];
         if (this._effects.ContainsKey(key) == false)
         {
             se             = new SoundElement();
             se.audioSource = this.AddGameObject <AudioSource>("AudioSourceEffects-" + song);
             this._effects.Add(key, se);
         }
         else
         {
             se = this._effects[key];
         }
         se.time = Time.time + delta;
         se.audioSource.volume = volume;
         se.audioSource.PlayOneShot(clip, volume);
     }
     else
     {
         Debug.LogError("[SOUNDMANAGER] EFFECT NOT FOUND " + song);
     }
 }
Exemple #2
0
        public void AddSound(string path, int x = 0, int y = 0, int w = 100, int h = 20)
        {
            if (!Sound.IsSound(path))
            {
                return;
            }

            // check if sound already exists
            soundElements.ForEach((SoundElement element) =>
            {
                if (element.baseSound.filename == path)
                {
                    return;
                }
            });

            var sound = new Sound(soundElements.Count() + 1, path);

            var NewElement = new SoundElement(sound);

            NewElement.Parent = g.MainFrame.global;

            NewElement.OnRemove += (SoundElement self) => soundElements.Remove(self);

            NewElement.SetPos(x, y);
            NewElement.SetSize(w, h);

            OnTrackAdd?.Invoke(NewElement);
        }
Exemple #3
0
 private static void WriteKey(string fileName, StringBuilder builder, SoundElement element, string keyPrefix = "")
 {
     if (!string.IsNullOrEmpty(element.FilePath))
     {
         builder.AppendLine($"{keyPrefix}{(element.Key is Enum ? ((Enum)element.Key).GetStringValues().First() : element.Key.ToString())} = {Utilities.MakeRelativePath(fileName, element.FilePath)}");
     }
 }
Exemple #4
0
        public static void PlayVisualSound(Vector3 origin, float loudness)
        {
            GameObject   s  = GameObject.Instantiate(PrefabHolder.SoundElement(), origin, Quaternion.identity);
            SoundElement sE = s.GetComponent <SoundElement>();

            sE.Setup(loudness);
        }
Exemple #5
0
        public SoundShaderTest()
        {
            sound    = SoundBuffer.Load("Assets/Panacea.ogg");
            instance = sound.Play(true);

            program        = new SoundVisualizerShaderProgram(sound.Buffer.ToArray(), Window.Size);
            program.Origin = Window.Center + (0, 50);
        }
Exemple #6
0
        private static void ParseNode(string basePath, XElement parentNode, SoundElement element)
        {
            foreach (XElement childNode in parentNode.Elements())
            {
                switch (childNode.Name.LocalName.ToLowerInvariant())
                {
                case "filename":
                    if (!childNode.Value.Any() || Path.ContainsInvalidChars(childNode.Value))
                    {
                        Interface.AddMessage(MessageType.Error, false, $"FileName {childNode.Value} contains illegal characters or is empty in XML node {parentNode.Name.LocalName} at line {((IXmlLineInfo)childNode).LineNumber}.");
                        return;
                    }

                    element.FilePath = Path.CombineFile(basePath, childNode.Value);
                    break;

                case "position":
                    string[] Arguments = childNode.Value.Split(',');
                    double   x = 0.0, y = 0.0, z = 0.0;

                    if (Arguments.Length >= 1 && Arguments[0].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[0], out x))
                    {
                        Interface.AddMessage(MessageType.Error, false, $"Sound radius X {Arguments[0]} in XML node {parentNode.Name.LocalName} at line {((IXmlLineInfo)childNode).LineNumber} is invalid.");
                        x = 0.0;
                    }

                    if (Arguments.Length >= 2 && Arguments[1].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[1], out y))
                    {
                        Interface.AddMessage(MessageType.Error, false, $"Sound radius Y {Arguments[1]} in XML node {parentNode.Name.LocalName} at line {((IXmlLineInfo)childNode).LineNumber} is invalid.");
                        y = 0.0;
                    }

                    if (Arguments.Length >= 3 && Arguments[2].Length > 0 && !NumberFormats.TryParseDoubleVb6(Arguments[2], out z))
                    {
                        Interface.AddMessage(MessageType.Error, false, $"Sound radius Z {Arguments[2]} in XML node {parentNode.Name.LocalName} at line {((IXmlLineInfo)childNode).LineNumber} is invalid.");
                        z = 0.0;
                    }

                    element.PositionX       = x;
                    element.PositionY       = y;
                    element.PositionZ       = z;
                    element.DefinedPosition = true;
                    break;

                case "radius":
                    double radius;

                    if (!NumberFormats.TryParseDoubleVb6(childNode.Value, out radius))
                    {
                        Interface.AddMessage(MessageType.Error, false, $"The sound radius {childNode.Value} in XML node {parentNode.Name.LocalName} at line {((IXmlLineInfo)childNode).LineNumber} is invalid.");
                    }

                    element.Radius        = radius;
                    element.DefinedRadius = true;
                    break;
                }
            }
        }
Exemple #7
0
 // methods
 public static void ReloadAll()
 {
     engine.StopSound(true);
     WindowSettings.GUI.SetupAllValues();
     SoundElement.RefontAllElements();
     SoundElement.RetextAllElements();
     WindowSettings.DeviceButton.ReloadDeviceButtons();
     MainFrame.UpdateElements();
 }
        public Button()
        {
            this.DefaultStyleKey = typeof(Button);

            this.SizeChanged += (s, e) => UpdateCorners();
            this.Click       += (s, e) => SoundElement?.Play();
            // subscribe to the single, global FlashTimer such that everything flashes synchronously
            Extensions.FlashTimer.Tick += FlashTimer_Tick;
            this.Unloaded += Button_Unloaded;
        }
Exemple #9
0
        public static Sound GetSound(SoundElement element)
        {
            try
            {
                return(Sounds[element]);
            }
            catch { }

            return(null);
        }
Exemple #10
0
 private static void WriteSoundNode(XElement parent, string nodeName, SoundElement element)
 {
     parent.Add(new XElement(nodeName,
                             new XElement("Key", element.Key),
                             new XElement("FilePath", element.FilePath),
                             new XElement("DefinedPosition", element.DefinedPosition),
                             new XElement("Position", $"{element.PositionX}, {element.PositionY}, {element.PositionZ}"),
                             new XElement("DefinedRadius", element.DefinedRadius),
                             new XElement("Radius", element.Radius)
                             ));
 }
 private void _PlayEffect(string song, SoundEffectSetup setup)
 {
     if (this.ycManager.ycConfig.SoundEffect && this.ycManager.dataManager.GetSoundEffect() == true)
     {
         if (this._rc.effects.ContainsKey(song))
         {
             string key = song + setup.key;
             if (this._effects.ContainsKey(key) == false || Time.time >= this._effects[key].time)
             {
                 SoundElement se   = null;
                 AudioClip    clip = this._rc.effects[song];
                 if (this._effects.ContainsKey(key) == false)
                 {
                     se             = new SoundElement();
                     se.audioSource = this.AddGameObject <AudioSource>("AudioSourceEffects-" + song);
                     this._effects.Add(key, se);
                 }
                 else
                 {
                     se = this._effects[key];
                 }
                 se.time = Time.time + setup.delta;
                 se.audioSource.volume = setup.volume;
                 se.audioSource.pitch  = setup.pitch;
                 if (setup.spacialParent != null)
                 {
                     se.audioSource.transform.SetParent(setup.spacialParent);
                     se.audioSource.transform.localPosition = Vector3.zero;
                     se.audioSource.maxDistance             = setup.spacialMaxDistance;
                     se.audioSource.spatialBlend            = 1f;
                 }
                 if (setup.loop == true)
                 {
                     se.audioSource.clip = clip;
                     se.audioSource.loop = setup.loop;
                     se.audioSource.Play();
                 }
                 else
                 {
                     se.audioSource.PlayOneShot(clip);
                 }
             }
         }
         else
         {
             Debug.LogError("[SOUNDMANAGER] EFFECT NOT FOUND " + song);
         }
     }
 }
 public void UnPauseEffect(string song)
 {
     if (this._effects.ContainsKey(song))
     {
         SoundElement se = this._effects[song];
         if (se.audioSource != null && se.audioSource.loop == true)
         {
             se.audioSource.UnPause();
         }
         else
         {
             Debug.LogError("[SOUNDMANAGER] EFFECT NOT FOUND OR NOT LOOPING " + song);
         }
     }
 }
Exemple #13
0
        public void PlayBgm(string soundIdentifier)
        {
            if (!IsEnable)
            {
                return;
            }

            var soundInfo = soundInfos.FirstOrDefault(x => x.Key == soundIdentifier && x.Value.SoundType == SoundType.Bgm).Value;

            if (soundInfo == null)
            {
                return;
            }

            ExternalResources.GetCueInfo(soundInfo.ResourcePath, soundInfo.CueName)
            .Subscribe(x => bgm = SoundManagement.SoundManagement.Play(SoundType.Bgm, x))
            .AddTo(Disposable);
        }
        public static void CollectItem(object i)
        {
            if (DAO.GetSound (SoundElement.CollectItem).PlayingOffset == TimeSpan.Zero) {
            SoundElement[] sounds = new SoundElement[]{
              SoundElement.Booty, SoundElement.CollectItem
            };

            SoundElement snd;

            if (Game.Rand.NextDouble () > 0.5f)
              snd = SoundElement.Booty;
            else
              snd = SoundElement.CollectItem;

            DAO.GetSound (snd).Volume = SoundVolume;
            DAO.GetSound (snd).Play ();
              }
        }
Exemple #15
0
        static void Main(string[] args)
        {
            // g.debug true if defined DEBUG
#if DEBUG
            g.Debug = true;
#endif

            var split = Application.ExecutablePath.Split('\\');
            g.CurrentPath = Application.ExecutablePath.Replace(split[split.Length - 1], "");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // init sound engine
            g.engine = new SBEngine();

            // init frame
            g.MainFrame = new Frame();

            g.Settings    = new WindowSettings();
            g.tracksFrame = new TracksFrame();

            g.hotkeyManager = new HotkeyManager();

            //
            // arg controller
            //
            ArgsController argsController = new ArgsController('-', args);
            var            enableConsole  = new ArgsController.Arg("enableConsole", ref argsController, null, () => { if (!g.Debug)
                                                                                                                      {
                                                                                                                          WinAPI.FreeConsole();
                                                                                                                      }
                                                                   });
            var appSettings = new ArgsController.Arg("appSettings", ref argsController, (ArgStruct arg) => g.engine.config.LoadAppPath(arg.value), () => g.engine.config.LoadApp());
            argsController.CheckArgs();

            // setup font
            SoundElement.paintFont = SoundElement.CreateFont();

            g.ReloadAll();
            Application.Run(g.MainFrame);
        }
Exemple #16
0
        public void OnKeyPress(Key key)
        {
            switch (key)
            {
            case Key.P:
                if (instance?.Source.State == SoundState.Paused)
                {
                    instance.Source.Play();
                }
                else
                {
                    instance = buffer.Play(false, volume: 0.5, pitch: 1);
                }
                break;

            case Key.N:
                buffer.Play(true);
                break;

            case Key.O:
                instance = bufferWithOffset.Play(true);
                break;

            case Key.U:
                instance?.Source.Pause();
                break;

            case Key.S:
                if (Keyboard.IsDown(Key.ShiftLeft))
                {
                    buffer.StopAll();
                }
                else
                {
                    instance?.Destroy();
                    instance = null;
                }
                break;
            }
        }
Exemple #17
0
        public override async Task <IEnumerable <SoundElement> > GetSoundElements()
        {
            var elements = new ConcurrentBag <SoundElement>();
            var samples  = _osuFile.Events.SampleInfo;

            if (samples == null)
            {
                return(new List <SoundElement>(elements));
            }

            await Task.Run(() =>
            {
                samples.AsParallel()
                .WithDegreeOfParallelism(Environment.ProcessorCount > 1 ? Environment.ProcessorCount - 1 : 1)
                .ForAll(sample =>
                {
                    var element = SoundElement.Create(sample.Offset, sample.Volume / 100f, 0,
                                                      _player.GetFileUntilFind(_sourceFolder,
                                                                               Path.GetFileNameWithoutExtension(sample.Filename))
                                                      );
                    elements.Add(element);
                });
            }).ConfigureAwait(false);

            var elementList = new List <SoundElement>(elements);

            if (PlaybackRate.Equals(1.5f) && !UseTempo)
            {
                var duration = MathEx.Max(_player.MusicChannel.ChannelEndTime,
                                          _player.HitsoundChannel.ChannelEndTime,
                                          TimeSpan.FromMilliseconds(samples.Count == 0 ? 0 : samples.Max(k => k.Offset))
                                          );
                _nightcore = new NightcoreTilingProvider(_osuFile, duration);
                elementList.AddRange(await _nightcore.GetSoundElements().ConfigureAwait(false));
            }

            return(elementList);
        }
    public void PlaySound(string musicName, float speedTime = 10f)
    {
        SoundElement found = foundSound(musicName);

        if (found.name != null && found.name != currentName)
        {
            //We have found a sound
            currentName        = found.name;
            timeToTransition   = speedTime;
            currTimeTransition = timeToTransition;
            AudioSource newAudio = gameObject.AddComponent(typeof(AudioSource)) as AudioSource;
            Sound2D.Adapt2DSound(newAudio);
            newAudio.maxDistance = maxDistance;
            newAudio.minDistance = minDistance;
            newAudio.clip        = found.clip;
            newAudio.volume      = 0f;
            newAudio.Play();
            newAudio.loop = found.loop;
            allSources.Add(newAudio);

            InitVolumes();
        }
    }
Exemple #19
0
        public static Sound GetSound(SoundElement element)
        {
            try {
            return Sounds [element];
              } catch {
              }

              return null;
        }
        internal SoundElementViewModel(SoundElement element)
        {
            CultureInfo culture = CultureInfo.InvariantCulture;

            Key = element
                  .ToReactivePropertyAsSynchronized(x => x.Key)
                  .AddTo(disposable);

            FilePath = element
                       .ToReactivePropertyAsSynchronized(x => x.FilePath)
                       .AddTo(disposable);

            DefinedPosition = element
                              .ToReactivePropertyAsSynchronized(x => x.DefinedPosition)
                              .AddTo(disposable);

            PositionX = element
                        .ToReactivePropertyAsSynchronized(
                x => x.PositionX,
                x => x.ToString(culture),
                x => double.Parse(x, NumberStyles.Float, culture),
                ignoreValidationErrorValue: true
                )
                        .SetValidateNotifyError(x =>
            {
                double result;
                string message;

                Utilities.TryParse(x, NumberRange.Any, out result, out message);

                return(message);
            })
                        .AddTo(disposable);

            PositionY = element
                        .ToReactivePropertyAsSynchronized(
                x => x.PositionY,
                x => x.ToString(culture),
                x => double.Parse(x, NumberStyles.Float, culture),
                ignoreValidationErrorValue: true
                )
                        .SetValidateNotifyError(x =>
            {
                double result;
                string message;

                Utilities.TryParse(x, NumberRange.Any, out result, out message);

                return(message);
            })
                        .AddTo(disposable);

            PositionZ = element
                        .ToReactivePropertyAsSynchronized(
                x => x.PositionZ,
                x => x.ToString(culture),
                x => double.Parse(x, NumberStyles.Float, culture),
                ignoreValidationErrorValue: true
                )
                        .SetValidateNotifyError(x =>
            {
                double result;
                string message;

                Utilities.TryParse(x, NumberRange.Any, out result, out message);

                return(message);
            })
                        .AddTo(disposable);

            DefinedRadius = element
                            .ToReactivePropertyAsSynchronized(x => x.DefinedRadius)
                            .AddTo(disposable);

            Radius = element
                     .ToReactivePropertyAsSynchronized(
                x => x.Radius,
                x => x.ToString(culture),
                x => double.Parse(x, NumberStyles.Float, culture),
                ignoreValidationErrorValue: true
                )
                     .SetValidateNotifyError(x =>
            {
                double result;
                string message;

                Utilities.TryParse(x, NumberRange.Any, out result, out message);

                return(message);
            })
                     .AddTo(disposable);
        }
        private async Task AddSingleHitObject(RawHitObject obj, HashSet <string> waves,
                                              ConcurrentBag <SoundElement> elements)
        {
            if (obj.ObjectType != HitObjectType.Slider)
            {
                var itemOffset = obj.ObjectType == HitObjectType.Spinner
                    ? obj.HoldEnd // spinner
                    : obj.Offset; // hold & circle
                var timingPoint = _osuFile.TimingPoints.GetLine(itemOffset);

                float balance = GetObjectBalance(obj.X);
                float volume  = GetObjectVolume(obj, timingPoint);

                var tuples = AnalyzeHitsoundFiles(obj.Hitsound, obj.SampleSet, obj.AdditionSet,
                                                  timingPoint, obj, waves);
                foreach (var(filePath, _) in tuples)
                {
                    var element = SoundElement.Create(itemOffset, volume, balance, filePath);
                    elements.Add(element);
                }
            }
            else // sliders
            {
                // edges
                bool forceUseSlide = obj.SliderInfo.EdgeSamples == null;
                foreach (var item in obj.SliderInfo.Edges)
                {
                    var itemOffset  = item.Offset;
                    var timingPoint = _osuFile.TimingPoints.GetLine(itemOffset);

                    float balance = GetObjectBalance(item.Point.X);
                    float volume  = GetObjectVolume(obj, timingPoint);

                    var hs = forceUseSlide
                        ? obj.Hitsound
                        : item.EdgeHitsound;
                    var addition = forceUseSlide
                        ? obj.AdditionSet
                        : item.EdgeAddition;
                    var sample = forceUseSlide
                        ? obj.SampleSet
                        : item.EdgeSample;
                    var tuples = AnalyzeHitsoundFiles(hs, sample, addition,
                                                      timingPoint, obj, waves);
                    foreach (var(filePath, _) in tuples)
                    {
                        var element = SoundElement.Create(itemOffset, volume, balance, filePath);
                        elements.Add(element);
                    }
                }

                // ticks
                var ticks = obj.SliderInfo.Ticks;
                foreach (var sliderTick in ticks)
                {
                    var itemOffset  = sliderTick.Offset;
                    var timingPoint = _osuFile.TimingPoints.GetLine(itemOffset);

                    float balance = GetObjectBalance(sliderTick.Point.X);
                    float volume  = GetObjectVolume(obj, timingPoint) * 1.25f; // ticks x1.25

                    var(filePath, _) = AnalyzeHitsoundFiles(HitsoundType.Tick, obj.SampleSet, obj.AdditionSet,
                                                            timingPoint, obj, waves).First();

                    var element = SoundElement.Create(itemOffset, volume, balance, filePath);
                    elements.Add(element);
                }

                // sliding
                {
                    var slideElements = new List <SoundElement>();

                    var startOffset = obj.Offset;
                    var endOffset   = obj.SliderInfo.Edges[obj.SliderInfo.Edges.Length - 1].Offset;
                    var timingPoint = _osuFile.TimingPoints.GetLine(startOffset);

                    float balance = GetObjectBalance(obj.X);
                    float volume  = GetObjectVolume(obj, timingPoint);

                    // start sliding
                    var tuples = AnalyzeHitsoundFiles(
                        obj.Hitsound & HitsoundType.SlideWhistle | HitsoundType.Slide,
                        obj.SampleSet, obj.AdditionSet,
                        timingPoint, obj, waves);
                    foreach (var(filePath, hitsoundType) in tuples)
                    {
                        int channel;
                        if (hitsoundType.HasFlag(HitsoundType.Slide))
                        {
                            channel = 0;
                        }
                        else if (hitsoundType.HasFlag(HitsoundType.SlideWhistle))
                        {
                            channel = 1;
                        }
                        else
                        {
                            continue;
                        }

                        var element = SoundElement.CreateLoopSignal(startOffset, volume, balance, filePath, channel);
                        slideElements.Add(element);
                    }

                    // change sample (will optimize if only adjust volume) by inherit timing point
                    var timingsOnSlider = _osuFile.TimingPoints.TimingList
                                          .Where(k => k.Offset > startOffset && k.Offset < endOffset)
                                          .ToList();

                    for (var i = 0; i < timingsOnSlider.Count; i++)
                    {
                        var timing     = timingsOnSlider[i];
                        var prevTiming = i == 0 ? timingPoint : timingsOnSlider[i - 1];
                        if (timing.Track != prevTiming.Track ||
                            timing.TimingSampleset != prevTiming.TimingSampleset)
                        {
                            volume = GetObjectVolume(obj, timing);
                            tuples = AnalyzeHitsoundFiles(
                                obj.Hitsound & HitsoundType.SlideWhistle | HitsoundType.Slide,
                                obj.SampleSet, obj.AdditionSet,
                                timing, obj, waves);
                            foreach (var(filePath, hitsoundType) in tuples)
                            {
                                SoundElement element;
                                if (hitsoundType.HasFlag(HitsoundType.Slide) && slideElements
                                    .Last(k => k.PlaybackType == PlaybackType.Loop)
                                    .FilePath == filePath)
                                {
                                    // optimize by only change volume
                                    element = SoundElement.CreateLoopVolumeSignal(timing.Offset, volume);
                                }
                                else
                                {
                                    int channel;
                                    if (hitsoundType.HasFlag(HitsoundType.Slide))
                                    {
                                        channel = 0;
                                    }
                                    else if (hitsoundType.HasFlag(HitsoundType.SlideWhistle))
                                    {
                                        channel = 1;
                                    }
                                    else
                                    {
                                        continue;
                                    }

                                    // new sample
                                    element = SoundElement.CreateLoopSignal(timing.Offset, volume, balance,
                                                                            filePath, channel);
                                }

                                slideElements.Add(element);
                            }

                            continue;
                        }

                        // optimize useless timing point
                        timingsOnSlider.RemoveAt(i);
                        i--;
                    }

                    // end slide
                    var stopElement  = SoundElement.CreateLoopStopSignal(endOffset, 0);
                    var stopElement2 = SoundElement.CreateLoopStopSignal(endOffset, 1);
                    slideElements.Add(stopElement);
                    slideElements.Add(stopElement2);
                    foreach (var slideElement in slideElements)
                    {
                        elements.Add(slideElement);
                    }
                }

                // change balance while sliding (not supported in original game)
                var trails = obj.SliderInfo.BallTrail;
                var all    = trails
                             .Select(k => new
                {
                    offset  = k.Offset,
                    balance = GetObjectBalance(k.Point.X)
                })
                             .Select(k => SoundElement.CreateLoopBalanceSignal(k.offset, k.balance));
                foreach (var balanceElement in all)
                {
                    elements.Add(balanceElement);
                }
            }

            await Task.CompletedTask;
        }
Exemple #22
0
 public SoundPath(SoundElement element, string path)
 {
     Name = element;
       Path = path;
 }
Exemple #23
0
 public SoundPath(SoundElement element, string path)
 {
     Name = element;
     Path = path;
 }
        public static void ThrowEnemy(object nothing)
        {
            SoundElement[] ThrowSounds = new SoundElement[]{
            SoundElement.AhoyMatey,
            SoundElement.AhoyMeHearties,
            SoundElement.Arr01,
            SoundElement.Arr02,
            SoundElement.Arr03,
            SoundElement.Arr04,
            SoundElement.Arr05,
            SoundElement.AvastYe,
            SoundElement.Aye,
            SoundElement.Blimey,
            SoundElement.BlowMeDown,
            SoundElement.BlowTheManDown,
            SoundElement.CleaveHimToTheBrisket,
            SoundElement.DeadMenTellNoTales,
            SoundElement.FeedTheFishes,
            SoundElement.Gargle,
            SoundElement.HeaveHo,
            SoundElement.HoHoHo,
            SoundElement.ScurvyDog,
            SoundElement.ShiverMeTimbers,
            SoundElement.TharSheBlows,
            SoundElement.WalkThePlank,
            SoundElement.Yarr01,
            SoundElement.Yarr02,
            SoundElement.Yarr03,
            SoundElement.Yarr04
              };

              int max = ThrowSounds.Length;
              int sound = Game.Rand.Next (max);
              DAO.GetSound (ThrowSounds [sound]).Volume = SoundVolume;
              DAO.GetSound (ThrowSounds [sound]).Play ();
        }
Exemple #25
0
 public override async Task <IEnumerable <SoundElement> > GetSoundElements()
 {
     return(new[] { SoundElement.Create(_delay, _control.Volume, _control.Balance, _audioPath) });
 }
Exemple #26
0
        private static void WriteNode(string fileName, XElement parent, string nodeName, SoundElement element)
        {
            XElement newNode = new XElement(nodeName);

            if (element != null && !string.IsNullOrEmpty(element.FilePath))
            {
                newNode.Add(new XElement("FileName", Utilities.MakeRelativePath(fileName, element.FilePath)));
            }
            else
            {
                return;
            }

            if (element.DefinedPosition)
            {
                newNode.Add(new XElement("Position", $"{element.PositionX}, {element.PositionY}, {element.PositionZ}"));
            }

            if (element.DefinedRadius)
            {
                newNode.Add(new XElement("Radius", element.Radius));
            }

            parent.Add(newNode);
        }
Exemple #27
0
 internal void Remove(SoundElement instance)
 {
     _instances.Remove(instance);
 }