示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (_audioSource == null)
        {
            if (GameSceneManager.Instance._newScene == "Level")
            {
                GetAudioSource();
            }
            else if (GameSceneManager.Instance._newScene == "Menu")
            {
                GetAudioSource();
                PlayCurrentSong(_selectedSongIndex);
            }
        }

        PlayAudioOnStartGame();

        #region Keyboard Input Logic
        //if (Input.GetKeyDown(KeyCode.Return))
        //{
        //    if (AudioListener.pause == true)
        //    {
        //        AudioListener.pause = false;
        //        GameMaster.Instance.GameState = GameMaster.GamePlayState.PLAYING;
        //    }
        //    else if (AudioListener.pause == false)
        //    {
        //        AudioListener.pause = true;
        //        GameMaster.Instance.GameState = GameMaster.GamePlayState.PLAY_IDLE;
        //    }
        //    if (!_audioSource.isPlaying)
        //    {
        //        PlayCurrentSong(_currentSongIndex);
        //        _isPlaying = true;
        //    }
        //}
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            PlayNextSong();
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            PlayPreviousSong();
        }
        if (GameMaster.Instance.GameState == GameMaster.GamePlayState.PLAYING)
        {
            Debug.Log("Song Timer updating...");
            StartCoroutine(SongTimer.UpdateSongTime(_songTime));
        }

        #endregion
    }