Пример #1
0
    void Start()
    {
        audioSource = GetComponent <AudioSource>();

        if (leftTimeBar == null)
        {
            this.leftTimeBar = GameObject.Find("LeftTimeBar");
        }
        if (countDownText == null)
        {
            this.countDownText = GameObject.Find("CountDown");
        }
        if (player == null)
        {
            this.player = GameObject.Find("Player");
        }
        if (finishText == null)
        {
            this.finishText = GameObject.Find("Finish");
        }
        if (gameDirector == null)
        {
            this.gameDirector = GameObject.Find("GameDirector");
        }

        playerScript    = player.GetComponent <GamePlayerController>();
        calcPointScript = gameDirector.GetComponent <CalcPoint>();

        BGM         = GameObject.Find("BGM");
        musicScript = BGM.GetComponent <BackGroundMusic>();

        startFlag     = false;
        coroutineFlag = true;
        deltaTime     = 0;
    }
Пример #2
0
    private void Awake()
    {
        gameEnded      = false;
        Time.timeScale = 1f;
        playerRef      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHandler>();
        gameUI         = gameObject.GetComponent <UIHandler>();

        BackGroundMusic.PlayNewAudio(BackGroundMusic.instance.inGameBGM);
    }
Пример #3
0
    public void MuteInMain()
    {
        BackGroundMusic instance = BackGroundMusic.Instance;

        if (instance != null)
        {
            instance.Mute();
        }
    }
Пример #4
0
 void Start()
 {
     if (instance)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Пример #5
0
 private AudioClip FindClip(BackGroundMusic soundName)
 {
     foreach (SoundClip soundClip in soundClips)
     {
         if (soundClip.soundName == soundName)
         {
             return(soundClip.audioClip);
         }
     }
     print("No such clip");
     return(null);
 }
Пример #6
0
 void Awake()
 {
     if (backgroundMusic == null)
     {
         backgroundMusic = this;
         DontDestroyOnLoad(backgroundMusic);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        width = Screen.width;
        height = Screen.height;
        music = BackGroundMusic.Instance;

        if(PlayerPrefs.GetInt("background_music") > 0){
            music.Play();
        }else{
            music.Stop();
        }
    }
Пример #8
0
    public void GoHome()
    {
        print("LoadMode");
        orsom.instance.enabled = true;
        BackGroundMusic instance = BackGroundMusic.Instance;

        if (instance != null)
        {
            instance.Mute();
        }
        SceneManager.LoadScene(0);
    }
Пример #9
0
 // Update is called once per frame
 void MakeSingleton()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Пример #10
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Пример #11
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
     //SceneManager.sceneLoaded += OnSceneLoaded;
 }
Пример #12
0
    private void Awake()
    {
        DontDestroyOnLoad(transform.gameObject);

        // onlu one instance of background sound
        if (bgmInstance == null)
        {
            bgmInstance = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
Пример #13
0
    private void Awake()
    {
        GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("music");
        if (gameObjects.Length > 1)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }

        DontDestroyOnLoad(this.gameObject);
        print("started on awake music");
    }
Пример #14
0
    public void PlayClip(BackGroundMusic soundName)
    {
        if (soundName == actualClip)
        {
            return;
        }

        AudioClip audioClip = FindClip(soundName);

        if (audioClip != null)
        {
            audioSource.clip = audioClip;
            actualClip       = soundName;
            audioSource.Play();
        }
    }
Пример #15
0
    public IEnumerator FadeIntoAmbientMusic()
    {
        yield return(new WaitForSeconds(1));

        StartCoroutine(StartFade(1, 0));

        while (audioSource.volume > 0)
        {
            yield return(null);
        }

        audioSource.clip = FindClip(BackGroundMusic.AmbientMusic);
        actualClip       = BackGroundMusic.AmbientMusic;
        audioSource.Play();

        StartCoroutine(StartFade(5, 0.25f));
    }
 public void PlayOneShot(BackGroundMusic sound, float volumeScale = 1)
 {
     BGMSource.PlayOneShot(BackGroundSound[sound], volumeScale * 1);
 }
Пример #17
0
 public void SetMainMenuBGM()
 {
     BackGroundMusic.PlayNewAudio(BackGroundMusic.instance.mainMenu);
 }