using UnityEngine;

namespace Marro.PacManUdon
{
    public partial class GameManager
    {
        private void TimeSequenceStepStartNewGame(int sequenceProgress)
        {
            switch (sequenceProgress)
            {
                case 0:
                    // Prepare new game, hide everything except score bar
                    gameState = PacManGameState.InGame;

                    HideEverything();

                    SetMazeActive(true);

                    InitializeNewGame();
                    InitializeLevel();
                    RestartLevel();
                    SetFrozen(true);
                    soundManager.SuppressSound(false);
                    soundManager.PlayGameStartSound();
                    break;
                case 1:
                    // Show maze, lives indicator, level indicator, player 1 and ready text

                    // SOMEWHERE IN HERE UNITY (EDITOR) APPEARS TO HAVE A SMALL RANDOM CHANCE OF CRASHING !!
                    Debug.Log("Log dump in case of crash");
                    Debug.Log("Setting pellets visible");
                    SetPelletsActive(true);
                    Debug.Log("Setting maze visible");
                    SetMazeVisible(true);
                    Debug.Log("Setting extra lives display visible");
                    statusDisplay.SetExtraLivesDisplayVisible(true);
                    Debug.Log("Setting level display visible");
                    statusDisplay.SetLevelDisplayVisible(true);
                    Debug.Log("Setting player 1 text visible");
                    statusDisplay.SetPlayer1TextVisible(true);
                    Debug.Log("Setting ready text visible");
                    statusDisplay.SetReadyTextVisible(true);
                    Debug.Log("Starting 1UP blink");
                    statusDisplay.SetLabel1UPTextBlinking(true);
                    break;
                case 2:
                    // Subtract a life
                    DecrementLives();
                    break;
                case 3:
                    // Remove Player 1 text
                    statusDisplay.SetPlayer1TextVisible(false);
                    break;
                case 4:
                    // Show ghosts and pacman
                    SetGhostsActive(true);
                    SetPacManActive(true);
                    break;
                case 5:
                    // Remove ready text
                    statusDisplay.SetReadyTextVisible(false);
                    break;
                case 6:
                    break;
            }
        }

        private void TimeSequenceFinalizeStartNewGame()
        {
            // Start game, end sequence
            soundManager.StartGhostSound();
            SetFrozen(false);
        }
    }
}
