/// <summary> /// Get /// </summary> /// <param name="time"></param> /// <param name="content"></param> /// <returns></returns> public void Display(GameTime time) { if (_config.DebugMode) { DH.Border(CollisionPosition, thickness: 4); } float value = (float)Math.Cos(MathHelper.ToRadians(360 * ((float)(time.TotalGameTime.TotalMilliseconds % 1000) / 1000))); DH.Raw(_texture.Texture, DisplayX, DisplayY, _texture.Width, _texture.Height + (value * 20), align: AlignType.CB); }
/// <summary> /// Display single option (value, buttons and description) /// </summary> /// <param name="ID">Index of option in current category. Used for coloring odd/even options</param> /// <param name="optionID">Name of an option</param> /// <param name="value">Value to display</param> /// <param name="y">Position Y</param> /// <param name="second">Display in second column</param> private void DisplayOption(int ID, string optionID, Func <string> value, int y, bool secondColumn = false) { int half_size = (_config.WindowWidth - 288) / 2; int x = 288 + (secondColumn ? half_size : 0); if (ID % 2 == 0) { DH.Box(x, y, half_size, 32, ColorsManager.DarkGray * .25f); } DH.Text(_font, value?.Invoke( ), x + 75, y + 18, false, align: AlignType.CM); DH.Text(_font, LANG.Get(optionID).ToUpper( ), x + 160, y + 18, false, align: AlignType.LM); }
/// <summary> /// Display graphics /// </summary> /// <param name="gameTime"><see cref="GameTime"/></param> protected override void Draw(GameTime gameTime) { // View renders _console.Render(gameTime); _state.GetCurrentState( ).Render(gameTime); // Display DH.RenderScene(null, () => { _state.GetCurrentState( ).Display( ); DH.Text(Font, $"ver. {VERSION}", 10, Height - 10, false, COLOR.DarkGray, ALIGN.LM); DH.Text(Font, $"Copyright (C) Tomasz Babiak, ASwan, Oliver F. for Game Off 2020, itch.io", Width - 10, Height - 10, false, COLOR.DarkGray, ALIGN.RM); _console.Display( ); }); base.Draw(gameTime); }
/// <summary> /// State's render /// </summary> /// <param name="time"><see cref="GameTime"/></param> public override void Render(GameTime time) { DH.RenderScene(Scene, () => { DH.Raw(_content.TEXUI_MenuBG, 32, 0); _backButton.Display( ); if (_changedConfig.Count > 0) { _saveButton.Display( ); } int half_size = (_config.WindowWidth - 288) / 2; DH.Text(_font, "section_general", 296, 48, align: AlignType.LB); DH.Line(288, 56, 288 + half_size, 56); DisplayOption(0, "language", () => _translations[_cfg["language"].ToString( )], 56); DH.Text(_font, "section_graphics", 296, 120, align: AlignType.LB); DH.Line(288, 128, 288 + half_size, 128); DisplayOption(0, "window_mode", () => LANG.Get("mode_" + ((bool)_cfg["window_fullscreen"] ? "fullscreen" : "window")), 128); DisplayOption(1, "resolution", () => $"{_cfg["window_width"]}x{_cfg["window_height"]}", 160); DH.Text(_font, "section_audio", 296, 224, align: AlignType.LB); DH.Line(288, 232, 288 + half_size, 232); DisplayOption(0, "master_volume", () => $"{((float)_cfg["master_volume"] * 100):0}%", 232); DisplayOption(1, "music_volume", () => $"{((float)_cfg["music_volume"] * 100):0}%", 264); DisplayOption(2, "sound_volume", () => $"{((float)_cfg["sound_volume"] * 100):0}%", 296); DH.Text(_font, "section_controls", 296 + half_size, 48, align: AlignType.LB); DH.Line(288 + half_size, 56, _config.WindowWidth, 56); DisplayOption(0, "key_console", () => $"{_cfg["key_console"]}", 56, true); DisplayOption(1, "key_pause", () => $"{_cfg["key_pause"]}", 88, true); DisplayOption(2, "key_move_up", () => $"{_cfg["key_move_up"]}", 120, true); DisplayOption(3, "key_move_down", () => $"{_cfg["key_move_down"]}", 152, true); DisplayOption(4, "key_move_left", () => $"{_cfg["key_move_left"]}", 184, true); DisplayOption(5, "key_move_right", () => $"{_cfg["key_move_right"]}", 216, true); DH.Line(288 + half_size, 56, 288 + half_size, 256); }); }
/// <summary> /// Render state /// </summary> /// <param name="time"><see cref="GameTime"/></param> public override void Render(GameTime time) { DH.RenderScene(_gameplayScene, _camera, () => { foreach (WorldTile tile in _level.Map) { if (!tile.IsWall) { float distance = (float)Math.Sqrt(Math.Pow(tile.DisplayX - _player.X, 2) + Math.Pow(tile.DisplayY - _player.Y, 2)); float percentage = 1 - (distance < 350 ? 0 : (distance - 350) / 700); DH.Raw(_content.TEXGround.Texture, tile.DisplayX - 16, tile.DisplayY - 16, color: ColorsManager.Get(percentage)); } } if (_config.DebugMode) { foreach (WorldTile tile in _level.Map) { if (tile.Collisions.Contains(CollisionType.Left)) { DH.Line(tile.DisplayX, tile.DisplayY, tile.DisplayX, tile.DisplayY + tile.Size, 8, Color.Red); } if (tile.Collisions.Contains(CollisionType.Right)) { DH.Line(tile.DisplayX + tile.Size, tile.DisplayY, tile.DisplayX + tile.Size, tile.DisplayY + tile.Size, 8, Color.Red); } if (tile.Collisions.Contains(CollisionType.Top)) { DH.Line(tile.DisplayX, tile.DisplayY, tile.DisplayX + tile.Size, tile.DisplayY, 8, Color.Red); } if (tile.Collisions.Contains(CollisionType.Bottom)) { DH.Line(tile.DisplayX, tile.DisplayY + tile.Size, tile.DisplayX + tile.Size, tile.DisplayY + tile.Size, 8, Color.Red); } } } _player.Display(time); }); DH.RenderScene(Scene, () => { DH.Scene(_gameplayScene); DH.Text(_content.GetFont( ), _player.Name, 15, 15, false); // Mini-map UH.Loops(_level.Width, _level.Height, (x, y) => { if (!_level.Map[y * _level.Width + x].IsWall) { DH.Raw(_content.Pixel, _config.ViewWidth - 16 - _level.Width * 4 + x * 4, _config.ViewHeight - 16 - _level.Height * 4 + y * 4, 4, 4, (_player.OnMapX == x && _player.OnMapY == y ? Color.Red : Color.Gray) * .5f ); } }); if (_config.DebugMode) { DH.Text(_debugFont, $"{(int)(1 / time.ElapsedGameTime.TotalSeconds)} FPS", _config.WindowWidth - 10, 10, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Mouse ({_input.MouseX}, {_input.MouseY})", _config.WindowWidth - 10, 25, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Player ({_player.X:0.0}, {_player.Y:0.0}) ({_player.OnMapX}, {_player.OnMapY})", _config.WindowWidth - 10, 40, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Camera ({_camera.Target.X:0.0}, {_camera.Target.Y:0.0})", _config.WindowWidth - 10, 55, false, ColorsManager.DarkGray, AlignType.RT); DH.Text(_debugFont, $"Scale {_camera.Scale:0.00}x", _config.WindowWidth - 10, 70, false, ColorsManager.DarkGray, AlignType.RT); DH.Line(0, _config.WindowHeight / 2, _config.WindowWidth, _config.WindowHeight / 2, 1, ColorsManager.DarkestGray * .5f); DH.Line(_config.WindowWidth / 2, 0, _config.WindowWidth / 2, _config.WindowHeight, 1, ColorsManager.DarkestGray * .5f); } }); }