From 4fd28308f2863c160b95620aabd5c8b51a3f9f63 Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Wed, 16 Aug 2023 13:56:25 +0300 Subject: [PATCH] NetworkTask init --- DangerousD/GameCore/Network/Json/JsonTask.cs | 12 --- DangerousD/GameCore/Network/NetworkTask.cs | 87 +++++++++++++++++++ .../Network/NetworkTaskOperationEnum.cs | 14 +++ 3 files changed, 101 insertions(+), 12 deletions(-) delete mode 100644 DangerousD/GameCore/Network/Json/JsonTask.cs create mode 100644 DangerousD/GameCore/Network/NetworkTask.cs create mode 100644 DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs diff --git a/DangerousD/GameCore/Network/Json/JsonTask.cs b/DangerousD/GameCore/Network/Json/JsonTask.cs deleted file mode 100644 index c04414a..0000000 --- a/DangerousD/GameCore/Network/Json/JsonTask.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DangerousD.GameCore.Network.Json -{ - public class JsonTask - { - } -} diff --git a/DangerousD/GameCore/Network/NetworkTask.cs b/DangerousD/GameCore/Network/NetworkTask.cs new file mode 100644 index 0000000..54fd5b4 --- /dev/null +++ b/DangerousD/GameCore/Network/NetworkTask.cs @@ -0,0 +1,87 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DangerousD.GameCore.Network +{ + [Serializable] + public class NetworkTask + { + public NetworkTaskOperationEnum operation { get; set; } + public string name { get; set; } + public int value { get; set; } + public int objId { get; set; } + public Vector2 position { get; set; } + public Vector2 velocity { get; set; } + public Type type { get; set; } + + + /// + /// Нанести урон сущности + /// + /// + /// + public NetworkTask(int LivingEntityId, int Damage) + { + operation = NetworkTaskOperationEnum.TakeDamage; + objId = LivingEntityId; + value = Damage; + } + + /// + /// Проиграть звук на позиции + /// + /// + /// + public NetworkTask(Vector2 SoundPosition, string SoundName) + { + operation = NetworkTaskOperationEnum.SendSound; + position = SoundPosition; + name = SoundName; + } + + /// + /// Создать сущность на позиции с заданной скоростью и присвоить её родительской сущности + /// + /// + /// + /// + /// + public NetworkTask(Type EntityType, Vector2 EntityPosition, Vector2 EntityVelocity, int ParentId) + { + operation = NetworkTaskOperationEnum.CreateEntity; + type = EntityType; + position = EntityPosition; + velocity = EntityVelocity; + objId = ParentId; + } + + /// + /// Изменить позицию сущности со сложной логикой(игрок) + /// + /// + /// + public NetworkTask(int EntityId, Vector2 EntityPosition) + { + operation = NetworkTaskOperationEnum.SendPosition; + objId = EntityId; + position = EntityPosition; + } + /// + /// Изменяет состояние и/или скорость сущности + /// + /// + /// + /// + public NetworkTask(int EntityId, string StateName, Vector2 EntityVelocity) + { + operation = NetworkTaskOperationEnum.ChangeState; + objId = EntityId; + name = StateName; + velocity = EntityVelocity; + } + } +} diff --git a/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs b/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs new file mode 100644 index 0000000..49fee15 --- /dev/null +++ b/DangerousD/GameCore/Network/NetworkTaskOperationEnum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DangerousD.GameCore.Network +{ + [Serializable] + public enum NetworkTaskOperationEnum + { + TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState + } +}