public void PlaySound(soundType type)
    {
        //if already playing, skip
        if (soundFXSource.isPlaying)
        {
            soundFXSource.Stop();
        }

        if (type == soundType.NOTIFICATION)
        {
            soundFXSource.clip = notificationSound;
        }
        else if (type == soundType.BUTTON)
        {
            soundFXSource.clip = buttonSound;
        }
        else if (type == soundType.INSUFFICIENT)
        {
            soundFXSource.clip = insufficientSound;
        }
        else if (type == soundType.STATECHANGE)
        {
            soundFXSource.clip = stateWinSound;
        }
        else
        {
            throw new System.Exception($"OOPSIE WOOPSIE WE MADE A FUCKY WUCKY: soundfx type not found");
        }

        soundFXSource.Play();
    }
Beispiel #2
0
 public Effect(effectType _type, soundType _s_type, explosionType _e_type, int _x, int _y)
 {
     type   = _type;
     s_type = _s_type;
     e_type = _e_type;
     x      = _x;
     y      = _y;
 }
 public Effect(effectType _type, soundType _s_type, explosionType _e_type, int _x, int _y)
 {
     type = _type;
     s_type = _s_type;
     e_type = _e_type;
     x = _x;
     y = _y;
 }
	public AudioClip GetSound(soundType type){
		switch (type) {
		case soundType.glass:
			return RandomSound (glass);
		case soundType.metal:
			return RandomSound (metal);
		case soundType.box:
			return RandomSound (box);
		case soundType.wizardYays:
			return RandomSound (wizardYays);
		case soundType.wizardSpells:
			return RandomSound (wizardSpells);
		}
		return null;
	}
Beispiel #5
0
 public void play(soundType type = soundType.SOUND_BUTTONCLICK)
 {
     if(!Settings.soundMute)
     {
         switch (type)
         {
             case soundType.SOUND_BADSUDOKU:
                 audioSrc.PlayOneShot(badSudokuSound);
                 break;
             case soundType.SOUND_GOODSUDOKU:
                 audioSrc.PlayOneShot(goodSudokuSound);
                 break;
             case soundType.SOUND_BUTTONCLICK:
                 audioSrc.PlayOneShot(buttonClickSound);
                 break;
         }
     }
 }
Beispiel #6
0
 private AudioSource GetAudio(soundType myST)
 {
     if (myST == soundType.line)
     {
         if (Dialogue.Length == 0)
         {
             return(null);
         }
         AudioSource a = gameObject.AddComponent <AudioSource>();
         a.clip = Resources.Load <AudioClip>("Dialogue/" + (string)this.gameObject.name);
         if (a.clip != null)
         {
             audioLength         = a.clip.length;
             dialogueAdvanceTime = a.clip.length + 2;
             nextCharInterval    = (a.clip.length - 1) / Dialogue.Length;
             a.volume            = 1;
             a.loop        = false;
             a.playOnAwake = false;
             a.Stop();
         }
         else
         {
             nextCharInterval = .02f;
             audioLength      = .02f * Dialogue.Length;
         }
         return(a);
     }
     else
     {
         GameObject  g = (GameObject)Instantiate(Resources.Load("Blank"), this.transform);
         AudioSource a = g.AddComponent <AudioSource>();
         if (a != null)
         {
             a.clip        = Resources.Load <AudioClip>("SFX/NextSound");
             a.volume      = .03f;
             a.pitch       = .5f;
             a.loop        = false;
             a.playOnAwake = false;
             a.Stop();
         }
         return(a);
     }
 }
    public void play(soundType type = soundType.SOUND_BUTTONCLICK)
    {
        if (!Settings.soundMute)
        {
            switch (type)
            {
            case soundType.SOUND_BADSUDOKU:
                audioSrc.PlayOneShot(badSudokuSound);
                break;

            case soundType.SOUND_GOODSUDOKU:
                audioSrc.PlayOneShot(goodSudokuSound);
                break;

            case soundType.SOUND_BUTTONCLICK:
                audioSrc.PlayOneShot(buttonClickSound);
                break;
            }
        }
    }
Beispiel #8
0
        /// <summary>
        /// Takes enum dependant on situation, randomly selects a sound from a set of organized directories
        /// </summary>
        /// <param name="soundType"></param>
        private void playSituationalSound(soundType soundType)
        {
            if (settings.soundsOn)
            {
                if (soundWatch.ElapsedMilliseconds > random.Next(5000, 8000) || soundType == soundType.Startup || soundType == soundType.Shutdown || soundType == soundType.Saddness)                 //Exceptions for startup and shutdown so they dont have to wait the 5 seconds
                {
                    switch (soundType)
                    {
                    case soundType.Detection:
                        player.SoundLocation = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\detection")[random.Next(Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\detection").Length)];                         // I'm sorry
                        break;

                    case soundType.Startup:
                        player.SoundLocation = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\startup")[random.Next(Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\startup").Length)];
                        break;

                    case soundType.Shutdown:
                        player.SoundLocation = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\shutdown")[random.Next(Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\shutdown").Length)];
                        break;

                    case soundType.Missing:

                        player.SoundLocation = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\noDetection")[random.Next(Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\noDetection").Length)];
                        break;

                    case soundType.Saddness:
                        player.SoundLocation = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\saddness")[random.Next(Directory.GetFiles(Directory.GetCurrentDirectory() + @"\Sound\saddness").Length)];
                        break;
                    }

                    //Need to start the sound in a new thread to that it doesn't stall the main thread and so that souns don't overlap
                    Thread thread = new Thread(new ThreadStart(playSound));
                    thread.Start();

                    soundWatch = Stopwatch.StartNew();
                }
            }
        }
Beispiel #9
0
    public void playBgMusic(soundType type)
    {
        switch (type)
        {
        case soundType.bgShengming:
            audioSource.clip = bgShengming;
            audioSource.Play();
            break;

        case soundType.bgZuoteng:
            audioSource.clip = bgZuoteng;
            audioSource.Play();
            break;

        case soundType.fail:
            audioSource.clip = fail;
            audioSource.Play();
            break;

        default:
            break;
        }
    }
Beispiel #10
0
 public void RequestSound(soundType s_type)
 {
     all_effects.Add(new Effect(effectType.SOUND, s_type, explosionType.BIG, 0, 0));
 }
Beispiel #11
0
 public void LoadSound(ContentManager cont_man, string _path, soundType s_type)
 {
     sounds[(int)s_type] = cont_man.Load <SoundEffect>(_path);
 }
 public void RequestSound(soundType s_type)
 {
     // all_effects.Add(new Effect(effectType.SOUND, s_type, explosionType.BIG, 0, 0));
     sounds[(int)s_type].Play();
 }
Beispiel #13
0
 public void RequestSound(soundType s_type)
 {
     sounds[(int)s_type].Play();
 }
Beispiel #14
0
    public void playSound(soundType type)
    {
        switch (type)
        {
        case soundType.fashe:
            audioSource.PlayOneShot(fashe);
            break;

        case soundType.huishou:
            audioSource.PlayOneShot(huishou);
            break;

        case soundType.pengzhuang:
        {
            //Debug.Log("time>>>>>>>>>>>>>>"+(Time.time - pretTime));
            //pretTime = Time.time;
            for (int i = soundTimes.Count - 1; i >= 0; i--)
            {
                if (Time.time - soundTimes[i] > 0.18f)
                {
                    soundTimes.RemoveAt(i);
                }
            }

            if (soundTimes.Count < 4)
            {
                soundTimes.Add(Time.time);
                audioSource.PlayOneShot(pengzhuang);
            }
        }
        break;

        case soundType.xiaohui:
            audioSource.PlayOneShot(xiaohui);
            break;

        case soundType.dogEat:
            audioSource.PlayOneShot(dogEat);
            break;

        case soundType.thunder:
        {
            for (int i = soundTimes.Count - 1; i >= 0; i--)
            {
                if (Time.time - soundTimes[i] > 0.18f)
                {
                    soundTimes.RemoveAt(i);
                }
            }

            if (soundTimes.Count < 4)
            {
                soundTimes.Add(Time.time);
                audioSource.PlayOneShot(thunder);
            }
        }
        break;

        case soundType.fail:
            audioSource.PlayOneShot(fail);
            break;

        default:
            break;
        }
    }
 public void RequestSound(soundType s_type)
 {
     // all_effects.Add(new Effect(effectType.SOUND, s_type, explosionType.BIG, 0, 0));
     sounds[(int)s_type].Play();
 }
 public void LoadSound(ContentManager cont_man, string _path, soundType s_type)
 {
     sounds[(int)s_type] = cont_man.Load<SoundEffect>(_path); // play a sound
 }