Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class SceneBase : DrawableGameComponent
- {
- public List<GameComponent> SceneComponents { get; private set; }
- public SceneBase(Game game)
- : base(game)
- {
- SceneComponents = new List<GameComponent>();
- Visible = false;
- Enabled = false;
- }
- public void Show()
- {
- Enabled = true;
- Visible = true;
- }
- public void Hide()
- {
- Enabled = false;
- Visible = false;
- }
- public void Pause()
- {
- Enabled = false;
- Visible = true;
- }
- public override void Update(GameTime gameTime)
- {
- foreach (var component in SceneComponents
- .Where(x => x.Enabled))
- {
- component.Update(gameTime);
- }
- base.Update(gameTime);
- }
- public override void Draw(GameTime gameTime)
- {
- foreach (var component in SceneComponents
- .OfType<DrawableGameComponent>()
- .Where(x => x.Visible))
- {
- component.Draw(gameTime);
- }
- base.Draw(gameTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment