コード例 #1
0
        public void BlockFireballCollide(Block block, Fireball fireball)
        {
            Rectangle blockRect    = block.GetBoundingBox();
            Rectangle fireballRect = fireball.GetBoundingBox();
            Rectangle intersection = Rectangle.Intersect(blockRect, fireballRect);

            if (fireballRect.Bottom > blockRect.Top && fireballRect.Bottom < blockRect.Bottom)
            {
                fireball.position.Y = fireball.position.Y - intersection.Height;
            }
            if (!block.state.GetType().Equals((new GenericBlockState(SpriteFactory.sprites.ground).GetType())))
            {
                game.level.deadFireballs.Add(fireball);
                mario.fireballCount--;
            }
        }
コード例 #2
0
 public void Draw(SpriteBatch spriteBatch)
 {
     foreach (KeyValuePair <IAnimatedSprite, Vector2> backgroundObject in levelBackgroundObjects)
     {
         backgroundObject.Key.Draw(spriteBatch, backgroundObject.Value, Color.White);
     }
     foreach (ICollectable item in levelItems)
     {
         if (game.gameCamera.InCameraView(item.GetBoundingBox()))
         {
             item.Draw(spriteBatch);
         }
     }
     foreach (Enemy enemy in levelEnemies)
     {
         if (game.gameCamera.InCameraView(enemy.GetBoundingBox()))
         {
             enemy.Draw(spriteBatch);
         }
     }
     foreach (Fireball fireball in levelFireballs)
     {
         if (game.gameCamera.InCameraView(fireball.GetBoundingBox()))
         {
             fireball.Draw(spriteBatch);
         }
     }
     foreach (ThrowingStar throwingStar in levelThrowingStars)
     {
         if (game.gameCamera.InCameraView(throwingStar.GetBoundingBox()))
         {
             throwingStar.Draw(spriteBatch);
         }
     }
     foreach (Block blockDrawer in levelBlocks)
     {
         if (game.gameCamera.InCameraView(blockDrawer.GetBoundingBox()))
         {
             blockDrawer.Draw(spriteBatch, blockDrawer.position);
         }
     }
     foreach (Spike spikeDrawer in levelSpikes)
     {
         if (game.gameCamera.InCameraView(spikeDrawer.GetBoundingBox()))
         {
             spikeDrawer.Draw(spriteBatch);
         }
     }
     foreach (Trampoline trampolineDrawer in levelTrampolines)
     {
         if (game.gameCamera.InCameraView(trampolineDrawer.GetBoundingBox()))
         {
             trampolineDrawer.Draw(spriteBatch);
         }
     }
     if (!game.isTitle)
     {
         mario.Draw(spriteBatch);
     }
     if (game.gameCamera.InCameraView(exitPole.GetBoundingBox(exitPosition)))
     {
         exitPole.Draw(spriteBatch, exitPosition, Color.White);
     }
     foreach (Pipe pipeDrawer in levelPipes)
     {
         if (game.gameCamera.InCameraView(pipeDrawer.GetBoundingBox()))
         {
             pipeDrawer.Draw(spriteBatch, pipeDrawer.position);
         }
     }
 }