Merge branch 'Development' into ClientServerManager
This commit is contained in:
commit
7e2e042194
44 changed files with 723 additions and 139 deletions
|
@ -59,8 +59,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);
|
||||
//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
|
||||
{
|
||||
|
|
18
ZoFo.sln
18
ZoFo.sln
|
@ -1,8 +1,11 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZoFo", "ZoFo\ZoFo.csproj", "{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}"
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.35122.118
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZoFo", "ZoFo\ZoFo.csproj", "{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonogameLibrary", "MonogameLibrary\MonogameLibrary.csproj", "{D6272E15-AD49-468A-BE0F-D812E8697FAC}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonogameLibrary", "MonogameLibrary\MonogameLibrary.csproj", "{40880E68-4B3A-417B-A39B-95DE46AA2E7E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -14,9 +17,12 @@ Global
|
|||
{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D63272E5-A54D-4C24-AA48-2945CB1D0BBB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D6272E15-AD49-468A-BE0F-D812E8697FAC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40880E68-4B3A-417B-A39B-95DE46AA2E7E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -13,3 +13,29 @@
|
|||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
||||
#begin Fonts/Font.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Font.spritefont
|
||||
|
||||
#begin Fonts/Font2.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Font2.spritefont
|
||||
|
||||
#begin Textures/GUI/MenuBackground.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:Textures/GUI/MenuBackground.jpg
|
||||
|
||||
|
|
BIN
ZoFo/Content/Fonts/CarltineRegular-K7z5l.ttf
Normal file
BIN
ZoFo/Content/Fonts/CarltineRegular-K7z5l.ttf
Normal file
Binary file not shown.
BIN
ZoFo/Content/Fonts/Debrosee-ALPnL.ttf
Normal file
BIN
ZoFo/Content/Fonts/Debrosee-ALPnL.ttf
Normal file
Binary file not shown.
60
ZoFo/Content/Fonts/Font.spritefont
Normal file
60
ZoFo/Content/Fonts/Font.spritefont
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?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>Debrosee-ALPnL.ttf</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>100</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>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
60
ZoFo/Content/Fonts/Font2.spritefont
Normal file
60
ZoFo/Content/Fonts/Font2.spritefont
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?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>CarltineRegular-K7z5l.ttf</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>15</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>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
BIN
ZoFo/Content/Textures/GUI/MenuBackground.jpg
Normal file
BIN
ZoFo/Content/Textures/GUI/MenuBackground.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 592 KiB |
|
@ -1,52 +0,0 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace ZoFo;
|
||||
|
||||
public class Game1 : Game
|
||||
{
|
||||
private GraphicsDeviceManager _graphics;
|
||||
private SpriteBatch _spriteBatch;
|
||||
|
||||
public Game1()
|
||||
{
|
||||
_graphics = new GraphicsDeviceManager(this);
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
// TODO: Add your initialization logic here
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
protected override void LoadContent()
|
||||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
|
||||
// TODO: use this.Content to load your game content here
|
||||
}
|
||||
|
||||
protected override void Update(GameTime gameTime)
|
||||
{
|
||||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
||||
Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
// TODO: Add your update logic here
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
// TODO: Add your drawing code here
|
||||
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,10 @@ using System.Text.Json;
|
|||
using ZoFo.GameCore.GameManagers.NetworkManager;
|
||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace ZoFo.GameCore
|
||||
{
|
||||
public class Client
|
||||
|
@ -18,7 +22,7 @@ namespace ZoFo.GameCore
|
|||
public void OnDataSend(string data)
|
||||
{
|
||||
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
|
||||
// Тут будет switch
|
||||
// тут будет switch
|
||||
}
|
||||
|
||||
public void GameEndedUnexpectedly(){ }
|
||||
|
@ -26,5 +30,13 @@ namespace ZoFo.GameCore
|
|||
public void JoinRoom(){ }
|
||||
|
||||
public void JoinYourself(){ }
|
||||
|
||||
internal void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
internal void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
|
||||
namespace ZoFo.GameCore.GUI;
|
||||
|
||||
|
@ -29,22 +30,27 @@ public abstract class AbstractGUI
|
|||
private GraphicsDevice graphicsDevice;
|
||||
public virtual void Initialize()
|
||||
{
|
||||
// Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||
CreateUI();
|
||||
}
|
||||
|
||||
public virtual void LoadContent()
|
||||
{
|
||||
|
||||
Manager.LoadContent(AppManager.Instance.Content, "Font");
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
Manager.Update(gameTime);
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Manager.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual void ResolutioChenges()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
72
ZoFo/GameCore/GUI/DebugHUD.cs
Normal file
72
ZoFo/GameCore/GUI/DebugHUD.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using static System.String;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
|
||||
namespace ZoFo.GameCore.GUI;
|
||||
|
||||
public class DebugHUD
|
||||
{
|
||||
private SpriteFont _spriteFont;
|
||||
private Dictionary<string, string> _text = new();
|
||||
private List<string> _log = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Fonts\\Font2");
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
keysString,
|
||||
new Vector2(10, 10),
|
||||
Color.Cyan,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
1,
|
||||
SpriteEffects.None,
|
||||
0
|
||||
);
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
Join("\n", _log),
|
||||
new Vector2(10, 10 + _spriteFont.MeasureString(keysString).Y),
|
||||
Color.Green,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
1,
|
||||
SpriteEffects.None,
|
||||
0
|
||||
);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public void Set(string key, string value)
|
||||
{
|
||||
_text[key] = value;
|
||||
}
|
||||
|
||||
public void Log(string value)
|
||||
{
|
||||
_log.Add(value);
|
||||
if (_log.Count > 30)
|
||||
{
|
||||
_log.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,19 +9,74 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using ZoFo.GameCore.GameManagers;
|
||||
|
||||
namespace ZoFo.GameCore.GUI;
|
||||
|
||||
public class MainMenuGUI : AbstractGUI
|
||||
{
|
||||
private DrawableUIElement menuBackground;
|
||||
Color mainBackgroundColor = Color.White;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
// int width = AppManager.Instance.inGameHUDHelperResolution.X;
|
||||
// int height = AppManager.Instance.inGameHUDHelperResolution.Y;
|
||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
|
||||
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = mainBackgroundColor, textureName = "Textures\\GUI\\MenuBackground" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 5, (int)(width / 4), (int)(height / 20)), text = "ZoFo", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"});
|
||||
|
||||
|
||||
Button playButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + height / 20 + height / 40, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Play",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
playButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
||||
};
|
||||
Elements.Add(playButton);
|
||||
Button optionButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 2, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Options",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
optionButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
||||
};
|
||||
Elements.Add(optionButton);
|
||||
Button exitButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 3, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Exit",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
exitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.Exit();
|
||||
};
|
||||
Elements.Add(exitButton);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -8,8 +8,10 @@ using DangerousD.GameCore.Graphics;
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using ZoFo.GameCore.GameManagers.ItemManager;
|
||||
using ZoFo.GameCore.GUI;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
using MonogameLibrary.UI.Base;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers
|
||||
{
|
||||
|
@ -18,18 +20,22 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
private GraphicsDeviceManager _graphics;
|
||||
private SpriteBatch _spriteBatch;
|
||||
|
||||
|
||||
|
||||
|
||||
public static AppManager Instance { get; private set; }
|
||||
public GameState gamestate;
|
||||
public AbstractGUI currentGUI;
|
||||
//public Client client;
|
||||
//public Server server;
|
||||
public DebugHUD debugHud;
|
||||
public Point CurentScreenResolution = new Point(1920, 1080);
|
||||
public Client client;
|
||||
public Server server;
|
||||
|
||||
|
||||
#region Managers
|
||||
|
||||
public InputManager InputManager;
|
||||
public ItemManager.ItemManager ItemManager;
|
||||
|
||||
public AnimationBuilder animationBuilder{get;set; }
|
||||
|
||||
|
@ -38,20 +44,28 @@ namespace ZoFo.GameCore.GameManagers
|
|||
public AppManager()
|
||||
{
|
||||
_graphics = new GraphicsDeviceManager(this);
|
||||
SetResolution(CurentScreenResolution.X, CurentScreenResolution.Y);
|
||||
FulscrreenSwitch();
|
||||
|
||||
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
|
||||
Instance = this;
|
||||
InputManager = new InputManager();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
currentGUI = new MainMenuGUI();
|
||||
debugHud = new DebugHUD();
|
||||
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
|
||||
currentGUI.Initialize();
|
||||
debugHud.Initialize();
|
||||
|
||||
|
||||
|
||||
base.Initialize();
|
||||
|
@ -60,7 +74,8 @@ namespace ZoFo.GameCore.GameManagers
|
|||
protected override void LoadContent()
|
||||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
|
||||
debugHud.LoadContent();
|
||||
currentGUI.LoadContent();
|
||||
|
||||
|
||||
|
||||
|
@ -71,19 +86,21 @@ namespace ZoFo.GameCore.GameManagers
|
|||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
||||
Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
|
||||
debugHud.Set("key", "value");
|
||||
|
||||
InputManager.Update();
|
||||
//currentGUI.Update();
|
||||
currentGUI.Update(gameTime);
|
||||
switch (gamestate)
|
||||
{
|
||||
case GameState.NotPlaying:
|
||||
break;
|
||||
case GameState.HostPlaying:
|
||||
//server.Update(GameTime gameTime);
|
||||
//client.Update(GameTime gameTime);
|
||||
server.Update(gameTime);
|
||||
client.Update(gameTime);
|
||||
break;
|
||||
case GameState.ClientPlaying:
|
||||
//server.Update(GameTime gameTime);
|
||||
server.Update(gameTime);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -96,13 +113,15 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
|
||||
|
||||
//currentGUI.Draw(_spriteBatch);
|
||||
debugHud.Draw(_spriteBatch);
|
||||
currentGUI.Draw(_spriteBatch);
|
||||
switch (gamestate)
|
||||
{
|
||||
case GameState.ClientPlaying:
|
||||
case GameState.HostPlaying:
|
||||
//client.Draw(_spriteBatch);
|
||||
client.Draw(_spriteBatch);
|
||||
break;
|
||||
case GameState.NotPlaying:
|
||||
default:
|
||||
|
@ -118,13 +137,22 @@ namespace ZoFo.GameCore.GameManagers
|
|||
public void SetGUI(AbstractGUI gui)
|
||||
{
|
||||
currentGUI = gui;
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
||||
public void GameEnded(Dictionary<string, int> lootIGot)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
public void SetResolution(int x, int y)
|
||||
{
|
||||
_graphics.PreferredBackBufferWidth = x;
|
||||
_graphics.PreferredBackBufferHeight = y;
|
||||
}
|
||||
|
||||
public void FulscrreenSwitch()
|
||||
{
|
||||
_graphics.IsFullScreen = !_graphics.IsFullScreen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZoFo.GameCore.GameObjects;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||
{
|
||||
public class CollisionComponent
|
||||
{
|
||||
//поля
|
||||
public Rectangle Bounds { get; set; }
|
||||
|
||||
//остановлен ли перс
|
||||
bool doesStop;
|
||||
Rectangle stopRectangle;
|
||||
|
||||
// triggers for rectangle
|
||||
bool isTrigger;
|
||||
Rectangle triggerRectangle;
|
||||
|
||||
//delegate
|
||||
public delegate void EventHandler(object sender, EventArgs e);
|
||||
|
||||
public CollisionComponent(int x, int y, int width, int height)
|
||||
{
|
||||
Bounds = new Rectangle(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
//events
|
||||
public event EventHandler<CollisionComponent> OnTriggerEnter;
|
||||
public event EventHandler<CollisionComponent> OnTriggerZone;
|
||||
public event EventHandler<CollisionComponent> OnTriggerExit;
|
||||
|
||||
// methods-event
|
||||
public void TriggerEnter(object component, Player player,
|
||||
EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
public void TriggerZone(object component,Player player,
|
||||
EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
public void TriggerExit(object component,Player player,
|
||||
EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZoFo.GameCore.GameObjects;
|
||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||
using Microsoft.Xna.Framework;
|
||||
using ZoFo.GameCore.GameManagers.MapManager.MapElements;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||
{
|
||||
public class CollisionManager
|
||||
{
|
||||
public List<CollisionComponent> CollisionComponent;
|
||||
public List<CollisionComponent> TriggerComponent;
|
||||
|
||||
|
||||
|
||||
public static bool CheckComponentCollision(List<CollisionComponent> collisionComponents, CollisionComponent component)
|
||||
{
|
||||
foreach (var collisionComponent in collisionComponents)
|
||||
{
|
||||
if (component.Bounds.IntersectsWith(collisionComponent.Bounds))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void UpdateComponentCollision(List<CollisionComponent> collisionComponents)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void UpdatePositions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//public void GetObjectInArea(Rectangle area)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//public void Register(Rectangle rectangle)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
17
ZoFo/GameCore/GameManagers/ItemManager/EquippableItemInfo.cs
Normal file
17
ZoFo/GameCore/GameManagers/ItemManager/EquippableItemInfo.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||
{
|
||||
class EquippableItemInfo : ItemInfo
|
||||
{
|
||||
bool IsEquiped; //экипирован ли предмет
|
||||
public EquippableItemInfo(string tag) : base(tag)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,10 +15,23 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
Texture2D itemTexture;
|
||||
bool isCraftable;
|
||||
Dictionary<string, int> resourcesNeededToCraft;
|
||||
public ItemInfo (string tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
public ItemInfo(string tag,string textureName,bool isCraftable, Dictionary<string, int> resourcesNeededToCraft)
|
||||
{
|
||||
this.tag = tag;
|
||||
this.textureName = textureName;
|
||||
|
||||
this.isCraftable = isCraftable;
|
||||
this.resourcesNeededToCraft = resourcesNeededToCraft;
|
||||
}
|
||||
//методы
|
||||
private void LoadTexture()
|
||||
public void LoadTexture()
|
||||
{
|
||||
//я что-то хз как это
|
||||
itemTexture=AppManager.Instance.Content.Load<Texture2D>(textureName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||
{
|
||||
class ItemManager
|
||||
public class ItemManager
|
||||
{
|
||||
//поля
|
||||
Dictionary<string, ItemInfo> tagItemPairs;
|
||||
|
@ -15,9 +15,18 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
{
|
||||
return tagItemPairs.GetValueOrDefault(tag);
|
||||
}
|
||||
void LoadItemTexture()
|
||||
void LoadItemTextures()
|
||||
{
|
||||
|
||||
foreach (var item in tagItemPairs)
|
||||
{
|
||||
item.Value.LoadTexture();
|
||||
}
|
||||
}
|
||||
void Initialize()
|
||||
{
|
||||
tagItemPairs.Add("wood", new ItemInfo("wood","wood",false,null));
|
||||
tagItemPairs.Add("rock", new ItemInfo("rock", "rock", false, null));
|
||||
tagItemPairs.Add("steel", new ItemInfo("steel", "steel", false, null));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
24
ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs
Normal file
24
ZoFo/GameCore/GameManagers/ItemManager/PlayerData.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс хранит информацю о количестве ресурсов у игрока
|
||||
/// </summary>
|
||||
internal class PlayerData
|
||||
{
|
||||
Dictionary<string, int> items;
|
||||
/// <summary>
|
||||
/// Принимает тэг и крафтит этот объект
|
||||
/// </summary>
|
||||
/// <param name="itemTag"></param>
|
||||
public void CraftItem(string itemTag)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,9 +6,13 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||
{
|
||||
class WeaponItemInfo:ItemInfo
|
||||
class WeaponItemInfo: EquippableItemInfo
|
||||
{
|
||||
//поля
|
||||
float damage;
|
||||
|
||||
public WeaponItemInfo(string tag) : base(tag)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager.MapElements
|
|||
public bool Infinite { get; set; }
|
||||
public int TileHeight { get; set; }
|
||||
public int TileWidth { get; set; }
|
||||
public List<TileSet> TileSets { get; set; }
|
||||
public List<TileSetInfo> TileSets { get; set; }
|
||||
public List<Layer> Layers { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -8,5 +9,16 @@ namespace ZoFo.GameCore.GameManagers.MapManager.MapElements
|
|||
{
|
||||
public class TileSet
|
||||
{
|
||||
public string Image { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int ImageHeight { get; set; }
|
||||
public int ImageWidth { get; set; }
|
||||
public int Margin { get; set; }
|
||||
public int Spacing { get; set; }
|
||||
public int TileCount { get; set; }
|
||||
public int TileHeight { get; set; }
|
||||
public int TileWidth { get; set; }
|
||||
public int Columns { get; set; }
|
||||
public int FirstGid { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.MapManager.MapElements
|
||||
{
|
||||
public class TileSetInfo
|
||||
{
|
||||
public int FirstGid { get; set; }
|
||||
public string Source { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,20 +1,71 @@
|
|||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using ZoFo.GameCore.GameManagers.MapManager.MapElements;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.MapManager
|
||||
{
|
||||
public class MapManager
|
||||
{
|
||||
public void LoadMap()
|
||||
private static readonly string _path = "/{0}.tmj";
|
||||
private List<TileSet> _tileSets = new List<TileSet>();
|
||||
|
||||
public void LoadMap(string mapName = "main")
|
||||
{
|
||||
TileMap tileMap;
|
||||
using (StreamReader reader = new StreamReader(string.Format(_path, mapName)))
|
||||
{
|
||||
string data = reader.ReadToEnd();
|
||||
tileMap = JsonSerializer.Deserialize<TileMap>(data);
|
||||
}
|
||||
|
||||
List<TileSet> tileSets = new List<TileSet>();
|
||||
foreach (TileSetInfo tileSetInfo in tileMap.TileSets)
|
||||
{
|
||||
TileSet tileSet = LoadTileSet(tileSetInfo.Source);
|
||||
tileSet.FirstGid = tileSetInfo.FirstGid;
|
||||
tileSets.Add(tileSet);
|
||||
}
|
||||
|
||||
foreach (var chunk in tileMap.Layers[0].Chunks)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var id in chunk.Data)
|
||||
{
|
||||
foreach (var tileSet in tileSets)
|
||||
{
|
||||
if (tileSet.FirstGid - id < 0)
|
||||
{
|
||||
int number = id - tileSet.FirstGid;
|
||||
|
||||
int relativeColumn = number % tileSet.Columns * tileSet.TileWidth;
|
||||
int relativeRow = number / tileSet.Columns * tileSet.TileHeight;
|
||||
|
||||
Rectangle sourceRectangle = new Rectangle(relativeColumn * tileSet.TileWidth, relativeRow * tileSet.TileHeight,
|
||||
relativeColumn * tileSet.TileWidth + tileSet.TileWidth, relativeRow * tileSet.TileHeight + tileSet.TileHeight);
|
||||
|
||||
Vector2 position = new Vector2(i % chunk.Width, i / chunk.Height);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void LoadTileSet()
|
||||
{
|
||||
|
||||
private TileSet LoadTileSet(string path)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(path))
|
||||
{
|
||||
string data = reader.ReadToEnd();
|
||||
return JsonSerializer.Deserialize<TileSet>(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,31 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
||||
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||
{
|
||||
public class ClientNetworkManager
|
||||
{
|
||||
private IPAddress iPAddress = IPAddress.Any;
|
||||
private int port = 7632;
|
||||
private EndPoint endPoint;
|
||||
private Socket socket;
|
||||
List<IUpdateData> updates = new List<IUpdateData>();
|
||||
public delegate void OnDataSent(string Data);
|
||||
public event OnDataSent GetDataSent; // event
|
||||
public void Init() //create endPoint, socket
|
||||
{
|
||||
endPoint = new IPEndPoint(iPAddress, port);
|
||||
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
|
||||
public void SendData()
|
||||
{
|
||||
|
||||
while(socket.Connected)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(updates.ToString());
|
||||
socket.Send(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
public void StopConnection()
|
||||
|
@ -34,23 +40,39 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
socket.Close();
|
||||
}
|
||||
|
||||
public void JoinRoom() // multyplayer
|
||||
/// <summary>
|
||||
/// приложение пытается подключиться к комнате
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
public void JoinRoom(string ip) // multyplayer
|
||||
{
|
||||
endPoint = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||
|
||||
socket.Connect(endPoint);
|
||||
|
||||
SendData();
|
||||
StartListening();
|
||||
Thread listen = new Thread(StartListening);
|
||||
listen.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// создается
|
||||
/// </summary>
|
||||
public void JoinYourself() // single player
|
||||
{
|
||||
endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
|
||||
|
||||
socket.Connect(endPoint);
|
||||
|
||||
SendData();
|
||||
StartListening();
|
||||
Thread listen = new Thread(StartListening);
|
||||
listen.Start();
|
||||
}
|
||||
|
||||
//поток 2
|
||||
public void StartListening()
|
||||
{
|
||||
socket.Connect(endPoint);
|
||||
|
||||
while(socket.Connected)
|
||||
{
|
||||
byte[] bytes = new byte[2048];
|
||||
|
|
33
ZoFo/GameCore/GameObjects/BaseClasses/Entity.cs
Normal file
33
ZoFo/GameCore/GameObjects/BaseClasses/Entity.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects
|
||||
{
|
||||
public abstract class Entity : GameObject
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public void CollisionComponent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AnimationComponent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void UpdateLogic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//вектор
|
||||
//вилосити
|
||||
//поситион
|
||||
//текстура
|
20
ZoFo/GameCore/GameObjects/BaseClasses/LivingEntity.cs
Normal file
20
ZoFo/GameCore/GameObjects/BaseClasses/LivingEntity.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects;
|
||||
public class LivingEntity : Entity
|
||||
{
|
||||
public Vector2 velocity;
|
||||
public Vector2 position;
|
||||
|
||||
public void TextureLoad(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
using System;
|
||||
using ZoFo.GameCore.GameObjects;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects;
|
||||
public class Entity : GameObject
|
||||
{
|
||||
public int Id{ get; set; }
|
||||
//public CollisionComponent collisionComponents{ get; set; }
|
||||
//public AnimationComponent animationComponent{ get; set; }
|
||||
|
||||
// в апдейте может заявляет изменения позиции
|
||||
public void UpdateLogic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Методы для клиента
|
||||
public void UpdateAnimation()
|
||||
{
|
||||
|
||||
}
|
||||
public void Draw(ContentManager manager)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects;
|
||||
public class LivingEntity : Entity
|
||||
{
|
||||
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -46,6 +47,14 @@ namespace ZoFo.GameCore
|
|||
UpdateGameEnded gameEnded = new UpdateGameEnded();
|
||||
networkManager.AddData(gameEnded);
|
||||
networkManager.CloseConnection();
|
||||
}
|
||||
internal void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
public void RegisterEntity(GameObject gameObject)
|
||||
{
|
||||
gameObjects.Add(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
@ -26,6 +26,9 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\MonogameLibrary\MonogameLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Content\Textures\GUI\" />
|
||||
</ItemGroup>
|
||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||
<Message Text="Restoring dotnet tools" Importance="High" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
|
|
Loading…
Add table
Reference in a new issue