示例#1
0
    void Awake()
    {
        share             = this;
        sounds            = new ArrayList();
        soundBG           = new Hashtable();
        soundSFX          = new Hashtable();
        currentThemeSound = SOUND_NAME.None;

        _backUpStateBG  = true;
        _backUpStateSFX = true;
    }
示例#2
0
    public GameObject playSoundSFX(SOUND_NAME type)
    {
        //		Debug.Log("playSound : " + type);
        GameObject retVal = null;
        bool       flag   = true;

        if (soundSFX[type] != null)
        {
            GameObject sound = (GameObject)soundSFX[type];
            if (sound != null)
            {
                sound.GetComponent <AudioSource>().Play();
                retVal = sound;
                //			Debug.Log("Play 1");
                flag = false;
            }
            else
            {
                soundSFX.Remove(type);
            }
        }

        if (flag)
        {
            AudioClip sound = getSound(type);

            GameObject audioSource = new GameObject("AudioSource", typeof(AudioSource));
            audioSource.transform.parent = transform;
            audioSource.GetComponent <AudioSource>().clip = sound;
            audioSource.name = type.ToString();
            soundSFX.Add(type, audioSource);
            audioSource.GetComponent <AudioSource>().spatialBlend = 0.0f;
            audioSource.GetComponent <AudioSource>().Play();

            retVal = audioSource;
        }

        recheckAllSound();
        return(retVal);
    }
示例#3
0
    public static AudioClip getSound(SOUND_NAME type)
    {
        string name = "";

        switch (type)
        {
        case SOUND_NAME.Shoot:
            name = "Sound/shoot";
            break;

        case SOUND_NAME.GoalKeeper_Catch:
            name = "Sound/goalkeeper_catch";
            break;

        case SOUND_NAME.Whistle:
            name = "Sound/whistle";
            break;

        case SOUND_NAME.Crowd_Goal:
            name = "Sound/crowd_goal";
            break;

        case SOUND_NAME.Crowd_Out:
            name = "Sound/crowd_out";
            break;

        case SOUND_NAME.Button:
            name = "Sound/button";
            break;

        case SOUND_NAME.Ball_Hit_Bar:
            name = "Sound/ball_hit_bar";
            break;

        case SOUND_NAME.Ball_Hit_Net:
            name = "Sound/ball_hit_net";
            break;

        case SOUND_NAME.Ball_Hit_Player_Wall:
            name = "Sound/ball_hit_player_wall";
            break;

        case SOUND_NAME.Ball_Hit_Goal:
            name = "Sound/ball_hit_goal_signal";
            break;

        case SOUND_NAME.Ball_Hit_Goal_Extra:
            name = "Sound/ball_hit_goal_extra_signal";
            break;

        case SOUND_NAME.BG_Crowd:
            name = "Sound/BG_crowd";
            break;

        case SOUND_NAME.BG_Menu:
            name = "Sound/BG_Football_Menu";
            break;

        case SOUND_NAME.BG_Menu1:
            name = "Sound/BG_Football_Fast";
            break;

        default:
            break;
        }

        return(Resources.Load(name, typeof(AudioClip)) as AudioClip);
    }
示例#4
0
    public GameObject playSoundBackGround(SOUND_NAME type)
    {
        GameObject retVal = null;

        if (currentThemeSound == type)
        {
            return(null);
        }

        if (soundBG[type] != null)
        {
            GameObject sound = (GameObject)soundBG[type];
            if (sound != null)
            {
                sound.GetComponent <AudioSource>().Play();
                sound.GetComponent <AudioSource>().volume = 1f;
                retVal = sound;
            }
            else
            {
                soundBG.Remove(type);
            }
        }

        if (retVal == null)
        {
            AudioClip clipAudio = getSound(type);

            GameObject  go          = new GameObject("AudioSource", typeof(AudioSource));
            AudioSource audioSource = go.GetComponent <AudioSource>();
            go.transform.parent = transform;
            go.name             = type.ToString();
            soundBG.Add(type, go);

            audioSource.clip         = clipAudio;
            audioSource.loop         = true;
            audioSource.spatialBlend = 0.0f;
            audioSource.volume       = 1f;
            audioSource.Play();

            retVal = go;
        }

        if (currentThemeSound != SOUND_NAME.None)
        {
            if (soundBG[currentThemeSound] != null)
            {
                GameObject sound = (GameObject)soundBG[currentThemeSound];
                if (sound != null)
                {
                    sound.GetComponent <AudioSource>().Stop();
                }
                else
                {
                    soundBG.Remove(currentThemeSound);
                }
            }
        }

        currentThemeSound = type;
        recheckAllSound();

        return(retVal);
    }
 //==========재생할거 찾기=============
 public AudioClip findAudioClip(SOUND_NAME s)
 {
     return(audioClipList[(int)s]);
 }