Beispiel #1
0
 public void Move(Game1.Direction direction, GameLand gameLand, GameObject[,] block, int height, int width, Bonuses bonuses, int[,] bonusBoard, GameTime gameTime)
 {
     bushSpeed = speed - 0.8f;
     if (direction == Game1.Direction.UP)
     {
         Position.Y = Position.Y - velocity.Length();
         CheckLandCollision(direction, gameLand, block, height, width);
         CheckBonuseCollision(bonuses, bonusBoard, height, width, gameTime);
         checkForGameLandAnd(direction, height, width);
     }
     if (direction == Game1.Direction.Down)
     {
         Position.Y = Position.Y + velocity.Length();
         CheckLandCollision(direction, gameLand, block, height, width);
         CheckBonuseCollision(bonuses, bonusBoard, height, width, gameTime);
         checkForGameLandAnd(direction, height, width);
     }
     if (direction == Game1.Direction.Right)
     {
         texture    = content.Load <Texture2D>("heroright");
         Position.X = Position.X + velocity.Length();
         CheckLandCollision(direction, gameLand, block, height, width);
         CheckBonuseCollision(bonuses, bonusBoard, height, width, gameTime);
         checkForGameLandAnd(direction, height, width);
     }
     if (direction == Game1.Direction.Left)
     {
         texture    = content.Load <Texture2D>("heroleft");
         Position.X = Position.X - velocity.Length();
         CheckLandCollision(direction, gameLand, block, height, width);
         CheckBonuseCollision(bonuses, bonusBoard, height, width, gameTime);
         checkForGameLandAnd(direction, height, width);
     }
 }
Beispiel #2
0
 public void Move(GameLand gameLand, GameObject[,] block, int height, int width, Hero hero)
 {
     Position.X += speedX;
     Position.Y += speedY;
     CheckLandCollision(gameLand, block, height, width);
     checkForGameLandAnd(height, width);
 }
Beispiel #3
0
 public void CheckLandCollision(Game1.Direction direction, GameLand gameLand, GameObject[,] block, int height, int width)
 {
     int[,] gameBoard = gameLand.GameBoard;
     block            = gameLand.Block;
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             if (gameBoard[y, x] == 30)
             {
                 if (BoundingBox.Intersects(block[y, x].BoundingBox))
                 {
                     if (direction == Game1.Direction.UP)
                     {
                         Position.X = Position.X + 0;
                         Position.Y = Position.Y + velocity.Length();
                     }
                     if (direction == Game1.Direction.Right)
                     {
                         Position.X = Position.X - velocity.Length();
                         Position.Y = Position.Y + 0;
                     }
                     if (direction == Game1.Direction.Down)
                     {
                         Position.X = Position.X + 0;
                         Position.Y = Position.Y - velocity.Length();
                     }
                     if (direction == Game1.Direction.Left)
                     {
                         Position.X = Position.X + velocity.Length();
                         Position.Y = Position.Y + 0;
                     }
                 }
             }
             else if (gameBoard[y, x] == 20)
             {
                 if (BoundingBox.Intersects(block[y, x].BoundingBox))
                 {
                     velocity = new Vector2(bushSpeed);
                 }
             }
             else if (gameBoard[y, x] != 30 && gameBoard[y, x] != 20)
             {
                 if (BoundingBox.Intersects(block[y, x].BoundingBox))
                 {
                     velocity = new Vector2(constantSpeed);
                 }
             }
         }
     }
 }
Beispiel #4
0
 public void Move(GameLand gameLand, GameObject[,] block, int height, int width, Hero hero)
 {
     if (speedX > 0)
     {
         texture = content.Load <Texture2D>("Flyingmonster");
     }
     else
     {
         texture = content.Load <Texture2D>("Flyingmonsterleft");
     }
     Position.X += speedX;
     Position.Y += speedY;
     checkForGameLandAnd(height, width);
 }
Beispiel #5
0
 public void Move(GameLand gameLand, GameObject[,] block, int height, int width, Hero hero)
 {
     if (speedX > 0)
     {
         texture = content.Load <Texture2D>("Zombie");
     }
     else
     {
         texture = content.Load <Texture2D>("Zombieleft");
     }
     Position.X += speedX;
     Position.Y += speedY;
     CheckLandCollision(gameLand, block, height, width);
     CheckForGameLandAnd(height, width);
 }
Beispiel #6
0
 public void Move(GameLand gameLand, GameObject[,] block, Hero hero)
 {
     for (int i = 0; i < count; i++)
     {
         if (monster[i] != null)
         {
             monster[i].Move(gameLand, block, h, w, hero);
         }
         if (zombie[i] != null)
         {
             zombie[i].Move(gameLand, block, h, w, hero);
         }
         if (flyingMonster[i] != null)
         {
             flyingMonster[i].Move(gameLand, block, h, w, hero);
         }
     }
 }
Beispiel #7
0
 public void CheckLandCollision(GameLand gameLand, GameObject[,] block, int height, int width)
 {
     int[,] gameBoard = gameLand.GameBoard;
     block            = gameLand.Block;
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             if (gameBoard[y, x] == 30)
             {
                 if (BoundingBox.Intersects(block[y, x].BoundingBox))
                 {
                     speedX *= -1;
                 }
             }
         }
     }
 }
Beispiel #8
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            gameLand = new GameLand(spriteBatch, height, width);
            gameLand.load(Content);


            bonuses = new Bonuses(spriteBatch, gameLand.H, gameLand.W);
            bonuses.load(Content, gameLand.GameBoard);


            enemys = new Enemys(Content, spriteBatch, 12, gameLand.H, gameLand.W);
            enemys.load(gameLand.GameBoard);

            hero         = new Hero(Content.Load <Texture2D>("heroright"), new Vector2(3, 3), 1.7f);
            hero.Content = Content;

            userInterface = new UserInterface(spriteBatch);
            userInterface.Load(Content, height, width);
        }