Esempio n. 1
0
 public AbstractMusical()
 {
     Sound = null;
     Fade = null;
     Instances = new Dictionary<int, SoundEffectInstance>();
     State = SoundState.Stopped;
     NextState = SoundState.Stopped;
 }
Esempio n. 2
0
        public virtual void Resume(bool progressive, int fadeTime)
        {
            if (Instances.Count == 0 || State != SoundState.Paused)
                return;

            if (progressive)
            {
                Fade = new Fade((int) (Volume * 100), Fade.Type.IN, fadeTime, 0);
                Fade.Max = (int)(volume * 100);

                foreach (var instance in Instances.Values)
                    instance.Volume = 0;
            }

            foreach (var instance in Instances.Values)
                instance.Resume();

            State = SoundState.Playing;
            NextState = SoundState.Playing;
        }
Esempio n. 3
0
        public virtual int Play(bool progressive, int fadeTime, bool loop)
        {
            SoundEffectInstance instance = Sound.CreateInstance();

            instance.IsLooped = loop;

            if (progressive)
            {
                instance.Volume = 0;
                Fade = new Fade(0, Fade.Type.IN, fadeTime, 0);
                Fade.Max = (int)(volume * 100);
            }

            else
                instance.Volume = volume;

            instance.Play();

            Id = NextId++;

            Instances.Add(Id, instance);

            State = SoundState.Playing;
            NextState = SoundState.Playing;

            return Id;
        }
Esempio n. 4
0
        public virtual void Stop(bool progressive, int fadeTime)
        {
            if (Instances.Count == 0 || State == SoundState.Stopped)
                return;

            if (progressive)
            {
                Fade = new Fade((int)(Volume * 100), Fade.Type.OUT, 0, fadeTime);
                NextState = SoundState.Stopped;
            }
            else
            {
                foreach (var instance in Instances.Values)
                    instance.Stop();

                State = SoundState.Stopped;
                NextState = SoundState.Stopped;
            }
        }