Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_gameManager.GetCurrentState() == GameStates.LevelEditor)
        {
            if (Input.GetKey(KeyCode.Escape) && m_currentState != LevelEditorState.DetailedEditor &&
                m_currentState != LevelEditorState.TapToTheBeat)
            {
                m_audioManager.StopSong();
                m_audioManager.PlayStuckSound();
                m_gameManager.ChangeState(GameStates.MainMenu);
            }

            if (m_currentState == LevelEditorState.CreateOrLoad) // Choose to create or load
            {
                if (m_createOrLoad.CreateLevel)
                {
                    m_songSelection.Init();
                    m_songSelection.LoadMusicNames(m_audioManager.GetAllSongNames());
                    m_currentState = LevelEditorState.SongSelection;
                    m_createOrLoad.gameObject.SetActive(false);
                    m_songSelection.gameObject.SetActive(true);
                }
                else if (m_createOrLoad.LoadLevel)
                {
                    m_currentState = LevelEditorState.LoadLevel;
                    m_createOrLoad.gameObject.SetActive(false);
                    m_loadLevel.gameObject.SetActive(true);
                }
                else if (m_createOrLoad.Quit)
                {
                    m_gameManager.ChangeState(GameStates.MainMenu);
                    m_audioManager.StopSong();
                }
            }
            else if (m_currentState == LevelEditorState.LoadLevel)
            {
                if (m_loadLevel.LevelSelected)
                {
                    m_currentState     = LevelEditorState.DetailedEditor;
                    m_newLevel         = m_loadLevel.GetOldLevel();
                    m_selectedSongName = m_newLevel.MusicName;
                    m_audioManager.PlaySong(m_selectedSongName);
                    m_audioManager.StopSong();
                    m_loadLevel.gameObject.SetActive(false);
                    m_detailedEditor.gameObject.SetActive(true);
                    m_detailedEditor.Init(m_newLevel);
                }
                else if (m_loadLevel.Quit)
                {
                    m_gameManager.ChangeState(GameStates.MainMenu);
                }
            }
            else if (m_currentState == LevelEditorState.SongSelection) // Song Selection
            {
                if (m_songSelection.Quit)
                {
                    m_gameManager.ChangeState(GameStates.MainMenu);
                    m_audioManager.StopSong();
                }
                else if (m_songSelection.SongSelected)
                {
                    m_songSelection.gameObject.SetActive(false);
                    m_selectedSongName = m_songSelection.GetSelectedSongName();
                    m_currentState     = LevelEditorState.TapToTheBeat;
                    if (!m_audioManager.PlaySong(m_selectedSongName))
                    {
                        m_gameManager.ChangeState(GameStates.MainMenu);
                        print("Error in LevelEditorManager: Couldn't play selected song");
                    }
                    else
                    {
                        m_tapToTheBeat.gameObject.SetActive(true);
                    }
                }
            }
            else if (m_currentState == LevelEditorState.TapToTheBeat) // Tap To The Beat
            {
                if (m_tapToTheBeat.Skip || m_tapToTheBeat.SongOver)
                {
                    m_audioManager.StopSong();
                    m_detailedEditor.gameObject.SetActive(true);
                    m_newLevel = m_tapToTheBeat.GetNewLevel();
                    m_detailedEditor.Init(m_newLevel);
                    m_tapToTheBeat.gameObject.SetActive(false);
                    m_currentState = LevelEditorState.DetailedEditor;
                }
                else if (m_tapToTheBeat.Quit)
                {
                    m_gameManager.ChangeState(GameStates.MainMenu);
                    m_audioManager.StopSong();
                }
            }
            else if (m_currentState == LevelEditorState.DetailedEditor) // Detailed Selection
            {
                m_detailedEditor.UpdateDetailedEditor();
                if (m_detailedEditor.Save)
                {
                    SaveLevel(m_detailedEditor.GetNewLevel());
                    m_gameManager.ChangeState(GameStates.MainMenu);
                }
                else if (m_detailedEditor.Quit)
                {
                    m_gameManager.ChangeState(GameStates.MainMenu);
                    m_audioManager.StopSong();
                }
            }
        }
    }