Exemple #1
0
        /// <summary>
        /// 更新処理を行う。
        /// </summary>
        public static void Update()
        {
            if (core == null)
            {
                return;
            }

            core.BeginDrawing();

            layerProfiler.Refresh();

            if (CurrentScene != null && CurrentScene.IsAlive)
            {
                CurrentScene.Update();

                foreach (var item in CurrentScene.Layers)
                {
                    layerProfiler.Record(item.Name, item.ObjectCount, item.TimeForUpdate);
                }
            }

            CommitChanges();

            if (CurrentScene != null)
            {
                CurrentScene.Draw();
            }

            transitionState.Update();
            transitionState.Draw();

            core.Draw();

            core.EndDrawing();
        }
Exemple #2
0
 /// <summary>
 /// Draw the current scene.
 /// If the game allow virtual resolution, render it with the virtual resolution
 /// else render it normally.
 /// </summary>
 public void Draw(SpriteBatch spriteBatch, GameTime time)
 {
     if (GraphicsManager.Instance.AllowVirtualResolution)
     {
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.SetRenderTarget(GraphicsManager.Instance.RenderVirtualResolution);
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.DepthStencilState = new DepthStencilState()
         {
             DepthBufferEnable = true
         };
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Clear(Color.CornflowerBlue);
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, CameraManager.Instance.Transform);
         CurrentScene.Draw(time);
         spriteBatch.End();
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.SetRenderTarget(null);
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Clear(Color.Black);
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / GraphicsManager.Instance.VirtualResolution.X, GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / GraphicsManager.Instance.VirtualResolution.X, 1f) * Matrix.CreateTranslation(GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / 2, GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Height / 2, 0));
         spriteBatch.Draw(GraphicsManager.Instance.RenderVirtualResolution, new Vector2(0, 0), null, Color.White, 0f, new Vector2(GraphicsManager.Instance.RenderVirtualResolution.Width / 2, GraphicsManager.Instance.RenderVirtualResolution.Height / 2), 1f, SpriteEffects.None, 0f);
         spriteBatch.End();
     }
     else
     {
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Clear(Color.CornflowerBlue);
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
         CurrentScene.Draw(time);
         spriteBatch.End();
     }
 }
Exemple #3
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            CurrentScene?.Draw(gameTime);

            base.Draw(gameTime);
        }
Exemple #4
0
 public void Draw()
 {
     if (CurrentScene != null)
     {
         CurrentScene.Draw();
     }
     if (LoadingThread != null)
     {
         LoadingScene.Draw();
     }
 }
Exemple #5
0
 public void Draw(GameTime gameTime)
 {
     if (Transition != null)
     {
         Transition.Draw(gameTime);
     }
     else
     {
         CurrentScene.Draw(gameTime);
     }
 }
Exemple #6
0
        public static void Play()
        {
            //scenesCreation
            TitleScene aivTitle = new TitleScene("Assets/aivBG.png", KeyCode.Return);
            WelcomeScene welcome = new WelcomeScene("Assets/welcomeBg.jpg", KeyCode.Return);
            PlayScene playScene = new PlayScene();
            GameOverScene gameover = new GameOverScene();
            //scenes config
            aivTitle.NextScene = welcome;
            aivTitle.ShowTime = 3;
            aivTitle.FadeIn = true;
            aivTitle.FadeOut = true;

            welcome.NextScene = playScene;
            welcome.FadeOut = false;

            playScene.NextScene = gameover;
            gameover.NextScene = playScene;

            aivTitle.Start();
            CurrentScene = aivTitle;

            //GfxManager.Load();
            while (Window.opened)
            {
                if (!CurrentScene.IsPlaying)
                {
                    //next scene
                    if (CurrentScene.NextScene != null)
                    {
                        CurrentScene.OnExit();
                        CurrentScene = CurrentScene.NextScene;
                        CurrentScene.Start();
                    }
                    else
                        return;
                }

                //Input
                if (Window.GetKey(KeyCode.Esc))
                    break;
                CurrentScene.Input();

                //Update
                CurrentScene.Update();

                //Draw
                CurrentScene.Draw();

                Window.Update();
            }
        }
Exemple #7
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);

            _spriteBatch.Begin();

            CurrentScene.Draw(gameTime, _spriteBatch, _texture);

            _spriteBatch.End();


            base.Draw(gameTime);
        }
 /// <summary>
 /// 現在のシーンの更新と描画処理を行う
 /// </summary>
 public static int Update()
 {
     FpsAdjuster.WaitNextFrame();
     InputManager.UpdateInput();
     CurrentScene.Update();
     if (FpsAdjuster.IsDraw())
     {
         DX.ClearDrawScreen();
         CurrentScene.Draw();
         DX.ScreenFlip();
     }
     return(DX.ProcessMessage());
 }
Exemple #9
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            //spriteBatch.Begin(samplerState: SamplerState.PointClamp); // Avec l'anti-alliasing

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Camera.Transformation);
            CurrentScene.Draw(spriteBatch, gameTime);
            spriteBatch.End();

            primitiveBatch.Begin(PrimitiveType.TriangleList);
            CurrentScene.Draw(primitiveBatch, gameTime);
            primitiveBatch.End();

            base.Draw(gameTime);
        }
Exemple #10
0
        public static void Play()
        {
            while (window.opened)
            {
                AudioManager.SetStreamingMusic("intro", 0.5f);
                //backGround.Stream(intro, window.deltaTime); //audio background



                if (!CurrentScene.IsPlaying)
                {
                    //next scene
                    if (CurrentScene.NextScene != null)
                    {
                        CurrentScene.OnExit();
                        CurrentScene = CurrentScene.NextScene;
                        CurrentScene.Start();
                    }
                    else
                    {
                        return;
                    }
                }

                //totalTime += GfxTools.Win.deltaTime;
                Console.SetCursorPosition(0, 0);
                //float fps = 1 / window.deltaTime;
                //if(fps<59)
                //    Console.Write((1 / window.deltaTime) + "                   ");

                //Input
                if (window.GetKey(KeyCode.Esc))
                {
                    break;
                }

                CurrentScene.Input();

                //Update
                CurrentScene.Update();

                //Draw
                CurrentScene.Draw();

                window.Update();
            }
        }
Exemple #11
0
        public override void Draw(GameTime gameTime)
        {
            // run the pre processor
            PreProcessor.Apply();

            GraphicsDevice.SetRenderTarget(_renderTarget);
            GraphicsDevice.Clear(Color.Black);

            if (CurrentScene != null)
            {
                CurrentScene.Draw();
            }

            PostProcessor.Apply(_renderTarget, null);

            base.Draw(gameTime);
        }
Exemple #12
0
        /// <summary>
        /// Draw this instance on current frame.
        /// </summary>
        public void Draw()
        {
            IDrawable current;

            for (int i = 0; i < _drawablesCount; i++)
            {
                current = _drawables[i];

                if (current.Enabled)
                {
                    current.Draw(_drawContext);
                }
            }

            CurrentScene.Draw(_drawContext);

            GraphicSystem.Render();
        }
        public void Draw(GameTime gameTime)
        {
            Performance.Push("Render loop on main thread");

            lock (lockObj)
            {
                if (CurrentScene != null)
                {
                    CurrentScene.Draw(gameTime);
                }
                else
                {
                    GraphicsDevice.Clear(BaseScene.StandardBackgroundColor);
                }
            }

            Performance.Pop();
        }
Exemple #14
0
        public RenderTarget2D GetSnapshot()
        {
            if (CurrentScene == null)
            {
                throw new InvalidOperationException("There must be a current scene in order to take a snapshot.");
            }

            RenderTarget2D renderTarget = new RenderTarget2D(
                _graphicsDevice,
                _graphicsDevice.Viewport.Width,
                _graphicsDevice.Viewport.Height);

            _graphicsDevice.SetRenderTarget(renderTarget);
            CurrentScene.Draw();
            _graphicsDevice.SetRenderTarget(null);

            return(renderTarget);
        }
Exemple #15
0
        /**
         *  You have to call this method on your monogame project's draw method
         */
        public virtual void Draw()
        {
            // draw the current scene
            if (CurrentScene != null)
            {
                CurrentScene.Draw();
            }

            // Draw a cursor
            if (ShowSpecialCursor && CursorToShow != null)
            {
                BaseGame.IsMouseVisible = false;
                BaseGame.spriteBatch.Draw(CursorToShow, new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 50, 50), Color.White);
            }
            else
            {
                BaseGame.IsMouseVisible = true;
            }
        }
Exemple #16
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(CurrentScene.ClearColor);

            spriteBatch.Begin(transformMatrix: Camera.Transform, samplerState: SamplerState.AnisotropicWrap, sortMode: SpriteSortMode.FrontToBack);

            CurrentScene.Draw(spriteBatch);

            spriteBatch.End();

            spriteBatch.Begin(sortMode: SpriteSortMode.FrontToBack, rasterizerState: rasterizerState);

            // UI draw

            FPS = 1 / gameTime.ElapsedGameTime.TotalSeconds;

            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #17
0
        public static void Play()
        {
            while (window.opened)
            {
                if (!CurrentScene.IsPlaying)
                {
                    //next scene
                    if (CurrentScene.NextScene != null)
                    {
                        CurrentScene.OnExit();
                        CurrentScene = CurrentScene.NextScene;
                        CurrentScene.Start();
                    }
                    else
                    {
                        return;
                    }
                }

                //totalTime += GfxTools.Win.deltaTime;
                //Console.SetCursorPosition(0, 0);
                //Console.Write((1 / window.deltaTime)+"                   ");

                //Input
                if (window.GetKey(KeyCode.Esc))
                {
                    break;
                }

                CurrentScene.Input();

                //Update
                CurrentScene.Update();

                //Draw
                CurrentScene.Draw();

                window.Update();
            }
        }
Exemple #18
0
        /// <summary>
        /// 更新処理を行う。
        /// </summary>
        public static void Update()
        {
            if (core == null)
            {
                return;
            }

            core.BeginDrawing();

            if (CurrentScene != null)
            {
                CurrentScene.Update();
            }

            if (CurrentScene != null)
            {
                CurrentScene.Draw();
            }

            core.Draw();

            core.EndDrawing();
        }
Exemple #19
0
 public static void DrawScenes()
 {
     CurrentScene.Draw();
 }
Exemple #20
0
 public void Draw(GameTime gameTime)
 {
     CurrentScene?.Draw(gameTime);
 }
Exemple #21
0
 public void Draw(GameTime gameTime) => CurrentScene.Draw(gameTime);
Exemple #22
0
        /// <summary>
        /// 更新処理を行う。
        /// </summary>
        public static void Update()
        {
            if (core == null)
            {
                return;
            }

            core.BeginDrawing();

            layerProfiler.Refresh();

            if (CurrentScene != null)
            {
                CurrentScene.Update();

                foreach (var item in CurrentScene.Layers)
                {
                    layerProfiler.Record(item.Name, item.ObjectCount, item.TimeForUpdate);
                }
            }

            if (transition != null)
            {
                transition.OnUpdate();
            }

            if (CurrentScene != null)
            {
                CurrentScene.Draw();
            }

            if (transition != null)
            {
                swig.CoreScene prevScene = null;
                swig.CoreScene curScene  = null;

                if (CurrentScene != null)
                {
                    curScene = CurrentScene.CoreScene;
                }

                if (previousScene != null)
                {
                    prevScene = previousScene.CoreScene;
                }

                if (transition.SwigObject.GetIsSceneChanged())
                {
                    core.DrawSceneToWindowWithTransition(curScene, prevScene, transition.SwigObject);
                }
                else
                {
                    core.DrawSceneToWindowWithTransition(null, curScene, transition.SwigObject);
                }
            }
            else
            {
                if (CurrentScene != null)
                {
                    core.DrawSceneToWindow(CurrentScene.CoreScene);
                }
            }

            core.Draw();

            core.EndDrawing();
        }
Exemple #23
0
 public void Draw(SpriteBatch sb)
 {
     CurrentScene.Draw(sb);
 }
Exemple #24
0
 public void Draw(float deltaTime) => CurrentScene?.Draw(deltaTime);
Exemple #25
0
 public override void Draw(IDrawContext context)
 {
     PreviousScene?.Draw(context);
     CurrentScene.Draw(context);
     base.Draw(context);
 }
Exemple #26
0
 internal static void Draw(SpriteBatch spriteBatch)
 {
     CurrentScene?.Draw(spriteBatch);
     DrawTransitions(spriteBatch);
 }
Exemple #27
0
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     CurrentScene.Draw(gameTime, spriteBatch, background, spriteFont);
 }
Exemple #28
0
 internal static void Draw()
 {
     CurrentScene?.Draw();
     DrawTransitions();
 }
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Texture2D portrait)
 {
     CurrentScene.Draw(gameTime, spriteBatch, portrait);
 }