public HelpComponent(Microsoft.Xna.Framework.Game game) : base(game) { var services = ServiceLocator.Current; _inputService = services.GetInstance <IInputService>(); _graphicsService = services.GetInstance <IGraphicsService>(); _gameObjectService = services.GetInstance <IGameObjectService>(); // Add a new graphics screen to the graphics service. _graphicsScreen = new SampleGraphicsScreen(services); _graphicsService.Screens.Add(_graphicsScreen); game.Components.ComponentAdded += OnGameComponentAdded; }
public ProfilerComponent(Microsoft.Xna.Framework.Game game) : base(game) { _services = ServiceLocator.Current; _inputService = _services.GetInstance <IInputService>(); _graphicsService = _services.GetInstance <IGraphicsService>(); // Add a new graphics screen to the graphics service. _graphicsScreen = new SampleGraphicsScreen(_services); _graphicsScreen.UseFixedWidthFont = true; _graphicsService.Screens.Add(_graphicsScreen); _stopwatch = Stopwatch.StartNew(); // Add format/description for profiler values which are captured in Update(). Profiler.SetFormat("NumBodies", 1, "The number of rigid bodies in the physics simulation."); Profiler.SetFormat("NumContacts", 1, "The number of contact constraints in the physics simulation."); }
protected BasicSample(Microsoft.Xna.Framework.Game game) : base(game) { // Create a graphics screen for rendering basic stuff. GraphicsScreen = new SampleGraphicsScreen(Services); // The order of the graphics screens is back-to-front. Add the screen at index 0, // i.e. behind all other screens. The screen should be rendered first and all other // screens (menu, GUI, help, ...) should be on top. GraphicsService.Screens.Insert(0, GraphicsScreen); // GameObjects that need to render stuff will retrieve the DebugRenderers or // Scene through the service provider. Services.Register(typeof(DebugRenderer), null, GraphicsScreen.DebugRenderer); Services.Register(typeof(DebugRenderer), "DebugRenderer2D", GraphicsScreen.DebugRenderer2D); Services.Register(typeof(IScene), null, GraphicsScreen.Scene); // Add a default light setup (ambient light + 3 directional lights). _defaultLightsObject = new DefaultLightsObject(Services); GameObjectService.Objects.Add(_defaultLightsObject); }