using UnityEngine;

namespace Marro.PacManUdon
{
    public partial class GameManager
    {
        private void TimeSequenceStepIntermission1(int sequenceProgress)
        {
            var blinky = ghostManager.Ghosts[0];

            switch (sequenceProgress)
            {
                case 0:
                    PrepareForCutscene();
                    
                    // Show just level display
                    statusDisplay.SetLevelDisplayVisible(true);
                    break;
                case 1:
                    // Start animation, pacman running and blinky prepared to chase
                    soundManager.SuppressSound(false);
                    soundManager.StartIntermissionSound();

                    pacMan.SetLevel(4);
                    pacMan.SetPowerPellet(false); // Update speed
                    pacMan.SetKinematic(true);
                    pacMan.SetActive(true);
                    pacMan.SetPosition(intermissionScreenElements[0].transform.localPosition);
                    pacMan.SetDirectionAndTargetDirection(Direction.Left);

                    ghostManager.SetLevel(5);
                    ghostManager.SetKinematic(true);
                    ghostManager.gameObject.SetActive(true);
                    blinky.SetElroy(2);
                    blinky.SetPosition(intermissionScreenElements[1].transform.localPosition);
                    blinky.SetDirectionAndTargetDirection(Direction.Left);
                    blinky.SetState(PacManGhostState.Normal);
                    
                    SetFrozen(false);
                    break;
                case 2:
                    // Start blinky chasing
                    blinky.SetActive(true);
                    break;
                case 3:
                    // Reached end, make ghost scared and turn around
                    blinky.BecomeScared();
                    blinky.SetPosition(intermissionScreenElements[3].transform.localPosition);
                    pacMan.SetDirection(Direction.Zero);
                    pacMan.SetPosition(intermissionScreenElements[2].transform.localPosition);
                    pacMan.SetPowerPellet(true);
                    
                    break;
                case 4:
                    // Pacman starts chasing ghosts
                    pacMan.SetDirectionAndTargetDirection(Direction.Right);
                    pacMan.BecomeBig();
                    break;
                case 5:
                    // End cutscene
                    soundManager.StopAllSound();
                    SetFrozen(true);
                    break;
            }
        }

        private void TimeSequenceFinishedIntermission1()
        {
            StartTimeSequence(PacManTimeSequence.StartNewLevel);
        }
    }
}
