/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { fullScreenSettings = new ResolutionSettings(320, 240, this.GraphicsDevice.DisplayMode.Width, this.GraphicsDevice.DisplayMode.Height, true); //Initialization Logic // Set our XNA content directory Content.RootDirectory = "Content"; // create our services CreateServices(); #if !XBOX // create our screens Screen editorScreen = new EditorScreen(this, EditorScreen.ScreenName); this.screenList.Add(editorScreen); #endif Screen gameScreen = new GameScreen(this, GameScreen.ScreenName); this.screenList.Add(gameScreen); Screen titleScreen = new StoryboardScreen("TitleScreen", "Introduction", @"StoryboardXML\TitleScreenStoryboard"); this.screenList.Add(titleScreen); Screen introScreen = new StoryboardScreen("Introduction", "Game", @"StoryboardXML\IntroductionStoryboard"); this.screenList.Add(introScreen); Screen midpoint = new StoryboardScreen("MidPoint", "Game", @"StoryboardXML\MidPointStoryboard"); this.screenList.Add(midpoint); Screen endScreen = new StoryboardScreen("Ending", "Game", @"StoryboardXML\EndingStoryboard"); this.screenList.Add(endScreen); this.AddScreenToDisplay(titleScreen); resolutionService = new ScreenResolutionService(graphics, ScreenManager.WindowedSettings); this.Services.AddService(typeof(IScreenResolutionService), resolutionService); sb = new SpriteBatch(GraphicsDevice); //For profiling: /* this.IsFixedTimeStep = false; graphics.SynchronizeWithVerticalRetrace = false; graphics.ApplyChanges(); */ // Initialize all components base.Initialize(); }
public void Update() { if (this.CurrentProgress == ScreenTransitionProgess.Fading && this.currentAlphaValue <= 0.0f) { this.CurrentProgress = ScreenTransitionProgess.Brightening; this.currentAlphaValue = 0.0f; Screen screenToRemove = (from sc in ScreenManager.Instance.ScreenList where sc.Name == this.FromScreenName select sc).First(); ScreenManager.Instance.RemoveScreenFromDisplay(screenToRemove); if (this.resetGame) { ScreenManager.Instance.ScreenList.Remove(screenToRemove); Screen gameScreen = new GameScreen(ScreenManager.Instance, GameScreen.ScreenName); ScreenManager.Instance.ScreenList.Add(gameScreen); ICameraService camera = (ICameraService)ScreenManager.Instance.Services.GetService(typeof(ICameraService)); camera.Position = new Vector2(0, 0); } if (this.resetSpriteBatchService) { ScreenManager.Instance.UseSpriteBatchService = true; } Screen screenToAdd = (from sc in ScreenManager.Instance.ScreenList where sc.Name == this.ToScreenName select sc).First(); screenToAdd.Enabled = false; ScreenManager.Instance.AddScreenToDisplay(screenToAdd); } if (this.IsTransitionComplete) { this.EnableNewScreen(); } }