protected override void OnRender(UIRenderContext context) { Screen.Renderer.EndBatch(); Rectangle originalViewport = Screen.Renderer.GraphicsDevice.Viewport.Bounds; Rectangle viewport = new Rectangle((int)ActualX, (int)ActualY, (int)ActualWidth, (int)ActualHeight); if (viewport.Width == 0 || viewport.Height == 0) return; viewport = Rectangle.Intersect(originalViewport, viewport); using (new ViewportScope(Screen.Renderer.GraphicsDevice, new Viewport(viewport))) { if (_minimap == null) { Camera.Camera2D minimapCam = new Camera.Camera2D(null, false); minimapCam.CamViewPortHeight = (int)ActualHeight; minimapCam.CamViewPortWidth = (int)ActualWidth; minimapCam.CamWorldHeight = _gameManager.Galaxy.Height; //Should be gotten from the current Galaxy in GameManager minimapCam.CamWorldWidth = _gameManager.Galaxy.Width; //Should be gotten from the current Galaxy in GameManager minimapCam.Pos = new Vector2(minimapCam.CamWorldWidth / 2, minimapCam.CamWorldHeight / 2); _minimap = RenderMiniMap(minimapCam, Screen.Renderer.GraphicsDevice); } RenderMinimapWithOverlay(Screen.Renderer.SpriteBatch); } base.OnRender(context); }
private void SetupGalaxyCamera() { _galaxyCam = new Camera.Camera2D(_consoleManager, true); //Setup the limits, depends on the galaxy size _galaxyCam.MaxZoom = 1.0f; _galaxyCam.MinZoom = 0.07f; _galaxyCam.Limits = new Rectangle( 0 - (_gameGalaxy.Width / 2), 0 -( _gameGalaxy.Height / 2), _gameGalaxy.Width *2, _gameGalaxy.Height *2); //Temporary, should set position to current homeworld (not implemented yet) _galaxyCam.Pos = _gameGalaxy.Sectors[0].Stars[0].Position + new Vector2(Model.Constants.STAR_WIDTH / 2, Model.Constants.STAR_WIDTH / 2); _galaxyCam.CamWorldHeight = 400; _galaxyCam.CamWorldWidth = 640; _galaxyCam.Zoom = 1.0f; }
public override void Initialize() { //Initialise the SpriteBatch and load the Textures and calculate the center of the screen. this.batch = new SpriteBatch(this.Game.GraphicsDevice); Vector2 center = new Vector2(this.Game.GraphicsDevice.Viewport.Width / 2, this.Game.GraphicsDevice.Viewport.Height / 2); this.pictures = new Texture2D[6]; for (int i = 1; i <= this.pictures.Length; i++) { //Check if the picture is loaded already. if (!this.Game.Assets.ContainsKey <Texture2D>(Key + i.ToString())) { this.Game.Assets.SaveAsset <Texture2D>(Key + i.ToString(), PicturesLocation + i.ToString()); } this.pictures[i - 1] = this.Game.Assets.Load <Texture2D>(Key + i.ToString()); } //Initialise the sum of the pictures width and height for a worldwidth worldheight and use those to initialise the camera. int worldWidth = 0; int worldHeight = 0; for (int i = 0; i < this.pictures.Length; i++) { worldHeight += this.pictures[i].Height; worldWidth += this.pictures[i].Width; } this.camera = new Camera.Camera2D(this.Game.GraphicsDevice, worldWidth, worldHeight, 1); //Calculate the positions of the pictures. All pictures are 1080 × 720. this.picturePositions = new Vector2[this.pictures.Length]; for (int i = 0; i < this.pictures.Length; i++) { this.picturePositions[i] = new Vector2(center.X + this.pictures[i].Width * i, center.Y); } this.pictureHalfSize = new Vector2(this.pictures[0].Width / 2, this.pictures[0].Height / 2); //Initialise and play the narrative. Song narrative = this.Game.Assets.Load <Song>("story"); MediaPlayer.Play(narrative); this.duration = 0f; base.Initialize(); }
public override void Initialize() { //Initialise the SpriteBatch and load the Textures and calculate the center of the screen. this.batch = new SpriteBatch(this.Game.GraphicsDevice); Vector2 center = new Vector2(this.Game.GraphicsDevice.Viewport.Width / 2, this.Game.GraphicsDevice.Viewport.Height / 2); this.pictures = new Texture2D[6]; for (int i = 1; i <= this.pictures.Length; i++) { //Check if the picture is loaded already. if (!this.Game.Assets.ContainsKey<Texture2D>(Key + i.ToString())) { this.Game.Assets.SaveAsset<Texture2D>(Key + i.ToString(), PicturesLocation + i.ToString()); } this.pictures[i - 1] = this.Game.Assets.Load<Texture2D>(Key + i.ToString()); } //Initialise the sum of the pictures width and height for a worldwidth worldheight and use those to initialise the camera. int worldWidth = 0; int worldHeight = 0; for (int i = 0; i < this.pictures.Length; i++) { worldHeight += this.pictures[i].Height; worldWidth += this.pictures[i].Width; } this.camera = new Camera.Camera2D(this.Game.GraphicsDevice, worldWidth, worldHeight, 1); //Calculate the positions of the pictures. All pictures are 1080 × 720. this.picturePositions = new Vector2[this.pictures.Length]; for (int i = 0; i < this.pictures.Length; i++) { this.picturePositions[i] = new Vector2(center.X + this.pictures[i].Width * i, center.Y); } this.pictureHalfSize = new Vector2(this.pictures[0].Width / 2, this.pictures[0].Height / 2); //Initialise and play the narrative. Song narrative = this.Game.Assets.Load<Song>("story"); MediaPlayer.Play(narrative); this.duration = 0f; base.Initialize(); }