Beispiel #1
0
        /// <summary>
        /// Everything drawn here will not be translated by a camera.
        /// </summary>
        private static void DrawUserInterface()
        {
            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DefaultDepthStencil, ScissorRectRasterizer);
            Overlay.Draw(_spriteBatch);
            switch (TMBAW_Game.CurrentGameState)
            {
            case GameState.MainMenu:
                MainMenu.Draw(_spriteBatch);
                break;

            case GameState.LoadingScreen:
                LoadingScreen.Draw(_spriteBatch);
                break;

            case GameState.GameWorld:
                GameWorld.DrawUi(_spriteBatch);
                break;

            default:
                break;
            }

            PauseMenu.Draw(_spriteBatch);
            OptionsMenu.Draw(_spriteBatch);
            TMBAW_Game.Dialog.Draw(_spriteBatch);
            GameDebug.Draw(_spriteBatch);
            TMBAW_Game.MessageBox.Draw(_spriteBatch);
            TMBAW_Game.TextInputBox.Draw(_spriteBatch);

            Cursor.Draw(_spriteBatch);

            _spriteBatch.End();
        }
    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Black);

        spriteBatch.Begin();

        switch (currentMode)
        {
        case MODE.GAME: game.Draw(gameTime, spriteBatch); break;

        case MODE.WELCOME: welcomeScr.Draw(gameTime, spriteBatch); break;

        case MODE.LOADING: loadingScr.Draw(gameTime, spriteBatch); break;

        case MODE.CREDITS: creditsScr.Draw(gameTime, spriteBatch); break;

        case MODE.CONFIG: configScr.Draw(gameTime, spriteBatch); break;

        case MODE.HELP: helpScr.Draw(gameTime, spriteBatch); break;

        case MODE.END: endScr.Draw(gameTime, spriteBatch); break;
        }

        spriteBatch.End();
        base.Draw(gameTime);
    }
Beispiel #3
0
 public void Draw(SpriteBatch spriteBatch)
 {
     if (SceneLoaded)
     {
         this.EntityManager.Draw(spriteBatch);
     }
     else if (SceneLoadingScreen != null)
     {
         SceneLoadingScreen.Draw(spriteBatch);
     }
 }
Beispiel #4
0
 /// <summary>
 /// The Draw method implementation for CFMG
 /// </summary>
 /// <param name="gt">Denotes an instant in time</param>
 protected override void Draw(GameTime gt)
 {
     if (IsLoading)
     {
         LoadingScreen.Draw(gt);
     }
     else
     {
         CurrentScreen.Draw(gt);
     }
     base.Draw(gt);
 }
        public void PrepareLoadingScreen(GameCartridge gameCartridge, MachinaRuntime runtime, AssetLibrary assets, WindowInterface machinaWindow, Action <GameCartridge> onFinished)
        {
            var loader = assets.GetStaticAssetLoadTree();

            LoadDefaultStyle(loader, assets, runtime.Painter);
            gameCartridge.PrepareDynamicAssets(loader, runtime);

            var loadingScreen =
                new LoadingScreen(loader);

            var introScene  = SceneLayers.AddNewScene();
            var loaderActor = introScene.AddActor("Loader");
            var adHoc       = new AdHoc(loaderActor);

            adHoc.onPreDraw += (spriteBatch) =>
            {
                if (!loadingScreen.IsDoneUpdateLoading())
                {
                    // Waiting for this to complete before draw loading
                }
                else if (!loadingScreen.IsDoneDrawLoading())
                {
                    loadingScreen.IncrementDrawLoopLoad(assets, spriteBatch);
                }
            };

            adHoc.onDraw += (spriteBatch) =>
            {
                loadingScreen.Draw(spriteBatch, machinaWindow.CurrentWindowSize);
            };

            adHoc.onUpdate += (dt) =>
            {
                if (!loadingScreen.IsDoneUpdateLoading())
                {
                    var increment = 3;
                    for (var i = 0; i < increment; i++)
                    {
                        loadingScreen.Update(dt / increment);
                    }
                }

                if (loadingScreen.IsDoneDrawLoading() && loadingScreen.IsDoneUpdateLoading())
                {
                    onFinished(gameCartridge);
                }
            };
        }
Beispiel #6
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(Gfx.BackgroundColor);
            var mousePos = input.MousePos;

            Cursor.Reset();

            Gfx.SamplerState = SamplerState.AnisotropicClamp;
            Gfx.BeginSpriteBatch();


            if (EscMenuBool)
            {
                EscMenu.Draw(gameTime, mousePos);
            }
            else
            {
                switch (State)
                {
                case GameState.MainMenu:
                    MainMenu.Draw(gameTime, mousePos);
                    break;

                case GameState.Loading:
                    LoadingScreen.Draw(gameTime, mousePos);
                    break;

                case GameState.InGame:
                    Gfx.SpriteBatch.DrawString(Gfx.Fonts.SmallFont, "Hello World.",
                                               new Vector2(3, 0), Gfx.CgccGreen);
                    break;

                case GameState.NewGame:
                    NewGame.Draw(gameTime, mousePos);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(State), State + " is an invalid state");
                }
            }

            FpsCounter.Draw(gameTime, mousePos);
            Cursor.Draw(mousePos);

            Gfx.SpriteBatch.End();
            base.Draw(gameTime);
        }
Beispiel #7
0
        protected override void Draw(GameTime gameTime)
        {
            //第五步

            if (Platform.PlatFormType == PlatFormType.Win || Platform.PlatFormType == PlatFormType.UWP || Platform.PlatFormType == PlatFormType.Android || Platform.PlatFormType == PlatFormType.Desktop)
            {
                if (takePicture == true)
                {
                    try
                    {
                        if (screenshot == null || screenshot.GraphicsDevice == null)
                        {
                            screenshot = new RenderTarget2D(Platform.GraphicsDevice, Platform.GraphicsDevice.Viewport.Width, Platform.GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None);
                        }
                        Platform.GraphicsDevice.SetRenderTarget(screenshot);
                    }
#pragma warning disable CS0168 // The variable 'ex' is declared but never used
                    catch (Exception ex)
#pragma warning restore CS0168 // The variable 'ex' is declared but never used
                    {
                        //Log...
                    }
                    //takePicture = false;
                }
            }

            var spriteMode = mainGameScreen == null ? SpriteSortMode.Deferred : SpriteSortMode.BackToFront;

            if (disScale) //Platform.PlatFormType == PlatForm.iOS && isRetina)
            {
                if (mainGameScreen == null || loadingScreen != null)
                {
                    SpriteBatch.Begin(spriteMode, BlendState.AlphaBlend, null, null, null, null, SpriteScale1);
                }
                else
                {
                    SpriteBatch.Begin(spriteMode, BlendState.AlphaBlend, null, null, null, null, SpriteScale2);
                }
            }
            else
            {
                SpriteBatch.Begin(spriteMode, BlendState.AlphaBlend);
            }

            Platform.GraphicsDevice.Clear(Color.TransparentBlack);
            //this.graphics.GraphicsDevice.Clear(Color.TransparentBlack);

            if (loadingScreen == null)
            {
                if (mainGameScreen == null)
                {
                    if (mainMenuScreen == null)
                    {
                    }
                    else
                    {
                        mainMenuScreen.Draw(gameTime);
                    }
                }
                else
                {
                    if (isDebug)
                    {
                        mainGameScreen.Draw(gameTime);
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(err))
                        {
                            try
                            {
                                mainGameScreen.Draw(gameTime);
                            }
                            catch (Exception ex)
                            {
                                err = "不好意思,游戏运行出错,点击将返回主菜单,请考虑读取自动存档。\r\n" + ex.Message;
                                WebTools.TakeWarnMsg("mainGameScreen.Draw", "", ex);
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(err))
                            {
                                CacheManager.DrawString(Session.Current.Font, err.SplitLineString(100), errPos, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                            }

                            if (InputManager.IsPressed)
                            {
                                err = "";

                                //保存當前進度
                                mainGameScreen.SaveGameAutoPosition();

                                loadingScreen = new LoadingScreen();
                                loadingScreen.LoadScreenEvent += (sender0, e0) =>
                                {
                                    Platform.Sleep(1000);
                                };
                            }
                        }
                    }
                }
            }
            else
            {
                loadingScreen.Draw(gameTime);
            }

            //view = Platform.Current.MemoryUsage;
            //if (!String.IsNullOrEmpty(view))
            //{
            //    CacheManager.DrawString(Session.Current.Font, "view:" + view.SplitLineString(100), errPos, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            //}

            //if (!String.IsNullOrEmpty(warn) && lastWarnTime != null && (DateTime.Now - (DateTime)lastWarnTime).TotalSeconds < 20)
            //{
            //    CacheManager.DrawString(Session.Current.Font, "Warn:" + warn, errPos, Color.Red, 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 1f);
            //}

            ////if (!String.IsNullOrEmpty(err))
            ////{
            ////CacheManager.DrawString(LightAncient, "Err:" + err.SplitLineString(100).ProcessStar(), errPos, Color.Red, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 1f);
            ////}

            if (renderLast != null)
            {
                SpriteBatch.Draw(renderLast, Vector2.Zero, Color.White);
            }

            SpriteBatch.End();

            if (takePicture == true && String.IsNullOrEmpty(err))
            {
                takePicture = false;
                try
                {
                    if (Platform.PlatFormType == PlatFormType.Win || Platform.PlatFormType == PlatFormType.UWP || Platform.PlatFormType == PlatFormType.Android || Platform.PlatFormType == PlatFormType.Desktop)  // || Platform.PlatFormType == PlatForm.iOS)
                    {
                        if (screenshot != null)
                        {
                            byte[] shot = Platform.Current.ScreenShot(Platform.GraphicsDevice, screenshot);
                            //Season.GraphicsDevice.SetRenderTarget(null);

                            if (shot != null && shot.Length > 0)
                            {
                                var task = new PlatformTask(() => { });
                                task.OnStartFinish += (result) =>
                                {
                                    if (task.ParamArrayResultBytes != null && task.ParamArrayResultBytes.Length > 0)
                                    {
                                        Platform.Current.SaveUserFile(picture, task.ParamArrayResultBytes, null);
                                    }
                                };
                                Platform.Current.ResizeImageFile(shot, 800, 480, false, task);
                            }
                        }
                        //Task.Run(async () => await Season.Current.SaveUserFile(picture, shot));
                        //var task = new SeasonTask(() =>
                        //{
                        //    screenshot = new RenderTarget2D(Season.GraphicsDevice, 800, 480, false, SurfaceFormat.Color, DepthFormat.None);
                        //});
                    }
                }
                catch (Exception ex)
                {
                    WebTools.TakeWarnMsg("游戏界面截屏失败:", "takePicture:", ex);
                }
            }

            base.Draw(gameTime);
        }
Beispiel #8
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.Black);

            if (_currentState != GameState.Playing)
            {
                _spriteBatch.Begin();
            }

            switch (_currentState)
            {
            case GameState.IntroScreen:
                _introScreen.Draw(gameTime, _spriteBatch);
                break;

            case GameState.MainMenu:
                _mainMenu.Draw(gameTime, _spriteBatch);
                break;

            case GameState.Playing:
                if (_overworld != null)
                {
                    _overworld.Draw(GraphicsDevice, gameTime, _spriteBatch, Window.ClientBounds);
                }
                break;

            case GameState.LoadGame:
                _loadscreen.Draw(gameTime, _spriteBatch);
                break;

            case GameState.Options:
                _options.Draw(gameTime, _spriteBatch);
                break;

            case GameState.Credits:
                _credits.Draw(gameTime, _spriteBatch);
                break;

            case GameState.LoadingGame:
            case GameState.NewGame:
                _loadingScreen.Draw(gameTime, _spriteBatch);
                break;

            case GameState.HowToPlay:
                _howToPlay.Draw(gameTime, _spriteBatch);
                break;

            case GameState.GameOver:
                _gameOver.Draw(gameTime, _spriteBatch);
                break;

            case GameState.Saving:
                _savescreen.Draw(gameTime, _spriteBatch);
                break;
            }

            if (_currentState != GameState.Playing)
            {
                _spriteBatch.End();
            }

            base.Draw(gameTime);
        }