RepairMain
This commit is contained in:
commit
d25af5a0ca
25 changed files with 646 additions and 113 deletions
|
@ -200,6 +200,13 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||
|
||||
#begin PixelFont.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:PixelFont.spritefont
|
||||
|
||||
#begin playerAnimation.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
64
DangerousD/Content/PixelFont.spritefont
Normal file
64
DangerousD/Content/PixelFont.spritefont
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>PublicPixel-z84yD.ttf</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>12</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
<CharacterRegion>
|
||||
<Start>а</Start>
|
||||
<End>я</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
BIN
DangerousD/Content/PublicPixel-z84yD.ttf
Normal file
BIN
DangerousD/Content/PublicPixel-z84yD.ttf
Normal file
Binary file not shown.
1
DangerousD/Content/animations/playerShootUpLeft
Normal file
1
DangerousD/Content/animations/playerShootUpLeft
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"playerShootUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/playerShootUpRight
Normal file
1
DangerousD/Content/animations/playerShootUpRight
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"playerShootUpRight","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
|
@ -1,8 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
|
||||
namespace DangerousD.GameCore.GUI;
|
||||
|
||||
|
@ -10,6 +16,10 @@ public abstract class AbstractGui : IDrawableObject
|
|||
{
|
||||
protected UIManager Manager = new();
|
||||
protected List<DrawableUIElement> Elements = new();
|
||||
private List<DrawableUIElement> ActiveElements;
|
||||
protected DrawableUIElement SelectedElement;
|
||||
private bool isStartedPrint = false;
|
||||
private bool isPressed = false;
|
||||
|
||||
public AbstractGui()
|
||||
{
|
||||
|
@ -21,6 +31,16 @@ public abstract class AbstractGui : IDrawableObject
|
|||
{
|
||||
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||
CreateUI();
|
||||
ActiveElements = new List<DrawableUIElement>();
|
||||
foreach (var element in Elements)
|
||||
{
|
||||
if (CheckOnBadElements(element))
|
||||
{
|
||||
ActiveElements.Add(element);
|
||||
}
|
||||
}
|
||||
if (ActiveElements.Count > 0) { SelectedElement = ActiveElements.First(); }
|
||||
|
||||
}
|
||||
|
||||
public virtual void LoadContent()
|
||||
|
@ -30,11 +50,163 @@ public abstract class AbstractGui : IDrawableObject
|
|||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
string state = AppManager.Instance.InputManager.currentControlsState;
|
||||
|
||||
|
||||
|
||||
if (ActiveElements.Count != 0)
|
||||
{
|
||||
if (state == "Gamepad")
|
||||
{
|
||||
GamePadState gamePadState = GamePad.GetState(0);
|
||||
GamepadInput(gamePadState);
|
||||
}
|
||||
else if (state == "Keyboard" || state == "Mouse")
|
||||
{
|
||||
KeyboardState keyBoardState = Keyboard.GetState();
|
||||
KeyBoardInput(keyBoardState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Manager.Update(gameTime);
|
||||
|
||||
if (SelectedElement is not null)
|
||||
{
|
||||
if (SelectedElement is Button)
|
||||
{
|
||||
(SelectedElement as Button).hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering;
|
||||
}
|
||||
if (SelectedElement is ButtonText)
|
||||
{
|
||||
(SelectedElement as ButtonText).hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering;
|
||||
}
|
||||
if (SelectedElement is TextBox)
|
||||
{
|
||||
TextBox box = (TextBox)SelectedElement;
|
||||
box.hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering;
|
||||
if (isStartedPrint)
|
||||
{
|
||||
box.SelectIt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Manager.Draw(spriteBatch);
|
||||
}
|
||||
protected virtual void GamepadInput(GamePadState gamePadState)
|
||||
{
|
||||
if (gamePadState.DPad.Up == ButtonState.Pressed && !isPressed)
|
||||
{
|
||||
isPressed = true;
|
||||
ChangeSelectedElement(-1);
|
||||
Debug.WriteLine("switch");
|
||||
}
|
||||
else if (gamePadState.DPad.Down == ButtonState.Pressed && !isPressed)
|
||||
{
|
||||
isPressed = true;
|
||||
ChangeSelectedElement(1);
|
||||
}
|
||||
else if (gamePadState.Buttons.A == ButtonState.Pressed && !isPressed)
|
||||
{
|
||||
isPressed = true;
|
||||
if (SelectedElement is Button)
|
||||
{
|
||||
Button button = SelectedElement as Button;
|
||||
button.CallLeftBtnEvent();
|
||||
}
|
||||
else if (SelectedElement is TextBox)
|
||||
{
|
||||
TextBox textBox = SelectedElement as TextBox;
|
||||
isStartedPrint = true;
|
||||
}
|
||||
}
|
||||
else if (isPressed && (gamePadState.Buttons.A == ButtonState.Released &&
|
||||
gamePadState.DPad.Down == ButtonState.Released &&
|
||||
gamePadState.DPad.Up == ButtonState.Released))
|
||||
{
|
||||
isPressed = false;
|
||||
}
|
||||
}
|
||||
protected virtual void KeyBoardInput(KeyboardState keyboardState)
|
||||
{
|
||||
if (keyboardState.IsKeyDown(Keys.Up) && !isPressed)
|
||||
{
|
||||
isPressed = true;
|
||||
isStartedPrint = false;
|
||||
ChangeSelectedElement(-1);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.Down) && !isPressed)
|
||||
{
|
||||
isPressed = true;
|
||||
isStartedPrint = false;
|
||||
ChangeSelectedElement(1);
|
||||
}
|
||||
else if (keyboardState.IsKeyDown(Keys.Enter) && !isPressed)
|
||||
{
|
||||
isPressed = true;
|
||||
if (SelectedElement is Button)
|
||||
{
|
||||
Button button = SelectedElement as Button;
|
||||
button.CallLeftBtnEvent();
|
||||
}
|
||||
else if (SelectedElement is TextBox)
|
||||
{
|
||||
TextBox textBox = SelectedElement as TextBox;
|
||||
isStartedPrint = true;
|
||||
}
|
||||
}
|
||||
else if (isPressed && (keyboardState.IsKeyUp(Keys.Enter) &&
|
||||
keyboardState.IsKeyUp(Keys.Down) &&
|
||||
keyboardState.IsKeyUp(Keys.Up)))
|
||||
{
|
||||
isPressed = false;
|
||||
}
|
||||
}
|
||||
private void ChangeSelectedElement(int x) // Меняет выбранный элемент
|
||||
{
|
||||
for (int i = 0; i < ActiveElements.Count; i++)
|
||||
{
|
||||
if (ActiveElements[i] == SelectedElement)
|
||||
{
|
||||
if (i + x >= ActiveElements.Count)
|
||||
{
|
||||
SelectedElement = ActiveElements.First();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i + x < 0)
|
||||
{
|
||||
SelectedElement = ActiveElements.Last();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedElement = ActiveElements[i + x];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool CheckOnBadElements(DrawableUIElement element)
|
||||
{
|
||||
if (element is Button)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (element is ButtonText)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (element is TextBox)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
|
@ -13,17 +13,29 @@ internal class DeathGUI : AbstractGui
|
|||
{
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.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 });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2 - 80, 50, 50), text = "You died", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2, 50, 50), text = $"Score: {0}", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
|
||||
var butMenu = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, (height - 50) / 2 + 80, 300, 50), text = "Back to menu", scale = 0.7f, fontName = "ButtonFont" };
|
||||
Elements.Add(butMenu);
|
||||
butMenu.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
foreach (var item in Elements)
|
||||
{
|
||||
item.rectangle.X = (int)(scaler * item.rectangle.X);
|
||||
item.rectangle.Y = (int)(scaler * item.rectangle.Y);
|
||||
item.rectangle.Width = (int)(scaler * item.rectangle.Width);
|
||||
item.rectangle.Height = (int)(scaler * item.rectangle.Height);
|
||||
if (item is DrawableTextedUiElement)
|
||||
{
|
||||
(item as DrawableTextedUiElement).scale *= scaler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
|
|
|
@ -6,34 +6,84 @@ using System.Xml.Linq;
|
|||
using DangerousD.GameCore.Managers;
|
||||
using DangerousD.GameCore;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
public class HUD : AbstractGui
|
||||
public class HUD : IDrawableObject
|
||||
{
|
||||
List<Rect> rects = new List<Rect> { };
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
|
||||
Elements.Add(background);
|
||||
Rect rect = new Rect(Manager) { rectangle = new Rectangle(wigth / 35, height / 35, 120, 70), mainColor = Color.DarkRed };
|
||||
Elements.Add(rect);
|
||||
Label label = new Label(Manager) { rectangle = new Rectangle(wigth / 34, height / 30, 120, 20), text = "ammout", fontName = "font2", scale = 0.2f, mainColor = Color.Transparent, fontColor = Color.Black };
|
||||
Elements.Add(label);
|
||||
float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
Texture2D texture;
|
||||
SpriteFont spriteFont;
|
||||
|
||||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
rects.Clear();
|
||||
for (int i = 0; i < AppManager.Instance.GameManager.GetPlayer1.Bullets; i++)
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.Draw(texture, new Rectangle(
|
||||
(int)((wigth / 35 - 2) * scaler),
|
||||
(int)((height / 35 - 2) * scaler),
|
||||
(int)((120 + 2) * scaler),
|
||||
(int)((70 + 2) * scaler)), Color.DarkRed);
|
||||
spriteBatch.DrawString(spriteFont, "AMMO", new Vector2((wigth / 34 + 4)* scaler, height / 30 - 6), Color.Gray, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0);
|
||||
spriteBatch.DrawString(spriteFont, "AMMO", new Vector2((wigth / 34 + 1 )* scaler, height / 30 - 6), Color.White, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0);
|
||||
for (int i = 1; i < 6; i++)
|
||||
{
|
||||
rects.Add(new Rect(Manager) { rectangle = new Rectangle(wigth / 29 + i * 13, height / 17, 5, 20), mainColor = Color.Yellow });
|
||||
rects[i].LoadTexture(AppManager.Instance.Content);
|
||||
if (i <= AppManager.Instance.GameManager.players[0].Bullets)
|
||||
{
|
||||
spriteBatch.Draw(texture, new Rectangle((int)((wigth / 30 + i * 13 + 2) * scaler), (int)((height / 17 + 4) * scaler), (int)((5) * scaler), (int)((20) * scaler)), new Color(0.8f, 0.8f, 0, 1f));
|
||||
spriteBatch.Draw(texture, new Rectangle((int)((wigth / 30 + i * 13) * scaler), (int)((height / 17 + 4) * scaler), (int)((5) * scaler), (int)((20) * scaler)), Color.Yellow);
|
||||
}
|
||||
base.Update(gameTime);
|
||||
else
|
||||
{
|
||||
spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13, height / 17 + 4, 7, 20), new Color(0.2f, 0.2f, 0, 1f));
|
||||
}
|
||||
}
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
texture = new Texture2D(AppManager.Instance.GraphicsDevice, 1, 1);
|
||||
texture.SetData<Color>(new Color[] { Color.White });
|
||||
spriteFont = AppManager.Instance.Content.Load<SpriteFont>("PixelFont");
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
//public class HUD1 : AbstractGui
|
||||
//{
|
||||
//
|
||||
// protected override void CreateUI()
|
||||
// {
|
||||
// DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
|
||||
// Elements.Add(background);
|
||||
// Rect rect = new Rect(Manager) { rectangle = new Rectangle(wigth / 35, height / 35, 120, 70), mainColor = Color.DarkRed };
|
||||
// Elements.Add(rect);
|
||||
// Label label = new Label(Manager) { rectangle = new Rectangle(wigth / 34, height / 30, 120, 20), text = "ammout", fontName = "font2", scale = 0.2f, mainColor = Color.Transparent, fontColor = Color.Black };
|
||||
// Elements.Add(label);
|
||||
|
||||
// }
|
||||
// public override void Update(GameTime gameTime)
|
||||
// {
|
||||
//
|
||||
// rects.Clear();
|
||||
// for (int i = 0; i < ammout; i++)
|
||||
// {
|
||||
// rects.Add(new Rect(Manager) { rectangle = new Rectangle(wigth / 29 + i * 13, height / 17, 5, 20), mainColor = Color.Yellow });
|
||||
// rects[i].LoadTexture(AppManager.Instance.Content);
|
||||
// }
|
||||
// base.Update(gameTime);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
int screenWidth = AppManager.Instance.inGameResolution.X;
|
||||
int screenHeight = AppManager.Instance.inGameResolution.Y;
|
||||
float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
|
||||
var lobbyBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon3" };
|
||||
Elements.Add(lobbyBackground);
|
||||
|
@ -51,6 +52,7 @@ namespace DangerousD.GameCore.GUI
|
|||
textureName = "textboxbackground6-1"
|
||||
|
||||
};
|
||||
Elements.Add(searchBarTextBox);
|
||||
searchBarTextBox.TextChanged += input => {
|
||||
if (searchBarTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
|
@ -73,6 +75,7 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "font2",
|
||||
textureName = "textboxbackground1-1"
|
||||
};
|
||||
Elements.Add(backButton);
|
||||
backButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
|
@ -86,6 +89,7 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
Elements.Add(hostButton);
|
||||
hostButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
AppManager.Instance.NetworkManager.HostInit(AppManager.Instance.IpAddress);
|
||||
|
@ -101,6 +105,7 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
Elements.Add(refreshButton);
|
||||
refreshButton.LeftButtonPressed += () => {
|
||||
|
||||
};
|
||||
|
@ -114,6 +119,7 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
Elements.Add(joinSelectedButton);
|
||||
joinSelectedButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
AppManager.Instance.NetworkManager.ClientInit(AppManager.Instance.IpAddress);
|
||||
|
@ -127,10 +133,25 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "buttonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
Elements.Add(joinByIpButton);
|
||||
joinByIpButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.NetworkManager.ClientInit(searchBarTextBox.text);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var item in Elements)
|
||||
{
|
||||
item.rectangle.X = (int)(scaler * item.rectangle.X);
|
||||
item.rectangle.Y = (int)(scaler * item.rectangle.Y);
|
||||
item.rectangle.Width = (int)(scaler * item.rectangle.Width);
|
||||
item.rectangle.Height = (int)(scaler * item.rectangle.Height);
|
||||
if (item is DrawableTextedUiElement)
|
||||
{
|
||||
(item as DrawableTextedUiElement).scale *= scaler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
int screenWidth = AppManager.Instance.inGameResolution.X;
|
||||
int screenHeight = AppManager.Instance.inGameResolution.Y;
|
||||
float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
|
||||
var loginBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon2" };
|
||||
Elements.Add(loginBackground);
|
||||
|
@ -40,6 +41,19 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "ButtonFont"
|
||||
});
|
||||
|
||||
Button backButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)),
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2",
|
||||
textureName = "textboxbackground1-1"
|
||||
};
|
||||
backButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
Elements.Add(backButton);
|
||||
|
||||
|
||||
// TextBox-ы
|
||||
{
|
||||
TextBox loginTextBox = new TextBox(Manager)
|
||||
|
@ -53,6 +67,7 @@ namespace DangerousD.GameCore.GUI
|
|||
textureName = "textboxbackground6-1"
|
||||
|
||||
};
|
||||
Elements.Add(loginTextBox);
|
||||
loginTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
loginTextBox.TextChanged += input => {
|
||||
if (loginTextBox.fontColor == Color.Gray)
|
||||
|
@ -67,6 +82,7 @@ namespace DangerousD.GameCore.GUI
|
|||
loginTextBox.fontColor = Color.Gray;
|
||||
}
|
||||
};
|
||||
Elements.Add(loginTextBox);
|
||||
|
||||
TextBox passwordTextBox = new TextBox(Manager)
|
||||
{
|
||||
|
@ -78,6 +94,7 @@ namespace DangerousD.GameCore.GUI
|
|||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground6-1"
|
||||
};
|
||||
Elements.Add(passwordTextBox);
|
||||
passwordTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
passwordTextBox.TextChanged += input => {
|
||||
if (passwordTextBox.fontColor == Color.Gray)
|
||||
|
@ -92,6 +109,7 @@ namespace DangerousD.GameCore.GUI
|
|||
passwordTextBox.fontColor = Color.Gray;
|
||||
}
|
||||
};
|
||||
Elements.Add(passwordTextBox);
|
||||
}
|
||||
|
||||
// Кнопки
|
||||
|
@ -104,12 +122,14 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "ButtonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
Elements.Add(logButton);
|
||||
logButton.LeftButtonPressed += () => {
|
||||
if (CheckUser())
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Lobby);
|
||||
}
|
||||
};
|
||||
Elements.Add(logButton);
|
||||
|
||||
Button regButton = new Button(Manager)
|
||||
{
|
||||
|
@ -120,20 +140,22 @@ namespace DangerousD.GameCore.GUI
|
|||
fontName = "ButtonFont",
|
||||
textureName = "textboxbackground2-1"
|
||||
};
|
||||
Elements.Add(regButton);
|
||||
regButton.LeftButtonPressed += GoToRegWebServer;
|
||||
Elements.Add(regButton);
|
||||
|
||||
Button backButton = new Button(Manager)
|
||||
|
||||
}
|
||||
foreach (var item in Elements)
|
||||
{
|
||||
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)),
|
||||
text = "<-",
|
||||
scale = 0.72f,
|
||||
fontColor = Color.Black,
|
||||
fontName = "font2",
|
||||
textureName = "textboxbackground1-1"
|
||||
};
|
||||
backButton.LeftButtonPressed += () => {
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
item.rectangle.X = (int)(scaler * item.rectangle.X);
|
||||
item.rectangle.Y = (int)(scaler * item.rectangle.Y);
|
||||
item.rectangle.Width = (int)(scaler * item.rectangle.Width);
|
||||
item.rectangle.Height = (int)(scaler * item.rectangle.Height);
|
||||
if (item is DrawableTextedUiElement)
|
||||
{
|
||||
(item as DrawableTextedUiElement).scale *= scaler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,9 @@ internal class MenuGUI : AbstractGui
|
|||
List<Vector2> BigLetterPositions = new List<Vector2>();
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
int wigth = AppManager.Instance.inGameHUDHelperResolution.X;
|
||||
int height = AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
|
||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" };
|
||||
Elements.Add(menuBackground);
|
||||
|
@ -50,6 +51,7 @@ internal class MenuGUI : AbstractGui
|
|||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
|
||||
|
||||
};
|
||||
|
||||
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 470, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Multiplayer", scale = 1.2f, fontName = "ButtonFont" };
|
||||
|
@ -72,6 +74,18 @@ internal class MenuGUI : AbstractGui
|
|||
{
|
||||
AppManager.Instance.Exit();
|
||||
};
|
||||
|
||||
foreach ( var item in Elements)
|
||||
{
|
||||
item.rectangle.X = (int)(scaler * item.rectangle.X);
|
||||
item.rectangle.Y = (int)(scaler * item.rectangle.Y);
|
||||
item.rectangle.Width = (int)(scaler * item.rectangle.Width);
|
||||
item.rectangle.Height = (int)(scaler * item.rectangle.Height);
|
||||
if (item is DrawableTextedUiElement)
|
||||
{
|
||||
(item as DrawableTextedUiElement).scale *= scaler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,11 @@ namespace DangerousD.GameCore.GUI
|
|||
int selectedGUI = 0;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int wigth = AppManager.Instance.inGameResolution.X;
|
||||
int height = AppManager.Instance.inGameResolution.Y;
|
||||
int wigth = AppManager.Instance.inGameHUDHelperResolution.X;
|
||||
int height = AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" };
|
||||
Elements.Add(menuBackground);
|
||||
//Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
var slider = new Slider(Manager)
|
||||
|
@ -27,6 +28,8 @@ namespace DangerousD.GameCore.GUI
|
|||
indentation = 5,
|
||||
textureName = "sliderBackground"
|
||||
};
|
||||
//Elements.Add(slider);
|
||||
//AppManager.Instance.SettingsManager.SetMainVolume(slider.GetSliderValue);
|
||||
|
||||
var cB = new CheckBox(Manager);
|
||||
cB.rectangle = new Rectangle(wigth / 2 + 440, 405, (int)(40 * 2.4), (int)(40 * 2.4));
|
||||
|
@ -35,26 +38,28 @@ namespace DangerousD.GameCore.GUI
|
|||
SettingsManager sM = new SettingsManager();
|
||||
};
|
||||
cB.LoadTexture(AppManager.Instance.Content);
|
||||
Elements.Add(cB);
|
||||
|
||||
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();
|
||||
AppManager.Instance.SettingsManager.SetIsFullScreen(newCheckState);
|
||||
};
|
||||
checkBox.LoadTexture(AppManager.Instance.Content);
|
||||
Elements.Add(checkBox);
|
||||
|
||||
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 };
|
||||
{ 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);
|
||||
{ fontName = "buttonFont", scale = 1f , text = "Full Screen", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 580, 50, 50), mainColor = Color.Transparent };
|
||||
Elements.Add(lblIsFullScreen);
|
||||
|
||||
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 };
|
||||
|
@ -67,6 +72,26 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
|
||||
foreach (var item in Elements)
|
||||
{
|
||||
item.rectangle.X = (int)(scaler * item.rectangle.X);
|
||||
item.rectangle.Y = (int)(scaler * item.rectangle.Y);
|
||||
item.rectangle.Width = (int)(scaler * item.rectangle.Width);
|
||||
item.rectangle.Height = (int)(scaler * item.rectangle.Height);
|
||||
if (item is DrawableTextedUiElement)
|
||||
{
|
||||
(item as DrawableTextedUiElement).scale *= scaler;
|
||||
}
|
||||
}
|
||||
slider.rectangle.X = (int)(scaler * slider.rectangle.X);
|
||||
slider.rectangle.Y = (int)(scaler * slider.rectangle.Y);
|
||||
//slider.rectangle.Width = (int)(scaler * slider.rectangle.Width);
|
||||
//slider.rectangle.Height = (int)(scaler * slider.rectangle.Height);
|
||||
if (slider is DrawableTextedUiElement)
|
||||
{
|
||||
(slider as DrawableTextedUiElement).scale *= scaler;
|
||||
}
|
||||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
private Rectangle collision;
|
||||
private Vector2 position;
|
||||
private bool isFlyRight = true;
|
||||
private bool isFlyUp = true;
|
||||
private bool isAttacking = false;
|
||||
|
||||
public Rectangle Collision
|
||||
|
@ -29,34 +30,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
Width = 40;
|
||||
Height = 40;
|
||||
monster_speed = 3;
|
||||
velocity = new Vector2(3,-3);
|
||||
acceleration = Vector2.Zero;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if(!isAttacking)
|
||||
{
|
||||
Move(gameTime);
|
||||
}
|
||||
|
||||
AppManager.Instance.DebugHUD.Set(name, velocity.ToString());
|
||||
base.Update(gameTime);
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
|
||||
isAttacking = true;
|
||||
|
||||
if(isFlyRight)
|
||||
}
|
||||
public override void OnCollision(GameObject gameObject)
|
||||
{
|
||||
if (gameObject is Player)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.players[0].IsAlive)
|
||||
{
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
else if(!isFlyRight)
|
||||
{
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
|
||||
base.OnCollision(gameObject);
|
||||
}
|
||||
|
||||
public override void Death()
|
||||
|
@ -66,20 +65,50 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
velocity.X = 0;
|
||||
velocity.Y = 0;
|
||||
|
||||
if(isFlyRight)
|
||||
var getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
|
||||
var getColsVer= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ;
|
||||
if (isFlyRight)
|
||||
{
|
||||
velocity.X += monster_speed;
|
||||
velocity.Y += monster_speed;
|
||||
}
|
||||
else if(!isFlyRight)
|
||||
getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y , 42, 40));
|
||||
if(getColsHor.Count > 0)
|
||||
{
|
||||
velocity.X -= monster_speed;
|
||||
velocity.Y -= monster_speed;
|
||||
isFlyRight = false;
|
||||
velocity.X = -velocity.X;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-2, (int)Pos.Y, 42, 40));
|
||||
if (getColsHor.Count > 0)
|
||||
{
|
||||
isFlyRight = true;
|
||||
velocity.X = -velocity.X;
|
||||
}
|
||||
}
|
||||
if (isFlyUp)
|
||||
{
|
||||
|
||||
getColsVer = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X , (int)Pos.Y-3, 40, 43));
|
||||
if (getColsVer.Count > 0)
|
||||
{
|
||||
isFlyUp = false;
|
||||
velocity.Y = -velocity.Y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
getColsVer = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 40, 43));
|
||||
if (getColsVer.Count > 0)
|
||||
{
|
||||
isFlyUp = true;
|
||||
velocity.Y = -velocity.Y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
@ -12,8 +12,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Slime : CoreEnemy
|
||||
{
|
||||
|
||||
private bool isGoRight = true;
|
||||
private bool isDown = true;
|
||||
|
||||
int leftBorder;
|
||||
int rightBorder;
|
||||
bool isAttaking = false;
|
||||
|
@ -30,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
rightBorder = 400;
|
||||
//acceleration = Vector2.Zero;
|
||||
delay = 30;
|
||||
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
|
||||
|
@ -40,7 +43,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
|
||||
}
|
||||
public void Jump()
|
||||
public void Jump(GameTime gameTime)
|
||||
{
|
||||
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100));
|
||||
velocity.X = 0;
|
||||
|
@ -56,17 +59,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
if (delay <= 0)
|
||||
{
|
||||
|
||||
velocity = new Vector2(5, -3);
|
||||
velocity = new Vector2(5, -4);
|
||||
acceleration.Y = 0;
|
||||
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeJumpLeftBottom");
|
||||
}
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
|
||||
if (getCols.Count > 0)
|
||||
if (getCols.Count > 0 )
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = false;
|
||||
isAttaking = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +86,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
if (delay <= 0)
|
||||
{
|
||||
|
||||
velocity = new Vector2(-5, -3);
|
||||
velocity = new Vector2(-5, -4);
|
||||
acceleration.Y = 0;
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightBottom")
|
||||
{
|
||||
|
@ -92,6 +97,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
isJumping = false;
|
||||
isDown = false;
|
||||
isAttaking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,19 +112,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
if (delay <= 0)
|
||||
{
|
||||
|
||||
velocity = new Vector2(5, 3);
|
||||
velocity = new Vector2(5, 4);
|
||||
acceleration.Y = 0;
|
||||
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
|
||||
}
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X+1, (int)Pos.Y + Height, 46, 5));
|
||||
|
||||
if (getCols.Count > 0)
|
||||
if (getCols.Count > 0 )
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = true;
|
||||
isAttaking = false;
|
||||
acceleration.Y = 10;
|
||||
Move(gameTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,18 +141,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
delay--;
|
||||
if (delay <= 0)
|
||||
{
|
||||
velocity = new Vector2(-5, 3);
|
||||
velocity = new Vector2(-5, 4);
|
||||
acceleration.Y = 0;
|
||||
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
|
||||
}
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X+1, (int)Pos.Y + Height, 46, 5));
|
||||
if (getCols.Count > 0)
|
||||
if (getCols.Count > 0 )
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = true;
|
||||
isAttaking = false;
|
||||
acceleration.Y = 10;
|
||||
Move(gameTime);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +163,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
@ -246,24 +259,26 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
acceleration.Y = -acceleration.Y;
|
||||
}
|
||||
}
|
||||
Attack();
|
||||
|
||||
if (!isJumping)
|
||||
AppManager.Instance.DebugHUD.Set(name, isAttaking.ToString());
|
||||
if(!isJumping)
|
||||
{
|
||||
if (isDown)
|
||||
{
|
||||
Jump();
|
||||
Jump(gameTime);
|
||||
}
|
||||
else if(IsInAim())
|
||||
{
|
||||
Jump();
|
||||
Jump(gameTime);
|
||||
isAttaking = true;
|
||||
}
|
||||
else
|
||||
else if(!isAttaking)
|
||||
{
|
||||
Move(gameTime);
|
||||
}
|
||||
|
||||
}
|
||||
else { Jump(gameTime); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
base.Update(gameTime);
|
||||
|
@ -283,6 +298,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X + Width, (int)Pos.Y + Height, 200, 500), false);
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -291,9 +307,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y + Height, 200, 500), false);
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*/else if (isGoRight && isDown)
|
||||
{
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X +Width, (int)Pos.Y -500, 200, 500), false);
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
isAttaking = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (!isGoRight && isDown)
|
||||
{
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y - 500, 200, 500), false);
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
isAttaking = true;
|
||||
return true;
|
||||
}
|
||||
}/*/
|
||||
|
||||
return false;
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
isDownUp = true;
|
||||
isDown = true;
|
||||
physicsManager = AppManager.Instance.GameManager.physicsManager;
|
||||
web = new SpiderWeb(Pos);
|
||||
name = "Spider";
|
||||
Width = 112;
|
||||
Height = 24;
|
||||
delay = 0;
|
||||
web = new SpiderWeb(new Vector2(Pos.X-Width/2,Pos.Y));
|
||||
webLength = 0;
|
||||
monster_speed = 3;
|
||||
acceleration = new Vector2(0, -50);
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DangerousD.GameCore.Managers;
|
||||
using DangerousD.GameCore.GameObjects;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||
{
|
||||
|
@ -24,7 +25,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
Width = 24;
|
||||
Height = 40;
|
||||
monster_speed = 3;
|
||||
monster_speed = 2;
|
||||
name = "Zombie";
|
||||
monster_health = 2;
|
||||
leftBorder = (int)position.X - 100;
|
||||
|
@ -133,7 +134,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public void Target()
|
||||
{
|
||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0)
|
||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 200, Height), typeof(Player)).Count > 0)
|
||||
{
|
||||
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
||||
{
|
||||
|
@ -184,4 +185,4 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
public bool IsAlive { get { return isAlive; } }
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
|
||||
"playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot"}, "playerReload");
|
||||
"playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload");
|
||||
|
||||
public void Attack()
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
if (isRight)
|
||||
{
|
||||
StartCicycleAnimation("playerShootRight");
|
||||
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
|
||||
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
|
||||
if (targets.Count() > 0)
|
||||
{
|
||||
Zombie targetZombie = (Zombie)targets.First();
|
||||
|
@ -203,7 +203,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
else
|
||||
{
|
||||
StartCicycleAnimation("playerShootLeft");
|
||||
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(Zombie));
|
||||
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie));
|
||||
if (targets != null)
|
||||
{
|
||||
foreach (var target in targets)
|
||||
|
@ -290,15 +290,35 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
}
|
||||
}
|
||||
else if (isRight)
|
||||
{
|
||||
if (isUping)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "playerShootUpRight")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("playerShootUpRight");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphicsComponent.StartAnimation("playerRightStay");
|
||||
}
|
||||
}
|
||||
else if (!isRight)
|
||||
{
|
||||
if (isUping)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "playerShootUpLeft")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("playerShootUpLeft");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphicsComponent.StartAnimation("playerStayLeft");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
|
||||
{
|
||||
NetworkTask task = new NetworkTask(id, Pos);
|
||||
|
@ -310,5 +330,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
FallingThroughPlatform = true;
|
||||
isOnGround = false;
|
||||
}
|
||||
|
||||
public class Bullet : GameObjects.LivingEntity
|
||||
{
|
||||
public Bullet(Vector2 position) : base(position)
|
||||
{
|
||||
}
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||
using DangerousD.GameCore.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects;
|
||||
|
||||
|
@ -15,6 +17,14 @@ public abstract class LivingEntity : Entity
|
|||
public override void SetPosition(Vector2 position)
|
||||
{
|
||||
_pos = position;
|
||||
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
|
||||
{
|
||||
NetworkTask task = new NetworkTask(id, _pos);
|
||||
if (this is Player || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
||||
{
|
||||
AppManager.Instance.NetworkTasks.Add(task);
|
||||
}
|
||||
}
|
||||
|
||||
} //TODO befrend targetpos and physics engine
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using DangerousD.GameCore.Managers;
|
||||
using DangerousD.GameCore.GameObjects;
|
||||
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||
using DangerousD.GameCore.Managers;
|
||||
using DangerousD.GameCore.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
|
@ -108,14 +110,14 @@ namespace DangerousD.GameCore.Graphics
|
|||
|
||||
public void StartAnimation(string startedanimationId)
|
||||
{
|
||||
if (startedanimationId == "playerShootRight" && parentId == 17)
|
||||
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
|
||||
{
|
||||
string a = "2";
|
||||
}
|
||||
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer && startedanimationId != GetCurrentAnimation)
|
||||
LivingEntity entity = AppManager.Instance.GameManager.livingEntities.Find(x => x.id == parentId);
|
||||
if (((entity is Player) || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) && startedanimationId != GetCurrentAnimation)
|
||||
{
|
||||
AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero));
|
||||
}
|
||||
}
|
||||
currentFrame = 0;
|
||||
currentAnimation = animations.Find(x => x.Id == startedanimationId);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace DangerousD.GameCore
|
|||
|
||||
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
||||
public ScopeState ScopeState { get => scopeState; }
|
||||
public string currentControlsState;
|
||||
|
||||
public InputManager()
|
||||
{
|
||||
|
@ -205,7 +206,12 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
isShoot = false;
|
||||
}
|
||||
SetState(ControlsState.Keyboard);
|
||||
}
|
||||
}
|
||||
public void SetState(ControlsState controlsState)
|
||||
{
|
||||
currentControlsState = controlsState.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,9 @@ 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 resolution;
|
||||
public Point inGameResolution = new Point(1920, 1080);
|
||||
public Point inGameHUDHelperResolution= new Point(1920, 1080);
|
||||
IDrawableObject MenuGUI;
|
||||
IDrawableObject OptionsGUI;
|
||||
IDrawableObject LoginGUI;
|
||||
|
@ -61,6 +62,8 @@ namespace DangerousD.GameCore
|
|||
NetworkManager.GetReceivingMessages += NetworkSync;
|
||||
|
||||
resolution = SettingsManager.Resolution;
|
||||
SetIsFullScreen(!SettingsManager.IsFullScreen);
|
||||
SetIsFullScreen(SettingsManager.IsFullScreen);
|
||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||
_graphics.IsFullScreen = false;
|
||||
|
@ -133,10 +136,8 @@ namespace DangerousD.GameCore
|
|||
case GameState.Death:
|
||||
DeathGUI.Update(gameTime);
|
||||
break;
|
||||
case GameState.HUD:
|
||||
HUD.Update(gameTime);
|
||||
break;
|
||||
case GameState.Game:
|
||||
HUD.Update(gameTime);
|
||||
GameManager.Update(gameTime);
|
||||
break;
|
||||
default:
|
||||
|
@ -176,6 +177,7 @@ namespace DangerousD.GameCore
|
|||
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
|
||||
GameManager.Draw(_spriteBatch);
|
||||
_spriteBatch.End();
|
||||
HUD.Draw(_spriteBatch);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -204,7 +206,7 @@ namespace DangerousD.GameCore
|
|||
case GameState.Lobby:
|
||||
break;
|
||||
case GameState.Game:
|
||||
GameManager.mapManager.LoadLevel("LastLvl");
|
||||
GameManager.mapManager.LoadLevel("lvl");
|
||||
GameManager.FindBorders();
|
||||
break;
|
||||
case GameState.Death:
|
||||
|
@ -290,5 +292,24 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
this.multiPlayerStatus = multiPlayerStatus;
|
||||
}
|
||||
public void SetIsFullScreen(bool fullscrin)
|
||||
{
|
||||
DebugHUD?.Set("resX:", SettingsManager.Resolution.X.ToString());
|
||||
DebugHUD?.Set("resY:", SettingsManager.Resolution.Y.ToString());
|
||||
DebugHUD?.Set("FullScreen:", _graphics.IsFullScreen.ToString());
|
||||
if (fullscrin)
|
||||
{
|
||||
_graphics.PreferredBackBufferWidth = 1920;
|
||||
_graphics.PreferredBackBufferHeight = 1080;
|
||||
}
|
||||
else
|
||||
{
|
||||
_graphics.PreferredBackBufferWidth = SettingsManager.Resolution.X;
|
||||
_graphics.PreferredBackBufferHeight = SettingsManager.Resolution.Y;
|
||||
}
|
||||
UIManager.resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
|
||||
_graphics.IsFullScreen = fullscrin;
|
||||
_graphics.ApplyChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,6 @@ namespace DangerousD.GameCore
|
|||
}
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
|
||||
{
|
||||
|
|
|
@ -27,22 +27,26 @@ namespace DangerousD.GameCore.Managers
|
|||
public void SetMainVolume(float volume)
|
||||
{
|
||||
settingsContainer.MainVolume = MainVolume;
|
||||
///AppManager.Instance.SoundManager.
|
||||
//AppManager.Instance.SoundManager.
|
||||
|
||||
}
|
||||
public void SetMusicVolume(float volume)
|
||||
{
|
||||
settingsContainer.MusicVolume = MainVolume;
|
||||
SaveSettings();
|
||||
|
||||
}
|
||||
public void SetSoundEffectsVolume(float volume)
|
||||
{
|
||||
settingsContainer.SoundEffectsVolume = MainVolume;
|
||||
SaveSettings();
|
||||
|
||||
}
|
||||
public void SetIsFullScreen(bool isFullScreen)
|
||||
{
|
||||
settingsContainer.IsFullScreen = isFullScreen;
|
||||
AppManager.Instance.SetIsFullScreen(isFullScreen);
|
||||
SaveSettings();
|
||||
}
|
||||
public void LoadSettings()
|
||||
{
|
||||
|
@ -83,6 +87,6 @@ namespace DangerousD.GameCore.Managers
|
|||
[JsonProperty("SoundEffectsVolume")]
|
||||
public float SoundEffectsVolume { get; set; } = 1;
|
||||
[JsonProperty("Resolution")]
|
||||
public Point Resolution { get; set; } = new Point(1920,1080);
|
||||
public Point Resolution { get; set; } = new Point(1366,768);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MonogameLibrary.UI.Elements
|
|||
public delegate void OnButtonPressed();
|
||||
public event OnButtonPressed? RightButtonPressed;
|
||||
public event OnButtonPressed? LeftButtonPressed;
|
||||
protected HoverState hoverState = HoverState.None;
|
||||
public HoverState hoverState = HoverState.None;
|
||||
|
||||
public Button(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ namespace MonogameLibrary.UI.Elements
|
|||
if (mouseState.LeftButton != prevmouseState.LeftButton)
|
||||
{
|
||||
hoverState = HoverState.Pressing;
|
||||
LeftButtonPressed?.Invoke();
|
||||
CallLeftBtnEvent();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -77,5 +77,9 @@ namespace MonogameLibrary.UI.Elements
|
|||
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
public void CallLeftBtnEvent()
|
||||
{
|
||||
LeftButtonPressed?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,13 @@ namespace MonogameLibrary.UI.Elements
|
|||
public event OnTextChange? StopChanging;
|
||||
public event OnTextChange? OnEnter;
|
||||
|
||||
protected HoverState hoverState = HoverState.None;
|
||||
public HoverState hoverState = HoverState.None;
|
||||
protected IsSelected isSelected = IsSelected.NotSelected;
|
||||
public bool shouldEndOnEnter;
|
||||
public void SelectIt()
|
||||
{
|
||||
isSelected = IsSelected.Selected;
|
||||
}
|
||||
|
||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue