public static void Init(GameServiceContainer serviceContainer, string rootDir) { ContentManager = new ContentManager(serviceContainer); ContentManager.RootDirectory = rootDir; LoadEffects(false); }
private static void SetupKernel(IKernel kernel) { kernel.Load <ProtogameAssetModule>(); kernel.Load <ProtogameScriptIoCModule>(); var services = new GameServiceContainer(); var assetContentManager = new AssetContentManager(services); kernel.Bind <IAssetContentManager>().ToMethod(x => assetContentManager); kernel.Bind <IRenderBatcher>().To <NullRenderBatcher>(); kernel.Bind <ICoroutineScheduler>().To <DefaultCoroutineScheduler>().InSingletonScope(); kernel.Bind <ICoroutine>().To <DefaultCoroutine>(); kernel.Bind <IConsole>().To <ServerConsole>().InSingletonScope(); kernel.Bind <IConsoleHandle>().To <DefaultConsoleHandle>().InParentScope(); // Only allow source and raw load strategies. kernel.Unbind <ILoadStrategy>(); kernel.Bind <ILoadStrategy>().To <LocalSourceLoadStrategy>(); var assetModule = new ProtogameAssetModule(); assetModule.LoadRawAssetStrategies(kernel); // Set up remaining bindings. kernel.Bind <IAssetCleanup>().To <DefaultAssetCleanup>(); kernel.Bind <IAssetOutOfDateCalculator>().To <DefaultAssetOutOfDateCalculator>(); kernel.Bind <IAssetCompilationEngine>().To <DefaultAssetCompilationEngine>(); }
public MediaComponent(Game game) : base(game) { mediaLibrary = new MediaLibrary(); artists = new ArtistsMenu(); albums = new AlbumsMenu(); genres = new GenresMenu(); playlists = new PlaylistsMenu(); songs = new SongsMenu(); collectionSongs = new SubSongMenu(); playlist = new List <Song>(); songsPlayed = new List <bool>(); playing = false; random = new Random(); services = game.Services; artists.setSongList(mediaLibrary); albums.setSongList(mediaLibrary); genres.setSongList(mediaLibrary); playlists.setSongList(mediaLibrary); songs.setSongs(mediaLibrary); }
protected override void Initialize() { IsFixedTimeStep = true; IsMouseVisible = false; GameSettings.Initialize(Graphics, Game.VirtualResolution); var Services = new GameServiceContainer(); Services.AddService(typeof(IGraphicsDeviceService), Graphics); Services.AddService(typeof(ISkipContent), this); InputProvider = new UserInputProvider(); StackEngine = new StackEngine(Game, Services, InputProvider, GameSettings); if (GameSettings.Debug) { InputProvider.Handler += HandleDebugInputEvent; } InputProvider.Handler += HandleSkipInputEvent; StackEngine.OnExit += Exit; Counter = new FrameRateCounter(); SetSpeed(GameSpeed.Default); base.Initialize(); }
public FoliageGameObject(GameServiceContainer services, Tile tile) : base(services) { Tile = tile; Position = new Vector2(Tile.X * 32, Tile.Y * 32); }
/// <summary> /// Initializes the services. /// </summary> private void InitializeServices(GameServiceContainer services) { AlmiranteEngine.ResourceContents = new ResourceContentManager(services, "Content"); services.AddService(typeof(ResourceContentManager), AlmiranteEngine.ResourceContents); AlmiranteEngine.Time = new TimeManager(); services.AddService(typeof(TimeManager), AlmiranteEngine.Time); AlmiranteEngine.Camera = new CameraManager(); services.AddService(typeof(CameraManager), AlmiranteEngine.Camera); AlmiranteEngine.Audio = new AudioManager(); services.AddService(typeof(AudioManager), AlmiranteEngine.Audio); if (!windows) { AlmiranteEngine.DeviceManager = new GraphicsDeviceManager(Application); services.AddService(typeof(GraphicsDeviceManager), AlmiranteEngine.DeviceManager); } AlmiranteEngine.Settings = new Settings(); services.AddService(typeof(Settings), AlmiranteEngine.Settings); AlmiranteEngine.Resources = new ResourceManager(AlmiranteEngine.ResourceContents); services.AddService(typeof(ResourceManager), AlmiranteEngine.Resources); AlmiranteEngine.Input = new InputManager(); services.AddService(typeof(InputManager), AlmiranteEngine.Input); AlmiranteEngine.Scenes = new SceneManager(); services.AddService(typeof(SceneManager), AlmiranteEngine.Scenes); this.InitializeExports(); }
private void InitializeGFX(IGraphicsDeviceService graphics) { services = new GameServiceContainer(); services.AddService <IGraphicsDeviceService>(graphics); this.graphics = graphics.GraphicsDevice; Content = new ContentManager(services, "Content"); spriteBatch = new SpriteBatch(graphics.GraphicsDevice); Pixel = new Texture2D(graphics.GraphicsDevice, 1, 1); Pixel.SetData(new[] { Color.White }); Format = new System.Globalization.NumberFormatInfo(); Format.CurrencyDecimalSeparator = "."; Cam = new Camera2D(); Cam.Position = new Vector2( graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); #if DX InternContent = new ResourceContentManager(services, DX.Properties.Resources.ResourceManager); GetRenderTargetManager = new RenderTargetManager(this); AntialisingRenderTarget = GetRenderTargetManager.CreateNewRenderTarget2D("MSAA", true); RenderTargetTimer = new Timer(); RenderTargetTimer.Interval = 500; RenderTargetTimer.Elapsed += (sender, e) => OnRenderTargetTimeOutEnd(); #elif GL InternContent = new ResourceContentManager(services, GL.Properties.Resources.ResourceManager); #endif Font = InternContent.Load <SpriteFont>("Font"); FontHeight = Font.MeasureString("A").Y; FrameworkDispatcher.Update(); }
public static void LoadEditorContent() { //Start by creating a MonoGame Content Manager //We create a dummy game service so we can load up a content manager. var container = new GameServiceContainer(); container.AddService( typeof(IGraphicsDeviceService), new DummyGraphicsDeviceManager(Core.Graphics.GetGraphicsDevice()) ); sContentManger = new ContentManager(container, ""); LoadEntities(); LoadSpells(); LoadAnimations(); LoadImages(); LoadFogs(); LoadResources(); LoadPaperdolls(); LoadGui(); LoadFaces(); LoadItems(); LoadMisc(); LoadShaders(); LoadSounds(); LoadMusic(); }
public SceneManager(GameServiceContainer gameServices, ContentManager content, EntityManager entityManager, string sceneDefRootFolder = "SceneDefinitions") { SceneDefinitionRootFolder = sceneDefRootFolder; _entityManager = entityManager; this._gameServices = gameServices; _contentManager = content; }
/** @fn ModuleLoader( GameServiceContainer services, XNAModularApp app ) * @brief constructor * @param services [in] something the content manager needs... haven't looked into it * @param app [in] the application the loader belongs to */ public ModuleLoader(GameServiceContainer services, XNAModularApp app) { m_content = new ContentManager(services); m_nextModule = null; m_app = app; }
public Chicken(GameServiceContainer services) : base(services) { SupportedActions[nameof(Eat)] = new LivingAction() { Action = Eat }; }
/// <summary>Initializes a new shared content manager</summary> /// <param name="gameServices"> /// Game service container to use for accessing other game components /// like the graphics device service. The shared content manager also /// registers itself (under <see cref="ISharedContentService" />) herein. /// </param> public SharedContentManager(GameServiceContainer gameServices) { this.serviceProvider = gameServices; // Register ourselfes as the shared content service for the game to allow // other component to access the assets managed by us. gameServices.AddService(typeof(ISharedContentService), this); }
/// <summary> /// Create a new scene to reference content with. /// </summary> public Scene(GameServiceContainer services) { this.content = new ContentManager(services, "Content"); this.services = services; // Set up lists for models sceneModels = new Dictionary <string, Model>(); }
public void TestStandardConstructor() { var gameServices = new GameServiceContainer(); using (GuiManager guiManager = new GuiManager(gameServices)) { Assert.IsNotNull(gameServices.GetService(typeof(IGuiService))); } }
/// <summary> /// Initialisation de XNA et du SharedGraphicsManager /// </summary> private void InitializeXNA() { Services = new GameServiceContainer(); Services.AddService(typeof(IGraphicsDeviceService), new SharedGraphicsDeviceManager()); Content = new ContentManager(Services); Content.RootDirectory = "Content"; }
public TimeService(GameServiceContainer services) { _services = services; _penumbra = _services.GetService <PenumbraComponent>(); CurrentTime = new DateTime(); CurrentTime = CurrentTime.AddHours(12); }
public static void Add <T>(T Service) { if (Container == null) { Container = new GameServiceContainer(); } Container.AddService(typeof(T), Service); }
/// <summary>Initializes a new GUI manager using explicit services</summary> /// <param name="gameServices"> /// Game service container the GuiManager will register itself in /// </param> /// <param name="graphicsDeviceService"> /// Graphics device service the GUI will be rendered with /// </param> /// <param name="inputService"> /// Input service used to read data from the input devices /// </param> /// <remarks> /// This constructor is provided for users of dependency injection frameworks /// or if you just want to be more explicit in stating which manager consumes /// what services. /// </remarks> public GuiManager( GameServiceContainer gameServices, IGraphicsDeviceService graphicsDeviceService, IInputService inputService ) : this(gameServices) { this.graphicsDeviceService = graphicsDeviceService; this.inputService = inputService; }
public void ProcessKeybindings() { GameServiceContainer services = new GameServiceContainer(); ContentManager Content = new ContentManager(services); Content.RootDirectory = "Content"; Game.KeyBindings = Content.Load <KeybindingsConfig>("KeybindingsSettings"); }
/// <summary> /// Creates a new game service container containing the specified graphics device /// service only. /// </summary> /// <param name="graphicsDeviceService">Service to add to the service container</param> /// <returns>A service container with the specified graphics device service</returns> private static IServiceProvider makePrivateServiceContainer( IGraphicsDeviceService graphicsDeviceService ) { GameServiceContainer gameServices = new GameServiceContainer(); gameServices.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService); return(gameServices); }
internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host) { this.parent = parent; this.logic = logic; this.control = host; System.Windows.Forms.Control parentControl = this.control; while (parentControl != null) { if (parentControl is System.Windows.Forms.Form) { this.parentForm = (System.Windows.Forms.Form)parentControl; break; } parentControl = parentControl.Parent; } if (parentForm == null) { throw new ArgumentException("Unable to find Parent Form for display handle"); } parentForm.MouseWheel += new System.Windows.Forms.MouseEventHandler(parentControl_MouseWheel); parentForm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(parentForm_FormClosed); formsDeviceService = new WinFormsHostGraphicsDeviceService(this, this.control.ClientSize.Width, this.control.ClientSize.Height); services = new GameServiceContainer(); services.AddService(typeof(IGraphicsDeviceService), formsDeviceService); services.AddService(typeof(IGraphicsDeviceManager), formsDeviceService); presentation = RenderTargetUsage.PlatformContents; content = new ContentManager(services); int width = 0; int height = 0; SurfaceFormat format = SurfaceFormat.Color; width = control.ClientSize.Width; height = control.ClientSize.Height; parent.SetWindowSizeAndFormat(width, height, format, DepthFormat.Depth24Stencil8); parent.SetupGraphicsDeviceManager(null, ref presentation); formsDeviceService.CreateDevice(presentation, host); host.SetApplication(parent, this, formsDeviceService); host.BeginInvoke((EventHandler) delegate { parent.SetGraphicsDevice(GraphicsDevice); logic.Initialise(); logic.LoadContent(); }); }
public EditorHostGame(ICoreGame coreGame) { _coreGame = coreGame; _serviceContainer = new GameServiceContainer(); _graphicsDeviceService = new EditorGraphicsDeviceService(); _serviceContainer.AddService <IGraphicsDeviceService>(_graphicsDeviceService); _editorGameWindow = new EditorGameWindow(this); _contentManager = new ContentManager(_serviceContainer, "Content"); }
public ScreenManager(SoldiersGame game, GraphicsDeviceManager graphicsdevice, GameServiceContainer service, ContentManager m_content) : base(game) { graphics = graphicsdevice; services = service; content = m_content; TouchPanel.EnabledGestures = GestureType.None; // we must set EnabledGestures before we can query for them, but // we don't assume the game wants to read them. }
public void TestServiceConstructor() { var services = new GameServiceContainer(); using (var manager = new MockInputManager(services)) { Assert.IsNotNull(services.GetService(typeof(IInputService))); } Assert.IsNull(services.GetService(typeof(IInputService))); }
public void TestThrowOnMissingGraphicsDeviceService() { GameServiceContainer container = new GameServiceContainer(); Assert.Throws <InvalidOperationException>( delegate() { using (Drawable drawable = new TestDrawable(container)) { } } ); }
/// <summary>Initializes a new game state manager</summary> /// <param name="gameServices"> /// Services container the game state manager will add itself to /// </param> public GameStateManager(GameServiceContainer gameServices) : base(gameServices) { this.gameServices = gameServices; this.activeGameStates = new Stack <GameState>(); // Register ourselves as a service gameServices.AddService(typeof(IGameStateService), this); inputService = getInputService(gameServices); }
public Game() { _instance = this; _services = new GameServiceContainer(); Platform = GamePlatform.PlatformCreate(this); //创建移动平台 Platform.Activated += OnActivated; Platform.Deactivated += OnDeactivated; _services.AddService(typeof(GamePlatform), Platform); }
/// <summary> /// Creates a new instance of the <see cref="AlmiranteEngine" /> class. /// <param name="arguments">Arguments.</param> /// </summary> /// <param name="windows">if set to <c>true</c> WinForms will be used.</param> /// <param name="arguments">The arguments.</param> internal AlmiranteEngine() { this.windows = true; this.services = new GameServiceContainer(); this.arguments = new string[0]; AlmiranteEngine.Bootstrap = null; AlmiranteEngine.Instance = this; }
public void SoundEffectFromContent(string filename, long durationTicks) { var services = new GameServiceContainer(); services.AddService <IGraphicsDeviceService>(new GraphicsDeviceProxy()); var content = new ContentManagerProxy(services); var soundEffect = content.Load <SoundEffect>(Paths.Audio(filename)); Assert.AreEqual(durationTicks, soundEffect.Duration.Ticks); }
public void TestInitialization() { GameServiceContainer gameServices = new GameServiceContainer(); MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService(); gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics); using( SharedContentManager contentManager = new SharedContentManager(gameServices) ) { contentManager.Initialize(); } }