HUD
This commit is contained in:
parent
b37fbaf4ea
commit
488a0074f4
8 changed files with 145 additions and 31 deletions
|
@ -187,6 +187,13 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
/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
|
#begin playerAnimation.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
|
64
DangerousD/Content/PixelFont.spritefont
Normal file
64
DangerousD/Content/PixelFont.spritefont
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
This file contains an xml description of a font, and will be read by the XNA
|
||||||
|
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||||
|
of the font in your game, and to change the characters which are available to draw
|
||||||
|
with.
|
||||||
|
-->
|
||||||
|
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||||
|
<Asset Type="Graphics:FontDescription">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Modify this string to change the font that will be imported.
|
||||||
|
-->
|
||||||
|
<FontName>PublicPixel-z84yD.ttf</FontName>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Size is a float value, measured in points. Modify this value to change
|
||||||
|
the size of the font.
|
||||||
|
-->
|
||||||
|
<Size>12</Size>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Spacing is a float value, measured in pixels. Modify this value to change
|
||||||
|
the amount of spacing in between characters.
|
||||||
|
-->
|
||||||
|
<Spacing>0</Spacing>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||||
|
will be used when placing characters.
|
||||||
|
-->
|
||||||
|
<UseKerning>true</UseKerning>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||||
|
and "Bold, Italic", and are case sensitive.
|
||||||
|
-->
|
||||||
|
<Style>Regular</Style>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you uncomment this line, the default character will be substituted if you draw
|
||||||
|
or measure text that contains characters which were not included in the font.
|
||||||
|
-->
|
||||||
|
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
CharacterRegions control what letters are available in the font. Every
|
||||||
|
character from Start to End will be built and made available for drawing. The
|
||||||
|
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||||
|
character set. The characters are ordered according to the Unicode standard.
|
||||||
|
See the documentation for more information.
|
||||||
|
-->
|
||||||
|
<CharacterRegions>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start> </Start>
|
||||||
|
<End>~</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start>а</Start>
|
||||||
|
<End>я</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
</CharacterRegions>
|
||||||
|
</Asset>
|
||||||
|
</XnaContent>
|
BIN
DangerousD/Content/PublicPixel-z84yD.ttf
Normal file
BIN
DangerousD/Content/PublicPixel-z84yD.ttf
Normal file
Binary file not shown.
|
@ -17,8 +17,8 @@ internal class DeathGUI : AbstractGui
|
||||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" };
|
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" };
|
||||||
Elements.Add(menuBackground);
|
Elements.Add(menuBackground);
|
||||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
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 - 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 });
|
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" };
|
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);
|
Elements.Add(butMenu);
|
||||||
butMenu.LeftButtonPressed += () =>
|
butMenu.LeftButtonPressed += () =>
|
||||||
|
|
|
@ -6,36 +6,73 @@ using System.Xml.Linq;
|
||||||
using DangerousD.GameCore.Managers;
|
using DangerousD.GameCore.Managers;
|
||||||
using DangerousD.GameCore;
|
using DangerousD.GameCore;
|
||||||
using System.Collections.Generic;
|
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
|
namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
public class HUD : AbstractGui
|
public class HUD : IDrawableObject
|
||||||
{
|
{
|
||||||
int ammout = 0;
|
public int ammout = 8;
|
||||||
List<Rect> rects = new List<Rect> { };
|
|
||||||
int wigth = AppManager.Instance.inGameResolution.X;
|
int wigth = AppManager.Instance.inGameResolution.X;
|
||||||
int height = AppManager.Instance.inGameResolution.Y;
|
int height = AppManager.Instance.inGameResolution.Y;
|
||||||
protected override void CreateUI()
|
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||||
{
|
Texture2D texture;
|
||||||
DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
|
SpriteFont spriteFont;
|
||||||
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 void Draw(SpriteBatch spriteBatch)
|
||||||
public override void Update(GameTime gameTime)
|
|
||||||
{
|
{
|
||||||
|
spriteBatch.Begin();
|
||||||
rects.Clear();
|
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++)
|
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 });
|
spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13, height / 17 + 4, 5, 20), Color.Yellow);
|
||||||
rects[i].LoadTexture(AppManager.Instance.Content);
|
|
||||||
}
|
}
|
||||||
base.Update(gameTime);
|
spriteBatch.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadContent()
|
||||||
|
{
|
||||||
|
texture = new Texture2D(AppManager.Instance.GraphicsDevice, 1, 1);
|
||||||
|
texture.SetData<Color>(new Color[] { Color.White });
|
||||||
|
spriteFont = AppManager.Instance.Content.Load<SpriteFont>("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);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ internal class MenuGUI : AbstractGui
|
||||||
{
|
{
|
||||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||||
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
|
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" };
|
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" };
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace DangerousD.GameCore.GUI
|
||||||
int height = AppManager.Instance.inGameHUDHelperResolution.Y;
|
int height = AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||||
float scaler = AppManager.Instance.resolution.Y / (float)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" };
|
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);
|
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
var slider = new Slider(Manager)
|
var slider = new Slider(Manager)
|
||||||
|
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GUI
|
||||||
indentation = 5,
|
indentation = 5,
|
||||||
textureName = "sliderBackground"
|
textureName = "sliderBackground"
|
||||||
};
|
};
|
||||||
Elements.Add(slider);
|
//Elements.Add(slider);
|
||||||
//AppManager.Instance.SettingsManager.SetMainVolume(slider.GetSliderValue);
|
//AppManager.Instance.SettingsManager.SetMainVolume(slider.GetSliderValue);
|
||||||
|
|
||||||
var cB = new CheckBox(Manager);
|
var cB = new CheckBox(Manager);
|
||||||
|
@ -84,6 +84,14 @@ namespace DangerousD.GameCore.GUI
|
||||||
(item as DrawableTextedUiElement).scale *= scaler;
|
(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)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ using DangerousD.GameCore.GameObjects;
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
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
|
GameOver
|
||||||
}
|
}
|
||||||
public class AppManager : Game
|
public class AppManager : Game
|
||||||
|
@ -35,8 +35,9 @@ namespace DangerousD.GameCore
|
||||||
IDrawableObject LoginGUI;
|
IDrawableObject LoginGUI;
|
||||||
IDrawableObject LobbyGUI;
|
IDrawableObject LobbyGUI;
|
||||||
IDrawableObject DeathGUI;
|
IDrawableObject DeathGUI;
|
||||||
IDrawableObject HUD;
|
//IDrawableObject HUD;
|
||||||
public DebugHUD DebugHUD;
|
public DebugHUD DebugHUD;
|
||||||
|
public HUD HUD;
|
||||||
public List<NetworkTask> NetworkTasks = new List<NetworkTask>();
|
public List<NetworkTask> NetworkTasks = new List<NetworkTask>();
|
||||||
|
|
||||||
public GameManager GameManager { get; private set; } = new();
|
public GameManager GameManager { get; private set; } = new();
|
||||||
|
@ -130,9 +131,6 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Death:
|
case GameState.Death:
|
||||||
DeathGUI.Update(gameTime);
|
DeathGUI.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
case GameState.HUD:
|
|
||||||
HUD.Update(gameTime);
|
|
||||||
break;
|
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
GameManager.Update(gameTime);
|
GameManager.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
|
@ -140,6 +138,7 @@ namespace DangerousD.GameCore
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DebugHUD.Update(gameTime);
|
DebugHUD.Update(gameTime);
|
||||||
|
HUD.Update(gameTime);
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
@ -166,9 +165,6 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Death:
|
case GameState.Death:
|
||||||
DeathGUI.Draw(_spriteBatch);
|
DeathGUI.Draw(_spriteBatch);
|
||||||
break;
|
break;
|
||||||
case GameState.HUD:
|
|
||||||
HUD.Draw(_spriteBatch);
|
|
||||||
break;
|
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
|
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
|
||||||
GameManager.Draw(_spriteBatch);
|
GameManager.Draw(_spriteBatch);
|
||||||
|
@ -184,6 +180,7 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
|
|
||||||
DebugHUD.Draw(_spriteBatch);
|
DebugHUD.Draw(_spriteBatch);
|
||||||
|
HUD.Draw(_spriteBatch);
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue