Exemple #1
0
        private void RenderAlertWindow(string msg, bool trans = false)
        {
            var xx = (GameConts.Width - msg.Length * 8) / 2;
            var yy = (GameConts.Height - 8) / 2;
            var w  = msg.Length;
            var h  = 1;

            Screen.Render(xx - 8, yy - 8, 0 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 0);
            Screen.Render(xx + w * 8, yy - 8, 0 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 1);
            Screen.Render(xx - 8, yy + 8, 0 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 2);
            Screen.Render(xx + w * 8, yy + 8, 0 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 3);
            for (var x = 0; x < w; x++)
            {
                Screen.Render(xx + x * 8, yy - 8, 1 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 0);
                Screen.Render(xx + x * 8, yy + 8, 1 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 2);
            }
            for (var y = 0; y < h; y++)
            {
                Screen.Render(xx - 8, yy + y * 8, 2 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 0);
                Screen.Render(xx + w * 8, yy + y * 8, 2 + 13 * 32, Color.Get(!trans ? 0 : -1, 1, 5, 445), 1);
            }

            Font.Draw(msg, Screen, xx, yy,
                      TickCount / 20 % 2 == 0 ? Color.Get(5, 333, 333, 333) : Color.Get(5, 555, 555, 555));
        }
Exemple #2
0
        private void RenderGui()
        {
            if (Player != null)
            {
                if (Player.ActiveItem != null)
                {
                    for (var y = 0; y < 1; y++)
                    {
                        for (var x = 0; x < 10; x++)
                        {
                            Screen.Render(x * 8 + GameConts.ScreenMiddleWidth - 40, Screen.H - 18 + y * 8, 0 + 12 * 32,
                                          Color.Get(000, 000, 000, 000), 0);
                        }
                    }
                }

                for (var i = 0; i < 10; i++)
                {
                    Screen.Render(GameConts.ScreenMiddleWidth + i * 8 - 80, Screen.H - 9, 0 + 12 * 32,
                                  i < Player.Health ? Color.Get(-1, 200, 500, 533) : Color.Get(-1, 100, 000, 000), 0);

                    if (Player.StaminaRechargeDelay > 0)
                    {
                        Screen.Render((i * 8 + GameConts.ScreenMiddleWidth) + 5, Screen.H - 9, 1 + 12 * 32,
                                      Player.StaminaRechargeDelay / 4 % 2 == 0
                                ? Color.Get(-1, 555, 000, 100)
                                : Color.Get(-1, 110, 000, 100), 0);
                    }
                    else
                    {
                        Screen.Render((i * 8 + GameConts.ScreenMiddleWidth) + 5, Screen.H - 9, 1 + 12 * 32,
                                      i < Player.Stamina
                                ? Color.Get(-1, 220, 550, 553)
                                : Color.Get(-1, 110, 000, 000),
                                      0);
                    }
                }
                Player.ActiveItem?.RenderInventory(Screen, GameConts.ScreenMiddleWidth - 40, Screen.H - 18);

                /*if (_playerDeadTime < 60)
                 * {
                 *  int seconds = GameTime/60;
                 *  int minutes = seconds/60;
                 *  int hours = minutes/60;
                 *  minutes %= 60;
                 *  seconds %= 60;
                 *
                 *  var timeString = hours > 0
                 *      ? hours + "h" + (minutes < 10 ? "0" : "") + minutes + "m"
                 *      : minutes + "m " + (seconds < 10 ? "0" : "") + seconds + "s";
                 *
                 *  var xx = (GameConts.Width - timeString.Length*8) + 1;
                 *
                 *  Font.Draw(timeString, Screen, xx, 1, Color.White);
                 *
                 * }*/

                Font.Draw(GameConts.Version, Screen, (GameConts.Width - GameConts.Version.Length * 8) / 2, 1, Color.White);
            }
            Menu?.Render(Screen);
        }
Exemple #3
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)
        {
            if (Player != null)
            {
                var xScroll = Player.X - Screen.W / 2;
                var yScroll = Player.Y - (Screen.H - 8) / 2;
                if (xScroll < 16)
                {
                    xScroll = 16;
                }
                if (yScroll < 16)
                {
                    yScroll = 16;
                }
                if (xScroll > Level.W * 16 - Screen.W - 16)
                {
                    xScroll = Level.W * 16 - Screen.W - 16;
                }
                if (yScroll > Level.H * 16 - Screen.H - 16)
                {
                    yScroll = Level.H * 16 - Screen.H - 16;
                }
                if (CurrentLevel > 3)
                {
                    var col = Color.Get(20, 20, 121, 121);
                    for (var y = 0; y < GameConts.Height / 8 + 1; y++)
                    {
                        for (var x = 0; x < GameConts.Width / 8 + 1; x++)
                        {
                            Screen.Render(x * 8 - ((xScroll / 4) & 7), y * 8 - ((yScroll / 4) & 7), 0, col, 0);
                        }
                    }
                }


                Level.RenderBackground(Screen, xScroll, yScroll);
                Level.RenderSprites(Screen, xScroll, yScroll);

                if (CurrentLevel < 3)
                {
                    _lightScreen.Clear(0);
                    Level.RenderLight(_lightScreen, xScroll, yScroll);
                    Screen.Overlay(_lightScreen, xScroll, yScroll);
                }
            }

            RenderGui();

            if (Menu?.ShowNagger == true || Menu == null)
            {
                if (!HasFocus() && !IsLoadingWorld)
                {
                    RenderAlertWindow("Click to Focus", true);
                }
            }
            if (IsLoadingWorld)
            {
                RenderAlertWindow(LoadingText);
            }

            for (var y = 0; y < Screen.H; y++)
            {
                for (var x = 0; x < Screen.W; x++)
                {
                    var cc = Screen.GetPixel(x + y * Screen.W);
                    if (cc < 255)
                    {
                        _pixels[x + y * Screen.W] = _colors[cc];
                    }
                }
            }
            _image.SetData(_pixels);

            if (TakeScreenShot)
            {
                _image.Save(ImageFormat.Png,
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Minirealms.ss.png"));
                TakeScreenShot = false;
            }

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
            _spriteBatch.Draw(_image, new Rectangle(0, 0, GameConts.Width * GameConts.Instance.Scale, GameConts.Height * GameConts.Instance.Scale), Microsoft.Xna.Framework.Color.White);
            _spriteBatch.End();

            base.Draw(gameTime);
        }