/// <summary> /// Constructs a new screen manager component. /// </summary> public ScreenManager(Game game) : base(game) { // we must set EnabledGestures before we can query for them, but // we don't assume the game wants to read them. TouchPanel.EnabledGestures = GestureType.None; // Create the lighting system. sunBurnCoreSystem = new SunBurnCoreSystem(game.Services, game.Content); sceneState = new SceneState(); // Create the scene interface. Acts as a service provider containing all scene managers // and returning them by type (including custom managers). Also acts as a component // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering, // Unload, ...) are automatically called on all contained managers. // // This design allows managers to be plugged-in like modular components and for managers // to easily be added, removed, or replaced with custom implementations. // sceneInterface = new SceneInterface(); sceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true); // Create the frame buffers used for rendering (sized to the backbuffer) and // assign them to the ResourceManager so we don't have to worry about cleanup. frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.Medium); sceneInterface.ResourceManager.AssignOwnership(frameBuffers); }
/// <summary> /// Constructs a new screen manager component. /// </summary> public ScreenManager(Game game) : base(game) { // we must set EnabledGestures before we can query for them, but // we don't assume the game wants to read them. TouchPanel.EnabledGestures = GestureType.None; // Create the lighting system. sunBurnCoreSystem = new SunBurnCoreSystem(game.Services, game.Content); sceneState = new SceneState(); // Create the scene interface. Acts as a service provider containing all scene managers // and returning them by type (including custom managers). Also acts as a component // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering, // Unload, ...) are automatically called on all contained managers. // // This design allows managers to be plugged-in like modular components and for managers // to easily be added, removed, or replaced with custom implementations. // sceneInterface = new SceneInterface(); sceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true); // Create the frame buffers used for rendering (sized to the backbuffer) and // assign them to the ResourceManager so we don't have to worry about cleanup. frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.Medium); sceneInterface.ResourceManager.AssignOwnership(frameBuffers); // Post console messages letting the user know how to open the SunBurn Editor. sceneInterface.ShowConsole = true; SystemConsole.AddMessage("Welcome to the SunBurn Engine.", 4); SystemConsole.AddMessage("Use an Xbox controller or the W, A, S, D keys to navigate the scene.", 8); SystemConsole.AddMessage("Press F11 to open the SunBurn Editor.", 12); }
/// <summary> /// Initialize resources which should be available at any /// point during the game (eg: resources that are not screen specific). /// </summary> public override void OnPlatformInitializationComplete() { // Load the database of game assets. ContentDatabase = new ContentDatabase("GameContent"); // Create the core system. sunBurnCoreSystem = new SunBurnCoreSystem(ContentDatabase); // Set the initial game screen. Platform.Instance.SetGameScreen(splashScreenGameScreen); }
protected Application(string name, string contentDirectory, params Language[] supportedLanguages) { // set the game title Name = name; // set the default content directory Content.RootDirectory = contentDirectory; // set the static instance Instance = this; IsFixedTimeStep = true; TargetElapsedTime = TimeSpan.FromMilliseconds(1000d / 60d); EnableClearDevice = true; ClearDeviceColor = Color.Black; // create our GraphicsDeviceManager instance GraphicsDeviceManager = new GraphicsDeviceManager(this) { SynchronizeWithVerticalRetrace = true, #if !WINDOWS_PHONE PreferredBackBufferWidth = 1280, PreferredBackBufferHeight = 720, #else PreferredBackBufferWidth = 800, PreferredBackBufferHeight = 480, #endif }; GraphicsDeviceManager.PreparingDeviceSettings += (sender, e) => { #if WINDOWS // improves overall performance with dynamic shadows. e.GraphicsDeviceInformation. PresentationParameters. RenderTargetUsage = RenderTargetUsage.PlatformContents; #else // improves overall performance with dynamic shadows. e.GraphicsDeviceInformation. PresentationParameters. RenderTargetUsage = RenderTargetUsage.PreserveContents; #endif // Used for advanced edge cleanup. e.GraphicsDeviceInformation. PresentationParameters. DepthStencilFormat = DepthFormat.Depth24Stencil8; }; try { // create the SunBurn required SunBurnCoreSystem instance SunBurnCoreSystem = new SunBurnCoreSystem(Services, Content) { DetectOverSizedFrameBuffers = false }; } catch (Exception e) { Console.WriteLine(e.Message); } // create the SunBurn SunBurnSystemPreferences instance used when creating a new SceneInterface instance: defaults to average quality SunBurnSystemPreferences = new SystemPreferences { EffectDetail = DetailPreference.Medium, LightingDetail = DetailPreference.Medium, MaxAnisotropy = 4, PostProcessingDetail = DetailPreference.Medium, ShadowDetail = DetailPreference.Medium, ShadowQuality = 2.0f, TextureSampling = SamplingPreference.Anisotropic, }; // create and register InputManager instance for the game. new InputManager(this); // create and register StorageManager instance for the game. new StorageManager(this); StorageSettings.SetSupportedLanguages(supportedLanguages); // create our Thread pool Threads = new ThreadPool(); Window.ClientSizeChanged += (sender, args) => { Graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; Graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; Graphics.ApplyChanges(); }; }
public StarterGame() { // Default XNA setup. graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Required for lighting system. graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; // Required for lighting system. splashScreenGameComponent = new SplashScreenGameComponent(this); Components.Add(splashScreenGameComponent); // Create the lighting system. sunBurnCoreSystem = new SunBurnCoreSystem(Services, Content); sceneState = new SceneState(); // Create the scene interface. Acts as a service provider containing all scene managers // and returning them by type (including custom managers). Also acts as a component // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering, // Unload, ...) are automatically called on all contained managers. // // This design allows managers to be plugged-in like modular components and for managers // to easily be added, removed, or replaced with custom implementations. // SceneInterface = new SceneInterface(); SceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true); SpriteManager = new SpriteManager(SceneInterface); SceneInterface.AddManager(SpriteManager); // Create the frame buffers used for rendering (sized to the backbuffer) and // assign them to the ResourceManager so we don't have to worry about cleanup. frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.Medium); SceneInterface.ResourceManager.AssignOwnership(frameBuffers); physicsManager.RegisterPhysicsBody(Character); collisionManager.RegisterCollisionBody(Character); // Post console messages letting the user know how to open the SunBurn Editor. SceneInterface.ShowConsole = true; SystemConsole.AddMessage("Welcome to the SunBurn Engine.", 4); SystemConsole.AddMessage("Use an Xbox controller or the W, A, S, D keys to navigate the scene.", 8); SystemConsole.AddMessage("Press F11 to open the SunBurn Editor.", 12); }