#region Using Statements using System.Collections.Generic; using Microsoft.Xna.Framework; #endregion namespace RockRainIphone.Core { /// /// This is the base class for all game scenes. /// public abstract class GameScene : DrawableGameComponent { /// /// List of child GameComponents /// private readonly List components; public GameScene(Game game) : base(game) { components = new List(); Visible = false; Enabled = false; } /// /// Show the scene /// public virtual void Show() { Visible = true; Enabled = true; } /// /// Hide the scene /// public virtual void Hide() { Visible = false; Enabled = false; } /// /// Components of Game Scene /// public List Components { get { return components; } } /// /// Allows the game component to update itself. /// /// Provides a snapshot of timing values. public override void Update(GameTime gameTime) { // Update the child GameComponents for (int i = 0; i < components.Count; i++) { if (components[i].Enabled) { components[i].Update(gameTime); } } base.Update(gameTime); } /// /// Allows the game component draw your content in game screen /// public override void Draw(GameTime gameTime) { // Draw the child GameComponents (if drawable) for (int i = 0; i < components.Count; i++) { GameComponent gc = components[i]; if ((gc is DrawableGameComponent) && ((DrawableGameComponent) gc).Visible) { ((DrawableGameComponent) gc).Draw(gameTime); } } base.Draw(gameTime); } } }