using UnityEngine;

namespace Marro.PacManUdon
{
    public partial class GameManager
    {
        private void TimeSequenceStepAttractScreenDemo(int sequenceProgress)
        {
            switch (sequenceProgress)
            {
                case 0:
                    PrepareForCutscene();

                    SetGameState(PacManGameState.AttractModeDemo);
                    break;
                case 1:
                    InitializeLevel();
                    SetMazeVisible(true);
                    SetLevel(1);
                    break;
                case 2:
                    // Setup ghosts
                    ghostManager.Ghosts[0].SetPredefinedPath(new Vector2[]{ // Blinky
                        Vector2.down,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        // Goes through tunnel
                        Vector2.zero,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.left,
                        // Gets eaten
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                    });

                    ghostManager.Ghosts[1].SetPredefinedPath(new Vector2[]{ // Pinky
                        Vector2.down,
                        Vector2.left,
                        Vector2.up,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        // Pellet starts
                        Vector2.up,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        // Pellet ends
                        Vector2.zero,
                        Vector2.down,
                        // Pellet starts
                        Vector2.left,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.left,
                        // Caught
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        // Home
                        Vector2.down,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.left, 
                        // Power pellet active
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.up
                    });

                    ghostManager.Ghosts[2].SetPredefinedPath(new Vector2[]{ // Inky
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.right,
                        // Pellet starts
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        // Caught
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.left
                    });

                    ghostManager.Ghosts[3].SetPredefinedPath(new Vector2[]{ // Clyde
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right
                    });

                    pacMan.SetPredefinedPath(new Vector2[]{
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.up,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.left,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.zero,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.right,
                        Vector2.up,
                        Vector2.right,
                        Vector2.zero,
                        Vector2.down,
                        Vector2.left,
                        Vector2.down,
                        Vector2.right,
                        Vector2.down,
                        Vector2.left,
                        Vector2.zero,
                        Vector2.zero,
                        Vector2.up,
                        Vector2.right,
                        Vector2.up,
                        Vector2.left,
                        Vector2.up,
                        Vector2.right,
                    });

                    break;
                case 3:
                    SetPelletsActive(true);
                    pelletManager.RestoreAllPellets();
                    statusDisplay.SetGameOverTextVisible(true);
                    break;
                case 4:
                    // Show pacman, show ghosts
                    SetPacManActive(true);
                    SetGhostsActive(true);
                    break;
                case 5:
                    // Unfreeze
                    SetFrozen(false);
                    break;
                case 6:
                    break;
            }
        }

        private void TimeSequenceFinishedAttractScreenDemo()
        {
            StartTimeSequence(PacManTimeSequence.AttractScreenWaitToRestart);
        }
    }
}
