protected override void Update(GameTime gameTime)
        {
#if EDITOR
            if (GameManager.GetLevel() != null && GameManager.GetLevel().MyScene != null)
            {
                GameManager.GetLevel().MyScene.UpdateTime.Start();
            }
#endif

            Game1.gameTime = gameTime;
            if (gameTime.ElapsedGameTime.Milliseconds > 100)
            {
                MasterManager.Update(new GameTime(gameTime.ElapsedGameTime, TimeSpan.FromMilliseconds(100)));
            }
            else
            {
                MasterManager.Update(gameTime);
            }

#if EDITOR
            if (GameManager.GetLevel() != null && GameManager.GetLevel().MyScene != null)
            {
                GameManager.GetLevel().MyScene.UpdateTime.Stop();
            }
#endif

            base.Update(gameTime);
        }
        public override void Draw2D(GameObjectTag DrawTag)
        {
#if EDITOR
            if (FinalTarget == null)
            {
                Console.WriteLine("Final Target is null");
            }
#endif

            MasterManager.SetViewportToFullscreen();
            Game1.graphicsDevice.Clear(Color.Black);

            Game1.graphicsDevice.BlendState        = BlendState.Opaque;
            Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

            Game1.graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            Game1.graphicsDevice.Textures[0]      = FinalTarget;
            PasteEffect.CurrentTechnique.Passes[0].Apply();
            FullscreenQuad.Draw();
#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing)
            {
                objectControls.Draw3D(DrawCamera);
            }
#endif
        }
Beispiel #3
0
        public static void SwitchFromPlay()
        {
            EditorMode = true;
            GameManager.SwitchFromPlay();
            Game1.self.IsMouseVisible = true;
            MasterManager.ChangeSize(EditorSizeX, EditorSizeY);

            MyEditor.OldHeight = 100000;
            MyEditor.OldWidth  = 100000;
            PlayerProfile.Clear();
        }
Beispiel #4
0
        private void DMakeLightMap()
        {
            Game1.graphicsDevice.SetRenderTargets(null);
            Game1.graphicsDevice.SetRenderTarget(LightMap);
            Game1.graphicsDevice.Clear(Color.Transparent);
            Game1.graphicsDevice.BlendState        = LightMapBS;
            Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;


            Game1.graphicsDevice.Textures[0]      = GBufferTargets[0].RenderTarget;
            Game1.graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;

            Game1.graphicsDevice.SamplerStates[1] = SamplerState.PointWrap;
            Game1.graphicsDevice.Textures[1]      = GBufferTargets[1].RenderTarget;

            MasterManager.SetViewportToFullscreen();

            foreach (GameObject g in OverLightingChildren)
            {
                g.Draw3D(DrawCamera, GameObjectTag._3DDeferredOverLighting);
            }

#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing && DrawCamera != null)
            {
                DrawCamera.MakeInverse();
                foreach (GameObject g in WorldLightingChildren)
                {
                    g.Draw3D(DrawCamera, GameObjectTag._3DDeferredOverLighting);
                }
            }
            else
#endif
            {
                int      i             = 0;
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Render.ViewIndex = i++;
                    s.getSceneView().Set();
                    currentCamera = s.getCamera();

                    currentCamera.MakeInverse();
                    foreach (GameObject g in WorldLightingChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DDeferredOverLighting);
                    }
                }
            }
        }
        public void Draw()
        {
            Game1.graphicsDevice.SetRenderTarget(null);
            Game1.graphicsDevice.Clear(Color.Black);

#if !EDITOR
            //try
#endif
            {
                if (!Loading && MyScene != null)
                {
#if EDITOR && WINDOWS
                    Render.RenderTime.Reset();
#endif

                    if (!MyScene.CanLoad)
                    {
                        MyScene.Load();
                    }

#if !EDITOR
                    if (MyScene.WindowSize.X != Game1.ResolutionX || MyScene.WindowSize.Y != Game1.ResolutionY)
                    {
                        MyScene.SetWindowSize(new Vector2(Game1.ResolutionX, Game1.ResolutionY));
                    }
#endif
#if EDITOR
                    if (MyScene.WindowSize.X != Game1.self.Window.ClientBounds.Width || MyScene.WindowSize.Y != Game1.self.Window.ClientBounds.Height)
                    {
                        MyScene.SetWindowSize(new Vector2(Game1.self.Window.ClientBounds.Width, Game1.self.Window.ClientBounds.Height));
                    }
#endif

#if WINDOWS && EDITOR
                    if (!LevelForEditing || Game1.self.IsActive)
#endif
                    MyScene.PreDraw();

                    MyScene.Draw2D(GameObjectTag.SceneDrawScene);
                    Game1.graphicsDevice.SetRenderTarget(null);
                    MasterManager.SetViewportToFullscreen();
                }
            }
#if !EDITOR
            //catch (Exception e)
            //{ MasterManager.e = e; }
#endif
            loadingScreen.Draw(Math.Min(LoadingProgressBar, LoadingProgressBarMax), LoadingProgressBarMax, LoadingProgressBarAlpha);
            PlayerProfile.Draw();
        }
Beispiel #6
0
        public static void Draw()
        {
            if (EditorMode)
            {
                MyEditor.Draw();
            }
            else
            {
                GameManager.Draw();

                MasterManager.SetViewportToFullscreen();
                Game1.graphicsDevice.SetRenderTarget(null);
                FPSCounter.Draw();
            }
        }
        public void Draw(RenderTarget2D SceneRenderTarget, RenderTarget2D DisplacementRenderTarget)
        {
            Game1.graphicsDevice.BlendState        = BlendState.Opaque;
            Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
            Game1.graphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;

            if (!Ready)
            {
                Ready = true;

                BloomThreshold = 0.5f;
                BlurAmount     = 10f;

                EffectParameterCollection parameters = bloomCombineEffect.Parameters;
                parameters["BloomIntensity"].SetValue(BloomIntensity);
                parameters["BaseIntensity"].SetValue(BaseIntensity);
                parameters["BloomSaturation"].SetValue(BloomSaturation);
                parameters["BaseSaturation"].SetValue(BaseSaturation);

                bloomExtractEffect.Parameters["BloomThreshold"].SetValue(
                    BloomThreshold);


                SetBlurEffectParameters(1.0f / (float)renderTarget1.Width, 0, gaussianBlurEffectVertical);
                SetBlurEffectParameters(0, 1.0f / (float)renderTarget1.Height, gaussianBlurEffectHorizontal);
            }

            Game1.graphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;

            DrawFullscreenQuad(SceneRenderTarget, renderTarget1,
                               bloomExtractEffect);

            DrawFullscreenQuad(renderTarget1, renderTarget2,
                               gaussianBlurEffectHorizontal);

            DrawFullscreenQuad(renderTarget2, renderTarget1,
                               gaussianBlurEffectVertical);

            Game1.graphicsDevice.SetRenderTarget(null);
            Game1.graphicsDevice.Textures[1] = SceneRenderTarget;
            Game1.graphicsDevice.Textures[2] = DisplacementRenderTarget;

            MasterManager.SetViewportToFullscreen();

            DrawFullscreenQuad(renderTarget1, null, bloomCombineEffect);
        }
        protected override void Draw(GameTime gameTime)
        {
#if EDITOR
            if (GameManager.GetLevel() != null && GameManager.GetLevel().MyScene != null)
            {
                GameManager.GetLevel().MyScene.DrawTime.Start();
            }
#endif
            MasterManager.Draw();

#if EDITOR
            if (GameManager.GetLevel() != null && GameManager.GetLevel().MyScene != null)
            {
                GameManager.GetLevel().MyScene.DrawTime.Stop();
            }
#endif
            base.Draw(gameTime);
        }
        public override void Draw2D(GameObjectTag DrawTag)
        {
            if (DrawCamera == null)
            {
                return;
            }
            Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, DrawCamera.ViewMatrix);
            Render.AdditiveBlending = false;
            DrawGrid();

            foreach (GameObject g in DrawChildren)
            {
                g.Draw2D(GameObjectTag._2DForward);
            }

#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing)
            {
                objectControls.DrawControls();
            }
#endif
            Game1.spriteBatch.End();

            Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null, DrawCamera.ViewMatrix);
            Render.AdditiveBlending = true;
            foreach (GameObject g in DrawChildren)
            {
                g.Draw2D(GameObjectTag._2DForward);
            }
            Game1.spriteBatch.End();

            base.Draw2D(DrawTag);

            MasterManager.SetViewportToFullscreen();

            Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            foreach (GameObject o in OverDrawViewsChildren)
            {
                o.Draw2D(GameObjectTag.OverDrawViews);
            }
            Game1.spriteBatch.End();
        }
Beispiel #10
0
        public override void Draw2D(GameObjectTag DrawTag)
        {
#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
            {
#endif
            MasterManager.SetViewportToFullscreen();
            Game1.graphicsDevice.Clear(Color.Black);

#if EDITOR && WINDOWS
        }

        if (deferredControls.deferredMode == DeferredMode.Depth || deferredControls.deferredMode == DeferredMode.Normal || deferredControls.deferredMode == DeferredMode.Lighting)
        {
            Game1.graphicsDevice.BlendState        = BlendState.Opaque;
            Game1.graphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
            Game1.graphicsDevice.Textures[0]       = deferredControls.deferredMode == DeferredMode.Lighting ? LightMap : GBufferTargets[deferredControls.deferredMode == DeferredMode.Normal ? 0 : 1].RenderTarget;
            PasteEffect.CurrentTechnique.Passes[0].Apply();
            FullscreenQuad.Draw();
            objectControls.Draw3D(DrawCamera);
        }
        else
#endif
            if (DrawCamera != null)
            {
                Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

                Game1.graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
                Game1.graphicsDevice.Textures[0]      = FinalTarget;
                PasteEffect.CurrentTechnique.Passes[0].Apply();
                FullscreenQuad.Draw();
#if EDITOR && WINDOWS
                if (ParentLevel.LevelForEditing)
                {
                    objectControls.Draw3D(DrawCamera);
                }
#endif
            }
            base.Draw2D(DrawTag);
        }
        public override void PreDraw()
        {
            Game1.graphicsDevice.SetRenderTarget(FinalTarget);
            Game1.graphicsDevice.Clear(Color.Black);

#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
#endif
            {
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
                    Render.CurrentWorldViewer3D            = s;

                    s.getSceneView().Set();
                    Render.CurrentView          = s.getSceneView();
                    currentCamera               = s.getCamera();
                    StarshipScene.CurrentCamera = currentCamera;

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;

                    foreach (GameObject g in ForwardChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DForward);
                    }

                    ParticleManager.PreDraw(currentCamera);
                    ParticleManager.Draw(currentCamera);

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;
                }

                MasterManager.SetViewportToFullscreen();
            }
        }
Beispiel #12
0
        public static void SwitchToPlay()
        {
            LevelFromEditor = true;
            EditorMode      = false;

            EditorSizeX = Game1.self.Window.ClientBounds.Width;
            EditorSizeY = Game1.self.Window.ClientBounds.Height;

            GameManager.SetLevel(new Level(false));

            Stream s = new MemoryStream();

            GameManager.GetEditorLevel().Write(new BinaryWriter(s), false);
            Console.Write(s.Length);
            s.Position = 0;

            GameManager.GetLevel().Read(new BinaryReader(s));

            Game1.self.IsMouseVisible = false;

            //PauseEditor();
            MasterManager.ChangeSize(Game1.ResolutionX, Game1.ResolutionY);
            PlayerProfile.Clear();
        }
Beispiel #13
0
        public override void Draw2D(GameObjectTag DrawTag)
        {
#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing)
            {
                DrawScene(DrawCamera);
            }
            else
#endif
            {
                bloomRenderer.Draw(FinalTarget, distortionRenderer.distortionMap);
                Render.ViewIndex = 0;
                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Render.ViewIndex++;
                    Render.CurrentWorldViewer3D = s;
                    s.getSceneView().Set();
                    Render.CurrentView = s.getSceneView();
                    CurrentCamera      = s.getCamera();

                    if (s.GetType().Equals(typeof(PlayerShip)))
                    {
                        DrawingShip = (PlayerShip)s;
                    }

                    HudDisplaceWidthParam.SetValue(s.getSceneView().Size.X);
                    if (DrawingShip != null && DrawingShip.ShakeOffset.Length() > 0.1f)
                    {
                        HudDisplaceDisplacmentParam.SetValue(Math.Abs(DrawingShip.ShakeOffset.Length() * 10));
                    }
                    else
                    {
                        HudDisplaceDisplacmentParam.SetValue(0);
                    }


                    Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicWrap, DepthStencilState.None, RasterizerState.CullNone, HudDisplaceEffect);

                    if (s.GetType().Equals(typeof(PlayerShip)))
                    {
                        PlayerShip p = (PlayerShip)s;
                        TextParticleSystem.Draw(CurrentCamera);
                    }
                    foreach (GameObject o in Draw2DChildren)
                    {
                        o.Draw2D(GameObjectTag._2DForward);
                    }

                    foreach (GameObject o in OverDrawChildren2D)
                    {
                        o.Draw2D(GameObjectTag._2DOverDraw);
                    }

                    Game1.spriteBatch.End();
                }

                MasterManager.SetViewportToFullscreen();

                Game1.spriteBatch.Begin();
                foreach (GameObject o in OverDrawViewsChildren)
                {
                    o.Draw2D(GameObjectTag.OverDrawViews);
                }
                Game1.spriteBatch.End();
            }
        }
Beispiel #14
0
        public override void PreDraw()
        {
#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
#endif
            {
                distortionRenderer.SetRenderTarget();

                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Render.CurrentWorldViewer3D = s;
                    s.getSceneView().Set();
                    Render.CurrentView = s.getSceneView();
                    currentCamera      = s.getCamera();
                    CurrentCamera      = currentCamera;

                    foreach (GameObject g in DistortionChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DDistortion);
                    }

                    InstanceManager.DrawDistortion(currentCamera);
                    ParticleManager.DrawDistortion(currentCamera);
                }
            }

            Game1.graphicsDevice.SetRenderTarget(FinalTarget);
            Game1.graphicsDevice.Clear(Color.Black);

#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
#endif
            {
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

                    Render.CurrentWorldViewer3D = s;
                    if (s.GetType().Equals(typeof(PlayerShip)))
                    {
                        DrawingShip = (PlayerShip)s;
                    }

                    s.getSceneView().Set();
                    Render.CurrentView = s.getSceneView();
                    currentCamera      = s.getCamera();
                    CurrentCamera      = currentCamera;


                    foreach (GameObject g in BackgroundChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DBackground);
                    }

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;

                    foreach (GameObject g in ForwardChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DForward);
                    }

                    InstanceManager.DrawShield(currentCamera);

                    ParticleManager.PreDraw(currentCamera);

                    InstanceManager.Draw(currentCamera);

                    ParticleManager.Draw(currentCamera);

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;

                    foreach (GameObject g in DepthOverChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DForward);
                    }
                }

                MasterManager.SetViewportToFullscreen();
            }
        }
 protected override void LoadContent()
 {
     spriteBatch    = new SpriteBatch(GraphicsDevice);
     graphicsDevice = graphics.GraphicsDevice;
     MasterManager.Load();
 }