Ejemplo n.º 1
0
    public void MakeDamage(float damage)
    {
        if (DamageMeter.instance.isActive)
        {
            DamageMeter.instance.damage += damage;
        }

        if (ShipsController.instance.doubleDamageActive)
        {
            damage = damage * 2f;
        }
        if (health <= damage)
        {
            if (isActive)
            {
                isActive = false;
                destroyWithPointsAction.Invoke();
                RemoveFromExpObjList();
            }
        }
        else
        {
            health -= damage;
            StartCoroutine(DamageAnimation());

            string      audioEffectPoolPath = "Prefabs/AudioEffects/hitEffect";
            GameObject  audioEffectObj      = ObjectsPool.PullObject(audioEffectPoolPath);
            AudioEffect audioEffect         = audioEffectObj.GetComponent <AudioEffect> ();
            audioEffect.poolPath = audioEffectPoolPath;
            audioEffect.StartEffect();
        }
    }
Ejemplo n.º 2
0
 public override void SendMsg(string AudioName, AudioState State, AudioEffect effect)
 {
     if (RepeatAudioPool.ContainsKey(AudioName))
     {
         _AudioState.AudioExcute(RepeatAudioPool[AudioName], State, effect);
     }
 }
 void Update()
 {
     if (Fade.GetComponent <CanvasGroup>().alpha == 0 && !Call1)
     {
         Call1 = true;
         Destroy(Fade.GetComponent <scrInitialFade>());
         Chat.SetActive(true);
     }
     if (Chat == null)
     {
         Fade.GetComponent <CanvasGroup>().alpha += 0.008f;
         if (!call3)
         {
             Musica.GetComponent <scrAudioManager>().enabled = false;
             call3 = true;
         }
         Musica.GetComponent <AudioSource>().volume      -= 0.008f;
         AudioEffect.GetComponent <AudioSource>().volume -= 0.008f;
         if (Fade.GetComponent <CanvasGroup>().alpha == 1 && !call2)
         {
             call2 = true;
             StartCoroutine(LoadScene());
         }
     }
 }
Ejemplo n.º 4
0
    public void PlayEffect(AudioEffect effect)
    {
        switch (effect)
        {
        case AudioEffect.GainCash:
            effectSource.PlayOneShot(gainCash);
            break;

        case AudioEffect.BellNotification:
            effectSource.PlayOneShot(bellNotification);
            break;

        case AudioEffect.StartDialogue:
            effectSource.PlayOneShot(startDialogue);
            break;

        case AudioEffect.SelectDialogueOption:
            effectSource.PlayOneShot(selectDialogueOption);
            break;

        case AudioEffect.ReadNewsNoNotif:
            effectSource.PlayOneShot(readNewsNoNotification);
            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(effect), effect, null);
        }
    }
Ejemplo n.º 5
0
 public void SetSoundEffect()
 {
     if (type != 7 && type != 8 && type != 9)
     {
         string audioEffectPoolPath = "";
         if (
             type == 1 ||
             type == 2 ||
             type == 3 ||
             type == 6)
         {
             int expIndex = Random.Range(0, 5);
             audioEffectPoolPath = "Prefabs/AudioEffects/Explodes/exp" + expIndex.ToString();
         }
         else if (type == 4 || type == 5)
         {
             int expIndex = Random.Range(0, 4);
             audioEffectPoolPath = "Prefabs/AudioEffects/Explodes/texp" + expIndex.ToString();
         }
         GameObject  audioEffectObj = ObjectsPool.PullObject(audioEffectPoolPath);
         AudioEffect audioEffect    = audioEffectObj.GetComponent <AudioEffect> ();
         audioEffect.poolPath = audioEffectPoolPath;
         audioEffect.StartEffect();
     }
 }
Ejemplo n.º 6
0
        public override void SendMsg(string AudioName, AudioState State, AudioEffect effect)
        {
            GameObject obj;

            if (AudioSourceDictionary.ContainsKey(AudioName))
            {
                if (AudioSourceDictionary[AudioName] == null)
                {
                    obj = new GameObject();
                    obj.AddComponent <AudioSource>().clip = _AudioPlane.GetClipForDictionary(AudioName);
                    AudioSourceDictionary.Add(AudioName, obj.GetComponent <AudioSource>());
                }
                else
                {
                    obj = AudioSourceDictionary[AudioName].gameObject;
                }
            }
            else
            {
                obj = new GameObject();
                obj.AddComponent <AudioSource>().clip = _AudioPlane.GetClipForDictionary(AudioName);
                AudioSourceDictionary.Add(AudioName, obj.GetComponent <AudioSource>());
            }



            _AudioState.AudioExcute(obj.GetComponent <AudioSource>(), State, effect);
        }
        public ActionResult <Response> UpdateAudioEffect(AudioEffect audioEffect)
        {
            response = new Response();

            response = audioEffectService.UpdateAudioEffect(audioEffect);

            return(responseFactory.CreateControllerResponse(response));
        }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     pSystem      = this.GetComponent <ParticleSystem> ().shape;
     emmision     = this.GetComponent <ParticleSystem> ().emission;
     main         = this.GetComponent <ParticleSystem> ().main;
     audio_effect = this.GetComponent <AudioEffect> ();
     audio        = this.GetComponent <AudioSource> ();
     mat.SetColor("_EmissionColor", min_colour);
 }
Ejemplo n.º 9
0
        private void Save(string fileName)
        {
            AudioEffect af = tcEffects.SelectedTab.Tag as AudioEffect;

            byte[] data   = null;
            IntPtr format = IntPtr.Zero;

            Prepare(arw, af, ref format, ref data);
            Save(format, data, fileName);
        }
Ejemplo n.º 10
0
    public void StopSound(AudioEffect audioEffect)
    {
        SFXInstance selectedAudio = soundEffectInstances.Find(x => x.audioEffect == audioEffect);

        if (selectedAudio == null)
        {
            return;
        }
        selectedAudio.audioS.Stop();
    }
Ejemplo n.º 11
0
        public Response UpdateAudioEffect(AudioEffect audioEffect)
        {
            response = responseFactory.CreateAudioEffectResponse();

            response.audioEffect.id = magmaDbContext.Update <AudioEffect>(audioEffect).Entity.id;

            magmaDbContext.SaveChanges();

            return(responseFactory.UpdateResponse(response, "Success: updated audio effect", ResponseStatus.OK));
        }
    // Use this for initialization
    void Start()
    {
        aberration_model = ppp.chromaticAberration.settings;

        aberration_model.intensity = 0.0f;

        if (audioEffect == null)
        {
            audioEffect = GameObject.Find("Audio").GetComponent <AudioEffect>();
        }
    }
Ejemplo n.º 13
0
    public void BossExplodeSound()
    {
        int bossType = type - 6;

        string      audioEffectPoolPath = "Prefabs/AudioEffects/Explodes/race_" + explodeObject.raceType.ToString() + "_boss_" + bossType.ToString();
        GameObject  audioEffectObj      = ObjectsPool.PullObject(audioEffectPoolPath);
        AudioEffect audioEffect         = audioEffectObj.GetComponent <AudioEffect> ();

        audioEffect.poolPath = audioEffectPoolPath;
        audioEffect.StartEffect();
    }
Ejemplo n.º 14
0
 public void SendMsg(AudioUse use, string AudioName, AudioState state, AudioEffect effect = AudioEffect.Normal)
 {
     if (use == AudioUse.Repeat)
     {
         RepeateAudio.SendMsg(AudioName, state, effect);
     }
     else
     {
         SingleAudio.SendMsg(AudioName, state, effect);
     }
 }
Ejemplo n.º 15
0
 void Awake()
 {
     if (instance)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Ejemplo n.º 16
0
 public void Play(IAudioReader wr, AudioEffect af)
 {
     //string fileName = @"c:\Wint\audio\NAudio-1-3\Source Code\MixDiff\bin\Debug\Windows XP Startup.wav";//1,16,8000.wav//G:\10\mp3\2,16,44100.wav
     //WaveReader wr = new WaveReader(File.OpenRead(fileName));
     IntPtr format = wr.ReadFormat();
     WaveFormat wf1 = AudioCompressionManager.GetWaveFormat(format);
     Console.WriteLine("{0},{1},{2}-{3}", wf1.nChannels, wf1.wBitsPerSample, wf1.nSamplesPerSec, wf1.wFormatTag);
     byte[] data = wr.ReadData();
     if (wf1.wFormatTag != 1)
     {
         IntPtr formatNew = IntPtr.Zero;
         byte[] dataNew = null;
         AudioCompressionManager.ToPcm(format, data, ref formatNew, ref dataNew);
         format = formatNew;
         data = dataNew;
         WaveFormat wf2 = AudioCompressionManager.GetWaveFormat(format);
         Console.WriteLine("{0},{1},{2}-{3}", wf2.nChannels, wf2.wBitsPerSample, wf2.nSamplesPerSec, wf2.wFormatTag);
     }
     else if (wf1.wBitsPerSample != 16)
     {
         WaveFormat wf = AudioCompressionManager.GetWaveFormat(format);
         IntPtr formatNew = AudioCompressionManager.GetPcmFormat(wf.nChannels, 16, wf.nSamplesPerSec);
         byte[] dataNew = AudioCompressionManager.Convert(format, formatNew, data, false);
         format = formatNew;
         data = dataNew;
         WaveFormat wf2 = AudioCompressionManager.GetWaveFormat(format);
         Console.WriteLine("{0},{1},{2}-{3}", wf2.nChannels, wf2.wBitsPerSample, wf2.nSamplesPerSec, wf2.wFormatTag);
     }
     //wr.Close();
     if (af != null)
     {
         bool hasProcessInPlace = af.HasProcessInPlace;
         //af.GetSupportedOutputFormats();
         GCHandle src = GCHandle.Alloc(data, GCHandleType.Pinned);
         IntPtr formatPtr = src.AddrOfPinnedObject();
         bool res = af.ProcessInPlace(format, data);
         src.Free();
         if (!res)
         {
             MessageBox.Show("Unable to convert the audio data");
             return;
         }
     }
     if (plex.State != DeviceState.Closed)
     {
         plex.ClosePlayer();
     }
     Console.WriteLine(plex.State);
     plex.OpenPlayer(format);
     plex.AddData(data);
     plex.StartPlay();
 }
Ejemplo n.º 17
0
    public void PlaySound(AudioEffect audioEffect, float volume, bool makeInstace = false)
    {
        AudioInstance selectedAudio = soundEffectInstances.Find(x => x.audioEffect == audioEffect);

        if (makeInstace)
        {
            selectedAudio = new AudioInstance();
            GameObject newObj = Instantiate(selectedAudio.audioS.gameObject);
            selectedAudio.audioS = newObj.GetComponent <AudioSource>();
        }
        selectedAudio.audioS.spatialBlend = 0;
        selectedAudio.audioS.volume       = volume;
        selectedAudio.audioS.Play();
    }
Ejemplo n.º 18
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            AudioEffect af = tcEffects.SelectedTab.Tag as AudioEffect;

            byte[] data   = null;
            IntPtr format = IntPtr.Zero;

            Prepare(arw, af, ref format, ref data);
            Play(format, data);
            tcEffectsEnabled = false;
            btnPlay.Enabled  = false;
            btnOpen.Enabled  = false;
            btnStop.Enabled  = true;
        }
Ejemplo n.º 19
0
        public void Play()
        {
            switch (PlayMode)
            {
            case AudioEffectPlayMode.FireAndForget:
                AudioEffect.Play();
                break;

            case AudioEffectPlayMode.Syncronious:
                CheckChanges();
                _instance.Play();
                _instance.IsLooped = Loop;
                break;
            }
        }
Ejemplo n.º 20
0
    public void PlaySound(AudioEffect audioEffect, float volume, float pitch = 1f)
    {
        SFXInstance selectedAudio = soundEffectInstances.Find(x => x.audioEffect == audioEffect);

        if (selectedAudio == null)
        {
            return;
        }

        selectedAudio.audioS.spatialBlend = 0;
        selectedAudio.audioS.clip         = selectedAudio.getClip;
        selectedAudio.audioS.volume       = volume * Settings.SFX;
        selectedAudio.audioS.pitch        = pitch;
        selectedAudio.audioS.Play();
    }
Ejemplo n.º 21
0
 /// <summary>
 /// Plays the audio effect linked to the AudioEffectType. Can also adjust the pitch and volume.
 /// </summary>
 /// <param name="_audioType"></param>
 /// <param name="_pitch"></param>
 /// <param name="_volume"></param>
 public void PlayEffect(AudioEffectType _audioType, float _pitch = 1f, float _volume = 1)
 {
     for (int i = 0; i < audioEffects.Count; i++)
     {
         if (audioEffects[i].Effect == _audioType)
         {
             if (audioEffects[i].Clip != null)
             {
                 AudioEffect _effect = audioEffects[i];
                 PlayClipAtPoint(_effect.Clip, _pitch, _effect.Volume);
             }
             break;
         }
     }
 }
Ejemplo n.º 22
0
    public void Play3DSound(AudioEffect audioEffect, float volume, Vector3 position, float pitch = 1)
    {
        SFXInstance selectedAudio = soundEffectInstances.Find(x => x.audioEffect == audioEffect);

        if (selectedAudio == null)
        {
            return;
        }

        selectedAudio.audioS.pitch        = pitch;
        selectedAudio.audioS.spatialBlend = 1;
        selectedAudio.audioS.gameObject.transform.position = position;
        selectedAudio.audioS.volume = volume * Settings.SFX;
        selectedAudio.audioS.Play();
    }
Ejemplo n.º 23
0
 public Master(int bufsize)
 {
     name    = "Master";
     mute    = false;
     level   = 1;
     preE    = true;
     preS    = true;
     Plugins = new AudioEffect[10];
     plugine = new bool[10];
     Stereo  = new float[2][];
     peaklvl = new float[2];
     for (int i = 0; i < 2; i++)
     {
         Stereo[i] = new float[bufsize];
     }
 }
Ejemplo n.º 24
0
    public void Play3DSound(AudioEffect audioEffect, float volume, Vector3 position, bool makeInstace = false, float pitch = 1)
    {
        AudioInstance selectedAudio = soundEffectInstances.Find(x => x.audioEffect == audioEffect);

        if (makeInstace)
        {
            selectedAudio = new AudioInstance();
            GameObject newObj = Instantiate(selectedAudio.audioS.gameObject);
            selectedAudio.audioS = newObj.GetComponent <AudioSource>();
        }
        selectedAudio.audioS.pitch        = pitch;
        selectedAudio.audioS.spatialBlend = 1;
        selectedAudio.audioS.gameObject.transform.position = position;
        selectedAudio.audioS.volume = volume * Settings.SFX;
        selectedAudio.audioS.Play();
    }
Ejemplo n.º 25
0
        public override async void Initialize(IResolver resolver)
        {
            this.playerVm = new PlayerViewModel();
            this.InitWorld();
            this.InitUi();

            this.musicManager = resolver.Resolve <IMusicManager>();
            this.musicManager.LoadSongs("Audio/LOOP_1", "Audio/LOOP_2", "Audio/LOOP_3", "Audio/LOOP_4", "Audio/LOOP_5");
            if (this.musicManager is Component musicComp)
            {
                this.WorldRoot.Components.Add(musicComp);
            }

            base.Initialize(resolver);

            this.IsPaused = true;

            this.playerVm.Dies += async(s, e) =>
            {
                await this.WaitForUpdate();

                foreach (var npc in this.WorldRoot.Children.OfType <Npc>())
                {
                    npc.PlayerDied();
                }

                this.musicManager.EndSongs();
                var shutdown = new AudioEffect("Audio/windows_shutdown")
                {
                    Volume = .75f
                };
                this.UiRoot.Components.Add(shutdown);
                shutdown.Stopped += (_s, _e) => this.UiRoot.Components.Remove(shutdown);
                shutdown.Play();
                await this.player.PlayDeathAnimation();

                this.UiRoot.Insert(0, new DeathScreen());
            };

            await Task.Delay(1500);

            await this.WaitForUpdate();

            this.IsPaused = false;
        }
Ejemplo n.º 26
0
        public void Prepare(IAudioReader wr, AudioEffect af, ref IntPtr format, ref byte[] data)
        {
            format = wr.ReadFormat();
            WaveFormat wf1 = AudioCompressionManager.GetWaveFormat(format);

            Console.WriteLine("{0},{1},{2}-{3}", wf1.nChannels, wf1.wBitsPerSample, wf1.nSamplesPerSec, wf1.wFormatTag);
            data = wr.ReadData();
            if (wf1.wFormatTag != 1)
            {
                IntPtr formatNew = IntPtr.Zero;
                byte[] dataNew   = null;
                AudioCompressionManager.ToPcm(format, data, ref formatNew, ref dataNew);
                format = formatNew;
                data   = dataNew;
                WaveFormat wf2 = AudioCompressionManager.GetWaveFormat(format);
                Console.WriteLine("{0},{1},{2}-{3}", wf2.nChannels, wf2.wBitsPerSample, wf2.nSamplesPerSec, wf2.wFormatTag);
            }
            else if (wf1.wBitsPerSample != 16)
            {
                WaveFormat wf        = AudioCompressionManager.GetWaveFormat(format);
                IntPtr     formatNew = AudioCompressionManager.GetPcmFormat(wf.nChannels, 16, wf.nSamplesPerSec);
                byte[]     dataNew   = AudioCompressionManager.Convert(format, formatNew, data, false);
                format = formatNew;
                data   = dataNew;
                WaveFormat wf2 = AudioCompressionManager.GetWaveFormat(format);
                Console.WriteLine("{0},{1},{2}-{3}", wf2.nChannels, wf2.wBitsPerSample, wf2.nSamplesPerSec, wf2.wFormatTag);
            }
            //wr.Close();
            if (af != null)
            {
                bool hasProcessInPlace = af.HasProcessInPlace;
                //af.GetSupportedOutputFormats();
                GCHandle src       = GCHandle.Alloc(data, GCHandleType.Pinned);
                IntPtr   formatPtr = src.AddrOfPinnedObject();
                bool     res       = af.ProcessInPlace(format, data);
                src.Free();
                if (!res)
                {
                    MessageBox.Show("Unable to convert the audio data");
                    return;
                }
            }
        }
Ejemplo n.º 27
0
        private void CheckPowerups()
        {
            var powerups = this.WorldRoot.Children.OfType <ShoePowerup>().ToArray();

            foreach (var powerup in powerups)
            {
                var pos = powerup.GlobalPosition.ToPoint();
                if (this.player.GlobalRegion.Contains(pos.X, pos.Y))
                {
                    var audio = new AudioEffect("Audio/newShoes");
                    this.player.Components.Add(audio);
                    audio.Play();
                    audio.Stopped += (s, e) => this.player.Components.Remove(audio);
                    this.player.EquipShoe(powerup.Powerup);
                    powerup.Dismiss();
                    break;
                }
            }
        }
Ejemplo n.º 28
0
 public Channel(int bufsize, string name)
 {
     Sends   = new Tuple <Bus, float> [10];
     Plugins = new AudioEffect[10];
     plugine = new bool[10];
     peaklvl = new float[2];
     Stereo  = new float[2][];
     Stereo2 = new float[2][];
     for (int i = 0; i < 2; i++)
     {
         Stereo[i]  = new float[bufsize];
         Stereo2[i] = new float[bufsize];
     }
     this.name = name;
     level     = 1;
     mute      = false;
     preE      = true;
     preS      = true;
     Pan       = 0;
 }
Ejemplo n.º 29
0
        private void Attack()
        {
            if (!this.IsCloseEnoughToHit())
            {
                return;
            }

            if (this.viewModel.IsInvulnerable)
            {
                return;
            }

            this.viewModel.DamagePlayer(15f);

            var rnd = new Random();
            var hit = new AudioEffect(rnd.Next(2) == 0 ? "Audio/hit" : "Audio/hit2");

            this.Components.Add(hit);
            hit.Play();
            hit.Stopped += (s, e) => this.Components.Remove(hit);
        }
Ejemplo n.º 30
0
        private void Init()
        {
            sfdAudio.Filter     = "*.wav|*.wav";
            sfdAudio.DefaultExt = "wav";
            ofdAudio.Filter     = "*.wav|*.wav|*.mp3|*.mp3|*.avi|*.avi|*.wma;*.wmv;*.asf;*.mpg;*.aif;*.au;*.snd;*.mid;*.rmi;*.ogg;*.flac;*.cda;*.ac3;*.dts;*.mka;*.mkv;*.mpc;*.m4a;*.aac;*.mpa;*.mp2;*.m1a;*.m2a|*.wma;*.wmv;*.asf;*.mpg;*.aif;*.au;*.snd;*.mid;*.rmi;*.ogg;*.flac;*.cda;*.ac3;*.dts;*.mka;*.mkv;*.mpc;*.m4a;*.aac;*.mpa;*.mp2;*.m1a;*.m2a|*.*|*.*";
            btnPlay.Enabled     = false;
            btnStop.Enabled     = false;
            btnSave.Enabled     = false;

            ChorusAudioEffect aeChorus = AudioEffect.CreateChorusAudioEffect();

            NewTab(aeChorus, "Chorus");
            CompressorAudioEffect aeCompressor = AudioEffect.CreateCompressorAudioEffect();

            NewTab(aeCompressor, "Compressor");
            DistortionAudioEffect aeDistortion = AudioEffect.CreateDistortionAudioEffect();

            NewTab(aeDistortion, "Distortion");
            EchoAudioEffect aeEcho = AudioEffect.CreateEchoAudioEffect();

            NewTab(aeEcho, "Echo");
            FlangerAudioEffect aeFlanger = AudioEffect.CreateFlangerAudioEffect();

            NewTab(aeFlanger, "Flanger");
            GargleAudioEffect aeGargle = AudioEffect.CreateGargleAudioEffect();

            NewTab(aeGargle, "Gargle");
            I3DL2ReverbAudioEffect aeI3DL2Reverb = AudioEffect.CreateI3DL2ReverbAudioEffect();

            NewTab(aeI3DL2Reverb, "I3DL2Reverb");
            ParamEqAudioEffect aeParamEq = AudioEffect.CreateParamEqAudioEffect();

            NewTab(aeParamEq, "ParamEq");
            WavesReverbAudioEffect aeWavesReverb = AudioEffect.CreateWavesReverbAudioEffect();

            NewTab(aeWavesReverb, "WavesReverb");
        }
Ejemplo n.º 31
0
        public Response UpdateAudioEffect(AudioEffect audioEffect)
        {
            if (audioEffect == null)
            {
                return(responseFactory.CreateResponse("Error: input parameter is null", ResponseStatus.BADREQUEST));
            }
            if (audioEffect.id == 0)
            {
                return(responseFactory.CreateResponse("Error: audio effect id is null", ResponseStatus.BADREQUEST));
            }

            response = new Response();

            try
            {
                response = audioEffectDao.UpdateAudioEffect(audioEffect);
            }
            catch (Exception exception)
            {
                return(responseFactory.CreateResponse(exception.Message, ResponseStatus.EXCEPTION));
            }

            return(response);
        }