Preparatin For Project

This commit is contained in:
SergoDobro 2023-08-14 01:25:32 +03:00
parent 613efe3be0
commit 2c817911a9
17 changed files with 131 additions and 18 deletions

View file

@ -21,7 +21,7 @@
<MonoGameContentReference Include="Content\Content.mgcb" /> <MonoGameContentReference Include="Content\Content.mgcb" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="GameCore\GameObjects\" /> <Folder Include="GameCore\GameObjects\LivingEntities\" />
<Folder Include="GameCore\UI\" /> <Folder Include="GameCore\UI\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -9,14 +9,13 @@ using DangerousD.GameCore.HUD;
namespace DangerousD.GameCore namespace DangerousD.GameCore
{ {
enum GameState { Menu, Options, Lobby, Game } public enum GameState { Menu, Options, Lobby, Game }
public class AppManager : Game public class AppManager : Game
{ {
private GraphicsDeviceManager _graphics; private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch; private SpriteBatch _spriteBatch;
GameState gameState; GameState gameState;
GameManager GameManager;
IHUD MenuGUI; IHUD MenuGUI;
IHUD OptionsGUI; IHUD OptionsGUI;
IHUD LobbyGUI; IHUD LobbyGUI;
@ -39,7 +38,9 @@ namespace DangerousD.GameCore
{ {
_spriteBatch = new SpriteBatch(GraphicsDevice); _spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here TextureManager.contentManager = Content;
TextureManager.graphicsDevice = GraphicsDevice;
MenuGUI = new HUD.MenuHUD();
} }
protected override void Update(GameTime gameTime) protected override void Update(GameTime gameTime)
@ -94,7 +95,10 @@ namespace DangerousD.GameCore
base.Draw(gameTime); base.Draw(gameTime);
} }
public void ChangeGameState(GameState gameState)
{
this.gameState = gameState;
}
} }
} }

View file

@ -1,4 +1,5 @@
using Microsoft.Xna.Framework; using DangerousD.GameCore.GameObjects;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -6,13 +7,28 @@ using System.Text;
namespace DangerousD.GameCore namespace DangerousD.GameCore
{ {
class GameManager static class GameManager
{ {
public void Draw(SpriteBatch _spriteBatch) static List<LivingEntity> livingEntities;
static List<MapObject> MapObjects;
internal static void Register(GameObject gameObject)
{
if (gameObject is LivingEntity)
livingEntities.Add(gameObject as LivingEntity);
if (gameObject is MapObject)
MapObjects.Add(gameObject as MapObject);
}
public static void Start()
{
livingEntities = new List<LivingEntity>();
MapObjects = new List<MapObject>();
}
public static void Draw(SpriteBatch _spriteBatch)
{ {
} }
public void Update(GameTime gameTime) public static void Update(GameTime gameTime)
{ {
} }

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DangerousD.GameCore.GameObjects
{
class Entity
{
}
}

View file

@ -6,5 +6,9 @@ namespace DangerousD.GameCore
{ {
class GameObject class GameObject
{ {
public GameObject()
{
GameManager.Register(this);
}
} }
} }

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DangerousD.GameCore.GameObjects
{
class LivingEntity : GameObject
{
}
}

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DangerousD.GameCore.GameObjects
{
class MapObject : GameObject
{
}
}

View file

@ -1,4 +1,5 @@
using System; using Microsoft.Xna.Framework.Content;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;

View file

@ -0,0 +1,27 @@
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
namespace DangerousD.GameCore.HUD
{
class MenuHUD : IHUD
{
MonogameLibrary.UI.Base.MonoClassManagerUI managerUI = new MonogameLibrary.UI.Base.MonoClassManagerUI();
public MenuHUD()
{
managerUI.InitManager("");
var lab = new MonogameLibrary.UI.Elements.CheckBox(managerUI) { rectangle = new Microsoft.Xna.Framework.Rectangle(10, 10, 50, 50)};
lab.LoadTexture();
}
public void Draw(SpriteBatch _spriteBatch)
{
managerUI.Draw(_spriteBatch);
}
public void Update()
{
managerUI.Update(null);
}
}
}

View file

@ -0,0 +1,14 @@
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
namespace DangerousD.GameCore
{
static class TextureManager
{
public static ContentManager contentManager;
public static GraphicsDevice graphicsDevice;
}
}

View file

@ -1,4 +1,5 @@
using Microsoft.Xna.Framework; using DangerousD.GameCore;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
@ -20,13 +21,13 @@ namespace MonogameLibrary.UI.Base
static GraphicsDevice _graphicsDevice; static GraphicsDevice _graphicsDevice;
static ContentManager _content; static ContentManager _content;
static SpriteFont _baseFont; static SpriteFont _baseFont;
public void InitManager(GraphicsDevice graphicsDevice, ContentManager content, string font) public void InitManager(string font)
{ {
_graphicsDevice = graphicsDevice; _graphicsDevice = TextureManager.graphicsDevice;
_content = content; _content = TextureManager.contentManager;
try try
{ {
_baseFont = _content.Load<SpriteFont>(font); //_baseFont = _content.Load<SpriteFont>(font);
} }
catch catch
{ {

View file

@ -17,6 +17,9 @@ namespace MonogameLibrary.UI.Compounds
public enum BasicDrawableCompound_Type { Vertical, Horizontal }; public enum BasicDrawableCompound_Type { Vertical, Horizontal };
public class BasicDrawableCompound : MonoDrawableTextedUI public class BasicDrawableCompound : MonoDrawableTextedUI
{ {
public BasicDrawableCompound(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex)
{
}
Dictionary<string, MonoDrawableTextedUI> drawables = new Dictionary<string, MonoDrawableTextedUI>(); Dictionary<string, MonoDrawableTextedUI> drawables = new Dictionary<string, MonoDrawableTextedUI>();
public Vector2 lastPos; public Vector2 lastPos;
Vector2 offset = new Vector2(10, 10); Vector2 offset = new Vector2(10, 10);

View file

@ -12,6 +12,9 @@ namespace MonogameLibrary.UI.Elements
{ {
public class CheckBox : MonoDrawableTextedUI, IInteractable public class CheckBox : MonoDrawableTextedUI, IInteractable
{ {
public CheckBox(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex)
{
}
public delegate void OnCheck(bool checkState); public delegate void OnCheck(bool checkState);
public event OnCheck? Checked; public event OnCheck? Checked;
private bool isChecked; private bool isChecked;

View file

@ -14,6 +14,9 @@ namespace MonogameLibrary.UI.Elements
public class Label : MonoDrawableTextedUI public class Label : MonoDrawableTextedUI
{ {
public Label(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex)
{
}
protected HoverState hoverState = HoverState.None; protected HoverState hoverState = HoverState.None;
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState) public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)

View file

@ -12,6 +12,9 @@ namespace MonogameLibrary.UI.Elements
{ {
public class Slider : MonoDrawableTextedUI, IInteractable public class Slider : MonoDrawableTextedUI, IInteractable
{ {
public Slider(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex)
{
}
public delegate void OnSliderChanges(float value); public delegate void OnSliderChanges(float value);
public event OnSliderChanges? SliderChanged; public event OnSliderChanges? SliderChanged;

View file

@ -14,6 +14,9 @@ namespace MonogameLibrary.UI.Elements
{ {
public class TextBox : MonoDrawableTextedUI, IInteractable public class TextBox : MonoDrawableTextedUI, IInteractable
{ {
public TextBox(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex)
{
}
public delegate void OnTextChange(string text); public delegate void OnTextChange(string text);
public event OnTextChange? TextChanged; public event OnTextChange? TextChanged;
public event OnTextChange? StopChanging; public event OnTextChange? StopChanging;
@ -34,7 +37,7 @@ namespace MonogameLibrary.UI.Elements
{ {
if (isSelected == IsSelected.Selected) if (isSelected == IsSelected.Selected)
{ {
if (MonoClassManagerUI.GetKeyboardState.IsKeyDown(Keys.Enter)) if (Keyboard.GetState().IsKeyDown(Keys.Enter))
{ {
OnEnter?.Invoke(text); OnEnter?.Invoke(text);
if (shouldEndOnEnter) if (shouldEndOnEnter)
@ -110,7 +113,7 @@ namespace MonogameLibrary.UI.Elements
public static void GetInput(ref string text) public static void GetInput(ref string text)
{ {
var state = MonoClassManagerUI.GetKeyboardState; var state = Keyboard.GetState();
var keys = state.GetPressedKeys(); var keys = state.GetPressedKeys();
isShiftPressed = state.IsKeyDown(Keys.LeftShift) || state.IsKeyDown(Keys.RightShift); isShiftPressed = state.IsKeyDown(Keys.LeftShift) || state.IsKeyDown(Keys.RightShift);
isCTRLPressed = state.IsKeyDown(Keys.LeftControl) || state.IsKeyDown(Keys.RightControl); isCTRLPressed = state.IsKeyDown(Keys.LeftControl) || state.IsKeyDown(Keys.RightControl);

View file

@ -1,4 +1,5 @@
using System; using DangerousD.GameCore;
using System;
namespace DangerousD namespace DangerousD
{ {