示例#1
0
 /// <summary>
 /// Draws the level's map, player, NPCs, and objects currently on screen
 /// </summary>
 /// <param name="batch">The SpriteBatch to perform the drawing</param>
 public void draw(SpriteBatch batch)
 {
     batch.Draw(map, Vector2.Zero, Color.White);
     foreach (Pit pit in pits)
     {
         pit.draw(batch);
         if (debug)
         {
             game.outline(batch, pit.getBounds());
         }
     }
     foreach (PressButton p in pressButtons)
     {
         p.draw(batch);
         if (debug)
         {
             game.outline(batch, p.getBounds());
         }
     }
     foreach (Projectile p in projectiles)
     {
         p.draw(batch);
         if (debug)
         {
             game.outline(batch, p.getBounds());
         }
     }
     foreach (GameObject o in objects)
     {
         if (o.isOnScreen(game))
         {
             o.draw(batch, mode);
         }
         if (debug)
         {
             game.outline(batch, o.getBounds());
         }
     }
     foreach (Cubicle c in cubicles)
     {
         c.draw(batch, debug);
     }
     foreach (Token t in tokens)
     {
         t.draw(batch, mode);
         if (debug && !t.isCollected())
         {
             game.outline(batch, t.getBounds());
         }
     }
     foreach (Key k in keys)
     {
         k.draw(batch, mode);
         if (debug && !k.isCollected())
         {
             game.outline(batch, k.getBounds());
         }
     }
     foreach (Door d in doors)
     {
         batch.Draw(d.getTexture(), d.getBounds(), Color.White);
         if (debug)
         {
             game.outline(batch, d.getBounds());
         }
     }
     foreach (Wall w in walls)
     {
         batch.Draw(w.getTexture(), w.getBounds(), Color.White);
         if (debug)
         {
             game.outline(batch, w.getBounds());
         }
     }
     foreach (Barrier b in barriers)
     {
         b.draw(batch);
         if (debug)
         {
             game.outline(batch, b.getBounds());
         }
     }
     foreach (Npc n in npcs)
     {
         n.draw(batch);
         n.getDefinition().drawThought(batch);
         if (n.wasHit() && n.getCombatTicks() < 250)
         {
             n.getDisplayBar().draw(batch);
             n.getHitsplat().draw(batch);
         }
         if (debug)
         {
             game.outline(batch, n.getBounds());
             game.outline(batch, n.getLineOfSight());
         }
     }
     batch.Draw(player.getTexture(), player.getBounds(), Color.White);
     if (debug)
     {
         game.outline(batch, player.getBounds());
     }
     playerManager.getKeyBox().draw(batch);
     playerManager.getHealthBar().draw(batch);
     playerManager.getManaBar().draw(batch);
     playerManager.getPowerBar().draw(batch);
     oldText = text;
     text    = inputManager.getDropText();
     if (text != null)
     {
         if (textTicks < 300)
         {
             if (text != oldText)
             {
                 textTicks = 0;
             }
             Vector2 size = game.getDropFont().MeasureString(text);
             dropLocation = new Vector2(game.getWidth() / 2.0F - (size.X / 2.0F), game.getHeight() / 2.0F - (size.Y / 2.0F));
             batch.DrawString(game.getDropFont(), text, dropLocation, Color.DodgerBlue);
             textTicks++;
         }
         else
         {
             text      = null;
             textTicks = 0;
             inputManager.setDropText(null);
         }
     }
 }