Merge branch 'Development' into GUI_gr

This commit is contained in:
SergoDobro 2024-08-16 09:33:06 +03:00 committed by GitHub
commit 01004096dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 1005 additions and 167 deletions

View file

@ -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

View file

@ -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);
}
}

42
ZoFo/GameCore/Client.cs Normal file
View file

@ -0,0 +1,42 @@
using System.Collections.Generic;
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
{
ClientNetworkManager networkManager;
public Client()
{
networkManager = new ClientNetworkManager();
networkManager.GetDataSent += OnDataSend;
}
public void OnDataSend(string data)
{
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
// тут будет switch
}
public void GameEndedUnexpectedly(){ }
public void JoinRoom(){ }
public void JoinYourself(){ }
internal void Update(GameTime gameTime)
{
}
internal void Draw(SpriteBatch spriteBatch)
{
}
}
}

View file

@ -4,9 +4,11 @@ using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
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;
@ -26,13 +28,16 @@ namespace ZoFo.GameCore.GameManagers
public AbstractGUI currentGUI;
public DebugHUD debugHud;
public Point CurentScreenResolution = new Point(1920, 1080);
//public Client client;
//public Server server;
public Client client;
public Server server;
#region Managers
public InputManager InputManager;
public ItemManager.ItemManager ItemManager;
public AnimationBuilder animationBuilder{get;set; }
#endregion
@ -91,11 +96,11 @@ namespace ZoFo.GameCore.GameManagers
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;
@ -116,7 +121,7 @@ namespace ZoFo.GameCore.GameManagers
{
case GameState.ClientPlaying:
case GameState.HostPlaying:
//client.Draw(_spriteBatch);
client.Draw(_spriteBatch);
break;
case GameState.NotPlaying:
default:
@ -131,11 +136,11 @@ namespace ZoFo.GameCore.GameManagers
}
public void SetGUI(AbstractGUI gui)
{
currentGUI = gui;
currentGUI = gui;
currentGUI.Initialize();
currentGUI.LoadContent();
//TODO
//TODO
}
public void GameEnded(Dictionary<string, int> lootIGot)

View file

@ -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.Entities.LivingEntities.Player;
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)
{
}
}
}

View file

@ -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)
//{
//}
}
}

View 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)
{
}
}
}

View file

@ -0,0 +1,37 @@
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.ItemManager
{
class ItemInfo
{
//поля
string tag;
string textureName;
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;
}
//методы
public void LoadTexture()
{
//я что-то хз как это
itemTexture=AppManager.Instance.Content.Load<Texture2D>(textureName);
}
}
}

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.ItemManager
{
public class ItemManager
{
//поля
Dictionary<string, ItemInfo> tagItemPairs;
//методы
ItemInfo GetItemInfo(string tag)
{
return tagItemPairs.GetValueOrDefault(tag);
}
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));
}
}
}

View 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
}
}
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.ItemManager
{
class WeaponItemInfo: EquippableItemInfo
{
//поля
float damage;
public WeaponItemInfo(string tag) : base(tag)
{
}
}
}

View 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.MapManager.MapElements
{
public class Chunk
{
public int[] Data { get; set; }
public int Height { get; set; }
public int Width { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
}

View 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.MapManager.MapElements
{
public class Layer
{
public List<Chunk> Chunks { get; set; }
public int Height { get; set; }
public int Width { get; set; }
public int Id { get; set; }
public bool Visibility { get; set; }
}
}

View 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.MapManager.MapElements
{
public class TileMap
{
public bool Infinite { get; set; }
public int TileHeight { get; set; }
public int TileWidth { get; set; }
public List<TileSetInfo> TileSets { get; set; }
public List<Layer> Layers { get; set; }
}
}

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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; }
}
}

View file

@ -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; }
}
}

View file

@ -0,0 +1,72 @@
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
{
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 TileSet LoadTileSet(string path)
{
using (StreamReader reader = new StreamReader(path))
{
string data = reader.ReadToEnd();
return JsonSerializer.Deserialize<TileSet>(data);
}
}
}
}

View file

@ -0,0 +1,85 @@
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 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
{
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()
{
socket.Shutdown(SocketShutdown.Both);
socket.Close();
}
/// <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();
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();
Thread listen = new Thread(StartListening);
listen.Start();
}
//поток 2
public void StartListening()
{
while(socket.Connected)
{
byte[] bytes = new byte[2048];
var countAnsw = socket.Receive(bytes);
string update = Encoding.UTF8.GetString(bytes, 0, countAnsw); // обновление отосланные сервером
GetDataSent(update);
}
}
}
}

View file

@ -0,0 +1,100 @@
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics.PackedVector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
namespace ZoFo.GameCore.GameManagers.NetworkManager
{
public class ServerNetworkManager
{
private IPAddress ip = IPAddress.Any;
private int port = 7632;
private IPEndPoint endPoint;
private Socket socket;
private List<Socket> clients;
private List<IUpdateData> updates;
public delegate void OnDataSend(string data);
public event OnDataSend GetDataSend; // event
Dictionary<Socket, Thread> managerThread;
public void Init() //create Socket
{
endPoint = new IPEndPoint(ip, port);
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
managerThread = new Dictionary<Socket, Thread>();
}
public void SendData() //отправляет клиенту Data
{
string data = JsonSerializer.Serialize(updates);
var databytes = Encoding.UTF8.GetBytes(data);
foreach (var item in clients)
{
item.SendAsync(databytes);
}
}
public void AddData(IUpdateData data)//добавляет в лист updates новую data
{
updates.Add(data);
}
public void CloseConnection() //По сути коне игры и отключение игроков
{
foreach (var item in clients)
{
//Закрывает сокеты клиентов
item.Shutdown(SocketShutdown.Both);
item.Close();
}
foreach (var item in managerThread)
{
foreach (var socket in clients)
{
//Закрывает потоки клиентов
managerThread[socket].Interrupt();
}
}
//очищает листы
managerThread.Clear();
clients.Clear();
}
//Потоки Клиентов
public void StartWaitingForPlayers(object players)//Слушает игроков, которые хотят подключиться
{
int playNumber = (int)players;
socket.Bind(endPoint);
socket.Listen(playNumber);
for (int i = 0; i < playNumber; i++)
{
Socket client = socket.Accept();
Thread thread = new Thread(StartListening);
thread.Start(client);
managerThread.Add(client, thread);
clients.Add(client); //добавляем клиентов в лист
}
}
private void StartListening(object socket)//начать слушать клиентов в самой игре активируют Ивент
{
// obj to Socket
Socket client = (Socket)socket;
while (client.Connected)
{
var buff = new byte[1024];
var answ = client.Receive(buff);
string response = Encoding.UTF8.GetString(buff, 0, answ);
GetDataSend(response);
}
Thread.Sleep(-1);
}
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer
{
public class UpdateInput :IUpdateData
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer
{
public class UpdatePlayerExit : IUpdateData
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates
{
[JsonDerivedType(typeof(UpdateAnimation))]
[JsonDerivedType(typeof(UpdateEntityHealth))]
[JsonDerivedType(typeof(UpdateGameEnded))]
[JsonDerivedType(typeof(UpdateGameObjectCreated))]
[JsonDerivedType(typeof(UpdateLoot))]
[JsonDerivedType(typeof(UpdatePlayerParametrs))]
[JsonDerivedType(typeof(UpdatePosition))]
[JsonDerivedType(typeof(UpdateInput))]
[JsonDerivedType(typeof(UpdatePlayerExit))]
public interface IUpdateData
{
public int IdEntity { get; set; } //Id объекта
public string UpdateType { get; set; } //тип обновления
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateAnimation : IUpdateData //хранит новую анимации
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateEntityHealth : IUpdateData//хранит новое хп entity
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateGameEnded : IUpdateData //хранит полученый лут и уведомляет о конце игры
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateGameObjectCreated : IUpdateData //Хранит объект, который только отправили
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateLoot : IUpdateData //Хранит лут
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdatePlayerParametrs : IUpdateData //Хранит хп, радиацию
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdatePosition : IUpdateData //Хранит новую позицию
{
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}
}

View file

@ -1,6 +0,0 @@
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates;
public class Update
{
}

View file

@ -1,7 +0,0 @@
using System;
namespace ZoFo.GameCore.GameObjects;
public class Bullet : Projectile
{
}

View file

@ -1,7 +0,0 @@
using System;
namespace ZoFo.GameCore.GameObjects;
public class Collectable : Entity
{
}

View 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.Entities
{
public abstract class Entity : GameObject
{
public int Id { get; set; }
public void CollisionComponent()
{
}
public void AnimationComponent()
{
}
public void UpdateLogic()
{
}
}
}
//вектор
//вилосити
//поситион
//текстура

View file

@ -0,0 +1,7 @@
using System;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
public class Collectable : Entity
{
}

View file

@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Net.Mime;
using System.Reflection;
using Microsoft.Xna.Framework.Content;
namespace ZoFo.GameCore.GameObjects;
public class Enemy : LivingEntity
{
using System;
using System.Collections.Generic;
using System.Net.Mime;
using System.Reflection;
using Microsoft.Xna.Framework.Content;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
public class Enemy : LivingEntity
{
}

View file

@ -0,0 +1,21 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameObjects.Entities;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities;
public class LivingEntity : Entity
{
public Vector2 velocity;
public Vector2 position;
public void TextureLoad(SpriteBatch spriteBatch)
{
}
}

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameObjects
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player
{
internal interface IPlayerWeaponAttack
{

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameObjects
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player
{
internal class LootData
{

View file

@ -0,0 +1,7 @@
using System;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
public class Player : LivingEntity
{
}

View file

@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameObjects
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player.PlayerAttacks
{
internal class GunAttack:IPlayerWeaponAttack
internal class GunAttack : IPlayerWeaponAttack
{
}

View file

@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameObjects
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player.PlayerAttacks
{
internal class HandAttack:IPlayerWeaponAttack
internal class HandAttack : IPlayerWeaponAttack
{
}

View file

@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZoFo.GameCore.GameObjects
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player.PlayerAttacks
{
internal class SwordAttack:IPlayerWeaponAttack
internal class SwordAttack : IPlayerWeaponAttack
{
}

View file

@ -0,0 +1,7 @@
using System;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
public class Bullet : Projectile
{
}

View file

@ -0,0 +1,7 @@
using System;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
public class Rock : Projectile
{
}

View file

@ -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)
{
}
}

View file

@ -1,7 +0,0 @@
using System;
namespace ZoFo.GameCore.GameObjects;
public class LivingEntity : Entity
{
}

View file

@ -1,7 +0,0 @@
using System;
namespace ZoFo.GameCore.GameObjects;
public class Player : LivingEntity
{
}

View file

@ -1,4 +1,5 @@
using System;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities;
namespace ZoFo.GameCore.GameObjects;
public class Projectile : LivingEntity

View file

@ -1,7 +0,0 @@
using System;
namespace ZoFo.GameCore.GameObjects;
public class Rock : Projectile
{
}

View file

@ -1,8 +0,0 @@
using System;
namespace ZoFo.GameCore.GameObjects;
public class StopObject
{
}

View file

@ -0,0 +1,8 @@
using System;
namespace ZoFo.GameCore.GameObjects.StopObjects;
public class StopObject
{
}

61
ZoFo/GameCore/Server.cs Normal file
View file

@ -0,0 +1,61 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.NetworkManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameObjects.Entities;
namespace ZoFo.GameCore
{
public class Server
{
private List<GameObject> gameObjects;
private ServerNetworkManager networkManager;
private List<Entity> entity; //entity
public Server()
{
networkManager = new ServerNetworkManager();
networkManager.GetDataSend += OnDataSend;
}
public void OnDataSend(string data)
{
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
//ТУТ Switch case будет честное слово
}
/// <summary>
/// Для красоты) Отдел Серверов
/// </summary>
/// <param name="data"></param>
public void AddData(IUpdateData data)//добавляет в лист updates новую data
{
networkManager.AddData(data);
}
public void CreateRoom(int players) //Создает комнату и запускает ожидание подключений
{
networkManager.StartWaitingForPlayers(players);
}
// public void StartGame() { } принудительный запуск
public void EndGame() //Добавляет UpdateGameEnded и отключает игроков
{
UpdateGameEnded gameEnded = new UpdateGameEnded();
networkManager.AddData(gameEnded);
networkManager.CloseConnection();
}
internal void Update(GameTime gameTime)
{
}
public void RegisterEntity(GameObject gameObject)
{
gameObjects.Add(gameObject);
}
}
}

View file

@ -1,6 +1,5 @@
/*using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.NetworkManager;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@ -85,7 +84,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
animations = new List<AnimationContainer>();
foreach (var id in animationsId)
{
animations.Add(AppManager.Instance.AnimationBuilder.Animations.Find(x => x.Id == id));
animations.Add(AppManager.Instance.animationBuilder.Animations.Find(x => x.Id == id));
if (id == neitralAnimationId)
{
neitralAnimation = animations.Last();
@ -110,6 +109,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
public void StartAnimation(string startedanimationId)
{
/*
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
{
LivingEntity entity = AppManager.Instance.GameManager.livingEntities.Find(x => x.id == parentId);
@ -118,6 +118,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero));
}
}
*/
currentFrame = 0;
currentAnimation = animations.Find(x => x.Id == startedanimationId);
@ -253,6 +254,8 @@ namespace ZoFo.GameCore.ZoFo_graphics
CameraPosition.X -= 200;
CameraPosition.Y -= 120;
// TODO
/*
if (CameraPosition.X > AppManager.Instance.GameManager.CameraBorder.Y - 460)
{
CameraPosition.X = (int)AppManager.Instance.GameManager.CameraBorder.Y - 460;
@ -270,9 +273,10 @@ namespace ZoFo.GameCore.ZoFo_graphics
{
CameraPosition.Y = (int)AppManager.Instance.GameManager.CameraBorder.W - 240;
}
AppManager.Instance.DebugHUD.Set("CameraPosition", $"{CameraPosition.X}, {CameraPosition.Y}");
*/
}
public static Point CameraPosition = new Point(-700, 300);
}
}
*/

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
@ -10,6 +10,11 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Compile Remove="GameCore\GameObjects\BaseClasses\**" />
<EmbeddedResource Remove="GameCore\GameObjects\BaseClasses\**" />
<None Remove="GameCore\GameObjects\BaseClasses\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />

11
macos-fix-mgcb.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
brew install freetype
brew install freeimage
mgcb_ver=$(ls ~/.nuget/packages/dotnet-mgcb/)
mgcb_path=~/.nuget/packages/dotnet-mgcb/$mgcb_ver/tools/net6.0/any/
rm $mgcb_path/libfreetype6.dylib $mgcb_path/libFreeImage.dylib
ln -s /opt/homebrew/lib/libfreetype.dylib $mgcb_path/libfreetype6.dylib
ln -s /opt/homebrew/lib/libfreeimage.dylib $mgcb_path/libFreeImage.dylib