// _____________________________________________________________________________________________________________________ // // Render just gets the graphicsdevice and the spritebatch // so we can render the entities that are drawn in RenderEntities // method. public void Render(GameDependencies gm) { graphics = gm.GraphicsDeviceManager.GraphicsDevice; SpriteBatch spriteBatch = gm.SpriteBatch; CameraViewComponent cameraEntities = ComponentManager.GetEntitiesWithComponent(typeof(CameraViewComponent)).First().Value as CameraViewComponent; graphics.Clear(Color.Black); // Maybe done outside Rectangle cameraView = cameraEntities.View; // Matrix.CreateScale(new Vector3(camera.Scale, camera.Scale, camera.Scale)); // Using a matrix makes it easier for us to move the camera // independently of all the sprites, which means that we easily can // rotate, scale, etc. without much effort. plus its recommended. // What we do when are multiplying matrices is that we combine them // so the result will be a matrix that does the combination of it's // products. Now when we use this transform in the begindraw, it will // affect all the stuff that is drawn after it. // We create a translation matrix so we are able to move our points easily // from one place to another. // X,Y and Z, ofcourse Z will be 0. // We won't be having any rotation. // Our zoom effect will be doing its jobb here, // as this matrix will easily help us achieve it. Matrix transform = Matrix.Identity * Matrix.CreateTranslation(new Vector3(-cameraView.X, -cameraView.Y, 0)) * Matrix.CreateRotationZ(0) * Matrix.CreateScale(1); spriteBatch.Begin(SpriteSortMode.FrontToBack, null, null, null, null, null, transform); DrawEntities(spriteBatch); spriteBatch.End(); }
// This draw method is used to start the system process. // it uses DrawTitleSafe to draw the components. public void Draw(GameDependencies gameDependencies) { this._gameDependencies = gameDependencies; // _gameDependencies.SpriteBatch.Begin(SpriteSortMode.FrontToBack); DrawTitleSafe(); // _gameDependencies.SpriteBatch.End(); }
// This method is used to initialize the penumbra instance, and add // all the entities that have an associated instance of light component. public PenumbraComponent Initialize(GameDependencies gameDependencies) { var penumbra = new PenumbraComponent(gameDependencies.Game) { // Ambient color will determine how dark everything else // except for the light will be. AmbientColor = new Color(new Vector3(0.5f)) // should be an entity? }; var lights = ComponentManager.Instance.GetEntitiesWithComponent(typeof(LightComponent)); foreach (var instance in lights) { var lightComponent = instance.Value as LightComponent; penumbra.Lights.Add(lightComponent.Light); } penumbra.Initialize(); return(penumbra); }
// This draw method call will render the video playing to the screen. public void Draw(GameDependencies gameDependencies) { Texture2D videoTexture = null; var viewport = gameDependencies.GraphicsDeviceManager.GraphicsDevice.Viewport; if (!IsStopped()) { videoTexture = _videoPlayer.GetTexture(); } if (videoTexture != null) { gameDependencies.SpriteBatch.Begin(); gameDependencies.SpriteBatch.Draw(videoTexture, new Rectangle(0, 0, (int)viewport.X, (int)viewport.Y), Color.White); gameDependencies.SpriteBatch.End(); } }
protected virtual void Awake() { audioManager = GameDependencies.Get <AudioManager>(); }
protected override void Awake() { audioManager = GameDependencies.Get <AudioManager>(); }