public override void Draw(SpriteBatch batch, GameTime gameTime, StateBasedGame container)
 {
     if (container.SwitchingStates)
         return;
     switch (currentState)
     {
         case MENUSTATES.START_1:
             DrawIntro(batch, title_devil);
             break;
         case MENUSTATES.START_2:
             DrawIntro(batch, title_arma);
             break;
         case MENUSTATES.START_3:
              DrawIntro(batch, title_pacamari);
             break;
         case MENUSTATES.START_4:
              DrawIntro(batch, title_of);
             break;
         case MENUSTATES.START_5:
              DrawIntro(batch, title_death);
             break;
         case MENUSTATES.START_6:
              DrawIntro(batch, title_hme);
             break;
         case MENUSTATES.SELECT:
             DrawSelect(batch, container);
             break;
     }
 }
 public override void Enter(StateBasedGame container)
 {
     menuSelection = 0;
     currentState = MENUSTATES.SELECT;
     MediaPlayer.IsRepeating = true;
     MediaPlayer.Volume = 0.5f;
     MusicManager.Get().PlayMenuMusic();
     flashTimer = 1000;
     menuTimer = 200;
     oldState = Keyboard.GetState();
 }
 public override void Enter(StateBasedGame container)
 {
     startTimer = 4000;
     pacman.SetStartPositionTile(50, 50);
     currentState = GAMEPLAYSTATES.START;
     cam.SetFixVector(Vector2.Zero);
     cam.CamSpeed = 0.2f;
     cam.Position = pacman.Position - Globals.CENTER_PACMAN / cam.Scale;
     MediaPlayer.IsRepeating = false;
     MediaPlayer.Volume = 1f;
     cam.ShakeScreen(2, 1);
     factory.ResetFactory(gameMap.Width, gameMap.Height);
     survialManager.ResetSurivalMode();
     hud.Reset();
 }
        public override void Draw(SpriteBatch batch, GameTime gameTime, StateBasedGame container)
        {
            DrawMap(batch, container.GraphicsDevice);
            DrawEntities(batch);
            DrawPlayer(batch);

            if (currentState == GAMEPLAYSTATES.END || currentState == GAMEPLAYSTATES.ENDRESULT)
                Globals.DrawBlendOut(batch, startTimer, 2000);

            if (currentState == GAMEPLAYSTATES.ENDRESULT)
                DrawEndResults(batch);
            hud.DrawHUD(batch);

            if (startTimer > 0)
            {
                if (currentState == GAMEPLAYSTATES.START)
                    Globals.DrawBlendIn(batch, startTimer, 4000);
            }
        }
 /// <summary>
 /// Called when entering this state
 /// </summary>
 /// <param name="container"> the container for the states</param>
 public abstract void Enter(StateBasedGame container);
 /// <summary>
 /// Called for draw updates
 /// </summary>
 /// <param name="batch"> the batch to use</param>
 /// <param name="gameTime"> the game time of the current context</param>
 /// <param name="container"> the container for the states</param>
 public abstract void Draw(SpriteBatch batch, GameTime gameTime, StateBasedGame container);
 public override void Init(StateBasedGame container)
 {
     pacman.Init(container.Content);
     gameMap = Map.Load(Path.Combine(container.Content.RootDirectory, "test.tmx"), container.Content);
     cam.MapSize = new Point(gameMap.Width, gameMap.Height);
     factory.Init(gameMap.Width, gameMap.Height);
     survialManager.Init();
     hud.Init(container.Content);
     highscore = container.Content.Load<Texture2D>("Graphics/Highscore");
 }
 public override void Exit(StateBasedGame container)
 {
 }
 public override void Update(GameTime gameTime, StateBasedGame container)
 {
     switch (currentState)
     {
         case MENUSTATES.START_0:
             UpdateMusicIntro(gameTime.ElapsedGameTime.Milliseconds);
             break;
         case MENUSTATES.START_1:
         case MENUSTATES.START_2:
         case MENUSTATES.START_3:
         case MENUSTATES.START_4:
         case MENUSTATES.START_5:
         case MENUSTATES.START_6:
             if (Keyboard.GetState().IsKeyDown(Keys.Escape))
             {
                 MusicManager.Get().PlaySound("cursor", 1f);
                 currentState = MENUSTATES.SELECT;
                 return;
             }
             UpdateIntro(gameTime.ElapsedGameTime.Milliseconds);
             break;
         case MENUSTATES.SELECT:
             UpdateSelect(gameTime.ElapsedGameTime.Milliseconds, container);
             UpdateFlash(gameTime.ElapsedGameTime.Milliseconds);
             break;
     }
 }
        private void UpdatePlay(int delta, StateBasedGame container)
        {
            pacman.Update(Keyboard.GetState(), delta);
            cam.Update(delta);
            survialManager.Update(delta);

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                startTimer = 2000;
                survialManager.NullCombo();
                currentState = GAMEPLAYSTATES.END;
                musicManager.PlayWinMusic();
            }

               //container.EnterState(Globals.MENUSTATE);

            if (/*musicManager.isSongStopped()*/ false)
            {
                startTimer = 2000;
                currentState = GAMEPLAYSTATES.END;
            }
        }
 public override void Update(GameTime gameTime, StateBasedGame container)
 {
     switch (currentState)
     {
         case GAMEPLAYSTATES.START:
             UpdateStart(gameTime.ElapsedGameTime.Milliseconds);
             break;
         case GAMEPLAYSTATES.PLAY:
             UpdatePlay(gameTime.ElapsedGameTime.Milliseconds, container);
             break;
         case GAMEPLAYSTATES.END:
             UpdateEnd(gameTime.ElapsedGameTime.Milliseconds);
             break;
         case GAMEPLAYSTATES.ENDRESULT:
             UpdateResult(gameTime.ElapsedGameTime.Milliseconds, container);
             break;
         default:
             throw new NullReferenceException("GAMEPLAYSTATE is invalid: " + currentState);
     }
 }
        private void UpdateSelect(int delta, StateBasedGame container)
        {
            if(menuTimer <= 0)
            {
                pacmanState = !pacmanState;
                menuTimer = 200;
            }
            else
                menuTimer -= delta;

            KeyboardState newState = Keyboard.GetState();

            if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
            {
                MusicManager.Get().PlaySound("cursor", 1f);
                menuSelection++;
                if (menuSelection > 2)
                    menuSelection = 0;
            }
            if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
            {
                MusicManager.Get().PlaySound("cursor", 1f);
                menuSelection--;
                if (menuSelection < 0)
                    menuSelection = 2;
            }
            if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
            {
                MusicManager.Get().PlaySound("enter", 1f);
                switch (menuSelection)
                {
                    case 0:
                        MediaPlayer.Stop();
                        container.EnterState(Globals.GAMEPLAYSTATE);
                        break;
                    case 1:
                        container.Graphics.ToggleFullScreen();
                        break;
                    case 2:
                        Thread.Sleep(600);
                        container.Exit();
                        break;
                }
            }

            oldState = newState;
        }
        private void DrawSelect(SpriteBatch batch, StateBasedGame container)
        {
            Vector2 titelpos = new Vector2(15, 13);

            batch.Begin();
            batch.Draw(background, Vector2.Zero, Color.White);
            batch.Draw(title_devil, titelpos, Color.White);
            batch.Draw(title_arma, titelpos, Color.White);
            batch.Draw(title_pacamari, titelpos, Color.White);
            batch.Draw(title_of, titelpos, Color.White);
            batch.Draw(title_death, titelpos, Color.White);
            batch.Draw(title_hme, new Vector2(99, 271), Color.White);

            batch.Draw(menu_start, new Vector2(551, 259), Color.White);
            if(container.Graphics.IsFullScreen)
                batch.Draw(menu_windowed, new Vector2(552, 306), Color.White);
            else
            batch.Draw(menu_fullscreen, new Vector2(552, 306), Color.White);

            batch.Draw(menu_end, new Vector2(553, 352), Color.White);

            batch.End();

            batch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(2));
            if(pacmanState)
                batch.DrawSprite(Player.Get().PacmanAnimation, new Vector2(264, 140 + (23 * menuSelection)), 0, 0, 0);
            else
                batch.DrawSprite(Player.Get().PacmanAnimation, new Vector2(264, 140 + (23 * menuSelection)), 0, 1, 0);

            batch.End();

            DrawHigscore(batch);

            DrawFlash(batch);
        }
 /// <summary>
 /// Called on adding into the list of states
 /// </summary>
 /// <param name="container"> the container for the states</param>
 public abstract void Init(StateBasedGame container);
 private void UpdateResult(int delta, StateBasedGame container)
 {
     if (Keyboard.GetState().IsKeyDown(Keys.Enter))
     {
         container.EnterState(Globals.MENUSTATE);
         Globals.HIGHSCORE = survialManager.GetPoints();
         Globals.WriteHighscore();
     }
 }
 /// <summary>
 /// Called for logic updates
 /// </summary>
 /// <param name="gameTime"> the game time of the current context</param>
 /// <param name="container"> the container for the states</param>
 public abstract void Update(GameTime gameTime, StateBasedGame container);
        public override void Init(StateBasedGame container)
        {
            background = container.Content.Load<Texture2D>("Graphics/Menu/bgmenu");
            title_devil = container.Content.Load<Texture2D>("Graphics/Menu/start_1");
            title_arma = container.Content.Load<Texture2D>("Graphics/Menu/start_2");
            title_pacamari = container.Content.Load<Texture2D>("Graphics/Menu/start_3");
            title_of = container.Content.Load<Texture2D>("Graphics/Menu/start_4");
            title_death = container.Content.Load<Texture2D>("Graphics/Menu/start_5");
            title_hme = container.Content.Load<Texture2D>("Graphics/Menu/start_6");
            menu_start = container.Content.Load<Texture2D>("Graphics/Menu/start");
            menu_fullscreen = container.Content.Load<Texture2D>("Graphics/Menu/fullscreen");
            menu_windowed = container.Content.Load<Texture2D>("Graphics/Menu/windowed");
            menu_end = container.Content.Load<Texture2D>("Graphics/Menu/end");
            blend = container.Content.Load<Texture2D>("Graphics/BlendWhite");
            highscore = container.Content.Load<Texture2D>("Graphics/Highscore");

            currentState = MENUSTATES.START_0;
            introWaitTimer = 1700;
            flashTimer = 1000;
            cam.ShakeScreen(3000, 10);
            menuSelection = 0;
            menuTimer = 200;
            oldState = Keyboard.GetState();
        }