예제 #1
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (EndGame)
            {
                /*Reset the intro booleans*/
                StartGame = false;
                //Sets back to First level
                i      = -1;
                hasWon = false;
            }
            if (!StartGame)
            {
                IntroScreen();
            }
            else
            {
                // TODO: Add your update logic here
                if (hasWon)
                {
                    //blob.reset();
                    i++;
                    if (i >= levels.Count)
                    {
                        //End of the whole game
                        EndGame           = true;
                        StartGame         = false;
                        PlayBtn.isClicked = false;
                    }
                    if (!EndGame && levels[i] != null)
                    {
                        level         = levels[i];
                        hasWon        = false;
                        blob.Position = level.StartPosition;
                    }
                }

                blob.Update(gameTime);

                foreach (var item in level.BlokArray)
                {
                    if (item != null)
                    {
                        collisionManager.ExecuteCollision(blob.CollisionRectangle, item.CollisionRectangle, level.Width, level.Height, blob);
                    }
                }

                camera.Update(blob.Position, level.Width, level.Height);

                foreach (var platform in level.Platforms)
                {
                    platform.animHandler(blob.hasJumped);
                }

                //Game over check
                hasWon = collisionManager.CheckEndCollision(blob.CollisionRectangle, level.endPlatform.CollisionRectangle);

                base.Update(gameTime);
            }
        }