Exemplo n.º 1
0
 public void PlayClip(AudioClip clip)
 {
     if (current != null && audio.isPlaying && current.name == clip.name)
     {
     return;
     }
     RegisterClip(clip);
     PlayClip(clip, true);
 }
    } // constructor
 
    public void AddClip(string name, AudioClip clip)
    {
        if (jukebox == null)
        {
            jukebox = new Hashtable();
        } // if
 
        GameObject obj;
        obj = new GameObject();
        obj.AddComponent("AudioSource");
        obj.audio.clip = clip;
        obj.audio.ignoreListenerVolume = true;
        DontDestroyOnLoad(obj);
        jukebox.Add(name, obj);
    } // AddClip()
 public override void PlayClip(AudioClip clip, bool stopCurrent)
 {
     if (clips == null || index >= clips.Length)
     {
     return;
     }
     if (stopCurrent)
     {
     audio.Stop();
     }
     volume = initialVolume * PlayerPrefs.GetFloat("AmbientVolume", 1.0f);
     audio.volume = volume * maxVolume * globalVolume;
     audio.PlayOneShot(clip);
     current = clip;
 }
Exemplo n.º 4
0
 public override void PlayClip(AudioClip clip, bool stopCurrent)
 {
     if (stopCurrent)
     {
     audio.Stop();
     }
     volume = PlayerPrefs.GetFloat("MusicVolume", 1.0f);
     volume *= initialVolume;
     audio.volume = volume * maxVolume * globalVolume;
     audio.PlayOneShot(clip);
     current = clip;
     Console.Log(CurrentTrackInfo(), false);
     if (loopTracks)
     {
     Invoke("NextTrack", clip.length);
     }
 }
Exemplo n.º 5
0
 public void SetHitSound(AudioClip hitSound)
 {
     this.mHitSound = hitSound;
 }
Exemplo n.º 6
0
    IEnumerator showText(string text, float showCharTime, AudioClip se, float p)
    {
        // 读两个字符麻烦,偷懒
        text = text.Replace("\\c[10]", "\\c[9]");

        char[] A    = text.ToCharArray();
        string txt  = "";
        int    mark = 0;
        char   type = '0';

        foreach (var a in A)
        {
            if (!showFinish)
            {
                if (mark > 0)
                {
                    switch (a)
                    {
                    case '\\': break;

                    case '|':
                        if (se)
                        {
                            gameManager.instance.stopSE();
                        }
                        yield return(new WaitForSeconds(0.5f));

                        if (se)
                        {
                            gameManager.instance.playSE(se, p, true);
                        }
                        mark = 0; break;

                    case '.':
                        if (se)
                        {
                            gameManager.instance.stopSE();
                        }
                        yield return(new WaitForSeconds(0.25f));

                        if (se)
                        {
                            gameManager.instance.playSE(se, p, true);
                        }
                        mark = 0; break;

                    case 'c': mark = 2; type = 'c'; break;

                    case '{': mark = 0;
                        if (type == 's')
                        {
                            txt += "</size>";
                        }
                        else
                        {
                            type = 's';
                        }
                        txt += "<size=" + (int)(textPanel.mainText.fontSize * 1.3f) + ">"; break;

                    case '}': mark = 0;
                        if (type == 's')
                        {
                            txt += "</size>";
                        }
                        else
                        {
                            type = 's';
                        }
                        txt += "<size=" + (int)(textPanel.mainText.fontSize * 0.8f) + ">"; break;

                    case '[': mark--; break;

                    case ']': mark--; break;

                    case '1': if (type == 'c')
                        {
                            txt += "<color=#67c2ea>";
                        }
                        break;

                    case '2': if (type == 'c')
                        {
                            txt += "<color=#f78f6d>";
                        }
                        break;

                    case '3': if (type == 'c')
                        {
                            txt += "<color=#7f9782>";
                        }
                        break;

                    case '4': if (type == 'c')
                        {
                            txt += "<color=#99ccff>";
                        }
                        break;

                    case '6': if (type == 'c')
                        {
                            txt += "<color=#ffffa0>";
                        }
                        break;

                    case '9': if (type == 'c')
                        {
                            txt += "<color=#f45331>";
                        }
                        break;

                    case '0': if (type == 'c')
                        {
                            type = '0'; txt += "</color>";
                        }
                        break;

                    default: mark = 0; break;
                    }
                }
                else
                {
                    if (a == '\\')
                    {
                        mark = 1;
                    }
                    else
                    {
                        txt += a;
                        if (type == 'c')
                        {
                            textPanel.setMainText(txt + "</color>");
                        }
                        else if (type == 's')
                        {
                            textPanel.setMainText(txt + "</size>");
                        }
                        else
                        {
                            textPanel.setMainText(txt);
                        }
                        yield return(new WaitForSeconds(showCharTime));
                    }
                }
            }
            else
            {
                text = text.Replace("\\|", "");
                text = text.Replace("\\^", "");
                text = text.Replace("\\.", "");
                text = text.Replace("\\!", "");
                text = text.Replace("\\c[0]", "</color>");
                text = text.Replace("\\c[1]", "<color=#67c2ea>");
                text = text.Replace("\\c[2]", "<color=#f78f6d>");
                text = text.Replace("\\c[3]", "<color=#7f9782>");
                text = text.Replace("\\c[4]", "<color=#99ccff>");
                text = text.Replace("\\c[6]", "<color=#ffffa0>");
                text = text.Replace("\\c[9]", "<color=#f45331>");

                int num = Regex.Split(text, "\\{|\\}").Length - 1;
                if (text.Contains("\\{"))
                {
                    text = text.Replace("\\{", "<size=" + (int)(textPanel.mainText.fontSize * 1.3f) + ">");
                }
                if (text.Contains("\\}"))
                {
                    text = text.Replace("\\}", "<size=" + (int)(textPanel.mainText.fontSize * 0.8f) + ">");
                }
                for (int i = 0; i < num; i++)
                {
                    text += "</size>";
                }

                textPanel.setMainText(text);
                break;
            }
        }
        if (se)
        {
            gameManager.instance.stopSE();
        }
        showFinish = true;
        canHide    = true;
    }
    private static void WriteHeader(byte[] stream, AudioClip clip, uint length, uint samples)
    {
        var hz       = (uint)clip.frequency;
        var channels = (ushort)clip.channels;

        var offset = 0u;

        var riff = Encoding.UTF8.GetBytes("RIFF");

        AddDataToBuffer(stream, ref offset, riff);

        var chunkSize = BitConverter.GetBytes(length - 8);

        AddDataToBuffer(stream, ref offset, chunkSize);

        var wave = Encoding.UTF8.GetBytes("WAVE");

        AddDataToBuffer(stream, ref offset, wave);

        var fmt = Encoding.UTF8.GetBytes("fmt ");

        AddDataToBuffer(stream, ref offset, fmt);

        var subChunk1 = BitConverter.GetBytes(16u);

        AddDataToBuffer(stream, ref offset, subChunk1);

        const ushort one = 1;

        var audioFormat = BitConverter.GetBytes(one);

        AddDataToBuffer(stream, ref offset, audioFormat);

        var numChannels = BitConverter.GetBytes(channels);

        AddDataToBuffer(stream, ref offset, numChannels);

        var sampleRate = BitConverter.GetBytes(hz);

        AddDataToBuffer(stream, ref offset, sampleRate);

        var byteRate =
            BitConverter.GetBytes(hz * channels * 2); // sampleRate * bytesPerSample*number of channels, here 44100*2*2

        AddDataToBuffer(stream, ref offset, byteRate);

        var blockAlign = (ushort)(channels * 2);

        AddDataToBuffer(stream, ref offset, BitConverter.GetBytes(blockAlign));

        ushort bps           = 16;
        var    bitsPerSample = BitConverter.GetBytes(bps);

        AddDataToBuffer(stream, ref offset, bitsPerSample);

        var dataString = Encoding.UTF8.GetBytes("data");

        AddDataToBuffer(stream, ref offset, dataString);

        var subChunk2 = BitConverter.GetBytes(samples * 2);

        AddDataToBuffer(stream, ref offset, subChunk2);
    }
Exemplo n.º 8
0
 //Used to play single sound clips.
 public void PlaySingle(AudioClip clip)
 {
     efxSource.clip = clip;
     efxSource.Play();
 }
Exemplo n.º 9
0
 public void PlayOneShotPlayerSFX(AudioClip clip)
 {
     PlayerSFXSource.PlayOneShot(clip);
 }
Exemplo n.º 10
0
		public void PlayOneShot(AudioClip clip, float volumeScale){}
Exemplo n.º 11
0
 public void Play(AudioClip clip)
 {
     _audioSource.clip = clip;
     _audioSource.Play();
 }
 public void PlaySound(AudioClip audioClip)
 {
     audioSource.PlayOneShot(audioClip);
 }
Exemplo n.º 13
0
 public void Play(AudioClip clip)
 {
     source.PlayOneShot(clip);
 }
Exemplo n.º 14
0
 public void PlayAndLoop(AudioClip clip)
 {
     source.clip = clip;
     source.loop = true;
     source.Play();
 }
 private void MakeSound(AudioClip originalClip)
 {
     // As it is not 3D audio clip, position doesn't matter.
     AudioSource.PlayClipAtPoint(originalClip, transform.position);
 }
Exemplo n.º 16
0
 public void Play(AudioClip clip)
 {
     this.audioSource.PlayOneShot(clip);
 }
Exemplo n.º 17
0
    //This function will handle the synthesis of the creepy music to be played when the enemy appears
    //as well as the win/lose sound
    public static void GenerateAudio()
    {
        //The two samples lists for the bass and accompaniments
        List <float> samplesBass   = new List <float>();
        List <float> samplesAccomp = new List <float>();


        Envelope e = new Envelope();

        e.Init(0.1f, 0.1f, 0.04f, 0.01f, 1.0f, 1.0f);

        List <float> Note1 = new List <float>();
        List <float> Note2 = new List <float>();
        List <float> Note3 = new List <float>();

        //Generate the pulsing bass for the creepy music
        WaveType w = WaveType.SAW;

        for (int i = 0; i < 20; i++)
        {
            Note1 = new List <float>();
            Note2 = new List <float>();
            Note3 = new List <float>();

            Note1 = Synth(Note1, 0.25f, 0 - 21, w, 0.5f);
            Note1 = Modulate(Note1, e);
            Note2 = Synth(Note2, 0.25f, 1 - 21, w, 0.5f);
            Note2 = Modulate(Note2, e);
            Note3 = Synth(Note3, 0.25f, 2 - 21, w, 0.5f);
            Note3 = Modulate(Note3, e);

            samplesBass.AddRange(Note1);
            samplesBass.AddRange(Note2);
            samplesBass.AddRange(Note3);


            Note1 = new List <float>();
            Note2 = new List <float>();
            Note3 = new List <float>();

            Note1 = Synth(Note1, 0.25f, 3 - 21, w, 0.5f);
            Note1 = Modulate(Note1, e);
            Note2 = Synth(Note2, 0.25f, 2 - 21, w, 0.5f);
            Note2 = Modulate(Note2, e);
            Note3 = Synth(Note3, 0.25f, 1 - 21, w, 0.5f);
            Note3 = Modulate(Note3, e);

            samplesBass.AddRange(Note1);
            samplesBass.AddRange(Note2);
            samplesBass.AddRange(Note3);
        }

        //Generate the high pitched accompanying tone
        for (int i = 0; i < 20; i++)
        {
            Note1 = new List <float>();
            Note2 = new List <float>();
            Note3 = new List <float>();

            Note1 = Synth(Note1, 0.25f, 0 - 1, w, 0.5f);
            Note1 = Modulate(Note1, e);
            Note2 = Synth(Note2, 0.25f, 0 - 2, w, 0.5f);
            Note2 = Modulate(Note2, e);
            Note3 = Synth(Note3, 0.25f, 0 - 3, w, 0.5f);
            Note3 = Modulate(Note3, e);

            samplesAccomp.AddRange(Note1);
            samplesAccomp.AddRange(Note2);
            samplesAccomp.AddRange(Note3);


            Note1 = new List <float>();
            Note2 = new List <float>();

            Note1 = Synth(Note1, 0.25f, 0 - 2, w, 0.5f);
            Note1 = Modulate(Note1, e);
            Note2 = Synth(Note2, 0.25f, 0 - 1, w, 0.5f);
            Note2 = Modulate(Note2, e);


            samplesAccomp.AddRange(Note1);
            samplesAccomp.AddRange(Note2);
        }


        samplesBass   = AlterGain(samplesBass, 0.01f);
        samplesAccomp = AlterGain(samplesAccomp, 0.01f);

        samplesBass = TrimSilence(samplesBass, 0.2f);

        //Create the bass audio clip
        musicBass = AudioClip.Create("musicBass", samplesBass.Count, 2, samplerate, false);
        musicBass.SetData(samplesBass.ToArray(), 0);

        //Create the accompaniments audio clip
        musicAccomp = AudioClip.Create("musicAccomp", samplesAccomp.Count, 2, samplerate, false);
        musicAccomp.SetData(samplesAccomp.ToArray(), 0);



        w = WaveType.TRIANGLE;
        //Create the win and lose audio
        e.Init(0.01f, 0, 0.8f, 0.01f, 1.0f, 1.0f);

        List <float> winSamples  = new List <float>();
        List <float> loseSamples = new List <float>();

        Note1 = new List <float>();
        Note2 = new List <float>();
        Note3 = new List <float>();

        Note1 = Synth(Note1, 0.1f, 0 - 9, w, 1.0f);
        Note1 = Modulate(Note1, e);
        Note2 = Synth(Note2, 0.1f, 0 - 7, w, 1.0f);
        Note2 = Modulate(Note2, e);

        e.Init(0.01f, 0.05f, 0.05f, 0.069f, 1.0f, 1.0f);

        Note3 = Synth(Note3, 0.075f, 0 - 9, w, 1.0f);
        Note3 = Modulate(Note3, e);

        winSamples.AddRange(Note1);
        winSamples.AddRange(Note2);
        winSamples.AddRange(Note3);

        e.Init(0.01f, 0, 0.18f, 0.01f, 1.0f, 1.0f);

        Note3 = new List <float>();
        Note3 = Synth(Note3, 0.2f, 0 - 1, w, 1.0f);
        Note3 = Modulate(Note3, e);
        winSamples.AddRange(Note3);


        Note1 = new List <float>();
        Note2 = new List <float>();
        Note3 = new List <float>();

        Note1 = Synth(Note1, 0.1f, 0 - 10, w, 1.0f);
        Note1 = Modulate(Note1, e);
        Note2 = Synth(Note2, 0.1f, 0 - 8, w, 1.0f);
        Note2 = Modulate(Note2, e);

        e.Init(0.01f, 0.05f, 0.05f, 0.069f, 1.0f, 1.0f);

        Note3 = Synth(Note3, 0.075f, 0 - 10, w, 1.0f);
        Note3 = Modulate(Note3, e);


        loseSamples.AddRange(Note1);
        loseSamples.AddRange(Note2);
        loseSamples.AddRange(Note3);

        e.Init(0.01f, 0, 0.18f, 0.01f, 1.0f, 1.0f);
        Note3 = new List <float>();
        Note3 = Synth(Note3, 0.075f, 0 - 12, w, 1.0f);
        Note3 = Modulate(Note3, e);
        loseSamples.AddRange(Note3);


        //Create the bass audio clip
        winSound = AudioClip.Create("Win Sound", winSamples.Count, 1, samplerate, false);
        winSound.SetData(winSamples.ToArray(), 0);

        //Create the accompaniments audio clip
        loseSound = AudioClip.Create("Lose Sound", loseSamples.Count, 1, samplerate, false);
        loseSound.SetData(loseSamples.ToArray(), 0);
    }
Exemplo n.º 18
0
 private static JSONClass SerializeAudioClip(AudioClip clip)
 {
     if (clip == null)
     {
         return null;
     }
     JSONClass fieldData = new JSONClass();
     fieldData.Add("name", new JSONData(clip.name));
     return fieldData;
 }
Exemplo n.º 19
0
    //list of sounds and their id

    /* Sound Effect ID list (SFX)
     * 0: Death
     * 1: Eat
     * 2: Hurt
     * 3: Lose
     * 4: RoundBegin
     * 5: RoundEnd
     * 6: Victory
     */

    /* Music ID list
     * 0: Ambient Music
     * 1: Hunting Music
     * 2: Main Menu
     */
    /// <summary>
    /// Randomizes the pitch of a clip
    /// </summary>
    /// <param name="clip"></param>
    /// <param name="source"></param>
    private static void RandomizeSFX(AudioClip clip, AudioSource source)
    {
        source.clip = clip;
        // source.pitch = Random.Range(0.8f, 1.0f);
        source.Play();
    }
Exemplo n.º 20
0
 public void PlayOneShot(AudioClip clip, float volumeScale)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 21
0
 public void PlaySong(AudioClip clip)
 {
     audioSource.clip = clip;
     audioSource.Play();
 }
Exemplo n.º 22
0
		public static void PlayClipAtPoint(AudioClip clip, Vector3 position){}
Exemplo n.º 23
0
 public void StopRecording()
 {
     clip      = null;
     recording = false;
 }
Exemplo n.º 24
0
 private void SetSoundEffect(AudioClip sfx)
 {
     if (sfx != null)
     {
         sfx.Volume = volume;
         time = 0;
     }
 }
Exemplo n.º 25
0
 // play sound through the audiosource on the gameobject
 void PlaySound(AudioClip clip)
 {
     _audio.PlayOneShot(clip);
 }
Exemplo n.º 26
0
 public void PlayOneShotEnemySFX(AudioClip clip)
 {
     EnemySFXSource.PlayOneShot(clip);
 }
Exemplo n.º 27
0
    IEnumerator FadeOutInMusic(AudioClip clip, float musicVolume, float fadeOutTime, float fadeIntime)
    {
        if (Music.isPlaying)
        {
            if (fadeOutTime == 0)
            {
                Music.volume = 0;
                Music.Stop();
            }
            else
            {
                float maxVolume = Music.volume;
                float volume    = Music.volume;
                while (volume > 0)
                {
                    volume -= 1 / fadeOutTime * Time.deltaTime * maxVolume;

                    if (volume < 0)
                    {
                        volume = 0;
                    }

                    Music.volume = volume;

                    yield return(new WaitForEndOfFrame());
                }
                Music.Stop();
            }
        }


        yield return(new WaitForEndOfFrame());

        if (clip != null)
        {
            Music.clip = clip;
            Music.Play();

            if (fadeIntime == 0)
            {
                Music.volume = musicVolume;
            }
            else
            {
                float maxVolume = musicVolume;
                float volume    = 0;

                while (volume < maxVolume)
                {
                    volume += 1 / fadeIntime * Time.deltaTime * maxVolume;

                    if (volume > maxVolume)
                    {
                        volume = maxVolume;
                    }

                    Music.volume = volume;

                    yield return(new WaitForEndOfFrame());
                }
            }
        }
    }
Exemplo n.º 28
0
 private void PlayMusic(AudioSource source, AudioClip clip)
 {
     StopAllMusic();
     source.clip = clip;
     source.Play();
 }
Exemplo n.º 29
0
    IEnumerator PlayRoutine() {
        while (queuedTracks.Count <= 0 || isPlaying) {yield return null;}

        // If we have things to play queued up
        AudioClip toPlay = queuedTracks.Values[0];
        queuedTracks.RemoveAt(0);

        switch (toPlay.name) {
            // When we play ending, empty the queue
            case "14 Ending":
            // We just entered the hex room
                print("ending");
                queuedTracks = new SortedList<int, AudioClip>();
                StartCoroutine(PlayInSuccession(ending));
                break;

            // We are exiting trash room, clear the queue
            case "Warning - Anomaly Detected":
                queuedTracks = new SortedList<int, AudioClip>();
                StartCoroutine(PlayInSuccession(trashFinishedLines));
                break;

            // We grabbed the frisbee for the first time
            case "4 Hello":
                print("playing grabbed");
                queuedTracks = new SortedList<int, AudioClip>();
                instance.TrashLine();
                StartCoroutine(PlayInSuccession(frisbeeGrabbedLines));
                break;
            
            case "11 Where We":
                queuedTracks = new SortedList<int, AudioClip>();
                StartCoroutine(PlayInSuccession(newPlaceLines));
                break;

            // We just sucked up an item
            case "8 Success":
            // We just failed to suck up an item
            case "9 Fail":
                print("frisbeecall");
                StartCoroutine(PlayClip(toPlay));
                break;

            // We haven't grabbed the frisbee yet
            case "2 So Alone":
                StartCoroutine(PlayFrisbeeListLines(lostFrisbeeLines, 3, 4));
                break;

            // We are idling in the hex room
            case "13 Hex Lines":
                StartCoroutine(PlayFrisbeeListLines(hexRoomLines, 10, 8));
                break;

            // We are idling in the trash room
            case "0 Ugh":
                StartCoroutine(PlayFrisbeeListLines(trashRoomLines, 10, 7));
                break;

            // God knows why we'd be here
            default:
                StartCoroutine(PlayClip(toPlay));
                break;
        }

        yield return new WaitForSeconds(0);
    }
Exemplo n.º 30
0
    //显示文字框
    public void showTextPanel(Component _object, string name, string text, Sprite sprite, AudioClip se = null, float p = 1.0f, bool _new = false)
    {
        AudioClip s;

        if (se == null)
        {
            s = show;
        }
        else
        {
            s = se;
        }
        textRequest = _object;
        if (textPanel == null)
        {
            GameObject go = GameObject.Instantiate(TextPanel) as GameObject;
            textPanel = go.GetComponent <TextPanel>();
            go.transform.SetParent(GameObject.Find("Canvas").GetComponent <RectTransform>());
            go.transform.localPosition = Vector2.zero;
        }
        else if (_new)
        {
            Destroy(textPanel.gameObject);
            GameObject go = GameObject.Instantiate(TextPanel) as GameObject;
            textPanel = go.GetComponent <TextPanel>();
            go.transform.SetParent(GameObject.Find("Canvas").GetComponent <RectTransform>());
            go.transform.localPosition = Vector2.zero;
        }
        else
        {
            textPanel.gameObject.SetActive(true);
            textPanel.changeSize();
        }
        gameManager.instance.changeState(nowState.text, textPanel.gameObject);
        textPanel.setNameText(name);
        textPanel.setAvator(sprite);
        showFinish = false;
        if (s)
        {
            gameManager.instance.playSE(s, p, true);
        }
        StartCoroutine(showText(text, 0.05f, s, p));
    }
Exemplo n.º 31
0
 public void PlayMusic(AudioClip clip)
 {
     music.clip = clip;
     music.Play();
 }
Exemplo n.º 32
0
        /// <summary>
        /// Spawn one damage text.
        /// </summary>
        /// <param name="damage"> damage number </param>
        /// <param name="pos"> spawn position </param>
        public void SpawnDamageTextFromPool(
            int damage,
            Vector2 pos,
            AudioClip hitSound,
            bool secondSearch = false)
        {
            if (mNumberOfHandle == 0)
            {
                return;
            }

            JCS_DamageText dt;

            for (int index = mLastSpawnPos;
                 index < mNumberOfHandle;
                 ++index)
            {
                dt = mDamageTexts.at(index);
                // if not active, meaning we can spawn the text
                if (!dt.isActive())
                {
                    dt.SpawnDamageText(damage, pos);

                    // Hit Sound is the part of sfx sound
                    PlayHitSound(hitSound);

                    // set the last spawn count
                    mLastSpawnPos = index;
                    return;
                }
            }

            // if we get here mean we cycle once but we
            // did not spawn a text!
            // so reset the spawn pos and
            // try to search agian until we find one!
            mLastSpawnPos = 0;

            // if function call the second time,
            // and try to call the third time,
            // exit the function call.
            // so prevent "stack overflow
            // search/infinite function call".
            // IMPORTANT(JenChieh): it wont spawn damage text this time,
            // if this happens.
            if (secondSearch)
            {
#if (UNITY_EDITOR)
                if (JCS_GameSettings.instance.DEBUG_MODE)
                {
                    JCS_Debug.LogWarning(
                        "Prevent, stack overflow function call.");
                }
#endif
                return;
            }

            // dangerious, use carefully!
            // make sure u have enough number of handle
            // or else the program might crash? (too many delay?)
            SpawnDamageTextFromPool(damage, pos, hitSound, true);
        }
Exemplo n.º 33
0
    void OnGUI()
    {
        GUI.skin = mySkin;
        if (GUI.Button(new Rect(50, 50, 75, 75), "", GUI.skin.GetStyle("Back")))
        {
            SceneManager.LoadScene("Selection");
        }
        switch (Selection.GetChoose())
        {
        case "1":
            title = "镊子抓取固体";
            tips  = "Tips:除大拇指外其余四指基本平行";
            break;

        case "2":
            title = "往试管中加固体";
            tips  = "Tips:五指基本不弯曲";
            break;

        case "3":
            title = "胶头滴管吸取液体";
            tips  = "Tips:注意中指,无名指与小拇指的位置";
            break;

        case "4":
            title = "烧杯倒水";
            tips  = "Tips:注意右掌心与烧杯右侧相贴";
            break;

        default:
            break;
        }
        GUI.Label(new Rect(175, 50, 200, 75), title, GUI.skin.GetStyle("Text"));
        GUI.Label(new Rect(90, 240, 250, 100), condition, GUI.skin.GetStyle("Text"));
        GUI.Label(new Rect(500, 400, 600, 100), tips, GUI.skin.GetStyle("Text"));
        if (GUI.Button(new Rect(90, 140, 100, 100), "", GUI.skin.GetStyle("Start")))
        {
            show = 1;
        }
        if (GUI.Button(new Rect(240, 140, 100, 100), "", GUI.skin.GetStyle("Pause")))
        {
            show = 2;
        }
        if (result == 1)
        {
            GUI.Button(new Rect(90, 350, 250, 100), "", GUI.skin.GetStyle("Passed"));
        }
        if (result == 2)
        {
            GUI.Button(new Rect(90, 325, 250, 150), "", GUI.skin.GetStyle("Failed"));
        }
        if (isBegin)
        {
            //添加 Audio Source 组件
            _audioSource = this.gameObject.AddComponent <AudioSource>();
            //加载 Audio Clip 对象
            AudioClip audioClip = Resources.Load <AudioClip>("begin");
            //播放声音
            _audioSource.clip = audioClip;
            _audioSource.Play(0);
            isBegin = !isBegin;
        }
        if (isSuccess)
        {
            //添加 Audio Source 组件
            _audioSource = this.gameObject.AddComponent <AudioSource>();
            //加载 Audio Clip 对象
            AudioClip audioClip = Resources.Load <AudioClip>("success");
            //播放声音
            _audioSource.clip = audioClip;
            _audioSource.Play(0);
            isSuccess = !isSuccess;
        }
        if (isFailed)
        {
            //添加 Audio Source 组件
            _audioSource = this.gameObject.AddComponent <AudioSource>();
            //加载 Audio Clip 对象
            AudioClip audioClip = Resources.Load <AudioClip>("failed");
            //播放声音
            _audioSource.clip = audioClip;
            _audioSource.Play(0);
            isFailed = !isFailed;
        }
    }
Exemplo n.º 34
0
 public void PlayTrack(AudioClip audio)
 {
     MusicController.PlayTrack(audio);
 }
        public Explosion(Vector2 pos) : base(pos, "explosion_0", DrawMgr.Layer.Playground)
        {
            Create();

            explosionClip = AudioMgr.GetClip("explosion");
        }
Exemplo n.º 36
0
 private static void RegisterClip(AudioClip clip)
 {
     string clipName = clip.name;
     if (!clipsByName.ContainsKey(clipName))
     {
     clipsByName.Add(clipName, clip);
     }
 }
Exemplo n.º 37
0
    // Singleton instance.
    //  public static AudioManager Instance = null;

    /*
     * private void Awake()
     * {
     *  // If there is not already an instance of SoundManager, set it to this.
     *  if (Instance == null)
     *  {
     *      Instance = this;
     *  }
     *  //If an instance already exists, destroy whatever this object is to enforce the singleton.
     *  else if (Instance != this)
     *  {
     *      Destroy(gameObject);
     *  }
     *
     *  //Set SoundManager to DontDestroyOnLoad so that it won't be destroyed when reloading our scene.
     *  DontDestroyOnLoad(gameObject);
     * }*/
    public void Play(AudioClip clip)
    {
        EffectsSource.clip = clip;
        EffectsSource.Play();
    }
Exemplo n.º 38
0
 public virtual void PlayClip(AudioClip clip, bool stopCurrent)
 {
     if (stopCurrent)
     {
     audio.Stop();
     }
     volume = PlayerPrefs.GetFloat("AudioVolume", 1.0f);
     volume *= initialVolume;
     audio.volume = volume * maxVolume * globalVolume;
     audio.PlayOneShot(clip);
     current = clip;
 }
Exemplo n.º 39
0
 /// <summary>
 /// Plays an <a href="http://docs.unity3d.com/ScriptReference/AudioClip.html">AudioClip</a> at a given position in world space.
 /// </summary>
 /// <param name='clip'>
 /// Clip.
 /// </param>
 /// <param name='position'>
 /// Position.
 /// </param>
 /// <param name='volume'>
 /// Volume.
 /// </param>
 public static void PlayClipAtPoint(AudioClip clip, Vector3 position, float volume=1f)
 {
     SoundManager.PlaySFX(clip, false, 0f, volume, SoundManager.GetPitchSFX(), position);
 }
Exemplo n.º 40
0
		public void PlayOneShot(AudioClip clip){}
Exemplo n.º 41
0
 public static void PlayClipAtPoint(AudioClip clip, Vector3 position, float volume)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 42
0
		public static void PlayClipAtPoint(AudioClip clip, Vector3 position, float volume){}
Exemplo n.º 43
0
 public static void ChangeMusicCaller(int track, float speed, AudioClip audioClip, List <AudioClip> listAudioClip = null, int min = -2, int max = -2)
 {
     instance.StartCoroutine(ChangeMusic(track, speed, audioClip, listAudioClip, min, max));
 }
Exemplo n.º 44
0
    // Function to allow any object to call sound manager to obtain sound

    public void PlayOneShot(AudioClip clip)
    {
        soundEffectAudio.PlayOneShot(clip);
    }
Exemplo n.º 45
0
 public void PlayOneShot(AudioClip clip)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 46
0
 /// <summary>
 /// Plays an <a href="http://docs.unity3d.com/ScriptReference/AudioClip.html">AudioClip</a>, and scales the AudioSourcePro volume by volumeScale.
 /// </summary>
 /// <param name='clip'>
 /// Clip.
 /// </param>
 /// <param name='volumeScale'>
 /// Volume scale.
 /// </param>
 public void PlayOneShot(AudioClip clip, float volumeScale)
 {
     audioSource.PlayOneShot(clip, volumeScale);
 }
Exemplo n.º 47
0
 public static void LoopCaller(int track, float clipLength, AudioClip audioClip, List <AudioClip> listAudioClip, int min, int max)
 {
     instance.StartCoroutine(Loop(track, clipLength, audioClip, listAudioClip, min, max));
 }