コード例 #1
0
        public void BlockThrowingStarCollide(Block block, ThrowingStar throwingStar)
        {
            Rectangle blockRect        = block.GetBoundingBox();
            Rectangle throwingStarRect = throwingStar.GetBoundingBox();
            Rectangle intersection     = Rectangle.Intersect(blockRect, throwingStarRect);

            if (throwingStarRect.Bottom > blockRect.Top && throwingStarRect.Bottom < blockRect.Bottom)
            {
                throwingStar.position.Y = throwingStar.position.Y - intersection.Height;
            }
            if (!block.state.GetType().Equals((new GenericBlockState(SpriteFactory.sprites.ground).GetType())))
            {
                game.level.deadThrowingStars.Add(throwingStar);
                mario.throwingStarCount--;
            }
        }
コード例 #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);
         }
     }
 }