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:
                    SetMazeVisible(true);
                    SetLevel(1);
                    break;
                case 2:
                    // Setup ghosts
                    ghostManager.Ghosts[0].SetPredefinedPath(new Direction[]{ // Blinky
                        Direction.Up,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        // Goes through tunnel
                        Direction.Zero,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Left,
                        // Gets eaten
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                    });

                    ghostManager.Ghosts[1].SetPredefinedPath(new Direction[]{ // Pinky
                        Direction.Up,
                        Direction.Left,
                        Direction.Down,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        // Pellet starts
                        Direction.Down,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        // Pellet ends
                        Direction.Zero,
                        Direction.Up,
                        // Pellet starts
                        Direction.Left,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Left,
                        // Caught
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        // Home
                        Direction.Up,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Left, 
                        // Power pellet active
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Down
                    });

                    ghostManager.Ghosts[2].SetPredefinedPath(new Direction[]{ // Inky
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Right,
                        // Pellet starts
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        // Caught
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Left
                    });

                    ghostManager.Ghosts[3].SetPredefinedPath(new Direction[]{ // Clyde
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right
                    });

                    pacMan.SetPredefinedPath(new Direction[]{
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Down,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Left,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Zero,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Right,
                        Direction.Down,
                        Direction.Right,
                        Direction.Zero,
                        Direction.Up,
                        Direction.Left,
                        Direction.Up,
                        Direction.Right,
                        Direction.Up,
                        Direction.Left,
                        Direction.Zero,
                        Direction.Zero,
                        Direction.Down,
                        Direction.Right,
                        Direction.Down,
                        Direction.Left,
                        Direction.Down,
                        Direction.Right,
                    });

                    break;
                case 3:
                    SetPelletsActive(true);
                    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);
        }
    }
}
