Preparatin For Project
This commit is contained in:
parent
613efe3be0
commit
2c817911a9
17 changed files with 131 additions and 18 deletions
|
@ -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>
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
10
DangerousD/GameCore/GameObjects/Entity.cs
Normal file
10
DangerousD/GameCore/GameObjects/Entity.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GameObjects
|
||||||
|
{
|
||||||
|
class Entity
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,5 +6,9 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
class GameObject
|
class GameObject
|
||||||
{
|
{
|
||||||
|
public GameObject()
|
||||||
|
{
|
||||||
|
GameManager.Register(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
DangerousD/GameCore/GameObjects/LivingEntity.cs
Normal file
10
DangerousD/GameCore/GameObjects/LivingEntity.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GameObjects
|
||||||
|
{
|
||||||
|
class LivingEntity : GameObject
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
10
DangerousD/GameCore/GameObjects/MapObject.cs
Normal file
10
DangerousD/GameCore/GameObjects/MapObject.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GameObjects
|
||||||
|
{
|
||||||
|
class MapObject : GameObject
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
|
27
DangerousD/GameCore/HUD/MenuHUD.cs
Normal file
27
DangerousD/GameCore/HUD/MenuHUD.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
DangerousD/GameCore/TextureManager.cs
Normal file
14
DangerousD/GameCore/TextureManager.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using DangerousD.GameCore;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace DangerousD
|
namespace DangerousD
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue