diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index a27d614..cfe88ef 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -20,6 +20,18 @@ /processorParam:TextureFormat=Compressed /build:ButtonFont.spritefont +#begin deathBackground.jpg +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:deathBackground.jpg + #begin Font_25.spritefont /importer:FontDescriptionImporter /processor:FontDescriptionProcessor @@ -101,6 +113,30 @@ /processorParam:TextureFormat=Color /build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png +#begin textboxbackground.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:textboxbackground.png + +#begin textboxbackground2.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:textboxbackground2.png + #begin wall.jpg /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/deathBackground.jpg b/DangerousD/Content/deathBackground.jpg new file mode 100644 index 0000000..d8c4062 Binary files /dev/null and b/DangerousD/Content/deathBackground.jpg differ diff --git a/DangerousD/Content/textboxbackground.png b/DangerousD/Content/textboxbackground.png new file mode 100644 index 0000000..70f1d97 Binary files /dev/null and b/DangerousD/Content/textboxbackground.png differ diff --git a/DangerousD/Content/textboxbackground2.png b/DangerousD/Content/textboxbackground2.png new file mode 100644 index 0000000..8494c3e Binary files /dev/null and b/DangerousD/Content/textboxbackground2.png differ diff --git a/DangerousD/GameCore/GUI/DeathGUI.cs b/DangerousD/GameCore/GUI/DeathGUI.cs new file mode 100644 index 0000000..c69c7da --- /dev/null +++ b/DangerousD/GameCore/GUI/DeathGUI.cs @@ -0,0 +1,33 @@ +using DangerousD.GameCore.Managers; +using Microsoft.Xna.Framework; +using MonogameLibrary.UI.Base; +using MonogameLibrary.UI.Elements; +using System.Diagnostics; +using System.Runtime.Serialization; + +namespace DangerousD.GameCore.GUI; + +internal class DeathGUI : AbstractGui +{ + protected override void CreateUI() + { + int wigth = AppManager.Instance.Window.ClientBounds.Width; + int height = AppManager.Instance.Window.ClientBounds.Height; + var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" }; + Elements.Add(menuBackground); + menuBackground.LoadTexture(AppManager.Instance.Content); + Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, 120, 50, 50), text = "You death", mainColor = Color.Transparent, scale = 0.5f, fontName = "ButtonFont", fontColor = Color.White }); + Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, 190, 50, 50), text = $"Score = {0}", mainColor = Color.Transparent, scale = 0.5f, fontName = "ButtonFont", fontColor = Color.White }); + var butMenu = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 260, 300, 50), text = "Back to menu", fontName = "ButtonFont" }; + Elements.Add(butMenu); + butMenu.LeftButtonPressed += () => + { + AppManager.Instance.ChangeGameState(GameState.Menu); + }; + } + + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + } +} \ No newline at end of file diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs index f782750..0de943a 100644 --- a/DangerousD/GameCore/GUI/LobbyGUI.cs +++ b/DangerousD/GameCore/GUI/LobbyGUI.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using DangerousD.GameCore.Managers; using MonogameLibrary.UI.Base; using System.Diagnostics; +using System.Xml.Linq; namespace DangerousD.GameCore.GUI { @@ -29,8 +30,11 @@ namespace DangerousD.GameCore.GUI lobbyBackground.LoadTexture(AppManager.Instance.Content); // CheckBoxs - Elements.Add(new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5, - screenWidth / 30 * 26, screenHeight / 15 * 10) }); + var lobby = new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5, + screenWidth / 30 * 26, screenHeight / 15 * 10), textureName = "textboxbackground2" }; + Elements.Add(lobby); + lobby.LoadTexture(AppManager.Instance.Content); + // Buttons { @@ -101,11 +105,13 @@ namespace DangerousD.GameCore.GUI screenWidth / 30 * 10, screenHeight / 30 * 3), text = "ip", scale = 0.16f, - fontColor = Color.Gray, + fontColor = Color.White, fontName = "font2", - textAligment = TextAligment.Left + textAligment = TextAligment.Left, + textureName = "textboxbackground" }; + searchBarTextBox.LoadTexture(AppManager.Instance.Content); searchBarTextBox.TextChanged += input => { if (searchBarTextBox.fontColor == Color.Gray) { diff --git a/DangerousD/GameCore/GUI/LoginGUI.cs b/DangerousD/GameCore/GUI/LoginGUI.cs index a81284f..922775e 100644 --- a/DangerousD/GameCore/GUI/LoginGUI.cs +++ b/DangerousD/GameCore/GUI/LoginGUI.cs @@ -49,8 +49,11 @@ namespace DangerousD.GameCore.GUI scale = 0.16f, fontColor = Color.Gray, fontName = "Font2", - textAligment = TextAligment.Left + textAligment = TextAligment.Left, + textureName = "textboxbackground" + }; + loginTextBox.LoadTexture(AppManager.Instance.Content); loginTextBox.TextChanged += input => { if (loginTextBox.fontColor == Color.Gray) { @@ -72,8 +75,10 @@ namespace DangerousD.GameCore.GUI scale = 0.16f, fontColor = Color.Gray, fontName = "font2", - textAligment = TextAligment.Left + textAligment = TextAligment.Left, + textureName = "textboxbackground" }; + passwordTextBox.LoadTexture(AppManager.Instance.Content); passwordTextBox.TextChanged += input => { if (passwordTextBox.fontColor == Color.Gray) { diff --git a/DangerousD/GameCore/GUI/MenuGUI.cs b/DangerousD/GameCore/GUI/MenuGUI.cs index 91f7523..d0c7998 100644 --- a/DangerousD/GameCore/GUI/MenuGUI.cs +++ b/DangerousD/GameCore/GUI/MenuGUI.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using MonogameLibrary.UI.Base; using MonogameLibrary.UI.Elements; +using System.Collections.Generic; using System.Diagnostics; using System.Runtime.Serialization; @@ -9,10 +10,9 @@ namespace DangerousD.GameCore.GUI; internal class MenuGUI : AbstractGui { + int selected = 0; protected override void CreateUI() { - - int wigth = AppManager.Instance.Window.ClientBounds.Width; int height = AppManager.Instance.Window.ClientBounds.Height; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" }; diff --git a/DangerousD/GameCore/InputManager.cs b/DangerousD/GameCore/InputManager.cs index 83e224f..72d67f8 100644 --- a/DangerousD/GameCore/InputManager.cs +++ b/DangerousD/GameCore/InputManager.cs @@ -10,6 +10,7 @@ using System.Runtime.InteropServices; namespace DangerousD.GameCore { public enum ScopeState { Up, Middle, Down } + public enum ControlsState { Gamepad, Keyboard, Mouse } class InputManager { public delegate void Delegat(); @@ -19,26 +20,32 @@ namespace DangerousD.GameCore Vector2 vectorMovementDirection; ScopeState scopeState; // Положение оружия. Up, Middle, Down. + ControlsState controlsState; private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска private bool isShoot; public Vector2 VectorMovementDirection { get => vectorMovementDirection; } public ScopeState ScopeState { get => scopeState; } + public string currentControlsState = ""; public InputManager() { this.isJumpDown = false; this.isShoot = false; scopeState = ScopeState.Middle; + controlsState= ControlsState.Mouse; vectorMovementDirection = new Vector2(0, 0); } - + public void SetState(ControlsState controlsStates) + { + currentControlsState = controlsStates.ToString(); + } public void Update() { // Работа с GamePad if (GamePad.GetState(0).IsConnected) - { + { // Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика. GamePadState gamePadState = GamePad.GetState(0); vectorMovementDirection = gamePadState.ThumbSticks.Left; @@ -86,6 +93,7 @@ namespace DangerousD.GameCore { isShoot = false; } + SetState(ControlsState.Gamepad); } // Работа с KeyBoard diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index a6dbaac..d156464 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -12,7 +12,7 @@ using MonogameLibrary.UI.Base; namespace DangerousD.GameCore { - public enum GameState { Menu, Options, Lobby, Game, Login } + public enum GameState { Menu, Options, Lobby, Game, Login, Death } public class AppManager : Game { public static AppManager Instance { get; private set; } @@ -25,6 +25,7 @@ namespace DangerousD.GameCore IDrawableObject OptionsGUI; IDrawableObject LoginGUI; IDrawableObject LobbyGUI; + IDrawableObject DeathGUI; public GameManager GameManager { get; private set; } = new GameManager(); public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder(); @@ -40,11 +41,12 @@ namespace DangerousD.GameCore _graphics.PreferredBackBufferWidth = resolution.X; _graphics.PreferredBackBufferHeight = resolution.Y; - _graphics.IsFullScreen = true; + //_graphics.IsFullScreen = true; gameState = GameState.Menu; MenuGUI = new MenuGUI(); LoginGUI = new LoginGUI(); LobbyGUI = new LobbyGUI(); + DeathGUI = new DeathGUI(); UIManager.resolution = resolution; UIManager.resolutionInGame = inGameResolution; } @@ -55,6 +57,7 @@ namespace DangerousD.GameCore MenuGUI.Initialize(GraphicsDevice); LoginGUI.Initialize(GraphicsDevice); LobbyGUI.Initialize(GraphicsDevice); + DeathGUI.Initialize(GraphicsDevice); base.Initialize(); } @@ -64,6 +67,7 @@ namespace DangerousD.GameCore MenuGUI.LoadContent(); LoginGUI.LoadContent(); LobbyGUI.LoadContent(); + DeathGUI.LoadContent(); GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1); GameObject.debugTexture.SetData(new Color[] { new Color(1, 0,0,0.25f) }); renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y); @@ -88,6 +92,9 @@ namespace DangerousD.GameCore case GameState.Lobby: LobbyGUI.Update(gameTime); break; + case GameState.Death: + DeathGUI.Update(gameTime); + break; case GameState.Game: GameManager.Update(gameTime); break; @@ -117,6 +124,9 @@ namespace DangerousD.GameCore case GameState.Lobby: LobbyGUI.Draw(_spriteBatch); break; + case GameState.Death: + DeathGUI.Draw(_spriteBatch); + break; case GameState.Game: _spriteBatch.Begin(SpriteSortMode.Deferred,null,SamplerState.PointClamp); GameManager.Draw(_spriteBatch); diff --git a/MonogameLibrary/UI/Base/UIManager.cs b/MonogameLibrary/UI/Base/UIManager.cs index f8c1178..7f1af91 100644 --- a/MonogameLibrary/UI/Base/UIManager.cs +++ b/MonogameLibrary/UI/Base/UIManager.cs @@ -29,6 +29,7 @@ namespace MonogameLibrary.UI.Base static MouseState mouseState, prevmouseState; static KeyboardState keyboardState; public static Point resolutionInGame, resolution; + public void LoadContent(ContentManager content, string font) { diff --git a/MonogameLibrary/UI/Elements/TextBox.cs b/MonogameLibrary/UI/Elements/TextBox.cs index c5c7b56..3649692 100644 --- a/MonogameLibrary/UI/Elements/TextBox.cs +++ b/MonogameLibrary/UI/Elements/TextBox.cs @@ -93,7 +93,7 @@ namespace MonogameLibrary.UI.Elements _spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211)); else _spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144)); - DrawText(_spriteBatch); + DrawText(_spriteBatch); } }