예제 #1
0
        //public ISoundChannel Play() { return availablePlayables[random.Next(availablePlayables.Count)].Play(); }
        //public ISoundChannel Play(float fadeTime) { return availablePlayables[random.Next(availablePlayables.Count)].Play(fadeTime); }
        //public ISoundChannel Play(Vector3 position, Vector3 velocity) { return availablePlayables[random.Next(availablePlayables.Count)].Play(position, velocity); }
        //public ISoundChannel Play(Func<Vector3> GetPosition, Func<Vector3> GetVelocity) { return availablePlayables[random.Next(availablePlayables.Count)].Play(GetPosition, GetVelocity); }
        //public ISoundChannel PlayLoopedWithIntervals(float minWaitTime, float maxWaitTime, float initialCooldown)
        //{
        //    var channel = new IntervalChannel
        //    {
        //        Playable = this,
        //        Is3DSound = false,
        //        MinWaitTime = minWaitTime,
        //        MaxWaitTime = maxWaitTime,
        //        _3DPanLevel = SoundManager.Instance._3DPanLevel,
        //        //_3DSpread = SoundManager.Instance._3DSpread,
        //    };
        //    channel.QueuePlayback(initialCooldown);
        //    return channel;
        //}
        public ISoundChannel PlayLoopedWithIntervals(float minWaitTime, float maxWaitTime, float initialCooldown, PlayArgs args)
        {
            bool is3DSound = true;

            if (args.GetPosition == null || args.GetVelocity == null)
            {
                is3DSound = false;
            }

            bool sampleIs3DSound = ((IInternalSoundResource)availablePlayables[0]).Is3DSound;

            if (is3DSound != sampleIs3DSound)
            {
                throw new Exception(String.Format("Trying to play {0}D-sound as a {1}-sound", sampleIs3DSound ? 3 : 2, is3DSound ? 3 : 2));
            }

            var channel = new IntervalChannel
            {
                Playable    = this,
                Is3DSound   = is3DSound,
                MinWaitTime = minWaitTime,
                MaxWaitTime = maxWaitTime
            };

            if (is3DSound)
            {
                channel._3DPanLevel = SoundManager.Instance._3DPanLevel;
                channel.GetPosition = args.GetPosition;
                channel.GetVelocity = args.GetVelocity;
            }
            if (args.FadeInTime > 0)
            {
                channel.QueuePlayback(initialCooldown, args.FadeInTime);
            }
            else
            {
                channel.QueuePlayback(initialCooldown);
            }
            return(channel);
        }
예제 #2
0
        //public ISoundChannel Play() { return availablePlayables[random.Next(availablePlayables.Count)].Play(); }
        //public ISoundChannel Play(float fadeTime) { return availablePlayables[random.Next(availablePlayables.Count)].Play(fadeTime); }
        //public ISoundChannel Play(Vector3 position, Vector3 velocity) { return availablePlayables[random.Next(availablePlayables.Count)].Play(position, velocity); }
        //public ISoundChannel Play(Func<Vector3> GetPosition, Func<Vector3> GetVelocity) { return availablePlayables[random.Next(availablePlayables.Count)].Play(GetPosition, GetVelocity); }
        //public ISoundChannel PlayLoopedWithIntervals(float minWaitTime, float maxWaitTime, float initialCooldown)
        //{
        //    var channel = new IntervalChannel
        //    {
        //        Playable = this,
        //        Is3DSound = false,
        //        MinWaitTime = minWaitTime,
        //        MaxWaitTime = maxWaitTime,
        //        _3DPanLevel = SoundManager.Instance._3DPanLevel,
        //        //_3DSpread = SoundManager.Instance._3DSpread,
        //    };
        //    channel.QueuePlayback(initialCooldown);
        //    return channel;
        //}
        public ISoundChannel PlayLoopedWithIntervals(float minWaitTime, float maxWaitTime, float initialCooldown, PlayArgs args)
        {
            bool is3DSound = true;
            if (args.GetPosition == null || args.GetVelocity == null)
                is3DSound = false;

            bool sampleIs3DSound = ((IInternalSoundResource)availablePlayables[0]).Is3DSound;
            if (is3DSound != sampleIs3DSound)
                throw new Exception(String.Format("Trying to play {0}D-sound as a {1}-sound", sampleIs3DSound ? 3 : 2, is3DSound ? 3 : 2));

            var channel = new IntervalChannel
            {
                Playable = this,
                Is3DSound = is3DSound,
                MinWaitTime = minWaitTime,
                MaxWaitTime = maxWaitTime
            };
            if (is3DSound)
            {
                channel._3DPanLevel = SoundManager.Instance._3DPanLevel;
                channel.GetPosition = args.GetPosition;
                channel.GetVelocity = args.GetVelocity;
            }
            if (args.FadeInTime > 0)
                channel.QueuePlayback(initialCooldown, args.FadeInTime);
            else
                channel.QueuePlayback(initialCooldown);
            return channel;
        }