diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb
index 37d9842..0b61b7a 100644
--- a/DangerousD/Content/Content.mgcb
+++ b/DangerousD/Content/Content.mgcb
@@ -187,6 +187,13 @@
/processorParam:TextureFormat=Color
/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
+#begin PixelFont.spritefont
+/importer:FontDescriptionImporter
+/processor:FontDescriptionProcessor
+/processorParam:PremultiplyAlpha=True
+/processorParam:TextureFormat=Compressed
+/build:PixelFont.spritefont
+
#begin playerAnimation.png
/importer:TextureImporter
/processor:TextureProcessor
diff --git a/DangerousD/Content/PixelFont.spritefont b/DangerousD/Content/PixelFont.spritefont
new file mode 100644
index 0000000..2ee98cd
--- /dev/null
+++ b/DangerousD/Content/PixelFont.spritefont
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+ PublicPixel-z84yD.ttf
+
+
+ 12
+
+
+ 0
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+ ~
+
+
+ а
+ я
+
+
+
+
diff --git a/DangerousD/Content/PublicPixel-z84yD.ttf b/DangerousD/Content/PublicPixel-z84yD.ttf
new file mode 100644
index 0000000..618e5bb
Binary files /dev/null and b/DangerousD/Content/PublicPixel-z84yD.ttf differ
diff --git a/DangerousD/GameCore/GUI/DeathGUI.cs b/DangerousD/GameCore/GUI/DeathGUI.cs
index c19f9b5..bb91470 100644
--- a/DangerousD/GameCore/GUI/DeathGUI.cs
+++ b/DangerousD/GameCore/GUI/DeathGUI.cs
@@ -17,8 +17,8 @@ internal class DeathGUI : AbstractGui
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, (height - 50) / 2 - 80, 50, 50), text = "You death", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
- Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2, 50, 50), text = $"Score = {0}", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
+ Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2 - 80, 50, 50), text = "You died", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
+ Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2, 50, 50), text = $"Score: {0}", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
var butMenu = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, (height - 50) / 2 + 80, 300, 50), text = "Back to menu", scale = 0.7f, fontName = "ButtonFont" };
Elements.Add(butMenu);
butMenu.LeftButtonPressed += () =>
diff --git a/DangerousD/GameCore/GUI/HUD.cs b/DangerousD/GameCore/GUI/HUD.cs
index 07e446a..a9507de 100644
--- a/DangerousD/GameCore/GUI/HUD.cs
+++ b/DangerousD/GameCore/GUI/HUD.cs
@@ -6,36 +6,73 @@ using System.Xml.Linq;
using DangerousD.GameCore.Managers;
using DangerousD.GameCore;
using System.Collections.Generic;
+using Microsoft.Xna.Framework.Graphics;
+using static System.Formats.Asn1.AsnWriter;
+using static System.Net.Mime.MediaTypeNames;
namespace DangerousD.GameCore.GUI
{
- public class HUD : AbstractGui
+ public class HUD : IDrawableObject
{
- int ammout = 0;
- List rects = new List { };
+ public int ammout = 8;
int wigth = AppManager.Instance.inGameResolution.X;
int height = AppManager.Instance.inGameResolution.Y;
- protected override void CreateUI()
- {
- DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
- Elements.Add(background);
- Rect rect = new Rect(Manager) { rectangle = new Rectangle(wigth / 35, height / 35, 120, 70), mainColor = Color.DarkRed };
- Elements.Add(rect);
- Label label = new Label(Manager) { rectangle = new Rectangle(wigth / 34, height / 30, 120, 20), text = "ammout", fontName = "font2", scale = 0.2f, mainColor = Color.Transparent, fontColor = Color.Black };
- Elements.Add(label);
+ float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
+ Texture2D texture;
+ SpriteFont spriteFont;
- }
- public override void Update(GameTime gameTime)
+ public void Draw(SpriteBatch spriteBatch)
{
-
- rects.Clear();
+ spriteBatch.Begin();
+ spriteBatch.Draw(texture, new Rectangle(wigth / 35 - 2, height / 35 - 2, 120 + 2, 70 + 2), Color.DarkRed);
+ spriteBatch.DrawString(spriteFont, "AMMO", new Vector2(wigth / 34 + 4, height / 30 - 6), Color.Gray, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0);
+ spriteBatch.DrawString(spriteFont, "AMMO", new Vector2(wigth / 34 + 1, height / 30 - 6), Color.White, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0);
for (int i = 0; i < ammout; i++)
{
- rects.Add(new Rect(Manager) { rectangle = new Rectangle(wigth / 29 + i * 13, height / 17, 5, 20), mainColor = Color.Yellow });
- rects[i].LoadTexture(AppManager.Instance.Content);
+ spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13, height / 17 + 4, 5, 20), Color.Yellow);
}
- base.Update(gameTime);
+ spriteBatch.End();
+ }
+
+ public void Initialize()
+ {
+ }
+
+ public void LoadContent()
+ {
+ texture = new Texture2D(AppManager.Instance.GraphicsDevice, 1, 1);
+ texture.SetData(new Color[] { Color.White });
+ spriteFont = AppManager.Instance.Content.Load("PixelFont");
+ }
+
+ public void Update(GameTime gameTime)
+ {
}
}
+ //public class HUD1 : AbstractGui
+ //{
+ //
+ // protected override void CreateUI()
+ // {
+ // DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
+ // Elements.Add(background);
+ // Rect rect = new Rect(Manager) { rectangle = new Rectangle(wigth / 35, height / 35, 120, 70), mainColor = Color.DarkRed };
+ // Elements.Add(rect);
+ // Label label = new Label(Manager) { rectangle = new Rectangle(wigth / 34, height / 30, 120, 20), text = "ammout", fontName = "font2", scale = 0.2f, mainColor = Color.Transparent, fontColor = Color.Black };
+ // Elements.Add(label);
+
+ // }
+ // public override void Update(GameTime gameTime)
+ // {
+ //
+ // rects.Clear();
+ // for (int i = 0; i < ammout; i++)
+ // {
+ // rects.Add(new Rect(Manager) { rectangle = new Rectangle(wigth / 29 + i * 13, height / 17, 5, 20), mainColor = Color.Yellow });
+ // rects[i].LoadTexture(AppManager.Instance.Content);
+ // }
+ // base.Update(gameTime);
+ // }
+ //}
}
diff --git a/DangerousD/GameCore/GUI/MenuGUI.cs b/DangerousD/GameCore/GUI/MenuGUI.cs
index d6e376e..5f23b10 100644
--- a/DangerousD/GameCore/GUI/MenuGUI.cs
+++ b/DangerousD/GameCore/GUI/MenuGUI.cs
@@ -38,6 +38,7 @@ internal class MenuGUI : AbstractGui
{
AppManager.Instance.ChangeGameState(GameState.Game);
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
+
};
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 470, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Multiplayer", scale = 1.2f, fontName = "ButtonFont" };
@@ -45,7 +46,7 @@ internal class MenuGUI : AbstractGui
Elements.Add(butMulti);
butMulti.LeftButtonPressed += () =>
{
- AppManager.Instance.ChangeGameState(GameState.Login);
+ AppManager.Instance.ChangeGameState(GameState.Login);
};
var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(160 * 2.4)) / 2, 590, (int)(160 * 2.4), (int)(50 * 2.4)), text = "Option", scale = 1.2f, fontName = "ButtonFont" };
Elements.Add(butOption);
diff --git a/DangerousD/GameCore/GUI/OptionsGUI.cs b/DangerousD/GameCore/GUI/OptionsGUI.cs
index c879731..18ccd77 100644
--- a/DangerousD/GameCore/GUI/OptionsGUI.cs
+++ b/DangerousD/GameCore/GUI/OptionsGUI.cs
@@ -17,7 +17,7 @@ namespace DangerousD.GameCore.GUI
int height = AppManager.Instance.inGameHUDHelperResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" };
- Elements.Add(menuBackground);
+ //Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content);
var slider = new Slider(Manager)
@@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GUI
indentation = 5,
textureName = "sliderBackground"
};
- Elements.Add(slider);
+ //Elements.Add(slider);
//AppManager.Instance.SettingsManager.SetMainVolume(slider.GetSliderValue);
var cB = new CheckBox(Manager);
@@ -84,6 +84,14 @@ namespace DangerousD.GameCore.GUI
(item as DrawableTextedUiElement).scale *= scaler;
}
}
+ slider.rectangle.X = (int)(scaler * slider.rectangle.X);
+ slider.rectangle.Y = (int)(scaler * slider.rectangle.Y);
+ //slider.rectangle.Width = (int)(scaler * slider.rectangle.Width);
+ //slider.rectangle.Height = (int)(scaler * slider.rectangle.Height);
+ if (slider is DrawableTextedUiElement)
+ {
+ (slider as DrawableTextedUiElement).scale *= scaler;
+ }
}
public override void Update(GameTime gameTime)
{
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index b4b3872..6a6d9a5 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -16,7 +16,7 @@ using DangerousD.GameCore.GameObjects;
namespace DangerousD.GameCore
{
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
- public enum GameState { Menu, Options, Lobby, Game, Login, Death, HUD,
+ public enum GameState { Menu, Options, Lobby, Game, Login, Death,
GameOver
}
public class AppManager : Game
@@ -35,8 +35,9 @@ namespace DangerousD.GameCore
IDrawableObject LoginGUI;
IDrawableObject LobbyGUI;
IDrawableObject DeathGUI;
- IDrawableObject HUD;
+ //IDrawableObject HUD;
public DebugHUD DebugHUD;
+ public HUD HUD;
public List NetworkTasks = new List();
public GameManager GameManager { get; private set; } = new();
@@ -130,9 +131,6 @@ namespace DangerousD.GameCore
case GameState.Death:
DeathGUI.Update(gameTime);
break;
- case GameState.HUD:
- HUD.Update(gameTime);
- break;
case GameState.Game:
GameManager.Update(gameTime);
break;
@@ -140,6 +138,7 @@ namespace DangerousD.GameCore
break;
}
DebugHUD.Update(gameTime);
+ HUD.Update(gameTime);
base.Update(gameTime);
}
@@ -166,9 +165,6 @@ namespace DangerousD.GameCore
case GameState.Death:
DeathGUI.Draw(_spriteBatch);
break;
- case GameState.HUD:
- HUD.Draw(_spriteBatch);
- break;
case GameState.Game:
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
GameManager.Draw(_spriteBatch);
@@ -184,6 +180,7 @@ namespace DangerousD.GameCore
DebugHUD.Draw(_spriteBatch);
+ HUD.Draw(_spriteBatch);
base.Draw(gameTime);
}