Example #1
0
 // Loops through all components on the ship and calls Draw() on each one
 public void Draw(SpriteBatch spriteBatch, Grid.GridInfo gridInfo)
 {
     spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp);
     foreach (Component component in Components)
     {
         // Passes gridInfo so that if/when the grid is altered, the components will be rendered correctly
         component.Draw(spriteBatch, gridInfo);
     }
     spriteBatch.End();
 }
Example #2
0
 public virtual void Draw(SpriteBatch spriteBatch, Grid.GridInfo gridInfo)
 {
     if (Broken)
     {
         // Not sure how to handle this yet
         throw new Exception("Component is broken!");
     }
     else
     {
         // Calculates where it should go on the screen.
         // Uses gridInfo to determine the size/location of the grid.
         int       xPos  = gridInfo.GridRectangle.X + gridInfo.TileWidth * X;
         int       yPos  = gridInfo.GridRectangle.Y + gridInfo.TileHeight * Y;
         int       xSize = gridInfo.TileWidth;
         int       ySize = gridInfo.TileHeight;
         Rectangle dest  = new Rectangle(xPos, yPos, xSize, ySize);
         spriteBatch.Draw(Texture, dest, Color);
     }
 }