コード例 #1
0
        /// <summary>
        /// Initialize most static objects and dependencies
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Copy, if needed, the required assemblies (BASS) for 32 or 64bit CPUs
            NativeAssemblies.Copy();

            // Initialize the logging tool for troubleshooting
            PulsarcLogger.Initialize();

            // Initialize Discord Rich Presence
            PulsarcDiscord.Initialize();

            // Set the default culture (Font formatting Locals) for this thread
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Start the thread listening for user input
            InputManager.StartThread();

            // Start our time and frame-time tracker
            PulsarcTime.Start();

            // Initialize FPS
            fpsDisplay = new FPS(Vector2.Zero);

            // Initialize the game camera
            gameCamera = new Camera(Graphics.GraphicsDevice.Viewport, (int)GetDimensions().X, (int)GetDimensions().Y, 1)
            {
                Pos = new Vector2(GetDimensions().X / 2, GetDimensions().Y / 2)
            };

            // Start the song selection in the background to have music when entering the game
            SongScreen = new SongSelection();
            SongScreen.Init();

            // Create and display the default game screen
            // (Currently Main menu. In the future can implement an intro)
            Menu firstScreen = new Menu();

            ScreenManager.AddScreen(firstScreen);

            cursor = new Cursor();

            IsReadyToUpdate = true;
        }
コード例 #2
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();
                }
            }
        }
    }