/// <summary> /// Executes Draw events. /// </summary> internal static void CallDrawEvents() { foreach (var scene in Scenes) { if (scene.Visible) { CurrentScene = scene; foreach (var layer in scene.Layers) { if ( layer.Visible && !layer.IsGUI && !GraphicsMgr.CurrentCamera.Filter(scene.Name, layer.Name) ) { CurrentLayer = layer; bool hasPostprocessing = ( GraphicsMgr.CurrentCamera.PostprocessingMode == PostprocessingMode.CameraAndLayers && layer.PostprocessorEffects.Count > 0 ); if (hasPostprocessing) { GraphicsMgr.SetSurfaceTarget(GraphicsMgr.CurrentCamera._postprocessorLayerBuffer, GraphicsMgr.CurrentView); GraphicsMgr.Device.Clear(Color.TransparentBlack); } foreach (var entity in layer._depthSortedEntities) { if (entity.Visible && !entity.Destroyed) { foreach (var componentPair in entity._components) { if (componentPair.Value.Visible) { SystemMgr.Draw(componentPair.Value); } } entity.Draw(); } } if (hasPostprocessing) { GraphicsMgr.ResetSurfaceTarget(); var oldRasterizer = GraphicsMgr.Rasterizer; GraphicsMgr.Rasterizer = GraphicsMgr._cameraRasterizerState; GraphicsMgr.SetTransformMatrix(Matrix.CreateTranslation(Vector3.Zero)); layer.ApplyPostprocessing(); GraphicsMgr.ResetTransformMatrix(); GraphicsMgr.Rasterizer = oldRasterizer; } } } } } }
public void Draw() { GraphicsMgr.AddTransformMatrix( // Origin point for the panel is on the bottom, so we need to center it. Matrix.CreateTranslation((Vector2.UnitY * Root.Size.Y / 2f).ToVector3()) * Matrix.CreateRotationZ(MathHelper.ToRadians(Rotation)) * Matrix.CreateTranslation(Position.ToVector3()) ); Root.Draw(); GraphicsMgr.ResetTransformMatrix(); }
public override void Draw() { var canvasSize = GameMgr.WindowManager.CanvasSize; Text.CurrentFont = Resources.Fonts.Arial; Text.HorAlign = TextAlign.Left; Text.VerAlign = TextAlign.Top; // Description. if (CurrentFactory.Description != "") { var padding = 8; var textSize = Text.CurrentFont.MeasureString(CurrentFactory.Description); var origin = Vector2.UnitX * (canvasSize - (textSize + Vector2.One * padding * 2)); GraphicsMgr.CurrentColor = _barColor; RectangleShape.Draw(origin, origin + textSize + Vector2.One * padding * 2, false); GraphicsMgr.CurrentColor = _textColor; Text.Draw(CurrentFactory.Description, Vector2.One * padding + origin); } // Description. // Bottom bar. GraphicsMgr.AddTransformMatrix(Matrix.CreateTranslation(new Vector3(0, canvasSize.Y - _barHeight, 0))); GraphicsMgr.CurrentColor = _barColor; RectangleShape.Draw(Vector2.Zero, canvasSize, false); GraphicsMgr.CurrentColor = _textColor; Text.Draw( "fps: " + GameMgr.Fps + " | Current scene: " + CurrentScene.Name + Environment.NewLine + _prevSceneButton + "/" + _nextSceneButton + " - change scene, " + _restartButton + " - restart current scene, " + _toggleUIButton + " - toggle UI, " + _toggleFullscreenButton + " - toggle fullscreen" + Environment.NewLine + CameraController.UpButton + "/" + CameraController.DownButton + "/" + CameraController.LeftButton + "/" + CameraController.RightButton + " - move camera, " + CameraController.ZoomInButton + "/" + CameraController.ZoomOutButton + " - zoom, " + CameraController.RotateLeftButton + "/" + CameraController.RotateRightButton + " - rotate" , _indent ); GraphicsMgr.ResetTransformMatrix(); // Bottom bar. }
public void Draw() { // Transform matrices took care of the rotations, // so all panels assume they are drawn with no rotation\offset. RectangleShape.DrawBySize(Offset - Vector2.UnitY * Size / 2f, Size, true); CircleShape.Draw(Offset, 4, true); LineShape.Draw(Offset, Offset - Vector2.UnitY * 8); if (Attachments == null) { return; } // Transform matrices stack. GraphicsMgr.AddTransformMatrix( Matrix.CreateTranslation(-(Vector2.UnitY * Size / 2f).ToVector3()) ); foreach (var panel in Attachments) { // We need to offset the child panel by half of parent's // width or height depending on the side. var length = Size.X / 2f; var resultSide = panel.Side; if (panel.Side % 2 == 0) { length = Size.Y / 2f; } GraphicsMgr.AddTransformMatrix( //Matrix.CreateRotationZ(0.3f) // Future reference - use this to pivot the panels. Matrix.CreateTranslation(-(Vector2.UnitY * length).ToVector3()) * Matrix.CreateRotationZ((float)(Math.PI - Math.PI / 2f * resultSide)) * Matrix.CreateTranslation(Offset.ToVector3()) ); panel.Draw(); GraphicsMgr.ResetTransformMatrix(); } GraphicsMgr.ResetTransformMatrix(); }
public override void Draw() { GraphicsMgr.AddTransformMatrix( Matrix.CreateTranslation((GraphicsMgr.CurrentCamera.Position - GraphicsMgr.CurrentCamera.Size / 2).ToVector3()) ); GraphicsMgr.CurrentColor = Color.White; _sun.Draw(_sunBasePosition, _sun.Origin); _mountains.Draw( _mountainsBasePosition + GraphicsMgr.CurrentCamera.Size * Vector2.UnitY, _mountains.Origin ); DrawParallaxForest(_forest1, _forest1Parallax); DrawParallaxForest(_forest2, _forest2Parallax); GraphicsMgr.ResetTransformMatrix(); }