Beispiel #1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(_background, Bounds, Color.White);

            PlatformManager.Draw(spriteBatch);
            FlagManager.Draw(spriteBatch);

            Player.Draw(spriteBatch);
        }
Beispiel #2
0
        public void Update(GameTime gameTime)
        {
            Player.Update(gameTime);

            FlagManager.Update(gameTime);

            if (FlagManager.CompletedCount >= FlagManager.FlagCount)
            {
                GameComplete = true;
            }

            // Platform collision logic
            Tuple <bool, Platform, bool> platformResults = PlatformManager.PlayerOnPlatform();

            if (platformResults.Item1 && (Player.State == Player.States.running || Player.State == Player.States.standing))
            {
                if (platformResults.Item2.Bounds.X < Player.X)
                {
                    Player.SetX(platformResults.Item2.Bounds.X + platformResults.Item2.Bounds.Width - 5);
                }
                else
                {
                    Player.SetX(platformResults.Item2.Bounds.X - Player.CollisionBox.Width - 1);
                }
            }

            if (platformResults.Item1 && Player.State == Player.States.jumping)
            {
                if (platformResults.Item2.Bounds.Y < Player.CollisionBox.Y)
                {
                    Player.VerticalSpeed = 0;
                    Player.SetY(platformResults.Item2.Bounds.Y + platformResults.Item2.Bounds.Height);
                }
            }

            if (platformResults.Item1 && (Player.State == Player.States.falling || Player.State == Player.States.jumping))
            {
                if (platformResults.Item2.Bounds.Y - (Player.Y + Player.Height) > -27)
                {
                    Player.State = Player.States.standing;
                    Player.SetY(platformResults.Item2.Bounds.Y - Player.Height - 1);
                }
                else if (platformResults.Item2.Bounds.Y + platformResults.Item2.Bounds.Height > Player.Y)
                {
                    if (platformResults.Item2.Bounds.X < Player.X)
                    {
                        Player.SetX(platformResults.Item2.Bounds.X + platformResults.Item2.Bounds.Width);
                    }
                    else
                    {
                        Player.SetX(platformResults.Item2.Bounds.X - Player.CollisionBox.Width - 1);
                    }
                }
            }
            else if (Player.State != Player.States.jumping && platformResults.Item3 == false)
            {
                Player.State = Player.States.falling;
            }

            Player.UpdateAnimation(gameTime);
        }
Beispiel #3
0
 public void InitializeMap(ContentManager content)
 {
     PlatformManager = new PlatformManager(_tileMap, this, Player, content);
     FlagManager     = new FlagManager(_tileMap, this, Player, content);
 }