Merge branch 'main' into livingEntities
|
@ -14,12 +14,41 @@
|
|||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
||||
#begin ButtonFont.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
#begin MonstersAnimations.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:ButtonFont.spritefont
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:checkboxs_off-on.png
|
||||
|
||||
#begin checkboxs_off.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:checkboxs_off.png
|
||||
|
||||
#begin checkboxs_on.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:checkboxs_on.png
|
||||
|
||||
#begin deathAnimation.png
|
||||
/importer:TextureImporter
|
||||
|
@ -33,12 +62,31 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:deathAnimation.png
|
||||
|
||||
#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 DoomTestSong.mp3
|
||||
/importer:Mp3Importer
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:DoomTestSong.mp3
|
||||
|
||||
#begin Font_12.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_12.spritefont
|
||||
|
||||
#begin Font_25.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
|
@ -72,19 +120,6 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:menuFon.jpg
|
||||
|
||||
#begin MonstersAnimations.png
|
||||
#begin menuFon.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:menuFon.jpg
|
||||
|
||||
#begin MenuFon2.jpg
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -121,6 +156,114 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:MonstersAnimations.png
|
||||
|
||||
#begin optionsBackground.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:optionsBackground.jpg
|
||||
|
||||
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.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:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||
|
||||
#begin slider.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:slider.png
|
||||
|
||||
#begin sliderBackground.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:sliderBackground.png
|
||||
|
||||
#begin textboxbackground1-1.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:textboxbackground1-1.png
|
||||
|
||||
#begin textboxbackground2-1.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-1.png
|
||||
|
||||
#begin textboxbackground2,5-1.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,5-1.png
|
||||
|
||||
#begin textboxbackground6-1.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:textboxbackground6-1.png
|
||||
|
||||
#begin MonstersAnimations.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:MonstersAnimations.png
|
||||
|
||||
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
64
DangerousD/Content/Font_12.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>Arial</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/checkboxs_off-on.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
DangerousD/Content/checkboxs_off.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
DangerousD/Content/checkboxs_on.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
DangerousD/Content/deathBackground.jpg
Normal file
After Width: | Height: | Size: 396 KiB |
|
@ -752,7 +752,7 @@
|
|||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="10" name="Player" class="LivingEntities.Player">
|
||||
<object id="47" x="-260" y="461.333">
|
||||
<object id="47" x="-525" y="461.333">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
|
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 7.5 MiB |
BIN
DangerousD/Content/optionsBackground.jpg
Normal file
After Width: | Height: | Size: 252 KiB |
BIN
DangerousD/Content/slider.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
DangerousD/Content/sliderBackground.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
DangerousD/Content/textboxbackground1-1.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
DangerousD/Content/textboxbackground2,5-1.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
DangerousD/Content/textboxbackground2-1.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
DangerousD/Content/textboxbackground6-1.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
33
DangerousD/GameCore/GUI/DeathGUI.cs
Normal file
|
@ -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.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
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 });
|
||||
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 += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
50
DangerousD/GameCore/GUI/DebugHUD.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using static System.String;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
public class DebugHUD : IDrawableObject
|
||||
{
|
||||
private SpriteFont _spriteFont;
|
||||
private Dictionary<string, string> _text = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Font_12");
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()),
|
||||
new Vector2(10, 10),
|
||||
Color.Cyan,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
1,
|
||||
SpriteEffects.None,
|
||||
0
|
||||
);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public void Set(string key, string value)
|
||||
{
|
||||
_text[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
43
DangerousD/GameCore/GUI/HUD.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
public class HUD : IDrawableObject
|
||||
{
|
||||
|
||||
|
||||
public HUD()
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
public void Initialize(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
var content = AppManager.Instance.Content;
|
||||
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ using DangerousD.GameCore.Managers;
|
|||
using MonogameLibrary.UI.Base;
|
||||
using System.Diagnostics;
|
||||
using DangerousD.GameCore.Network;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
|
@ -30,8 +31,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,5-1" };
|
||||
Elements.Add(lobby);
|
||||
lobby.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
|
||||
// Buttons and ip textbox
|
||||
{
|
||||
|
@ -41,9 +45,10 @@ namespace DangerousD.GameCore.GUI
|
|||
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
||||
text = "ip",
|
||||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2",
|
||||
textAligment = TextAligment.Left
|
||||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground6-1"
|
||||
|
||||
};
|
||||
searchBarTextBox.TextChanged += input => {
|
||||
|
@ -59,25 +64,27 @@ namespace DangerousD.GameCore.GUI
|
|||
searchBarTextBox.text = "ip";
|
||||
}
|
||||
};
|
||||
Button backButton = new ButtonText(Manager)
|
||||
Button backButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, 60, 50),
|
||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, (int)(40 * 2.4), (int)(40 * 2.4)),
|
||||
text = "<-",
|
||||
scale = 0.3f,
|
||||
scale = 0.72f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
fontName = "font2",
|
||||
textureName = "textboxbackground1-1"
|
||||
};
|
||||
backButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
|
||||
Button hostButton = new ButtonText(Manager)
|
||||
Button hostButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, 120, 50),
|
||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||
text = "Host",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
scale = 0.48f,
|
||||
fontColor = Color.DarkBlue,
|
||||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
hostButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
|
@ -85,37 +92,40 @@ namespace DangerousD.GameCore.GUI
|
|||
|
||||
};
|
||||
|
||||
Button refreshButton = new ButtonText(Manager)
|
||||
Button refreshButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, 120, 50),
|
||||
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||
text = "Refresh",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
scale = 0.48f,
|
||||
fontColor = Color.DarkBlue,
|
||||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
refreshButton.LeftButtonPressed += () => {
|
||||
|
||||
};
|
||||
|
||||
Button joinSelectedButton = new ButtonText(Manager)
|
||||
Button joinSelectedButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, 120, 50),
|
||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||
text = "Join",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
scale = 0.48f,
|
||||
fontColor = Color.DarkBlue,
|
||||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
joinSelectedButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
AppManager.Instance.NetworkManager.ClientInit(AppManager.Instance.IpAddress);
|
||||
};
|
||||
Button joinByIpButton = new ButtonText(Manager)
|
||||
Button joinByIpButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, 120, 50),
|
||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||
text = "JoinByIp",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
scale = 0.48f,
|
||||
fontColor = Color.DarkBlue,
|
||||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
joinByIpButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.NetworkManager.ClientInit(searchBarTextBox.text);
|
||||
|
|
|
@ -32,9 +32,9 @@ namespace DangerousD.GameCore.GUI
|
|||
loginBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Elements.Add(new Label(Manager) {
|
||||
rectangle = new Rectangle(screenWidth / 2 - 250, screenHeight / 6 - 50, 500, 100),
|
||||
rectangle = new Rectangle(screenWidth / 2 - (int)(250 * 2.4), screenHeight / 6 - 100, (int)(500 * 2.4), (int)(100 * 2.4)),
|
||||
text = "Login",
|
||||
scale = 0.8f,
|
||||
scale = 1.7f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Transparent,
|
||||
fontName = "ButtonFont"
|
||||
|
@ -44,13 +44,16 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
TextBox loginTextBox = new TextBox(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 2 - 125, screenHeight / 6 * 2 - 20, 250, 40),
|
||||
rectangle = new Rectangle(screenWidth / 2 - (int)(125 * 2.4), screenHeight / 6 * 2 - 20, (int)(250 * 2.4), (int)(40 * 2.4)),
|
||||
text = "NickName",
|
||||
scale = 0.16f,
|
||||
scale = 0.33f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "Font2",
|
||||
textAligment = TextAligment.Left
|
||||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground6-1"
|
||||
|
||||
};
|
||||
loginTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
loginTextBox.TextChanged += input => {
|
||||
if (loginTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
|
@ -67,13 +70,15 @@ namespace DangerousD.GameCore.GUI
|
|||
|
||||
TextBox passwordTextBox = new TextBox(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 2 - 125, screenHeight / 6 * 3 - 40, 250, 40),
|
||||
rectangle = new Rectangle(screenWidth / 2 - (int)(125 * 2.4), screenHeight / 6 * 3 - 40, (int)(250 * 2.4), (int)(40 * 2.4)),
|
||||
text = "Password",
|
||||
scale = 0.16f,
|
||||
scale = 0.33f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "font2",
|
||||
textAligment = TextAligment.Left
|
||||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground6-1"
|
||||
};
|
||||
passwordTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
passwordTextBox.TextChanged += input => {
|
||||
if (passwordTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
|
@ -91,12 +96,13 @@ namespace DangerousD.GameCore.GUI
|
|||
|
||||
// Кнопки
|
||||
{
|
||||
Button logButton = new ButtonText(Manager) {
|
||||
rectangle = new Rectangle(screenWidth / 4 + 50, screenHeight / 6 * 4, 100, 50),
|
||||
Button logButton = new Button(Manager) {
|
||||
rectangle = new Rectangle(screenWidth / 4 + (int)(50 * 2.4), screenHeight / 6 * 3 + 100, (int)(100 * 2.4), (int)(50 * 2.4)),
|
||||
text = "LogIn",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
scale = 0.6f,
|
||||
fontColor = Color.White,
|
||||
fontName = "ButtonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
logButton.LeftButtonPressed += () => {
|
||||
if (CheckUser())
|
||||
|
@ -105,23 +111,25 @@ namespace DangerousD.GameCore.GUI
|
|||
}
|
||||
};
|
||||
|
||||
Button regButton = new ButtonText(Manager)
|
||||
Button regButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 4 * 2 + 50, screenHeight / 6 * 4, 100, 50),
|
||||
rectangle = new Rectangle(screenWidth / 4 * 2 + (int)(50 * 2.4), screenHeight / 6 * 3 + 100, (int)(100 * 2.4), (int)(50 * 2.4)),
|
||||
text = "Reg",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
scale = 0.6f,
|
||||
fontColor = Color.White,
|
||||
fontName = "ButtonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
regButton.LeftButtonPressed += GoToRegWebServer;
|
||||
|
||||
Button backButton = new ButtonText(Manager)
|
||||
Button backButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, 50, 50),
|
||||
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)),
|
||||
text = "<-",
|
||||
scale = 0.3f,
|
||||
scale = 0.72f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
fontName = "font2",
|
||||
textureName = "textboxbackground1-1"
|
||||
};
|
||||
backButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
|
|
|
@ -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,47 +10,50 @@ namespace DangerousD.GameCore.GUI;
|
|||
|
||||
internal class MenuGUI : AbstractGui
|
||||
{
|
||||
int selected = 0;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
|
||||
|
||||
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" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
int TopMenu = 0;
|
||||
|
||||
Color[] colors = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 60, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1-0.05f*i*i/10, fontName = "Font2", fontColor = colors[i] });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 200, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1.35f - 0.05f * i * i / 10, fontName = "Font2", fontColor = colors[i] });
|
||||
|
||||
int dx = 100;
|
||||
int dx = 50;
|
||||
Color[] colors2 = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||
for (int i = 0; i < colors2.Length; i++)
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 250 + dx-i*i, 90 - i * i/5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 1.3f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors2[i] });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 480 + dx - i * i, 260 - i * i / 5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 2.15f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors2[i] });
|
||||
|
||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 130, 300, 50), text = "Singleplayer", fontName = "ButtonFont" };
|
||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 350, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Singleplayer", scale = 1.2f, fontName = "ButtonFont" };
|
||||
Elements.Add(butSingle);
|
||||
butSingle.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
|
||||
};
|
||||
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 190, 300, 50), text = "Multiplayer", 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" };
|
||||
|
||||
Elements.Add(butMulti);
|
||||
butMulti.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Login);
|
||||
};
|
||||
var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 250, 300, 50), text = "Option", fontName = "ButtonFont" };
|
||||
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);
|
||||
butOption.LeftButtonPressed += () =>
|
||||
{
|
||||
// открытие настроек
|
||||
AppManager.Instance.ChangeGameState(GameState.Options);
|
||||
};
|
||||
var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 310, 300, 50), text = "Exit", fontName = "ButtonFont" };
|
||||
var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(110 * 2.4)) / 2, 710, (int)(110 * 2.4), (int)(50 * 2.4)), text = "Exit", scale = 1.2f, fontName = "ButtonFont" };
|
||||
Elements.Add(butExit);
|
||||
butExit.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
75
DangerousD/GameCore/GUI/OptionsGUI.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using System.Xml.Linq;
|
||||
using DangerousD.GameCore.Managers;
|
||||
using DangerousD.GameCore;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
public class OptionsGUI : AbstractGui
|
||||
{
|
||||
int selectedGUI = 0;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
var slider = new Slider(Manager)
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 1,
|
||||
rectangle = new Rectangle(wigth / 2 + 220, 275, (int)(100 * 2.4), 40),
|
||||
indentation = 5,
|
||||
textureName = "sliderBackground"
|
||||
};
|
||||
|
||||
var cB = new CheckBox(Manager);
|
||||
cB.rectangle = new Rectangle(wigth / 2 + 440, 405, (int)(40 * 2.4), (int)(40 * 2.4));
|
||||
cB.Checked += (newCheckState) =>
|
||||
{
|
||||
SettingsManager sM = new SettingsManager();
|
||||
};
|
||||
cB.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
var checkBox = new CheckBox(Manager);
|
||||
checkBox.rectangle = new Rectangle(wigth / 2 + 360, 540, (int)(40 * 2.4), (int)(40 * 2.4));
|
||||
checkBox.Checked += (newCheckState) =>
|
||||
{
|
||||
SettingsManager sM = new SettingsManager();
|
||||
};
|
||||
checkBox.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Label lblOptions = new Label(Manager)
|
||||
{ fontName = "buttonFont", scale = 1.2f, text = "Options", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 40, 50, 50), mainColor = Color.Transparent };
|
||||
Elements.Add(lblOptions);
|
||||
|
||||
Label lblValue = new Label(Manager)
|
||||
{ fontName = "buttonFont", scale = 1f, text = "Volume", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 250, 50, 50), mainColor = Color.Transparent };
|
||||
Elements.Add(lblValue);
|
||||
|
||||
Label lblIsFullScreen = new Label(Manager)
|
||||
{ fontName = "buttonFont", scale = 1f, text = "Full Screen", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 580, 50, 50), mainColor = Color.Transparent };
|
||||
Elements.Add(lblOptions);
|
||||
|
||||
Label lblSwitchMode = new Label(Manager)
|
||||
{ fontName = "buttonFont", scale = 1f, text = "Left/Right Mode", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 415, 50, 50), mainColor = Color.Transparent };
|
||||
Elements.Add(lblSwitchMode);
|
||||
|
||||
Button bTExit = new Button(Manager)
|
||||
{ fontName = "Font2", scale = 0.72f, text = "<-", rectangle = new Rectangle(wigth / 30, height / 30, (int)(40 * 2.4), (int)(40 * 2.4)), textureName = "textboxbackground1-1" };
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,8 +17,6 @@ namespace DangerousD.GameCore
|
|||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
|
||||
public Vector2 velocity;
|
||||
public Vector2 acceleration;
|
||||
protected abstract GraphicsComponent GraphicsComponent { get; }
|
||||
public GameObject(Vector2 pos)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
interface IDrawableObject
|
||||
public interface IDrawableObject
|
||||
{
|
||||
void Initialize();
|
||||
void LoadContent();
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
Width = 32;
|
||||
Height = 64;
|
||||
Width = 16;
|
||||
Height = 32;
|
||||
|
||||
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||
|
||||
|
@ -85,8 +85,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
public void Jump()
|
||||
{
|
||||
velocity.Y = -30;
|
||||
isJump = true;
|
||||
if (isOnGround)
|
||||
{
|
||||
velocity.Y = -11;
|
||||
}
|
||||
// здесь будет анимация
|
||||
}
|
||||
public void Shoot()
|
||||
|
@ -97,42 +99,39 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
||||
velocity.X = 0.5f;
|
||||
if (velocity.Y == 0)
|
||||
{
|
||||
isJump = false;
|
||||
}
|
||||
Move(gameTime);
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public void Move(GameTime gameTime)
|
||||
{
|
||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (Keyboard.GetState().IsKeyDown(Keys.D))
|
||||
velocity.X = 5 * AppManager.Instance.InputManager.VectorMovementDirection.X;
|
||||
if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")
|
||||
if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")//идёт направо
|
||||
{
|
||||
GraphicsComponent.StartAnimation("playerMoveRight");
|
||||
}
|
||||
velocity.X = 10;
|
||||
}
|
||||
else if (Keyboard.GetState().IsKeyDown(Keys.A))
|
||||
else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "playerMoveLeft")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("playerMoveLeft");
|
||||
}
|
||||
velocity.X = -10;
|
||||
}
|
||||
if (Keyboard.GetState().IsKeyDown(Keys.Space) && !isJump)
|
||||
else if(AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
|
||||
{
|
||||
Jump();
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveLeft");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void MoveDown()
|
||||
{
|
||||
|
||||
// ПОЧЕМУ
|
||||
velocity.Y = -11;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace DangerousD.GameCore.GameObjects;
|
|||
|
||||
public abstract class LivingEntity : Entity
|
||||
{
|
||||
private Vector2 targetPosition;
|
||||
public bool isOnGround = true;
|
||||
public Vector2 velocity;
|
||||
public Vector2 acceleration;
|
||||
public LivingEntity(Vector2 position) : base(position)
|
||||
|
@ -13,7 +13,7 @@ public abstract class LivingEntity : Entity
|
|||
}
|
||||
public override void SetPosition(Vector2 position)
|
||||
{
|
||||
targetPosition = position; _pos = position;
|
||||
_pos = position;
|
||||
|
||||
} //TODO befrend targetpos and physics engine
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
|
|||
namespace DangerousD.GameCore
|
||||
{
|
||||
public enum ScopeState { Up, Middle, Down }
|
||||
public enum ControlsState { Gamepad, Keyboard, Mouse }
|
||||
public class InputManager
|
||||
{
|
||||
public delegate void Delegat();
|
||||
|
@ -19,21 +20,27 @@ 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
|
||||
|
@ -86,6 +93,7 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
isShoot = false;
|
||||
}
|
||||
SetState(ControlsState.Gamepad);
|
||||
}
|
||||
|
||||
// Работа с KeyBoard
|
||||
|
|
|
@ -13,8 +13,10 @@ using DangerousD.GameCore.Managers;
|
|||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
public enum GameState { Menu, Options, Lobby, Game, Login, GameOver }
|
||||
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
||||
public enum GameState { Menu, Options, Lobby, Game, Login, Death,
|
||||
GameOver
|
||||
}
|
||||
public class AppManager : Game
|
||||
{
|
||||
public static AppManager Instance { get; private set; }
|
||||
|
@ -23,13 +25,14 @@ namespace DangerousD.GameCore
|
|||
private SpriteBatch _spriteBatch;
|
||||
public GameState gameState { get; private set; }
|
||||
public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer;
|
||||
public Point resolution = new Point(1920, 1080);
|
||||
public Point inGameResolution = new Point(1366, 768);
|
||||
IDrawableObject MenuGUI;
|
||||
IDrawableObject OptionsGUI;
|
||||
IDrawableObject LoginGUI;
|
||||
IDrawableObject LobbyGUI;
|
||||
public Point resolution = new Point(1920, 1080);
|
||||
public Point inGameResolution = new Point(800, 480);
|
||||
private RenderTarget2D renderTarget;
|
||||
IDrawableObject DeathGUI;
|
||||
public DebugHUD DebugHUD;
|
||||
|
||||
public GameManager GameManager { get; private set; } = new();
|
||||
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
|
||||
|
@ -37,6 +40,8 @@ namespace DangerousD.GameCore
|
|||
public InputManager InputManager { get; private set; } = new InputManager();
|
||||
public SoundManager SoundManager { get; private set; } = new SoundManager();
|
||||
public SettingsManager SettingsManager { get; private set; } = new SettingsManager();
|
||||
|
||||
private RenderTarget2D renderTarget;
|
||||
public AppManager()
|
||||
{
|
||||
Content.RootDirectory = "Content";
|
||||
|
@ -53,11 +58,14 @@ namespace DangerousD.GameCore
|
|||
resolution = SettingsManager.Resolution;
|
||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||
// _graphics.IsFullScreen = true;
|
||||
_graphics.IsFullScreen = true;
|
||||
gameState = GameState.Menu;
|
||||
MenuGUI = new MenuGUI();
|
||||
LoginGUI = new LoginGUI();
|
||||
OptionsGUI = new OptionsGUI();
|
||||
LobbyGUI = new LobbyGUI();
|
||||
DeathGUI = new DeathGUI();
|
||||
DebugHUD = new DebugHUD();
|
||||
UIManager.resolution = resolution;
|
||||
UIManager.resolutionInGame = inGameResolution;
|
||||
}
|
||||
|
@ -67,16 +75,24 @@ namespace DangerousD.GameCore
|
|||
AnimationBuilder.LoadAnimations();
|
||||
MenuGUI.Initialize();
|
||||
LoginGUI.Initialize();
|
||||
|
||||
DebugHUD.Initialize();
|
||||
OptionsGUI.Initialize();
|
||||
|
||||
LobbyGUI.Initialize();
|
||||
DeathGUI.Initialize();
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
protected override void LoadContent()
|
||||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
DebugHUD.LoadContent();
|
||||
MenuGUI.LoadContent();
|
||||
LoginGUI.LoadContent();
|
||||
OptionsGUI.LoadContent();
|
||||
LobbyGUI.LoadContent();
|
||||
DeathGUI.LoadContent();
|
||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
||||
SoundManager.LoadSounds();
|
||||
|
@ -91,6 +107,7 @@ namespace DangerousD.GameCore
|
|||
|
||||
InputManager.Update();
|
||||
SoundManager.Update();
|
||||
|
||||
switch (gameState)
|
||||
{
|
||||
case GameState.Menu:
|
||||
|
@ -105,12 +122,16 @@ namespace DangerousD.GameCore
|
|||
case GameState.Lobby:
|
||||
LobbyGUI.Update(gameTime);
|
||||
break;
|
||||
case GameState.Death:
|
||||
DeathGUI.Update(gameTime);
|
||||
break;
|
||||
case GameState.Game:
|
||||
GameManager.Update(gameTime);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DebugHUD.Update(gameTime);
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
@ -134,6 +155,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);
|
||||
|
@ -148,6 +172,7 @@ namespace DangerousD.GameCore
|
|||
_spriteBatch.End();
|
||||
|
||||
|
||||
DebugHUD.Draw(_spriteBatch);
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
|
||||
|
@ -167,7 +192,7 @@ namespace DangerousD.GameCore
|
|||
case GameState.Game:
|
||||
GameManager.mapManager.LoadLevel("lvl");
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
case GameState.Death:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DangerousD.GameCore.Managers
|
||||
|
@ -20,9 +21,9 @@ namespace DangerousD.GameCore.Managers
|
|||
item.velocity = item.velocity + item.acceleration * delta;
|
||||
}
|
||||
|
||||
CheckCollisions(livingEntities, mapObjects);
|
||||
OnCollision(entities, livingEntities);
|
||||
OnCollision(livingEntities);
|
||||
CheckCollisionsLE_MO(livingEntities, mapObjects);
|
||||
CheckCollisionsE_LE(entities, livingEntities);
|
||||
CheckCollisionsLE_LE(livingEntities);
|
||||
|
||||
//entities dont move
|
||||
//Living entities dont move
|
||||
|
@ -33,68 +34,88 @@ namespace DangerousD.GameCore.Managers
|
|||
//OnCollision
|
||||
|
||||
}
|
||||
public void CheckCollisions(List<LivingEntity> livingEntities,
|
||||
private void CheckCollisionsLE_MO(List<LivingEntity> livingEntities,
|
||||
List<MapObject> mapObjects)
|
||||
{
|
||||
LivingEntity currentEntity;
|
||||
Rectangle oldRect;
|
||||
for (int i = 0; i < livingEntities.Count; i++)
|
||||
foreach (var currentEntity in livingEntities)
|
||||
{
|
||||
currentEntity = livingEntities[i];
|
||||
oldRect = currentEntity.Rectangle;
|
||||
bool isXNormalise = true;
|
||||
bool isYNormalise = true;
|
||||
var currentRect = currentEntity.Rectangle;
|
||||
var newRect = currentRect;
|
||||
|
||||
oldRect.Offset((int)currentEntity.velocity.X, 0);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
#region x collision
|
||||
var collidedX = false;
|
||||
var tryingRectX = currentRect;
|
||||
tryingRectX.Offset((int)Math.Ceiling(currentEntity.velocity.X), 0);
|
||||
foreach (var mapObject in mapObjects)
|
||||
{
|
||||
if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 550)
|
||||
if (
|
||||
Math.Abs(mapObject.Pos.X - currentEntity.Pos.X) < 550
|
||||
&& Math.Abs(mapObject.Pos.Y - currentEntity.Pos.Y) < 550
|
||||
&& tryingRectX.Intersects(mapObject.Rectangle)
|
||||
)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
isXNormalise = false;
|
||||
oldRect.Offset(-(int)currentEntity.velocity.X, 0);
|
||||
collidedX = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isXNormalise)
|
||||
if (collidedX)
|
||||
{
|
||||
currentEntity.velocity.X = 0;
|
||||
|
||||
|
||||
oldRect.Offset(0, (int)currentEntity.velocity.Y);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
}
|
||||
else
|
||||
{
|
||||
newRect.X = tryingRectX.X;
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
#region y collision
|
||||
var collidedY = false;
|
||||
var tryingRectY = currentRect;
|
||||
tryingRectY.Offset(0, (int)Math.Ceiling(currentEntity.velocity.Y));
|
||||
if (currentEntity is Player)
|
||||
{
|
||||
isYNormalise = false;
|
||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y);
|
||||
AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString());
|
||||
AppManager.Instance.DebugHUD.Set("intersects y", "");
|
||||
}
|
||||
foreach (var mapObject in mapObjects)
|
||||
{
|
||||
if (tryingRectY.Intersects(mapObject.Rectangle))
|
||||
{
|
||||
if (currentEntity is Player) AppManager.Instance.DebugHUD.Set("intersects y", mapObject.GetType().ToString());
|
||||
collidedY = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isYNormalise)
|
||||
currentEntity.isOnGround = collidedY && currentEntity.velocity.Y > 0;
|
||||
if (collidedY)
|
||||
{
|
||||
currentEntity.velocity.Y = 0;
|
||||
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
newRect.Y = tryingRectY.Y;
|
||||
}
|
||||
#endregion
|
||||
|
||||
currentEntity.SetPosition(new Vector2(newRect.X, newRect.Y));
|
||||
}
|
||||
|
||||
}
|
||||
public void OnCollision(List<Entity> entities, List<LivingEntity> livingEntities)
|
||||
private void CheckCollisionsE_LE(List<Entity> entities, List<LivingEntity> livingEntities)
|
||||
{
|
||||
for (int i = 0; i < entities.Count; i++)
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
for (int j = 0; j < livingEntities.Count; j++)
|
||||
foreach (var livingEntity in livingEntities)
|
||||
{
|
||||
if (livingEntities[j].Rectangle.Intersects(entities[i].Rectangle))
|
||||
if (livingEntity.Rectangle.Intersects(entity.Rectangle))
|
||||
{
|
||||
livingEntities[j].OnCollision(entities[i]);
|
||||
entities[i].OnCollision(livingEntities[j]);
|
||||
livingEntity.OnCollision(entity);
|
||||
entity.OnCollision(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void OnCollision(List<LivingEntity> livingEntities)
|
||||
private void CheckCollisionsLE_LE(List<LivingEntity> livingEntities)
|
||||
{
|
||||
for (int i = 0; i < livingEntities.Count; i++)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace DangerousD.GameCore
|
|||
|
||||
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
||||
{
|
||||
return;
|
||||
var sound = new Sound(Sounds[soundName]);
|
||||
sound.SoundEffect.IsLooped = false;
|
||||
sound.SoundEffect.Play();
|
||||
|
|
|
@ -11,11 +11,13 @@ using static System.Net.Mime.MediaTypeNames;
|
|||
|
||||
namespace MonogameLibrary.UI.Base
|
||||
{
|
||||
public enum InputState { GamePad, Keyboard, Mouse }
|
||||
public class UIManager
|
||||
{
|
||||
Dictionary<int, List<DrawableUIElement>> layerCollection = new();
|
||||
public GraphicsDevice GraphicsDevice { get; private set; }
|
||||
public SpriteFont BaseFont { get; private set; }
|
||||
public InputState inputState = InputState.Mouse;
|
||||
public void Initialize(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
GraphicsDevice = graphicsDevice;
|
||||
|
@ -30,6 +32,7 @@ namespace MonogameLibrary.UI.Base
|
|||
static KeyboardState keyboardState;
|
||||
public static Point resolutionInGame, resolution;
|
||||
|
||||
|
||||
public void LoadContent(ContentManager content, string font)
|
||||
{
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace MonogameLibrary.UI.Elements
|
|||
|
||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
//if (Manager.)
|
||||
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||
{
|
||||
if (mouseState.LeftButton == ButtonState.Pressed || mouseState.RightButton == ButtonState.Pressed)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
|
@ -15,6 +16,9 @@ namespace MonogameLibrary.UI.Elements
|
|||
public CheckBox(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||
{
|
||||
}
|
||||
private Texture2D texture1;
|
||||
private Texture2D texture2;
|
||||
private Texture2D texture3;
|
||||
public delegate void OnCheck(bool checkState);
|
||||
public event OnCheck? Checked;
|
||||
private bool isChecked;
|
||||
|
@ -42,25 +46,33 @@ namespace MonogameLibrary.UI.Elements
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void LoadTexture(ContentManager content)
|
||||
{
|
||||
texture1 = content.Load<Texture2D>("checkboxs_off");
|
||||
texture2 = content.Load<Texture2D>("checkboxs_off-on");
|
||||
texture3 = content.Load<Texture2D>("checkboxs_on");
|
||||
base.LoadTexture(content);
|
||||
}
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (isChecked)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(124, 255, 0));
|
||||
_spriteBatch.Draw(texture3, rectangle, Color.White);
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(124, 215, 0));
|
||||
_spriteBatch.Draw(texture3, rectangle, Color.White);
|
||||
else
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(124, 175, 0));
|
||||
_spriteBatch.Draw(texture2, rectangle, Color.White );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(255, 20, 0));
|
||||
_spriteBatch.Draw(texture1, rectangle, Color.White);
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(215, 20, 0));
|
||||
_spriteBatch.Draw(texture2, rectangle, Color.White);
|
||||
else
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(175, 20, 0));
|
||||
_spriteBatch.Draw(texture2, rectangle, Color.White);
|
||||
}
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
|
@ -17,7 +18,9 @@ namespace MonogameLibrary.UI.Elements
|
|||
}
|
||||
public delegate void OnSliderChanges(float value);
|
||||
public event OnSliderChanges? SliderChanged;
|
||||
public int indentation = 5;
|
||||
|
||||
Texture2D texture2;
|
||||
public Rectangle sliderRect = new Rectangle(0, 0, 30, 30);
|
||||
private float sliderValue = 0;
|
||||
private float minValue = 0, maxValue = 1;
|
||||
|
@ -50,6 +53,13 @@ namespace MonogameLibrary.UI.Elements
|
|||
sliderState = SliderState.None;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void LoadTexture(ContentManager content)
|
||||
{
|
||||
texture2 = content.Load<Texture2D>("slider");
|
||||
base.LoadTexture(content);
|
||||
}
|
||||
|
||||
public void SetValue(float setvalue)
|
||||
{
|
||||
sliderValue = setvalue;
|
||||
|
@ -60,14 +70,14 @@ namespace MonogameLibrary.UI.Elements
|
|||
{
|
||||
base.Draw(_spriteBatch);
|
||||
sliderRect.Location = rectangle.Location;
|
||||
sliderRect.X += (int)(sliderValue * (rectangle.Width - sliderRect.Width));
|
||||
sliderRect.X += (int)(sliderValue * (rectangle.Width - sliderRect.Width - indentation * 2) + indentation);
|
||||
sliderRect.Y -= sliderRect.Height / 2 - rectangle.Height / 2;
|
||||
if (sliderState == SliderState.Moving)
|
||||
_spriteBatch.Draw(texture, sliderRect, Color.DarkRed);
|
||||
_spriteBatch.Draw(texture2, sliderRect, Color.DarkRed);
|
||||
else if(sliderState == SliderState.HoveringOverSliderButton)
|
||||
_spriteBatch.Draw(texture, sliderRect, new Color(200,0,0));
|
||||
_spriteBatch.Draw(texture2, sliderRect, new Color(200,0 ,0));
|
||||
else
|
||||
_spriteBatch.Draw(texture, sliderRect, Color.Red);
|
||||
_spriteBatch.Draw(texture2, sliderRect, Color.Red);
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
|
|