COnnected maploader and objects creation + mapobject fix + graphicsDeviceFix
This commit is contained in:
parent
5ef0a660cc
commit
8bf1bff778
11 changed files with 96 additions and 32 deletions
|
@ -82,8 +82,6 @@
|
||||||
/processorParam:Quality=Best
|
/processorParam:Quality=Best
|
||||||
/build:sounds/Zombi stoit.wav
|
/build:sounds/Zombi stoit.wav
|
||||||
|
|
||||||
#begin Textures/GUI/checkboxs_off.png
|
|
||||||
|
|
||||||
#begin Textures/GUI/background/base.png
|
#begin Textures/GUI/background/base.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
@ -142,9 +140,9 @@
|
||||||
/processorParam:ResizeToPowerOfTwo=False
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
/processorParam:MakeSquare=False
|
/processorParam:MakeSquare=False
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:Textures/GUI/checkboxs_off.png
|
/build:Textures/GUI/checkboxs_off-on.png
|
||||||
|
|
||||||
#begin Textures/GUI/checkboxs_off-on.png
|
#begin Textures/GUI/checkboxs_off.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
/processorParam:ColorKeyColor=255,0,255,255
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
@ -154,7 +152,7 @@
|
||||||
/processorParam:ResizeToPowerOfTwo=False
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
/processorParam:MakeSquare=False
|
/processorParam:MakeSquare=False
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:Textures/GUI/checkboxs_off-on.png
|
/build:Textures/GUI/checkboxs_off.png
|
||||||
|
|
||||||
#begin Textures/GUI/checkboxs_on.png
|
#begin Textures/GUI/checkboxs_on.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
|
@ -192,18 +190,6 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:Textures/GUI/mouse.png
|
/build:Textures/GUI/mouse.png
|
||||||
|
|
||||||
#begin Textures/GUI/switch.png
|
|
||||||
/importer:TextureImporter
|
|
||||||
/processor:TextureProcessor
|
|
||||||
/processorParam:ColorKeyColor=255,0,255,255
|
|
||||||
/processorParam:ColorKeyEnabled=True
|
|
||||||
/processorParam:GenerateMipmaps=False
|
|
||||||
/processorParam:PremultiplyAlpha=True
|
|
||||||
/processorParam:ResizeToPowerOfTwo=False
|
|
||||||
/processorParam:MakeSquare=False
|
|
||||||
/processorParam:TextureFormat=Color
|
|
||||||
/build:Textures/GUI/switch.png
|
|
||||||
|
|
||||||
#begin Textures/GUI/Switch_backgrownd.png
|
#begin Textures/GUI/Switch_backgrownd.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
@ -216,3 +202,27 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:Textures/GUI/Switch_backgrownd.png
|
/build:Textures/GUI/Switch_backgrownd.png
|
||||||
|
|
||||||
|
#begin Textures/GUI/switch.png
|
||||||
|
/importer:TextureImporter
|
||||||
|
/processor:TextureProcessor
|
||||||
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
/processorParam:ColorKeyEnabled=True
|
||||||
|
/processorParam:GenerateMipmaps=False
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
|
/processorParam:MakeSquare=False
|
||||||
|
/processorParam:TextureFormat=Color
|
||||||
|
/build:Textures/GUI/switch.png
|
||||||
|
|
||||||
|
#begin Textures/TileSets/TilesetFloor.png
|
||||||
|
/importer:TextureImporter
|
||||||
|
/processor:TextureProcessor
|
||||||
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
/processorParam:ColorKeyEnabled=True
|
||||||
|
/processorParam:GenerateMipmaps=False
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
|
/processorParam:MakeSquare=False
|
||||||
|
/processorParam:TextureFormat=Color
|
||||||
|
/build:Textures/TileSets/TilesetFloor.png;Textures/TileSets/TileSet 1.png
|
||||||
|
|
||||||
|
|
BIN
ZoFo/Content/Textures/TileSets/TilesetFloor.png
Normal file
BIN
ZoFo/Content/Textures/TileSets/TilesetFloor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
|
@ -50,6 +50,7 @@ namespace ZoFo.GameCore
|
||||||
}
|
}
|
||||||
internal void Draw(SpriteBatch spriteBatch)
|
internal void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@ using MonogameLibrary.UI.Elements;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GUI;
|
namespace ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
public class HUD
|
public class HUD : AbstractGUI
|
||||||
{
|
{
|
||||||
protected UIManager Manager = new();
|
protected UIManager Manager = new();
|
||||||
protected List<DrawableUIElement> Elements = new();
|
protected List<DrawableUIElement> Elements = new();
|
||||||
|
@ -39,6 +39,10 @@ public class HUD
|
||||||
|
|
||||||
public virtual void Draw(SpriteBatch spriteBatch)
|
public virtual void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
Manager.Draw(spriteBatch);
|
//Manager.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateUI()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -41,11 +41,14 @@ public class SelectModeMenu : AbstractGUI
|
||||||
// single
|
// single
|
||||||
Server server = new Server(); //Server Logic SinglePlayer
|
Server server = new Server(); //Server Logic SinglePlayer
|
||||||
Client client = new Client();
|
Client client = new Client();
|
||||||
server.CreateRoom(1);
|
|
||||||
client.JoinYourself();
|
|
||||||
AppManager.Instance.SetServer(server);
|
AppManager.Instance.SetServer(server);
|
||||||
AppManager.Instance.SetClient(client);
|
AppManager.Instance.SetClient(client);
|
||||||
AppManager.Instance.ChangeState(GameState.HostPlaying);
|
AppManager.Instance.ChangeState(GameState.HostPlaying);
|
||||||
|
AppManager.Instance.SetGUI(new HUD());
|
||||||
|
|
||||||
|
//server.CreateRoom(1);
|
||||||
|
//client.JoinYourself();
|
||||||
|
server.StartGame();
|
||||||
|
|
||||||
string key = client.IsConnected.ToString();
|
string key = client.IsConnected.ToString();
|
||||||
AppManager.Instance.debugHud.Set(key,"SinglePlayer");
|
AppManager.Instance.debugHud.Set(key,"SinglePlayer");
|
||||||
|
|
|
@ -91,8 +91,12 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
||||||
{
|
{
|
||||||
using (StreamReader reader = new StreamReader(path))
|
using (StreamReader reader = new StreamReader(path))
|
||||||
{
|
{
|
||||||
|
var options = new JsonSerializerOptions //TODO Remove
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
string data = reader.ReadToEnd();
|
string data = reader.ReadToEnd();
|
||||||
return JsonSerializer.Deserialize<TileSet>(data);
|
return JsonSerializer.Deserialize<TileSet>(data, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
||||||
{
|
{
|
||||||
public abstract class Entity : GameObject
|
public abstract class Entity : GameObject
|
||||||
{
|
{
|
||||||
protected override GraphicsComponent graphicsComponent => null;
|
public override GraphicsComponent graphicsComponent => null;
|
||||||
public CollisionComponent collisionComponent { get; protected set; }
|
public CollisionComponent collisionComponent { get; protected set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
protected Entity(Vector2 position) : base(position)
|
protected Entity(Vector2 position) : base(position)
|
||||||
|
|
|
@ -11,12 +11,13 @@ public abstract class GameObject
|
||||||
{
|
{
|
||||||
public Vector2 position;
|
public Vector2 position;
|
||||||
public Vector2 rotation; //вектор направления объекта
|
public Vector2 rotation; //вектор направления объекта
|
||||||
protected abstract GraphicsComponent graphicsComponent { get; }
|
public abstract GraphicsComponent graphicsComponent { get; }
|
||||||
|
|
||||||
#region ServerSide
|
#region ServerSide
|
||||||
public GameObject(Vector2 position)
|
public GameObject(Vector2 position)
|
||||||
{
|
{
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
AppManager.Instance.server.RegisterGameObject(this);
|
||||||
}
|
}
|
||||||
public virtual void UpdateLogic(GameTime gameTime)
|
public virtual void UpdateLogic(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,12 +14,13 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
|
||||||
{
|
{
|
||||||
public virtual bool IsColliderOn { get; protected set; } = true;
|
public virtual bool IsColliderOn { get; protected set; } = true;
|
||||||
private Rectangle _sourceRectangle;
|
private Rectangle _sourceRectangle;
|
||||||
protected override GraphicsComponent graphicsComponent => new("tiles");
|
public override GraphicsComponent graphicsComponent => new();
|
||||||
|
|
||||||
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position)
|
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position)
|
||||||
{
|
{
|
||||||
_sourceRectangle = sourceRectangle;
|
_sourceRectangle = sourceRectangle;
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y);
|
||||||
|
graphicsComponent.BuildComponent("Textures\\TileSets\\"+textureName);
|
||||||
}
|
}
|
||||||
public override void Draw(SpriteBatch spriteBatch)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ZoFo.GameCore.GameManagers.MapManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager;
|
using ZoFo.GameCore.GameManagers.NetworkManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
|
@ -21,18 +22,33 @@ namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
networkManager = new ServerNetworkManager();
|
networkManager = new ServerNetworkManager();
|
||||||
networkManager.GetDataSend += OnDataSend;
|
networkManager.GetDataSend += OnDataSend;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#region server logic as App
|
||||||
|
//TODO Comment pls
|
||||||
public void OnDataSend(string data)
|
public void OnDataSend(string data)
|
||||||
{
|
{
|
||||||
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
|
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
|
||||||
|
for (int i = 0; i < updateDatas.Count; i++) {
|
||||||
//ТУТ Switch case будет честное слово
|
ProcessIUpdateData(updateDatas[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка апдейтсов, которые нам прислал клиент
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="updateData"></param>
|
||||||
|
public void ProcessIUpdateData(IUpdateData updateData)
|
||||||
|
{
|
||||||
|
|
||||||
|
//ТУТ Switch case будет честное слово
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Для красоты) Отдел Серверов
|
/// Для красоты) Отдел Серверов
|
||||||
|
/// добавляет в лист updates новую data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
public void AddData(IUpdateData data)//добавляет в лист updates новую data
|
public void AddData(IUpdateData data)
|
||||||
{
|
{
|
||||||
networkManager.AddData(data);
|
networkManager.AddData(data);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +62,18 @@ namespace ZoFo.GameCore
|
||||||
networkManager.Start(players);
|
networkManager.Start(players);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void StartGame() { } принудительный запуск
|
/// <summary>
|
||||||
|
/// Запуск игры в комнате
|
||||||
|
/// </summary>
|
||||||
|
public void StartGame() {
|
||||||
|
|
||||||
|
//TODO начинает рассылку и обмен пакетами игры
|
||||||
|
//Грузит карту
|
||||||
|
|
||||||
|
gameObjects = new List<GameObject>();
|
||||||
|
entities = new List<Entity>();
|
||||||
|
new MapManager().LoadMap();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавляет UpdateGameEnded и отключает игроков
|
/// Добавляет UpdateGameEnded и отключает игроков
|
||||||
|
@ -57,7 +84,7 @@ namespace ZoFo.GameCore
|
||||||
networkManager.AddData(gameEnded);
|
networkManager.AddData(gameEnded);
|
||||||
networkManager.CloseConnection();
|
networkManager.CloseConnection();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
private List<GameObject> gameObjects;
|
private List<GameObject> gameObjects;
|
||||||
private List<Entity> entities; //entity
|
private List<Entity> entities; //entity
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
|
@ -80,9 +107,10 @@ namespace ZoFo.GameCore
|
||||||
/// Регистрирует игровой объект
|
/// Регистрирует игровой объект
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameObject"></param>
|
/// <param name="gameObject"></param>
|
||||||
public void RegisterEntity(GameObject gameObject)
|
public void RegisterGameObject(GameObject gameObject)
|
||||||
{
|
{
|
||||||
gameObjects.Add(gameObject);
|
gameObjects.Add(gameObject);
|
||||||
|
AddData(new UpdateTileCreated());//TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,14 @@ namespace ZoFo.GameCore.ZoFo_graphics
|
||||||
|
|
||||||
public GraphicsComponent(string textureName)
|
public GraphicsComponent(string textureName)
|
||||||
{
|
{
|
||||||
|
BuildComponent(textureName);
|
||||||
|
}
|
||||||
|
public GraphicsComponent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public void BuildComponent(string textureName)
|
||||||
|
{
|
||||||
|
|
||||||
animations = new List<AnimationContainer>();
|
animations = new List<AnimationContainer>();
|
||||||
textures = new List<Texture2D>();
|
textures = new List<Texture2D>();
|
||||||
var texture = AppManager.Instance.Content.Load<Texture2D>(textureName);
|
var texture = AppManager.Instance.Content.Load<Texture2D>(textureName);
|
||||||
|
@ -141,6 +149,10 @@ namespace ZoFo.GameCore.ZoFo_graphics
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
|
if (currentAnimation is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (interval == 0)
|
if (interval == 0)
|
||||||
{
|
{
|
||||||
currentFrame++;
|
currentFrame++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue