Exemplo n.º 1
0
        private void ToggleSuck(bool isOn)
        {
            _suckPending = isOn;

            if (isBlowing)
            {
                return;
            }

            if (isOn)
            {
                _audioComponent?.Play(3);
            }

            if (!powered)
            {
                return;
            }

            ToggleSuckEffects(isOn);
            isSucking = isOn;

            if (!isOn && _blowPending)
            {
                isBlowing = true;
                ToggleBlowEffects(true);
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public void Play(AudioClip clip, float volumeScale)
        {
            IAudio currentAudio = audioSources[random.Next(audioSources.Count)];

            currentAudio.SetAudioPosition(position);
            currentAudio.Play(clip, volumeScale);
        }
Exemplo n.º 3
0
    public void PlayHealthLoadedSFX()
    {
        IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>();

        audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound(healthFinishedSFX));
        audioPlayer.Play();
    }
Exemplo n.º 4
0
    public void PlayShieldBuildSFX()
    {
        IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>();

        audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("CocoonBuildingSFX"));
        audioPlayer.Play();
    }
Exemplo n.º 5
0
 private void cmdPlay_Click(object sender, EventArgs e)
 {
     if (m_Sound != null)
     {
         m_Sound.Play(chkLoop.Checked);
     }
     UpdateControls();
 }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public void Play(float localVolumeScale)
        {
            UnityEngine.AudioClip clip = clipProvider.GetNextClip();
            float volumeScale          = localVolumeScale * LocalVolume * MasterVolume;

            GetAudio();
            currentAudio?.Play(clip, volumeScale);
        }
Exemplo n.º 7
0
        private void AudioSuckHandler(bool toggle)
        {
            if (_audioComponent == null)
            {
                return;
            }

            if (toggle)
            {
                _audioComponent.Play(0);
                _audioComponent.PlayWithDelay(1, 0.71f);
            }
            else
            {
                _audioComponent.Stop(1);
                _audioComponent.Play(2);
            }
        }
Exemplo n.º 8
0
 // Update is called once per frame
 void Update()
 {
     if (interactable)
     {
         if (inputActions.Player.Fire.triggered &&
             !cb.GetIsHooked())
         {
             AttachCord();
         }
         else if (cordAttached && !cb.GetRopeBent() && inputActions.Player.Fire.triggered)
         {
             DetachCord();
         }
         else if ((cb.GetIsHooked() && !cordAttached || cb.GetRopeBent()) && inputActions.Player.Fire.triggered)
         {
             audio.Play(2);
         }
     }
 }
Exemplo n.º 9
0
        public override void OnUpdateFrame(OpenTK.FrameEventArgs e)
        {
            timeaccum += e.Time;
            double every = 0.2;

            while (timeaccum >= every)
            {
                audio.Play("rail" + ((++i % 4) + 1) + ".wav");
                timeaccum -= every;
            }
        }
Exemplo n.º 10
0
        public void HandlePlayerAtack(Models.Unit.Player.IPlayer player, IEnemy target)
        {
            var successfulHit = HandleAttack(player, target);

            if (successfulHit)
            {
                audio.Play((Sound)(7 + randomProvider.Next(3)));
                if (target.Dead || OnePunchMode)
                {
                    EnemyDied(target);
                    Engine.KillCounter++;
                    audio.Play(Sound.EnemyDie);
                }
            }
            else
            {
                //should be dodge sound
                //Audio.Play(Sound.GameOver);
            }
        }
Exemplo n.º 11
0
        private void UpdateWidgetsMouse(IForm form)
        {
            selectedWidget = null;
            float mousex = ((float)Mouse.X / d_MainWindow.Width) * ConstWidth;
            float mousey = ((float)Mouse.Y / d_MainWindow.Height) * ConstHeight;

            for (int i = 0; i < form.Widgets.Count; i++)
            {
                Widget b = form.Widgets[i];
                if (b.Rect.Contains(mousex, mousey))
                {
                    selectedWidget = i;
                }
            }
            if (mouseleftclick && selectedWidget != null)
            {
                var w = form.Widgets[selectedWidget.Value];
                if (w.Click != null)
                {
                    w.Click();
                    d_Audio.Play("destruct.wav");
                }
                if (w.IsTextbox)
                {
                    typingfield = selectedWidget.Value;
                }
                if (w.IsScrollbar)
                {
                    Widget b            = form.Widgets[selectedWidget.Value];
                    float  scrollheight = (b.Rect.Height - (40 * 2)) / (b.ScrollbarMax + 1);
                    float  scrollpos    = b.Rect.Y + ((float)b.ScrollbarValue / (b.ScrollbarMax + 1)) * (b.Rect.Height - 40 * 2) + 40;
                    if (mousey > scrollpos + scrollheight)
                    {
                        b.ScrollbarValue++;
                        if (b.ScrollbarValue > b.ScrollbarMax)
                        {
                            b.ScrollbarValue = b.ScrollbarMax;
                        }
                    }
                    if (mousey < scrollpos)
                    {
                        b.ScrollbarValue--;
                        if (b.ScrollbarValue < 0)
                        {
                            b.ScrollbarValue = 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
    public void OnInteract(InputAction.CallbackContext context)
    {
        if (context.performed && GameStateManager.instance.GetCurrentGameState() == GameStates.LevelClear && inRange && hasActivated == false)
        {
            IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>();
            audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("CarEngineSFX"));
            audioPlayer.Play();

            InitStateManager.instance.BeginNewState(InitStates.LoadMainMenu);
            InGamePrompt.instance.HidePrompt();
            InGamePrompt.instance.ShowPrompt();
            hasActivated = true;
        }
    }
Exemplo n.º 13
0
        public virtual void UpdateResourceSelection(MenuClickArgs args)
        {
            if (args.Data != null && args.Data is ExperienceResource)
            {
                ExperienceResource resource = (ExperienceResource)args.Data;
                if (resource.ResourceType == ResourceType.MUSIC)
                {   //Selection.Music = Array.Find(m_musicList, item => item.Clip == ((AudioResource)resource).Clip).Clip;
                    Selection.Music = ((AudioResource)resource).Clip;

                    AudioArgs audioStopArgs = new AudioArgs(null, AudioType.MUSIC)
                    {
                        FadeTime = 1.0f,
                        Done     = () =>
                        {
                            AudioClip audioClip = Selection.Music;
                            AudioArgs audioArgs = new AudioArgs(audioClip, AudioType.MUSIC)
                            {
                                FadeTime = 1
                            };
                            m_audio.Play(audioArgs);
                        }
                    };

                    m_audio.Stop(audioStopArgs);

                    //    var music = m_commonResource.GetResource(ResourceType.MUSIC, resource.Category);
                    //    Selection.Music = ((AudioResource)Array.Find(music, item => ((AudioResource)item).Clip == ((AudioResource)resource).Clip)).Clip;
                }


                if (resource.ResourceType == ResourceType.LOCATION)
                {
                    Selection.Location = resource.Name;
                }
            }
        }
Exemplo n.º 14
0
        private static void Audio()
        {
            ServiceLocator.ProvideService(typeof(LoggingAudioEngine), false);
            log.Info("Provided service");

            IAudioEngine audioEngine = ServiceLocator.GetService <IAudioEngine>();

            log.Info("Got service " + audioEngine);

            IAudio audio = audioEngine.Add("voice", AudioType.Voice, AudioFormat.MP3, File.ReadAllBytes(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "audio" + Path.DirectorySeparatorChar + "voice.mp3"));

            log.Info("Got audio " + audio);

            audio.Volume = 0.15d;
            audio.Play(true);
            log.Info("Playing audio");

            audio = audioEngine.Add("music", AudioType.Music, AudioFormat.MP3, File.ReadAllBytes(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "audio" + Path.DirectorySeparatorChar + "music.mp3"));
            log.Info("Got audio2 " + audio);

            audio.Volume = 0.15d;
            audio.Play(false);
            log.Info("Playing audio2");
        }
Exemplo n.º 15
0
    //---------------------------------------------------------
    //Interfaces
    //---------------------------------------------------------
    void IBreakable.Damage(float damage, BaseEnemy interfacingEnemy)
    {
        DamageTask(damage);
        if (damageVFX)
        {
            SpawnDamgeVFX(interfacingEnemy.transform);
        }
        IAudio audioPlayer = ObjectPoolManager.Spawn(audioPlayerPrefab, transform.position).GetComponent <IAudio>();

        audioPlayer.SetUpAudioSource(AudioManager.instance.GetSound("ApplianceAttacked"));
        audioPlayer.Play();
        if (!isFixed)
        {
            interfacingEnemy.GetComponent <IBreakable>().ObjectIsBroken();
        }
    }
Exemplo n.º 16
0
        private void Play(string filePath)
        {
            // return if play is auto play is disabled
            if (!autoPlayCheckBox.Checked)
            {
                return;
            }

            player = BassProxy.Instance;
            if (player != null)
            {
                player.Stop();
                player.OpenFile(filePath);
                if (player.CanPlay)
                {
                    player.Play();
                }
                else
                {
                    Debug.WriteLine("Failed playing using Un4Seen Bass, trying to use mplayer ...");

                    float[] audioData = Mirage.AudioFileReader.Decode(filePath, Analyzer.SAMPLING_RATE, Analyzer.SECONDS_TO_ANALYZE);
                    if (audioData != null && audioData.Length > 0)
                    {
                        player = NAudioProxy.GetWaveOutInstance();
                        if (player != null)
                        {
                            NAudioFloatArrayProvider provicer = new NAudioFloatArrayProvider(Analyzer.SAMPLING_RATE, audioData, 2);
                            ((NAudioProxy)player).OpenSampleProvider(provicer);
                            if (player.CanPlay)
                            {
                                player.Play();
                            }
                            else
                            {
                                MessageBox.Show("Could not play file!", "Error playing file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        private void PreviewSound(float volume, AudioType audioType)
        {
            if (Pair == null && m_uiEngine.ActiveModule != InputModule.STANDALONE)
            {
                return;
            }

            if (Pair != null && m_uiEngine.ActiveModule != InputModule.OCULUS)
            {
                return;
            }

            var audioSource = m_audio.GetAudioSource(audioType);

            if (audioSource.isPlaying)
            {
                audioSource.volume = volume;
                return;
            }

            var sampleSounds = m_commonResource.GetResource(GetResourceType(audioType), SampleSound);

            if (sampleSounds == null || sampleSounds.Length == 0)
            {
                return;
            }

            AudioClip sampleClip = ((AudioResource)sampleSounds[0]).Clip;
            AudioArgs args       = new AudioArgs(sampleClip, audioType)
            {
                FadeTime = 0
            };

            m_audio.Play(args);
            if (audioType == AudioType.SFX)
            {
                audioSource.loop = true;
            }

            m_playingSampleType = audioType;
        }
        private void Play(string filePath)
        {
            // return if play is auto play is disabled
            if (!autoPlayCheckBox.Checked) return;

            player = BassProxy.Instance;
            if (player != null) {
                player.Stop();
                player.OpenFile(filePath);
                if (player.CanPlay) {
                    player.Play();
                } else {
                    Debug.WriteLine("Failed playing using Un4Seen Bass, trying to use mplayer ...");

                    float[] audioData = Mirage.AudioFileReader.Decode(filePath, Analyzer.SAMPLING_RATE, Analyzer.SECONDS_TO_ANALYZE);
                    if (audioData != null && audioData.Length > 0) {
                        player = NAudioProxy.GetWaveOutInstance();
                        if (player != null) {
                            NAudioFloatArrayProvider provicer = new NAudioFloatArrayProvider(Analyzer.SAMPLING_RATE, audioData, 2);
                            ((NAudioProxy) player).OpenSampleProvider(provicer);
                            if (player.CanPlay) {
                                player.Play();
                            } else {
                                MessageBox.Show("Could not play file!", "Error playing file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
 public void PlayMusic()
 {
     audioScreen.Play();
 }
Exemplo n.º 20
0
 public void Play()
 {
     _audio.Play();
 }
Exemplo n.º 21
0
 public void Play(object data)
 {
     AudioComponent.Play(data);
 }