Source

HI-2DRTSSGMDDPP1 / GameProgram / GameProgram / GraphicsScene.cs

Full commit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GameProgram
{
  public class GraphicsScene : Loading, Draw
  {
    private List<GraphicsItem> graphicsItems = new List<GraphicsItem>();
    private SpriteBatch spriteBatch;

    public GraphicsScene( SpriteBatch spriteBatch )
    {
      // TODO: Complete member initialization
      this.spriteBatch = spriteBatch;
    }

    public GraphicsItem GraphicsItem
    {
      get
      {
        throw new System.NotImplementedException();
      }
      set
      {
      }
    }

    public void draw( SpriteBatch spriteBatch)
    {
      foreach( GraphicsItem graphicsItem in graphicsItems )      
      {
        graphicsItem.draw( spriteBatch );
      }

    }

    public void loadContent( Game1 game1 )
    {
      foreach( GraphicsItem graphicsItem in graphicsItems ) 
      {
        graphicsItem.loadContent( game1 );
      }
    }

    internal void Add( GameProgram.GraphicsItem newGraphicsItem )
    {
      graphicsItems.Add( newGraphicsItem );
    }

    public void setZoomFactor( float newZoomFactor )
    {
      if (newZoomFactor < 0.0F)
      {
        newZoomFactor = 0.0F;
      }

      foreach (GraphicsItem graphicsItem in graphicsItems)
      {
        graphicsItem.ZoomFactor = -newZoomFactor;
      }

    }

    public void setCameraOffset( Vector2 cameraOffset )
    {
      foreach (GraphicsItem graphicsItem in graphicsItems)
      {
        graphicsItem.CameraOffset = cameraOffset;
      }

    }

  }
}