protected override void Initialize() { base.Initialize(); //physics needs explicit initialization GameSystems.Add(new Bullet2PhysicsSystem(Services)); }
protected GameTestBase() { ConsoleLogMode = ConsoleLogMode.Always; // Override the default graphic device manager GraphicsDeviceManager.Dispose(); GraphicsDeviceManager = new TestGraphicsDeviceManager(this) { PreferredBackBufferWidth = 800, PreferredBackBufferHeight = 480, PreferredDepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt, DeviceCreationFlags = DeviceCreationFlags.Debug, PreferredGraphicsProfile = new[] { GraphicsProfile.Level_9_1 } }; Services.AddService <IGraphicsDeviceManager>(GraphicsDeviceManager); Services.AddService <IGraphicsDeviceService>(GraphicsDeviceManager); StopOnFrameCount = -1; AutoLoadDefaultSettings = false; FrameGameSystem = new FrameGameSystem(Services); GameSystems.Add(FrameGameSystem); // by default we want the same size for the back buffer on mobiles and windows. BackBufferSizeMode = BackBufferSizeMode.FitToDesiredValues; }
protected void Initialize() { // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Initialize the systems GameSystems.Initialize(); Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); GameSystems.Add(Streaming); GameSystems.Add(SceneSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); OnGameStarted(this); }
protected override void Initialize() { base.Initialize(); EffectSystem = new EffectSystem(Services); // If requested in game settings, compile effects remotely and/or notify new shader requests if (gameSettings != null) { EffectSystem.Compiler = EffectSystem.CreateEffectCompiler(EffectSystem, gameSettings.PackageId, gameSettings.EffectCompilation, gameSettings.RecordUsedEffects); } GameSystems.Add(EffectSystem); GameSystems.Add(SceneSystem); // TODO: data-driven? //Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuSamplerStateSerializer2(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuBlendStateSerializer(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuRasterizerStateSerializer(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuDepthStencilStateSerializer(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new ImageSerializer()); Asset.Serializer.RegisterSerializer(new SoundEffectSerializer(Audio.AudioEngine)); Asset.Serializer.RegisterSerializer(new SoundMusicSerializer(Audio.AudioEngine)); // enable multi-touch by default Input.MultiTouchEnabled = true; }
private void CreateScenePipeline() { // The gizmo scene EditorScene = new Scene(); // The gizmo scene var gizmoAmbientLight1 = new Entity("Gizmo Ambient Light1") { new LightComponent { Type = new LightAmbient(), Intensity = 0.1f } }; var gizmoDirectionalLight1 = new Entity("Gizmo Directional Light1") { new LightComponent { Type = new LightDirectional(), Intensity = 0.45f } }; var gizmoDirectionalLight2 = new Entity("Gizmo Directional Light2") { new LightComponent { Type = new LightDirectional(), Intensity = 0.45f } }; gizmoDirectionalLight1.Transform.Rotation = Quaternion.RotationY(MathUtil.Pi * 1.125f); gizmoDirectionalLight2.Transform.Rotation = Quaternion.RotationY(MathUtil.Pi * 0.125f); EditorScene.Entities.Add(gizmoAmbientLight1); EditorScene.Entities.Add(gizmoDirectionalLight1); EditorScene.Entities.Add(gizmoDirectionalLight2); // Root scene var rootScene = new Scene(); // Setup the scene instance SceneSystem.SceneInstance = new SceneInstance(Services, rootScene, ExecutionMode.Editor); // Create editor scene EditorSceneSystem = new SceneSystem(Services) { SceneInstance = new SceneInstance(Services, EditorScene, ExecutionMode.Editor) }; GameSystems.Add(EditorSceneSystem); EditorSceneSystem.DrawOrder = SceneSystem.DrawOrder + 1; EditorSceneSystem.GraphicsCompositor = GraphicsCompositorHelper.CreateDefault(true, EditorGraphicsCompositorHelper.EditorForwardShadingEffect, groupMask: GizmoBase.DefaultGroupMask); // Do a few adjustments to the default compositor EditorSceneSystem.GraphicsCompositor.RenderFeatures.OfType <MeshRenderFeature>().FirstOrDefault()?.RenderFeatures.Add(new WireframeRenderFeature()); EditorSceneSystem.GraphicsCompositor.Game = new EditorTopLevelCompositor { Child = new ForwardRenderer { Clear = null, // Don't clear (we want to keep reusing same render target and depth buffer) OpaqueRenderStage = EditorSceneSystem.GraphicsCompositor.RenderStages.FirstOrDefault(x => x.Name == "Opaque"), TransparentRenderStage = EditorSceneSystem.GraphicsCompositor.RenderStages.FirstOrDefault(x => x.Name == "Transparent"), }, }; }
public Game(Context ctx) { this.ctx = ctx; state = GameState.UNDEFINED; systems = new GameSystems(); systems.Add(new AnimSystem()); systems.Add(new MovementSystem()); systems.Add(new MapSystem(ctx.config.Get <MapSystemConfig>())); systems.Add(new CameraSystem()); systems.Add(new EntitySystem()); systems.Init(systems, ctx); ActionSystem actionSys = new ActionSystem(assemblyNames: "Game"); actionSys.OnActionSystemRegistered += iActionSystem => { if (iActionSystem is IGameSystem gs) { gs.Init(systems, ctx); } }; actionSys.RegisterSystems(); MapSystem mapSystem = systems.Get <MapSystem>(); mapSystem.Load(new[] { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0xB, 0xB, 0xB, 0xB, 0x1000A, 0xB, 0xB, 0xB, 0x1, 0x1, 0x1, 0x1, 0xB, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xB, 0x1, 0x1, 0x1, 0x1, 0xB, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xB, 0x1, 0x1, 0x1, 0x1, 0xB, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xB, 0x1, 0x1, 0x1, 0x1, 0xB, 0xB, 0xB, 0xB, 0xB, 0xB, 0xB, 0xB, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, }, 12, "Entrance"); player = systems.Get <EntitySystem>().CreatePlayer("Player"); int spawnpoint = mapSystem.Map.Spawnpoint; player.SetLocalPosition(mapSystem.Map.IndexToWorldPos(spawnpoint)); ctx.eventPump.Dispatch(); // systems.Get<CameraSystem>().SetTarget(player.transform); }
protected override void Initialize() { base.Initialize(); //now we probably are capable of detecting the gpu/cpu/etc so we confirm rendering settings if (AutoLoadDefaultSettings) { ConfirmRenderingSettings(); } // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager Input = InputManagerFactory.NewInputManager(Services, Context); GameSystems.Add(Input); // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the Audio System GameSystems.Add(Audio); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); GameSystems.Add(ProfilerSystem); EffectSystem = new EffectSystem(Services); // If requested in game settings, compile effects remotely and/or notify new shader requests if (Settings != null) { EffectSystem.Compiler = EffectSystem.CreateEffectCompiler(EffectSystem, Settings.PackageId, Settings.EffectCompilation, Settings.RecordUsedEffects); } GameSystems.Add(EffectSystem); GameSystems.Add(SceneSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); Content.Serializer.RegisterSerializer(new SoundEffectSerializer(Audio.AudioEngine)); Content.Serializer.RegisterSerializer(new SoundMusicSerializer(Audio.AudioEngine)); // enable multi-touch by default Input.MultiTouchEnabled = true; OnGameStarted(this); }
protected override void Initialize() { // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager // Add it first so that it can obtained by the UI system Input = new InputManager(Services); Services.AddService(Input); GameSystems.Add(Input); // Initialize the systems base.Initialize(); // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); GameSystems.Add(DebugTextSystem); GameSystems.Add(ProfilingSystem); EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); // If requested in game settings, compile effects remotely and/or notify new shader requests if (Settings != null) { EffectSystem.Compiler = EffectSystem.CreateEffectCompiler(EffectSystem, Settings.PackageId, Settings.EffectCompilation, Settings.RecordUsedEffects); } GameSystems.Add(EffectSystem); GameSystems.Add(Streaming); GameSystems.Add(SceneSystem); // Add the Audio System GameSystems.Add(Audio); // Add the VR System GameSystems.Add(VRDeviceSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); OnGameStarted(this); }
/// <summary> /// Initializes a new instance of the <see cref="Game"/> class. /// </summary> public Game() { // Register the logger backend before anything else logListener = GetLogListener(); if (logListener != null) { GlobalLogger.GlobalMessageLogged += logListener; } // Create and register all core services Input = new InputManager(Services); Script = new ScriptSystem(Services); SceneSystem = new SceneSystem(Services); Audio = new AudioSystem(Services); UI = new UISystem(Services); gameFontSystem = new GameFontSystem(Services); SpriteAnimation = new SpriteAnimationSystem(Services); ProfilerSystem = new GameProfilingSystem(Services); // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager GameSystems.Add(Input); // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the UI System GameSystems.Add(UI); // Add the Audio System GameSystems.Add(Audio); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); Asset.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Creates the graphics device manager GraphicsDeviceManager = new GraphicsDeviceManager(this); GameSystems.Add(ProfilerSystem); AutoLoadDefaultSettings = true; }
protected override void Initialize() { base.Initialize(); if (Context.InitializeDatabase) { InitializeAssetDatabase(); } EffectSystem = new EffectSystem(Services); GameSystems.Add(EffectSystem); // Add RenderSystem RenderSystem = new RenderSystem(Services); GameSystems.Add(RenderSystem); using (var profile = Profiler.Begin(GameProfilingKeys.EntityProcessorInitialize)) { // TODO: Do we need to make this list data-driven? Entities.Processors.Add(new HierarchicalProcessor()); Entities.Processors.Add(new AnimationProcessor()); Entities.Processors.Add(new ModelNodeLinkProcessor()); Entities.Processors.Add(new TransformationProcessor()); Entities.Processors.Add(new MeshProcessor()); Entities.Processors.Add(new AudioListenerProcessor()); Entities.Processors.Add(new AudioEmitterProcessor()); Entities.Processors.Add(new SpriteProcessor()); } // TODO: data-driven? Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture>(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture1D>(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture2D>(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture3D>(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.TextureCube>(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuSamplerStateSerializer2(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuBlendStateSerializer(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuRasterizerStateSerializer(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new GpuDepthStencilStateSerializer(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new ImageSerializer()); Asset.Serializer.RegisterSerializer(new SoundEffectSerializer(Audio.AudioEngine)); Asset.Serializer.RegisterSerializer(new SoundMusicSerializer(Audio.AudioEngine)); // determine the virtual resolution so that ratio is maintained const int screenDesiredHeight = 1080; var screenRatio = GraphicsDevice.BackBuffer.Width / (float)GraphicsDevice.BackBuffer.Height; VirtualResolution = new Vector3((int)(screenRatio * screenDesiredHeight), screenDesiredHeight, screenDesiredHeight); // enable multi-touch by default Input.MultiTouchEnabled = true; }
public PacmanGame() { Logger.NewMessageLogged += new Logger.LogAction(Logger_NewMessageLogged); Logger.Info("Logger initiated."); _graphics = new GraphicsDeviceManager(this); _graphics.PreferredBackBufferWidth = ScreenWidth; _graphics.PreferredBackBufferHeight = ScreenHeight; _screenManager = new PacmanScreenManager(this); GameSystems.Add(_screenManager); Content.RootDirectory = "Content"; }
/// <summary> /// Initializes a new instance of the <see cref="CustomEffectGame" /> class. /// </summary> public CustomEffectGame() { // Creates a graphics manager. This is mandatory. graphicsDeviceManager = new GraphicsDeviceManager(this); graphicsDeviceManager.PreferredDepthStencilFormat = DepthFormat.None; // Add dynamic EffectCompilerSystem, only active on desktop and compiled in debug mode. // While the program is running, you can edit the shader and save a new version // The EffectCompilerSystem will recompile dynamically the effect without having to // reload/recompile the whole application. GameSystems.Add(new EffectCompilerSystem(this)); // Setup the relative directory to the executable directory // for loading contents with the ContentManager Content.RootDirectory = "Content"; }
public Game(GameContext context) : base(context) { GraphicsDevice = Services.GetService <GraphicsDevice>(); if (GraphicsDevice != null) { GraphicsDevice.Presenter = Services.GetService <GraphicsPresenter>(); } Input = Services.GetRequiredService <InputManager>(); SceneSystem = Services.GetRequiredService <SceneSystem>(); Script = Services.GetRequiredService <ScriptSystem>(); GameSystems.Add(Input); GameSystems.Add(SceneSystem); GameSystems.Add(Script); }
protected override void Initialize() { Window.Title = "SharpDX Framework Tester"; IsMouseVisible = true; Engine.Initialize(this); InputManager.Initialize(this); PrimitiveBatch.Initialize(this.GraphicsDevice); sceneManager = new SceneManager(this); FrameRateCounter fpsCounter = new FrameRateCounter(this); GameSystems.Add(sceneManager); GameSystems.Add(fpsCounter); base.Initialize(); }
/// <summary> /// Create an instance of the game test /// </summary> public UITestGameBase() { StopOnFrameCount = -1; graphicsCompositor = new SceneGraphicsCompositorLayers { Cameras = { Camera.Get <CameraComponent>() }, Master = { Renderers = { new ClearRenderFrameRenderer { Color = Color.Green, Name = "Clear frame" }, new SceneDelegateRenderer(SpecificDrawBeforeUI) { Name = "Delegate before main UI" }, new SceneCameraRenderer { Mode = SceneCameraRenderer }, } } }; Scene = new Scene { Settings = { GraphicsCompositor = graphicsCompositor } }; Scene.Entities.Add(UIRoot); Scene.Entities.Add(Camera); Camera.Transform.Position = new Vector3(0, 0, 1000); UIComponent.IsFullScreen = true; UIComponent.Resolution = new Vector3(1000, 500, 500); UIComponent.ResolutionStretch = ResolutionStretch.FixedWidthFixedHeight; UI = (UISystem)Services.GetService(typeof(UISystem)); if (UI == null) { UI = new UISystem(Services); GameSystems.Add(UI); } }
protected GameTestBase() { // Override the default graphic device manager GraphicsDeviceManager.Dispose(); GraphicsDeviceManager = new TestGraphicsDeviceManager(this) { PreferredBackBufferWidth = 800, PreferredBackBufferHeight = 480, PreferredDepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt, DeviceCreationFlags = DeviceCreationFlags.Debug, PreferredGraphicsProfile = new[] { GraphicsProfile.Level_9_1 } }; Services.AddService(typeof(IGraphicsDeviceManager), GraphicsDeviceManager); Services.AddService(typeof(IGraphicsDeviceService), GraphicsDeviceManager); // Enable profiling //Profiler.EnableAll(); CurrentVersion = 0; StopOnFrameCount = -1; AutoLoadDefaultSettings = false; FrameGameSystem = new FrameGameSystem(Services); GameSystems.Add(FrameGameSystem); // by default we want the same size for the back buffer on mobiles and windows. BackBufferSizeMode = BackBufferSizeMode.FitToDesiredValues; #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP // get build number int buildNumber; if (ImageTester.ImageTestResultConnection.BuildNumber <= 0 && int.TryParse(Environment.GetEnvironmentVariable("XENKO_BUILD_NUMBER"), out buildNumber)) { ImageTester.ImageTestResultConnection.BuildNumber = buildNumber; } // get branch name if (string.IsNullOrEmpty(ImageTester.ImageTestResultConnection.BranchName)) { ImageTester.ImageTestResultConnection.BranchName = Environment.GetEnvironmentVariable("XENKO_BRANCH_NAME") ?? ""; } #endif SceneSystem.SplashScreenEnabled = false; }
/// <inheritdoc /> protected override void Initialize() { base.Initialize(); // Use a shared database for our shader system // TODO: Shaders compiled on main thread won't actually be visible to MicroThread build engine (contentIndexMap are separate). // It will still work and cache because EffectCompilerCache caches not only at the index map level, but also at the database level. // Later, we probably want to have a GetSharedDatabase() allowing us to mutate it (or merging our results back with IndexFileCommand.AddToSharedGroup()), // so that database created with MountDatabase also have all the newest shaders. ((IReferencable)effectCompiler).AddReference(); EffectSystem.Compiler = effectCompiler; // Record used effects if (effectLogPath != null) { EffectSystem.EffectUsed += (request, result) => { if (result.HasErrors) { return; } using (var stream = File.Open(effectLogPath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { var requests = AssetYamlSerializer.Default.DeserializeMultiple <EffectCompileRequest>(stream).ToList(); if (requests.Contains(request)) { return; } var documentMarker = Encoding.UTF8.GetBytes("---\r\n"); stream.Write(documentMarker, 0, documentMarker.Length); AssetYamlSerializer.Default.Serialize(stream, request); } }; } //init physics system var physicsSystem = new Bullet2PhysicsSystem(Services); Services.AddService <IPhysicsSystem>(physicsSystem); GameSystems.Add(physicsSystem); }
/// <summary> /// Initializes a new instance of the <see cref="CustomLoadingDataGame" /> class. /// </summary> public CustomLoadingDataGame() { // Creates a graphics manager. This is mandatory. graphicsDeviceManager = new GraphicsDeviceManager(this); graphicsDeviceManager.PreferredDepthStencilFormat = DepthFormat.None; // In order to support Yaml loading, we need to add the YamlManager yamlManager = new YamlManager(this); GameSystems.Add(yamlManager); // Register that !MyData will map to our local type. // We could have used YamlTagAttribute directly on our MyData type from YamlDotNet library. yamlManager.RegisterTagMapping("MyData", typeof(MyData)); // Setup the relative directory to the executable directory // for loading contents with the ContentManager Content.RootDirectory = "Content"; }
protected override Task <Scene> BuildScene() { var scene = new Scene(); UIRoot = new Entity("Root entity of camera UI") { new UIComponent() }; UIComponent.IsFullScreen = true; UIComponent.Resolution = new Vector3(10, 50, 50); UIComponent.ResolutionStretch = ResolutionStretch.FixedWidthFixedHeight; scene.Entities.Add(UIRoot); UI = Services.GetService <UISystem>(); if (UI == null) { UI = new UISystem(Services); Services.AddService(UI); GameSystems.Add(UI); } var button = new Button(); UIComponent.Page = new UIPage { RootElement = button }; scene.Entities.Add(GetCube(new Vector3(0, -1, 0), new Vector3(15, 1, 15))); scene.Entities.Add(GetLight()); var cameraSlot = Services.GetSafeServiceAs <SceneSystem>().GraphicsCompositor.Cameras[0].ToSlotId(); camera = new TopDownCamera(new TopDownCameraSettings(), cameraSlot); scene.Entities.Add(new Entity { camera }); camera.Entity.AddChild(GetCube(Vector3.Zero, new Vector3(1), Color.Red)); return(Task.FromResult(scene)); }
/// <summary> /// Initializes a new instance of the <see cref="SharpDXVideoPlayer" /> class. /// </summary> public SharpDXVideoPlayer() { // Creates a graphics manager. This is mandatory. graphicsDeviceManager = new GraphicsDeviceManager(this); graphicsDeviceManager.IsFullScreen = true; graphicsDeviceManager.PreferMultiSampling = Configuration.AntiAliasing; graphicsDeviceManager.SynchronizeWithVerticalRetrace = true; graphicsDeviceManager.PreferredBackBufferWidth = Configuration.PreferredBackBufferWidth; graphicsDeviceManager.PreferredBackBufferHeight = Configuration.PreferredBackBufferHeight; graphicsDeviceManager.PreferredRefreshRate = new SharpDX.DXGI.Rational(Configuration.PreferredRefreshRate, 1); // BUG WORKAROUND: Limit to DirectX feature level 9.1, 9.2 or 9.3 to work around crash in TransferVideoFrame on nVidia card used in this system if (Configuration.DirectX9Only) { graphicsDeviceManager.PreferredGraphicsProfile = new FeatureLevel[] { SharpDX.Direct3D.FeatureLevel.Level_9_3, SharpDX.Direct3D.FeatureLevel.Level_9_2, SharpDX.Direct3D.FeatureLevel.Level_9_1 }; } // Add dynamic EffectCompilerSystem, only active on desktop and compiled in debug mode. // While the program is running, you can edit the shader and save a new version // The EffectCompilerSystem will recompile dynamically the effect without having to // reload/recompile the whole application. GameSystems.Add(new EffectCompilerSystem(this)); // Setup the relative directory to the executable directory // for loading contents with the ContentManager Content.RootDirectory = "Content"; // Initialize input keyboard system keyboard = new KeyboardManager(this); Services.AddService(keyboard); // Initialize input mouse system mouse = new MouseManager(this); Services.AddService(mouse); string videosPath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos); string backgroundVideoPath = Path.Combine(videosPath, ConfigurationManager.AppSettings["Video"]); // Note pass an empty effect if you don't want to use a shader to modify the video VideoRenderer = new VideoPlaneRenderer(this, backgroundVideoPath, "VideoShader"); }
protected override void OnInitialize() { if (Settings != null) { _streamingManager.System.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>()); } _sceneSystem.System.InitialSceneUrl = Settings?.DefaultSceneUrl; // Add the input manager // Add it first so that it can obtained by the UI system //Input = new InputManager(Services); //Services.AddOrOverwriteService(Input); //GameSystems.Add(Input); // Initialize the systems GameSystems.Initialize(); Services.AddOrOverwriteService <IGameSystemCollection>(GameSystems); //GameSystems.Add(_scriptSystem.System); //GameSystems.Add(gameFontSystem); //GameSystems.Add(Audio); //var dynamicNavigationMeshSystem = new Stride.Navigation.DynamicNavigationMeshSystem(_services); //GameSystems.Add(dynamicNavigationMeshSystem); Services.AddOrOverwriteService(_scenePreUpdateSystem.System); GameSystems.Add(_scenePreUpdateSystem.System); Services.AddOrOverwriteService(_sceneSystem.System); GameSystems.Add(_sceneSystem.System); Services.AddOrOverwriteService(_scenePostUpdateSystem.System); GameSystems.Add(_scenePostUpdateSystem.System); Services.AddOrOverwriteService <IPhysicsSystem>(_physicsSystem.System); GameSystems.Add(_physicsSystem.System); GameSystems.Add(_networkSystem.System); // Make sure this is added AFTER _sceneSystem due to dependency on it }
protected override void Initialize() { base.Initialize(); EffectSystem = new EffectSystem(Services); GameSystems.Add(EffectSystem); GameSystems.Add(SceneSystem); // TODO: data-driven? //Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuSamplerStateSerializer2(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuBlendStateSerializer(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuRasterizerStateSerializer(GraphicsDevice)); //Asset.Serializer.RegisterSerializer(new GpuDepthStencilStateSerializer(GraphicsDevice)); Asset.Serializer.RegisterSerializer(new ImageSerializer()); Asset.Serializer.RegisterSerializer(new SoundEffectSerializer(Audio.AudioEngine)); Asset.Serializer.RegisterSerializer(new SoundMusicSerializer(Audio.AudioEngine)); // enable multi-touch by default Input.MultiTouchEnabled = true; }
protected GraphicsTestBase() { CurrentVersion = 0; FrameGameSystem = new FrameGameSystem(Services); GameSystems.Add(FrameGameSystem); #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP // get build number int buildNumber; if (ImageTester.ImageTestResultConnection.BuildNumber <= 0 && Int32.TryParse(Environment.GetEnvironmentVariable("PARADOX_BUILD_NUMBER"), out buildNumber)) { ImageTester.ImageTestResultConnection.BuildNumber = buildNumber; } // get branch name if (String.IsNullOrEmpty(ImageTester.ImageTestResultConnection.BranchName)) { ImageTester.ImageTestResultConnection.BranchName = Environment.GetEnvironmentVariable("PARADOX_BRANCH_NAME") ?? ""; } #endif }
protected override void Initialize() { base.Initialize(); GameSystems.Add(GameManager); }
protected override async Task LoadContent() { await base.LoadContent(); SceneSystem.GraphicsCompositor = Content.Load <GraphicsCompositor>("GraphicsCompositor"); StopOnFrameCount = -1; Scene = new Scene(); UIRoot = new Entity("Root entity of camera UI") { new UIComponent() }; UIComponent.IsFullScreen = true; UIComponent.Resolution = new Vector3(1000, 500, 500); UIComponent.ResolutionStretch = ResolutionStretch.FixedWidthFixedHeight; Scene.Entities.Add(UIRoot); UI = Services.GetService <UISystem>(); if (UI == null) { UI = new UISystem(Services); Services.AddService(UI); GameSystems.Add(UI); } Camera = new Entity("Scene camera") { new CameraComponent { Slot = SceneSystem.GraphicsCompositor.Cameras[0].ToSlotId() } }; Camera.Transform.Position = new Vector3(0, 0, 1000); Scene.Entities.Add(Camera); // Default styles // Note: this is temporary and should be replaced with default template of UI elements textBlockTextColor = Color.LightGray; scrollingTextTextColor = Color.LightGray; var buttonPressedTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonPressed); var buttonNotPressedTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonNotPressed); var buttonOverredTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ButtonOverred); buttonPressedImage = (SpriteFromTexture) new Sprite("Test button pressed design", buttonPressedTexture) { Borders = 8 * Vector4.One }; buttonNotPressedImage = (SpriteFromTexture) new Sprite("Test button not pressed design", buttonNotPressedTexture) { Borders = 8 * Vector4.One }; buttonMouseOverImage = (SpriteFromTexture) new Sprite("Test button overred design", buttonOverredTexture) { Borders = 8 * Vector4.One }; var editActiveTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextActive); var editInactiveTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextInactive); var editOverredTexture = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.EditTextOverred); editTextTextColor = Color.LightGray; editTextSelectionColor = Color.FromAbgr(0x623574FF); editTextCaretColor = Color.FromAbgr(0xF0F0F0FF); editTextActiveImage = (SpriteFromTexture) new Sprite("Test edit active design", editActiveTexture) { Borders = 12 * Vector4.One }; editTextInactiveImage = (SpriteFromTexture) new Sprite("Test edit inactive design", editInactiveTexture) { Borders = 12 * Vector4.One }; editTextMouseOverImage = (SpriteFromTexture) new Sprite("Test edit overred design", editOverredTexture) { Borders = 12 * Vector4.One }; var toggleButtonChecked = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonChecked); var toggleButtonUnchecked = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonUnchecked); var toggleButtonIndeterminate = TextureExtensions.FromFileData(GraphicsDevice, ElementTestDesigns.ToggleButtonIndeterminate); toggleButtonCheckedImage = (SpriteFromTexture) new Sprite("Test toggle button checked design", toggleButtonChecked) { Borders = 8 * Vector4.One }; toggleButtonUncheckedImage = (SpriteFromTexture) new Sprite("Test toggle button unchecked design", toggleButtonUnchecked) { Borders = 8 * Vector4.One }; toggleButtonIndeterminateImage = (SpriteFromTexture) new Sprite("Test toggle button indeterminate design", toggleButtonIndeterminate) { Borders = 8 * Vector4.One }; var designsTexture = TextureExtensions.FromFileData(GraphicsDevice, DefaultDesigns.Designs); sliderTrackBackgroundImage = (SpriteFromTexture) new Sprite("Default slider track background design", designsTexture) { Borders = 14 * Vector4.One, Region = new RectangleF(207, 3, 32, 32) }; sliderTrackForegroundImage = (SpriteFromTexture) new Sprite("Default slider track foreground design", designsTexture) { Borders = 0 * Vector4.One, Region = new RectangleF(3, 37, 32, 32) }; sliderThumbImage = (SpriteFromTexture) new Sprite("Default slider thumb design", designsTexture) { Borders = 4 * Vector4.One, Region = new RectangleF(37, 37, 16, 32) }; sliderMouseOverThumbImage = (SpriteFromTexture) new Sprite("Default slider thumb overred design", designsTexture) { Borders = 4 * Vector4.One, Region = new RectangleF(71, 37, 16, 32) }; sliderTickImage = (SpriteFromTexture) new Sprite("Default slider track foreground design", designsTexture) { Region = new RectangleF(245, 3, 3, 6) }; sliderTickOffset = 13f; sliderTrackStartingOffsets = new Vector2(3); Window.IsMouseVisible = true; SceneSystem.SceneInstance = new SceneInstance(Services, Scene); }
protected override void Initialize() { // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager // Add it first so that it can obtained by the UI system Input = new InputManager(Services); Services.AddService(Input); GameSystems.Add(Input); // Initialize the systems base.Initialize(); Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); GameSystems.Add(DebugRenderSystem); GameSystems.Add(DebugTextSystem); GameSystems.Add(ProfilingSystem); EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); // prepare effect compilation settings if we have a settings object if (Settings != null) { // align settings with what we may be forcing if (ForceReleaseEffects) { Settings.CompilationMode = CompilationMode.Release; } if (ForceCollectEffects) { // we want to collect effects. make sure they are release versions Settings.EffectCompilation = EffectCompilationMode.Local; Settings.CompilationMode = CompilationMode.Release; } else if (Settings.CompilationMode == CompilationMode.Testing || Settings.CompilationMode == CompilationMode.Debug) { // don't collect debug shaders, we won't want to distribute them! Settings.EffectCompilation = EffectCompilationMode.Local; } } // If requested in game settings, compile effects remotely and/or notify new shader requests EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem, Settings?.PackageName, ForceCollectEffects ? EffectCompilationMode.Local : (Settings?.EffectCompilation ?? EffectCompilationMode.Local)); // Setup shader compiler settings from a compilation mode. EffectSystem.SetCompilationMode(ForceReleaseEffects || ForceCollectEffects ? CompilationMode.Release : (Settings?.CompilationMode ?? CompilationMode.Release)); GameSystems.Add(EffectSystem); if (Settings != null) { Streaming.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>()); } GameSystems.Add(Streaming); GameSystems.Add(SceneSystem); // Add the Audio System GameSystems.Add(Audio); // Add the VR System GameSystems.Add(VRDeviceSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); OnGameStarted(this); }
protected override void Initialize() { // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager // Add it first so that it can obtained by the UI system Input = new InputManager(Services); Services.AddService(Input); GameSystems.Add(Input); // Initialize the systems base.Initialize(); Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); GameSystems.Add(DebugTextSystem); GameSystems.Add(ProfilingSystem); EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); // If requested in game settings, compile effects remotely and/or notify new shader requests EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem, Settings?.PackageName, Settings?.EffectCompilation ?? EffectCompilationMode.Local, Settings?.RecordUsedEffects ?? false); // Setup shader compiler settings from a compilation mode. // TODO: We might want to provide overrides on the GameSettings to specify debug and/or optim level specifically. if (Settings != null) { EffectSystem.SetCompilationMode(Settings.CompilationMode); } GameSystems.Add(EffectSystem); if (Settings != null) { Streaming.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>()); } GameSystems.Add(Streaming); GameSystems.Add(SceneSystem); // Add the Audio System GameSystems.Add(Audio); // Add the VR System GameSystems.Add(VRDeviceSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); OnGameStarted(this); }