Merge branch 'main' into livingEntitiesHunchMan
This commit is contained in:
commit
d34f541a7d
46 changed files with 887 additions and 154 deletions
|
@ -62,7 +62,7 @@ namespace AnimationsFileCreator
|
|||
container.TextureFrameInterval = 1;
|
||||
container.Id = id;
|
||||
string json = JsonConvert.SerializeObject(container);
|
||||
StreamWriter writer = new StreamWriter("../../../../DangerousD/Content/animations/"+id);
|
||||
StreamWriter writer = new StreamWriter("../../../../DangerousD/Content/animations/" + id);
|
||||
writer.WriteLine(json);
|
||||
writer.Close();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ with.
|
|||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Handjet-ExtraLight.ttf</FontName>
|
||||
<FontName>RubikWetPaint-Regular.ttf</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
Binary file not shown.
|
@ -13,27 +13,6 @@
|
|||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
||||
#begin File.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:File.spritefont
|
||||
|
||||
#begin Font_25.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_25.spritefont
|
||||
|
||||
#begin Font2.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font2.spritefont
|
||||
|
||||
#begin MonstersAnimations.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -46,6 +25,88 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:MonstersAnimations.png
|
||||
|
||||
#begin deathAnimation.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:deathAnimation.png
|
||||
|
||||
#begin ButtonFont.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:ButtonFont.spritefont
|
||||
|
||||
#begin DoomTestSong.mp3
|
||||
/importer:Mp3Importer
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:DoomTestSong.mp3
|
||||
|
||||
#begin Font_25.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_25.spritefont
|
||||
|
||||
#begin Font_30.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_30.spritefont
|
||||
|
||||
#begin Font2.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font2.spritefont
|
||||
|
||||
#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
|
||||
/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:MenuFon2.jpg
|
||||
|
||||
#begin menuFon3.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:menuFon3.jpg
|
||||
|
||||
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
BIN
DangerousD/Content/DoomTestSong.mp3
Normal file
BIN
DangerousD/Content/DoomTestSong.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
DangerousD/Content/MenuFon2.jpg
Normal file
BIN
DangerousD/Content/MenuFon2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 464 KiB |
BIN
DangerousD/Content/RubikWetPaint-Regular.ttf
Normal file
BIN
DangerousD/Content/RubikWetPaint-Regular.ttf
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
1
DangerousD/Content/animations/DeathFromZombie
Normal file
1
DangerousD/Content/animations/DeathFromZombie
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"DeathFromZombie","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":99,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
|
|
@ -1 +1 @@
|
|||
{"id":"GhostSpawn","textureName":"MonstersAnimations","startSpriteRectangle":{"X":26,"Y":503,"Width":24,"Height":30},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
||||
{"id":"GhostSpawn","textureName":"MonstersAnimations","startSpriteRectangle":{"X":26,"Y":503,"Width":24,"Height":30},"frameSecond":[{"Item1":0,"Item2":20}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
||||
|
|
1
DangerousD/Content/animations/HunchmanDaggerLeft
Normal file
1
DangerousD/Content/animations/HunchmanDaggerLeft
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"HunchmanDaggerLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":224,"Y":129,"Width":9,"Height":6},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/HunchmanDaggerRight
Normal file
1
DangerousD/Content/animations/HunchmanDaggerRight
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"HunchmanDaggerRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":224,"Y":116,"Width":9,"Height":6},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
|
@ -1 +1 @@
|
|||
{"id":"ZombieLeftAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":50,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":25}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"16, 0"}
|
||||
{"id":"ZombieLeftAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":50,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"16, 0"}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"id":"ZombieRightAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":9,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":25}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"16, 0"}
|
||||
{"id":"ZombieRightAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":9,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"16, 0"}
|
||||
|
|
BIN
DangerousD/Content/deathAnimation.png
Normal file
BIN
DangerousD/Content/deathAnimation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
DangerousD/Content/menuFon.jpg
Normal file
BIN
DangerousD/Content/menuFon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 197 KiB |
BIN
DangerousD/Content/menuFon3.jpg
Normal file
BIN
DangerousD/Content/menuFon3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 294 KiB |
|
@ -26,7 +26,7 @@ public abstract class AbstractGui : IDrawableObject
|
|||
|
||||
public virtual void LoadContent()
|
||||
{
|
||||
Manager.LoadContent(AppManager.Instance.Content, "Font");
|
||||
Manager.LoadContent(AppManager.Instance.Content, "Font2");
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
|
|
125
DangerousD/GameCore/GUI/LobbyGUI.cs
Normal file
125
DangerousD/GameCore/GUI/LobbyGUI.cs
Normal file
|
@ -0,0 +1,125 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using MonogameLibrary.UI.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DangerousD.GameCore.Managers;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
class LobbyGUI : AbstractGui
|
||||
{
|
||||
public LobbyGUI()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int screenWidth = AppManager.Instance.inGameResolution.X;
|
||||
int screenHeight = AppManager.Instance.inGameResolution.Y;
|
||||
|
||||
var lobbyBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon3" };
|
||||
Elements.Add(lobbyBackground);
|
||||
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) });
|
||||
|
||||
// Buttons
|
||||
{
|
||||
Button backButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, 60, 50),
|
||||
text = "<-",
|
||||
scale = 0.3f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
};
|
||||
backButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
|
||||
Button hostButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, 120, 50),
|
||||
text = "Host",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
};
|
||||
hostButton.LeftButtonPressed += () => {
|
||||
|
||||
};
|
||||
|
||||
Button refreshButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, 120, 50),
|
||||
text = "Refresh",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
};
|
||||
refreshButton.LeftButtonPressed += () => {
|
||||
|
||||
};
|
||||
|
||||
Button joinSelectedButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, 120, 50),
|
||||
text = "Join",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
};
|
||||
joinSelectedButton.LeftButtonPressed += () => {
|
||||
|
||||
};
|
||||
Button joinByIpButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, 120, 50),
|
||||
text = "JoinByIp",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2"
|
||||
};
|
||||
joinByIpButton.LeftButtonPressed += () => {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
// SearchBar
|
||||
{
|
||||
TextBox searchBarTextBox = new TextBox(Manager) {
|
||||
rectangle = new Rectangle(screenWidth / 30 * 14, screenHeight / 30,
|
||||
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
||||
text = "ip",
|
||||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "font2",
|
||||
textAligment = TextAligment.Left
|
||||
|
||||
};
|
||||
searchBarTextBox.TextChanged += input => {
|
||||
if (searchBarTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
searchBarTextBox.text = ""; searchBarTextBox.fontColor = Color.Black;
|
||||
}
|
||||
};
|
||||
searchBarTextBox.StopChanging += input => {
|
||||
if (input.Length == 0)
|
||||
{
|
||||
searchBarTextBox.fontColor = Color.Gray;
|
||||
searchBarTextBox.text = "ip";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,10 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
using DangerousD.GameCore.Managers;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using System.Diagnostics;
|
||||
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using MonogameLibrary.UI.Enums;
|
||||
|
||||
|
@ -12,10 +16,20 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
class LoginGUI : AbstractGui
|
||||
{
|
||||
private string username;
|
||||
private string password;
|
||||
|
||||
public string Username { get => username; }
|
||||
public string Password { get => password; }
|
||||
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int screenWidth = AppManager.Instance.resolution.X;
|
||||
int screenHeight = AppManager.Instance.resolution.Y;
|
||||
int screenWidth = AppManager.Instance.inGameResolution.X;
|
||||
int screenHeight = AppManager.Instance.inGameResolution.Y;
|
||||
|
||||
var loginBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon2" };
|
||||
Elements.Add(loginBackground);
|
||||
loginBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Elements.Add(new Label(Manager) {
|
||||
rectangle = new Rectangle(screenWidth / 2 - 250, screenHeight / 6 - 50, 500, 100),
|
||||
|
@ -23,7 +37,7 @@ namespace DangerousD.GameCore.GUI
|
|||
scale = 0.8f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Transparent,
|
||||
fontName = "font2"
|
||||
fontName = "ButtonFont"
|
||||
});
|
||||
|
||||
// TextBox-ы
|
||||
|
@ -34,7 +48,7 @@ namespace DangerousD.GameCore.GUI
|
|||
text = "NickName",
|
||||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "font2",
|
||||
fontName = "Font2",
|
||||
textAligment = TextAligment.Left
|
||||
};
|
||||
loginTextBox.TextChanged += input => {
|
||||
|
@ -43,6 +57,13 @@ namespace DangerousD.GameCore.GUI
|
|||
loginTextBox.text = ""; loginTextBox.fontColor = Color.Black;
|
||||
}
|
||||
};
|
||||
loginTextBox.StopChanging += input => {
|
||||
if (input.Length == 0)
|
||||
{
|
||||
loginTextBox.text = "NickName";
|
||||
loginTextBox.fontColor = Color.Gray;
|
||||
}
|
||||
};
|
||||
|
||||
TextBox passwordTextBox = new TextBox(Manager)
|
||||
{
|
||||
|
@ -59,11 +80,18 @@ namespace DangerousD.GameCore.GUI
|
|||
passwordTextBox.text = ""; passwordTextBox.fontColor = Color.Black;
|
||||
}
|
||||
};
|
||||
passwordTextBox.StopChanging += input => {
|
||||
if (input.Length == 0)
|
||||
{
|
||||
passwordTextBox.text = "Password";
|
||||
passwordTextBox.fontColor = Color.Gray;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Кнопки
|
||||
{
|
||||
Button logButton = new Button(Manager) {
|
||||
Button logButton = new ButtonText(Manager) {
|
||||
rectangle = new Rectangle(screenWidth / 4 + 50, screenHeight / 6 * 4, 100, 50),
|
||||
text = "LogIn",
|
||||
scale = 0.2f,
|
||||
|
@ -71,10 +99,13 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "font2"
|
||||
};
|
||||
logButton.LeftButtonPressed += () => {
|
||||
if (CheckUser())
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Lobby);
|
||||
}
|
||||
};
|
||||
|
||||
Button regButton = new Button(Manager)
|
||||
Button regButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 4 * 2 + 50, screenHeight / 6 * 4, 100, 50),
|
||||
text = "Reg",
|
||||
|
@ -84,7 +115,7 @@ namespace DangerousD.GameCore.GUI
|
|||
};
|
||||
regButton.LeftButtonPressed += GoToRegWebServer;
|
||||
|
||||
Button backButton = new Button(Manager)
|
||||
Button backButton = new ButtonText(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, 50, 50),
|
||||
text = "<-",
|
||||
|
@ -102,5 +133,9 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
// TODO
|
||||
}
|
||||
private bool CheckUser()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
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;
|
||||
|
||||
|
@ -8,31 +11,53 @@ internal class MenuGUI : AbstractGui
|
|||
{
|
||||
protected override void CreateUI()
|
||||
{
|
||||
|
||||
|
||||
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
||||
int height = AppManager.Instance.Window.ClientBounds.Height;
|
||||
var butSingle = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 130, 300, 50), text = "Singleplayer", fontName = "File" };
|
||||
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] });
|
||||
|
||||
int dx = 100;
|
||||
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] });
|
||||
|
||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 130, 300, 50), text = "Singleplayer", fontName = "ButtonFont" };
|
||||
Elements.Add(butSingle);
|
||||
butSingle.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
};
|
||||
var butMulti = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 190, 300, 50), text = "Multiplayer", fontName = "File" };
|
||||
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 190, 300, 50), text = "Multiplayer", fontName = "ButtonFont" };
|
||||
Elements.Add(butMulti);
|
||||
butMulti.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Login);
|
||||
};
|
||||
var butOption = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 250, 300, 50), text = "Option", fontName = "File" };
|
||||
var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 250, 300, 50), text = "Option", fontName = "ButtonFont" };
|
||||
Elements.Add(butOption);
|
||||
butOption.LeftButtonPressed += () =>
|
||||
{
|
||||
// открытие настроек
|
||||
};
|
||||
var butExit = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 310, 300, 50), text = "Exit", fontName = "File" };
|
||||
var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 310, 300, 50), text = "Exit", fontName = "ButtonFont" };
|
||||
Elements.Add(butExit);
|
||||
butExit.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.Exit();
|
||||
};
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ namespace DangerousD.GameCore
|
|||
AppManager.Instance.GameManager.Register(this);
|
||||
}
|
||||
|
||||
public virtual void OnCollision()
|
||||
public virtual void OnCollision(GameObject gameObject)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,12 @@ namespace DangerousD.GameCore
|
|||
GraphicsComponent.Update();
|
||||
}
|
||||
|
||||
//static Texture2D debugTexture;
|
||||
public static Texture2D debugTexture;
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
|
||||
//debug
|
||||
//spriteBatch.Draw(debugTexture, Rectangle, Color.White);
|
||||
// spriteBatch.Draw(debugTexture, Rectangle, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,11 +24,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (monster_health <= 0)
|
||||
{
|
||||
Death();
|
||||
isAlive = false;
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
public abstract void Death();
|
||||
|
@ -36,5 +31,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
public abstract void Attack();
|
||||
|
||||
public abstract void Move(GameTime gameTime);
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
monster_health -= damage;
|
||||
if (monster_health <= 0)
|
||||
{
|
||||
Death();
|
||||
isAlive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
acceleration = Vector2.Zero;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new (new List<string> { "BallMoveRight" }, "BallMoveRight");
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
||||
|
||||
public override void Attack()
|
||||
{
|
||||
|
|
|
@ -16,11 +16,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
name = "Ghost";
|
||||
Width = 48;
|
||||
Height = 62;
|
||||
GraphicsComponent.StartAnimation("GhostSpawn");
|
||||
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
|
||||
|
||||
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
using DangerousD.GameCore.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||
{
|
||||
public class HunchmanDagger : CoreEnemy
|
||||
{
|
||||
public HunchmanDagger(Vector2 position) : base(position)
|
||||
{
|
||||
name = "Hunchman";
|
||||
monster_speed = 1;
|
||||
Width = 9;
|
||||
Height = 6;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new (new List<string> { "HunchmanDaggerRight", "HunchmanDaggerLeft" }, "HunchmanDaggerLeft");
|
||||
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Death()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,30 +15,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
private bool isGoRight = true;
|
||||
int leftBorder;
|
||||
int rightBorder;
|
||||
bool isAttaking = false;
|
||||
public Zombie(Vector2 position) : base(position)
|
||||
{
|
||||
Width = 72;
|
||||
Height = 120;
|
||||
monster_speed = 10;
|
||||
GraphicsComponent.StartAnimation("ZombieLeftAttack");
|
||||
monster_speed = 3;
|
||||
name = "Zombie";
|
||||
leftBorder = (int)position.X;
|
||||
rightBorder = (int)position.X + 200;
|
||||
leftBorder = (int)position.X - 60;
|
||||
rightBorder = (int)position.X + 120;
|
||||
}
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.GetPlayer1.Pos.X>Pos.X)
|
||||
isGoRight = true;
|
||||
else
|
||||
isGoRight = false;
|
||||
Move(gameTime);
|
||||
|
||||
if(Pos.X + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.X || Pos.X - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.X)
|
||||
if (!isAttaking)
|
||||
{
|
||||
Attack();
|
||||
AppManager.Instance.GameManager.GetPlayer1.Death(name);
|
||||
Move(gameTime);
|
||||
}
|
||||
|
||||
base.Update(gameTime);
|
||||
|
@ -46,16 +39,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Attack()
|
||||
{
|
||||
velocity.X = 0;
|
||||
isAttaking = true;
|
||||
if (isGoRight)
|
||||
{
|
||||
GraphicsComponent.StopAnimation();
|
||||
GraphicsComponent.StartAnimation("ZombieRightAttack");
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieAttackRight");
|
||||
}
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
else if (!isGoRight)
|
||||
{
|
||||
GraphicsComponent.StopAnimation();
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieLeftAttack")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieLeftAttack");
|
||||
}
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
}
|
||||
|
@ -67,26 +66,45 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
double delta = gameTime.ElapsedGameTime.TotalSeconds;
|
||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if (isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveRight");
|
||||
velocity = new Vector2(monster_speed, 0);
|
||||
}
|
||||
velocity.X = monster_speed;
|
||||
}
|
||||
|
||||
else if (!isGoRight)
|
||||
{
|
||||
if(GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieMoveLeft");
|
||||
velocity = new Vector2(-monster_speed, 0);
|
||||
}
|
||||
velocity.X = -monster_speed;
|
||||
}
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
if(Pos.X >= rightBorder)
|
||||
{
|
||||
monster_health -= damage;
|
||||
//play take damage animation
|
||||
isGoRight = false;
|
||||
}
|
||||
|
||||
else if(Pos.X <= leftBorder)
|
||||
{
|
||||
isGoRight = true;
|
||||
}
|
||||
}
|
||||
public override void OnCollision(GameObject gameObject)
|
||||
{
|
||||
if(gameObject is Player)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.players[0].IsAlive)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
}
|
||||
base.OnCollision(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DangerousD.GameCore.GameObjects;
|
||||
using DangerousD.GameCore.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects.PlayerDeath
|
||||
{
|
||||
public class DeathRectangle : GameObject
|
||||
{
|
||||
public DeathRectangle(Vector2 pos, string DeathType) : base(pos)
|
||||
{
|
||||
Height = 128;
|
||||
Width = 128;
|
||||
PlayDeath(DeathType);
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> {"DeathFromZombie"},
|
||||
"DeathFromZombie");
|
||||
private void PlayDeath(string deathName)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("DeathFromZombie");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -5,18 +5,25 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DangerousD.GameCore.GameObjects.PlayerDeath;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||
{
|
||||
public class Player : LivingEntity
|
||||
{
|
||||
bool isAlive = true;
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
Width = 32;
|
||||
Height = 64;
|
||||
/*GraphicsComponent.actionOfAnimationEnd += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.GameOver);
|
||||
};*/
|
||||
}
|
||||
public bool IsAlive { get { return isAlive; } }
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");//TODO: Change to player
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack", "DeathFromZombie" }, "ZombieMoveLeft");//TODO: Change to player
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
|
@ -25,7 +32,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
|
||||
public void Death(string monsterName)
|
||||
{
|
||||
//анимация по имени монстра
|
||||
if(monsterName == "Zombie")
|
||||
{
|
||||
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
||||
//GraphicsComponent.actionOfAnimationEnd();
|
||||
}
|
||||
isAlive = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public abstract class LivingEntity : Entity
|
|||
public Vector2 acceleration;
|
||||
public LivingEntity(Vector2 position) : base(position)
|
||||
{
|
||||
acceleration = new Vector2(0, 10);
|
||||
acceleration = new Vector2(0, 30);
|
||||
}
|
||||
public void SetPosition(Vector2 position) { targetPosition = position; _pos = position; } //TODO befrend targetpos and physics engine
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ using System.Text;
|
|||
|
||||
namespace DangerousD.GameCore.Graphics
|
||||
{
|
||||
|
||||
public class GraphicsComponent
|
||||
{
|
||||
public Action<string> actionOfAnimationEnd;
|
||||
private List<AnimationContainer> animations;
|
||||
private List<Texture2D> textures;
|
||||
private List<string> texturesNames;
|
||||
|
@ -114,10 +116,16 @@ namespace DangerousD.GameCore.Graphics
|
|||
{
|
||||
if (!currentAnimation.IsCycle)
|
||||
{
|
||||
if(actionOfAnimationEnd != null)
|
||||
{
|
||||
actionOfAnimationEnd(currentAnimation.Id);
|
||||
}
|
||||
currentAnimation = neitralAnimation;
|
||||
|
||||
}
|
||||
|
||||
currentFrame = 0;
|
||||
|
||||
}
|
||||
|
||||
buildSourceRectangle();
|
||||
|
@ -146,6 +154,28 @@ namespace DangerousD.GameCore.Graphics
|
|||
}
|
||||
|
||||
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
}
|
||||
public void DrawAnimation(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||
{
|
||||
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
||||
float scale;
|
||||
if (currentAnimation.Offset.X != 0)
|
||||
{
|
||||
destinationRectangle.X -= (int)currentAnimation.Offset.X;
|
||||
scale = destinationRectangle.Height / sourceRectangle.Height;
|
||||
destinationRectangle.Width = (int)(sourceRectangle.Width * scale);
|
||||
|
||||
}
|
||||
else if (currentAnimation.Offset.Y != 0)
|
||||
{
|
||||
destinationRectangle.Y -= (int)currentAnimation.Offset.Y;
|
||||
scale = destinationRectangle.Width / sourceRectangle.Width;
|
||||
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||
}
|
||||
|
||||
|
||||
_spriteBatch.Draw(texture,
|
||||
destinationRectangle, sourceRectangle, Color.White);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||
namespace DangerousD.GameCore
|
||||
{
|
||||
public enum ScopeState { Up, Middle, Down }
|
||||
class InputManager
|
||||
public class InputManager
|
||||
{
|
||||
public delegate void Delegat();
|
||||
public event Delegat MovEventJump;
|
||||
|
|
|
@ -11,20 +11,18 @@ namespace DangerousD.GameCore.Levels
|
|||
public void InitLevel()
|
||||
{
|
||||
new Player(new Vector2(0,0));
|
||||
/*
|
||||
|
||||
var Zombie = new Zombie(new Vector2(140, 128));
|
||||
var Frank = new Frank(new Vector2(384, 128));
|
||||
var Spider = new Spider(new Vector2(112, 0));
|
||||
var Zombie = new Zombie(new Vector2(256, 0));
|
||||
var Frank = new Frank(new Vector2(384, 0));
|
||||
var FlameSkull = new FlameSkull(new Vector2(512, 0));
|
||||
var Werewolf = new Werewolf(new Vector2(640, 0));
|
||||
var Ghost = new Ghost(new Vector2(730, 0));
|
||||
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
|
||||
*/
|
||||
var HunchMan = new Hunchman(new Vector2(100, 100));
|
||||
|
||||
//Spider down-up
|
||||
|
||||
|
||||
new GrassBlock(new Vector2(0, 224));
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
|
|
|
@ -7,24 +7,33 @@ using System.Text;
|
|||
using DangerousD.GameCore.GUI;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using DangerousD.GameCore.Graphics;
|
||||
using DangerousD.GameCore.Network;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using DangerousD.GameCore.Managers;
|
||||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
public enum GameState { Menu, Options, Lobby, Game, Login }
|
||||
public enum GameState { Menu, Options, Lobby, Game, Login, GameOver }
|
||||
public class AppManager : Game
|
||||
{
|
||||
public static AppManager Instance { get; private set; }
|
||||
private GraphicsDeviceManager _graphics;
|
||||
private SpriteBatch _spriteBatch;
|
||||
public Point resolution;
|
||||
GameState gameState;
|
||||
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;
|
||||
|
||||
public GameManager GameManager { get; private set; }
|
||||
public GameManager GameManager { get; private set; } = new GameManager();
|
||||
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
|
||||
public NetworkManager NetworkManager { get; private set; } = new NetworkManager();
|
||||
public InputManager InputManager { get; private set; } = new InputManager();
|
||||
public SoundManager SoundManager { get; private set; } = new SoundManager();
|
||||
public SettingsManager SettingsManager { get; private set; } = new SettingsManager();
|
||||
public AppManager()
|
||||
{
|
||||
Instance = this;
|
||||
|
@ -33,11 +42,19 @@ namespace DangerousD.GameCore
|
|||
IsMouseVisible = true;
|
||||
TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / 30);
|
||||
|
||||
resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
|
||||
GameManager = new GameManager();
|
||||
SettingsManager = new SettingsManager();
|
||||
SettingsManager.LoadSettings();
|
||||
|
||||
resolution = SettingsManager.Resolution;
|
||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||
// _graphics.IsFullScreen = true;
|
||||
gameState = GameState.Menu;
|
||||
MenuGUI = new MenuGUI();
|
||||
LoginGUI = new LoginGUI();
|
||||
LobbyGUI = new LobbyGUI();
|
||||
UIManager.resolution = resolution;
|
||||
UIManager.resolutionInGame = inGameResolution;
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
|
@ -45,6 +62,7 @@ namespace DangerousD.GameCore
|
|||
AnimationBuilder.LoadAnimations();
|
||||
MenuGUI.Initialize(GraphicsDevice);
|
||||
LoginGUI.Initialize(GraphicsDevice);
|
||||
LobbyGUI.Initialize(GraphicsDevice);
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
|
@ -53,7 +71,12 @@ namespace DangerousD.GameCore
|
|||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
MenuGUI.LoadContent();
|
||||
LoginGUI.LoadContent();
|
||||
//GameObject.te
|
||||
LobbyGUI.LoadContent();
|
||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
||||
SoundManager.LoadSounds();
|
||||
SoundManager.StartAmbientSound("DoomTestSong");
|
||||
renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y);
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
|
@ -61,6 +84,8 @@ namespace DangerousD.GameCore
|
|||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
InputManager.Update();
|
||||
SoundManager.Update();
|
||||
switch (gameState)
|
||||
{
|
||||
case GameState.Menu:
|
||||
|
@ -89,6 +114,7 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
GraphicsDevice.SetRenderTarget(renderTarget);
|
||||
switch (gameState)
|
||||
{
|
||||
case GameState.Menu:
|
||||
|
@ -104,13 +130,18 @@ namespace DangerousD.GameCore
|
|||
LobbyGUI.Draw(_spriteBatch);
|
||||
break;
|
||||
case GameState.Game:
|
||||
_spriteBatch.Begin(SpriteSortMode.Deferred,null,SamplerState.PointClamp);
|
||||
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
|
||||
GameManager.Draw(_spriteBatch);
|
||||
_spriteBatch.End();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GraphicsDevice.SetRenderTarget(null);
|
||||
_spriteBatch.Begin();
|
||||
_spriteBatch.Draw(renderTarget, new Rectangle(0, 0, _graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight), Color.White);
|
||||
_spriteBatch.End();
|
||||
|
||||
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace DangerousD.GameCore
|
|||
public MapManager mapManager;
|
||||
public PhysicsManager physicsManager;
|
||||
public List<Player> players;
|
||||
public List<GameObject> otherObjects = new();
|
||||
public Player GetPlayer1 { get; private set; }
|
||||
public GameManager()
|
||||
{
|
||||
|
@ -33,16 +34,27 @@ namespace DangerousD.GameCore
|
|||
|
||||
internal void Register(GameObject gameObject)
|
||||
{
|
||||
if (gameObject is LivingEntity)
|
||||
livingEntities.Add(gameObject as LivingEntity);
|
||||
if (gameObject is Entity)
|
||||
entities.Add(gameObject as Entity);
|
||||
if (gameObject is MapObject)
|
||||
mapObjects.Add(gameObject as MapObject);
|
||||
if (gameObject is Player)
|
||||
{
|
||||
livingEntities.Add(gameObject as LivingEntity);
|
||||
players.Add(gameObject as Player);
|
||||
GetPlayer1= players[0];
|
||||
GetPlayer1 = players[0];
|
||||
}
|
||||
else if (gameObject is LivingEntity)
|
||||
{
|
||||
livingEntities.Add(gameObject as LivingEntity);
|
||||
}
|
||||
else if (gameObject is Entity)
|
||||
{
|
||||
entities.Add(gameObject as Entity);
|
||||
}
|
||||
else if (gameObject is MapObject)
|
||||
{
|
||||
mapObjects.Add(gameObject as MapObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
otherObjects.Add(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +66,8 @@ namespace DangerousD.GameCore
|
|||
item.Draw(_spriteBatch);
|
||||
foreach (var item in livingEntities)
|
||||
item.Draw(_spriteBatch);
|
||||
foreach (var item in otherObjects)
|
||||
item.Draw(_spriteBatch);
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
|
@ -64,6 +78,8 @@ namespace DangerousD.GameCore
|
|||
item.Update(gameTime);
|
||||
foreach (var item in livingEntities)
|
||||
item.Update(gameTime);
|
||||
foreach (var item in otherObjects)
|
||||
item.Update(gameTime);
|
||||
|
||||
physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, gameTime);
|
||||
|
||||
|
|
|
@ -40,26 +40,35 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
var currentEntity = livingEntities[i];
|
||||
Rectangle oldRect = currentEntity.Rectangle;
|
||||
|
||||
bool isXNormalise = true;
|
||||
bool isYNormalise = true;
|
||||
|
||||
oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
isXNormalise = false;
|
||||
oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (isXNormalise)
|
||||
{
|
||||
oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
isXNormalise = false;
|
||||
oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isXNormalise)
|
||||
currentEntity.velocity.X = 0;
|
||||
|
||||
|
||||
oldRect.Offset(0, (int)currentEntity.velocity.Y/2);
|
||||
|
@ -67,19 +76,26 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
isYNormalise = false;
|
||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isYNormalise)
|
||||
{
|
||||
oldRect.Offset(0, (int)currentEntity.velocity.Y / 2);
|
||||
for (int j = 0; j < mapObjects.Count; j++)
|
||||
{
|
||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||
{
|
||||
isYNormalise = false;
|
||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isYNormalise)
|
||||
currentEntity.velocity.Y = 0;
|
||||
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
||||
}
|
||||
|
||||
|
@ -92,8 +108,8 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
if (livingEntities[j].Rectangle.Intersects(entities[i].Rectangle))
|
||||
{
|
||||
livingEntities[j].OnCollision();
|
||||
entities[i].OnCollision();
|
||||
livingEntities[j].OnCollision(entities[i]);
|
||||
entities[i].OnCollision(livingEntities[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +123,8 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
if (livingEntities[i].Rectangle.Intersects(livingEntities[j].Rectangle))
|
||||
{
|
||||
livingEntities[i].OnCollision();
|
||||
livingEntities[j].OnCollision();
|
||||
livingEntities[i].OnCollision(livingEntities[j]);
|
||||
livingEntities[j].OnCollision(livingEntities[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +144,30 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
rectangle.X = (int)(entity2.Pos.X + (i / length) * distance.X);
|
||||
rectangle.Y = (int)(entity2.Pos.Y + (i / length) * distance.Y);
|
||||
}
|
||||
|
||||
//if (rectangle.Intersects(GameManager.Rectangle))
|
||||
//{
|
||||
// return game
|
||||
//}
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.entities.Count; i++)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.entities[i].Rectangle.Intersects(rectangle))
|
||||
{
|
||||
return AppManager.Instance.GameManager.entities[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.mapObjects.Count; i++)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.mapObjects[i].Rectangle.Intersects(rectangle))
|
||||
{
|
||||
return AppManager.Instance.GameManager.mapObjects[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.livingEntities.Count; i++)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.livingEntities[i].Rectangle.Intersects(rectangle))
|
||||
{
|
||||
return AppManager.Instance.GameManager.livingEntities[i];
|
||||
}
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
@ -140,23 +175,35 @@ namespace DangerousD.GameCore.Managers
|
|||
{
|
||||
Rectangle rectangle;
|
||||
Vector2 direction = entity1.Pos - targetCast;
|
||||
rectangle = new Rectangle((int)entity1.Pos.X, (int)entity1.Pos.Y, 1, 1);
|
||||
GameObject gameObject = null;
|
||||
rectangle = new Rectangle((int)targetCast.X, (int)targetCast.Y, 1, 1);
|
||||
double k = direction.Length();
|
||||
|
||||
for (int i = 0; i < k; i++)
|
||||
{
|
||||
rectangle.X = (int)(entity1.Pos.X + (i / k) * direction.X);
|
||||
rectangle.Y = (int)(entity1.Pos.Y + (i / k) * direction.X);
|
||||
if (gameObject != null)
|
||||
rectangle.X = (int)(targetCast.X + (i / k) * direction.X);
|
||||
rectangle.Y = (int)(targetCast.Y + (i / k) * direction.X);
|
||||
}
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.entities.Count; i++)
|
||||
{
|
||||
break;
|
||||
return gameObject;
|
||||
if (AppManager.Instance.GameManager.entities[i].Rectangle.Intersects(rectangle))
|
||||
{
|
||||
return AppManager.Instance.GameManager.entities[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.mapObjects.Count; i++)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.mapObjects[i].Rectangle.Intersects(rectangle))
|
||||
{
|
||||
return AppManager.Instance.GameManager.mapObjects[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.livingEntities.Count; i++)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.livingEntities[i].Rectangle.Intersects(rectangle))
|
||||
{
|
||||
return AppManager.Instance.GameManager.livingEntities[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,88 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace DangerousD.GameCore.Managers
|
||||
{
|
||||
internal class SettingsManager
|
||||
public class SettingsManager
|
||||
{
|
||||
private SettingsContainer settingsContainer= new SettingsContainer();
|
||||
public bool IsFullScreen { get => settingsContainer.IsFullScreen; }
|
||||
public float MainVolume { get => settingsContainer.MainVolume; }
|
||||
public float MusicVolume { get => settingsContainer.MusicVolume; }
|
||||
public float SoundEffectsVolume { get => settingsContainer.SoundEffectsVolume; }
|
||||
public Point Resolution { get => settingsContainer.Resolution; }
|
||||
public void SetResolution(Point resolution)
|
||||
{
|
||||
settingsContainer.Resolution = resolution;
|
||||
AppManager.Instance.resolution = resolution;
|
||||
}
|
||||
public void SetMainVolume(float volume)
|
||||
{
|
||||
settingsContainer.MainVolume = MainVolume;
|
||||
///AppManager.Instance.SoundManager.
|
||||
|
||||
}
|
||||
public void SetMusicVolume(float volume)
|
||||
{
|
||||
settingsContainer.MusicVolume = MainVolume;
|
||||
|
||||
}
|
||||
public void SetSoundEffectsVolume(float volume)
|
||||
{
|
||||
settingsContainer.SoundEffectsVolume = MainVolume;
|
||||
|
||||
}
|
||||
public void SetIsFullScreen(bool isFullScreen)
|
||||
{
|
||||
settingsContainer.IsFullScreen = isFullScreen;
|
||||
}
|
||||
public void LoadSettings()
|
||||
{
|
||||
if (!File.Exists("GameSettings.txt"))
|
||||
{
|
||||
SaveSettings();
|
||||
return;
|
||||
}
|
||||
|
||||
settingsContainer = JsonConvert.DeserializeObject<SettingsContainer>(File.ReadAllText("GameSettings.txt"));
|
||||
SetIsFullScreen(settingsContainer.IsFullScreen);
|
||||
SetMainVolume(settingsContainer.MainVolume);
|
||||
SetMusicVolume(settingsContainer.MusicVolume);
|
||||
SetResolution(settingsContainer.Resolution);
|
||||
SetSoundEffectsVolume(settingsContainer.SoundEffectsVolume);
|
||||
|
||||
|
||||
}
|
||||
public void SaveSettings()
|
||||
{
|
||||
using (StreamWriter streamWriter = new StreamWriter("GameSettings.txt"))
|
||||
{
|
||||
string _str = JsonConvert.SerializeObject(settingsContainer);
|
||||
streamWriter.Write(_str);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
[Serializable]
|
||||
public class SettingsContainer
|
||||
{
|
||||
[JsonProperty("IsFullScreen")]
|
||||
public bool IsFullScreen { get; set; } = false;
|
||||
[JsonProperty("MainVolume")]
|
||||
public float MainVolume { get; set; } = 1;
|
||||
[JsonProperty("MusicVolume")]
|
||||
public float MusicVolume { get; set; } = 1;
|
||||
[JsonProperty("SoundEffectsVolume")]
|
||||
public float SoundEffectsVolume { get; set; } = 1;
|
||||
[JsonProperty("Resolution")]
|
||||
public Point Resolution { get; set; } = new Point(1920,1080);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ using System.IO;
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using System.Linq;
|
||||
using DangerousD.GameCore.Graphics;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
|
@ -12,19 +15,19 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
public Dictionary<string, SoundEffectInstance> Sounds = new Dictionary<string, SoundEffectInstance>(); // словарь со звуками где строка - название файла
|
||||
public List<Sound> PlayingSounds = new List<Sound>(); // список со всеми звуками, которые проигрываются
|
||||
public string SoundDirectory = "Sounds"; // папка со звуками там где exe
|
||||
public float MaxSoundDistance = 1500; // максимальная дальность звука
|
||||
|
||||
public void LoadSounds(ContentManager content) // метод для загрузки звуков из папки
|
||||
public void LoadSounds() // метод для загрузки звуков из папки
|
||||
{
|
||||
var soundFiles = Directory.GetFiles(SoundDirectory);
|
||||
string[] soundFiles = Directory.GetFiles("../../../Content").Where(x=>x.EndsWith("mp3")).Select(x=>x.Split("\\").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
|
||||
foreach (var soundFile in soundFiles)
|
||||
{
|
||||
Sounds.Add(soundFile, content.Load<SoundEffectInstance>(soundFile));
|
||||
}
|
||||
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(soundFile).CreateInstance());
|
||||
}
|
||||
|
||||
public void StartSound(string soundName) // запустить звук у которого нет позиции
|
||||
}
|
||||
|
||||
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
||||
{
|
||||
var sound = new Sound(Sounds[soundName]);
|
||||
sound.SoundEffect.IsLooped = false;
|
||||
|
@ -39,7 +42,7 @@ namespace DangerousD.GameCore
|
|||
sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance;
|
||||
sound.SoundEffect.Play();
|
||||
PlayingSounds.Add(sound);
|
||||
}//GameManager.SendSound
|
||||
}
|
||||
public void StopAllSounds() // остановка всех звуков
|
||||
{
|
||||
foreach (var sound in PlayingSounds)
|
||||
|
@ -47,14 +50,21 @@ namespace DangerousD.GameCore
|
|||
PlayingSounds.Clear();
|
||||
}
|
||||
|
||||
public void Update(Vector2 playerPos) // апдейт, тут происходит изменение громкости
|
||||
|
||||
public void Update() // апдейт, тут происходит изменение громкости
|
||||
{
|
||||
foreach (var sound in PlayingSounds)
|
||||
|
||||
|
||||
var player = AppManager.Instance.GameManager.GetPlayer1;
|
||||
if (player != null)
|
||||
{
|
||||
if (!sound.isAmbient)
|
||||
sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance;
|
||||
if (sound.SoundEffect.State == SoundState.Stopped)
|
||||
PlayingSounds.Remove(sound);
|
||||
for (int i = 0; i < PlayingSounds.Count; i++)
|
||||
{
|
||||
if (!PlayingSounds[i].isAmbient)
|
||||
PlayingSounds[i].SoundEffect.Volume = (float)PlayingSounds[i].GetDistance(player.Pos) / MaxSoundDistance;
|
||||
if (PlayingSounds[i].SoundEffect.State == SoundState.Stopped)
|
||||
PlayingSounds.Remove(PlayingSounds[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ using System.Text;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DangerousD.GameCore.Network
|
||||
{
|
||||
public class NetworkManagerTest
|
||||
public class NetworkManager
|
||||
{
|
||||
public delegate void ReceivingHandler(string jsonMessage);
|
||||
public delegate void ReceivingHandler(NetworkTask networkTask);
|
||||
|
||||
public event ReceivingHandler GetReceivingMessages;
|
||||
|
||||
|
@ -68,9 +69,9 @@ namespace DangerousD.GameCore.Network
|
|||
Thread ReceivingThread = new Thread(ReceiveMsgFromHost);
|
||||
ReceivingThread.Start();
|
||||
}
|
||||
public void SendMsg(string jsonMessage)
|
||||
public void SendMsg(NetworkTask networkTask)
|
||||
{
|
||||
byte[] Data = Encoding.Unicode.GetBytes(jsonMessage);
|
||||
byte[] Data = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(networkTask));
|
||||
int count = Data.Length;
|
||||
if (state == "Host")
|
||||
{
|
||||
|
@ -111,7 +112,7 @@ namespace DangerousD.GameCore.Network
|
|||
}
|
||||
else
|
||||
{
|
||||
GetReceivingMessages(so.sb.ToString());
|
||||
GetReceivingMessages(JsonConvert.DeserializeObject<NetworkTask>(so.sb.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
106
DangerousD/GameCore/Network/NetworkTask.cs
Normal file
106
DangerousD/GameCore/Network/NetworkTask.cs
Normal file
|
@ -0,0 +1,106 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DangerousD.GameCore.Network
|
||||
{
|
||||
[Serializable]
|
||||
public class NetworkTask
|
||||
{
|
||||
public NetworkTaskOperationEnum operation { get; set; }
|
||||
public string name { get; set; }
|
||||
public int value { get; set; }
|
||||
public int objId { get; set; }
|
||||
public Vector2 position { get; set; }
|
||||
public Vector2 velocity { get; set; }
|
||||
public Type type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Нанести урон сущности
|
||||
/// </summary>
|
||||
/// <param name="LivingEntityId"></param>
|
||||
/// <param name="Damage"></param>
|
||||
public NetworkTask(int LivingEntityId, int Damage)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.TakeDamage;
|
||||
objId = LivingEntityId;
|
||||
value = Damage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проиграть звук на позиции
|
||||
/// </summary>
|
||||
/// <param name="SoundPosition"></param>
|
||||
/// <param name="SoundName"></param>
|
||||
public NetworkTask(Vector2 SoundPosition, string SoundName)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.SendSound;
|
||||
position = SoundPosition;
|
||||
name = SoundName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать сущность на позиции с заданной скоростью и присвоить её родительской сущности
|
||||
/// </summary>
|
||||
/// <param name="EntityType"></param>
|
||||
/// <param name="EntityPosition"></param>
|
||||
/// <param name="EntityVelocity"></param>
|
||||
/// <param name="ParentId"></param>
|
||||
public NetworkTask(Type EntityType, Vector2 EntityPosition, Vector2 EntityVelocity, int ParentId)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.CreateEntity;
|
||||
type = EntityType;
|
||||
position = EntityPosition;
|
||||
velocity = EntityVelocity;
|
||||
objId = ParentId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменить позицию сущности со сложной логикой(игрок)
|
||||
/// </summary>
|
||||
/// <param name="EntityId"></param>
|
||||
/// <param name="EntityPosition"></param>
|
||||
public NetworkTask(int EntityId, Vector2 EntityPosition)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.SendPosition;
|
||||
objId = EntityId;
|
||||
position = EntityPosition;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменяет состояние и/или скорость сущности
|
||||
/// </summary>
|
||||
/// <param name="EntityId"></param>
|
||||
/// <param name="StateName"></param>
|
||||
/// <param name="EntityVelocity"></param>
|
||||
public NetworkTask(int EntityId, string StateName, Vector2 EntityVelocity)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.ChangeState;
|
||||
objId = EntityId;
|
||||
name = StateName;
|
||||
velocity = EntityVelocity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Подключается к хосту и передаёт своё имя
|
||||
/// </summary>
|
||||
/// <param name="PlayerName"></param>
|
||||
public NetworkTask(string PlayerName)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.ConnectToHost;
|
||||
name = PlayerName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получает id игрока на клиенте от хоста
|
||||
/// </summary>
|
||||
/// <param name="PlayerId"></param>
|
||||
public NetworkTask(int PlayerId)
|
||||
{
|
||||
operation = NetworkTaskOperationEnum.GetClientPlayerId;
|
||||
objId = PlayerId;
|
||||
}
|
||||
}
|
||||
}
|
14
DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs
Normal file
14
DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DangerousD.GameCore.Network
|
||||
{
|
||||
[Serializable]
|
||||
public enum NetworkTaskOperationEnum
|
||||
{
|
||||
TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace MonogameLibrary.UI.Base
|
|||
protected Texture2D texture;
|
||||
protected int layerIndex;
|
||||
protected UIManager Manager;
|
||||
protected string textureName;
|
||||
public string textureName;
|
||||
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
||||
public Color mainColor = Color.White;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace MonogameLibrary.UI.Base
|
|||
public KeyboardState GetKeyboardState { get { return keyboardState; } }
|
||||
static MouseState mouseState, prevmouseState;
|
||||
static KeyboardState keyboardState;
|
||||
public static Point resolutionInGame, resolution;
|
||||
|
||||
public void LoadContent(ContentManager content, string font)
|
||||
{
|
||||
|
@ -53,6 +54,8 @@ namespace MonogameLibrary.UI.Base
|
|||
{
|
||||
keyboardState = Keyboard.GetState();
|
||||
mouseState = Mouse.GetState();
|
||||
mouseState = new MouseState((int)(mouseState.X*(float)resolutionInGame.X/resolution.X),
|
||||
(int)(mouseState.Y * (float)resolutionInGame.Y / resolution.Y), mouseState.ScrollWheelValue, mouseState.LeftButton, mouseState.MiddleButton, mouseState.RightButton, mouseState.XButton1, mouseState.XButton2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace MonogameLibrary.UI.Elements
|
|||
{
|
||||
}
|
||||
|
||||
public bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||
{
|
||||
|
@ -61,11 +61,19 @@ namespace MonogameLibrary.UI.Elements
|
|||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
{
|
||||
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||
}
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(211,211,211));
|
||||
{
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144));
|
||||
}
|
||||
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
|
|
37
MonogameLibrary/UI/Elements/ButtonText.cs
Normal file
37
MonogameLibrary/UI/Elements/ButtonText.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Enums;
|
||||
using MonogameLibrary.UI.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static MonogameLibrary.UI.Elements.Button;
|
||||
|
||||
namespace MonogameLibrary.UI.Elements
|
||||
{
|
||||
public class ButtonText : Button
|
||||
{
|
||||
public ButtonText(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||
{
|
||||
}
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
{
|
||||
fontColor = Color.White;
|
||||
}
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
fontColor = new Color(211, 211, 211);
|
||||
}
|
||||
else
|
||||
{
|
||||
fontColor = new Color(112, 128, 144);
|
||||
}
|
||||
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue