Exemplo n.º 1
0
 public cAudio(string audioName, bool loopingIn, bool playIn)
 {
     audioBuffer = mResource.LoadWav(audioName);
     looping     = loopingIn;
     audioSource = 0;
     play        = playIn;
 }
Exemplo n.º 2
0
        public void OnAction()
        {
            //Updates listener position every frame
            UpdateListener();

            foreach (oEntity entity in entityList)
            {
                //Retrieves list of components from current entity
                List <IComponent> components = entity.Components;

                //Retrieves transform component from current entity
                IComponent transformComponent = components.Find(delegate(IComponent component)
                {
                    return(component.ComponentMask == ComponentMasks.COMPONENT_TRANSFORM);
                });

                //Retrieves translation vector from the transform component
                Vector3 translation = ((cTransform)transformComponent).Translation;

                //Retrieves audio component from current entity
                IComponent audioComponent = components.Find(delegate(IComponent component)
                {
                    return(component.ComponentMask == ComponentMasks.COMPONENT_AUDIO);
                });

                //Retrieves needed values from the audio component
                oAudioBuffer audio     = ((cAudio)audioComponent).AudioBuffer();
                bool         looping   = ((cAudio)audioComponent).Looping();
                bool         isPlaying = ((cAudio)audioComponent).IsPlaying;

                //Checks if the audio component has already been assigned an audio source and assigns it one if not already assigned
                if (((cAudio)audioComponent).AudioSource == 0)
                {
                    AL.GenSources(1, out newSource);
                    ((cAudio)audioComponent).AudioSource = newSource;
                }

                //Checks if play variable is true, and if true plays the audio source
                if (((cAudio)audioComponent).Play == true)
                {
                    mySource = ((cAudio)audioComponent).AudioSource;

                    PlayAudio(looping, isPlaying, mySource, audio, translation);

                    ((cAudio)audioComponent).IsPlaying = true;
                }
            }
        }
Exemplo n.º 3
0
        public static oAudioBuffer LoadWav(string filename)
        {
            if (String.IsNullOrEmpty(filename))
            {
                throw new ArgumentException(filename);
            }

            oAudioBuffer audio;

            audioDictionary.TryGetValue(filename, out audio);

            if (audio == null)
            {
                audio = new oAudioBuffer();
                audio.LoadObject(filename);
                audioDictionary.Add(filename, audio);
            }
            return(audio);
        }
Exemplo n.º 4
0
 public void PlayAudio(bool isLooping, bool isPlaying, int source, oAudioBuffer audio, Vector3 position)
 {
     audio.Play(isLooping, isPlaying, source, position);
 }