From c0997c903cb25c88cde0b6d3816338181faf762a Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Fri, 18 Aug 2023 13:35:16 +0300 Subject: [PATCH] =?UTF-8?q?LivingEntitySendPositionSupport(=D0=97=D0=9E?= =?UTF-8?q?=D0=9C=D0=91=D0=98=20=D0=A5=D0=9E=D0=94=D0=AF=D0=A2!!!)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameObjects/LivingEntities/Player/Player.cs | 5 ----- DangerousD/GameCore/GameObjects/LivingEntity.cs | 12 +++++++++++- DangerousD/GameCore/Graphics/GraphicsComponent.cs | 14 ++++++++------ DangerousD/GameCore/Managers/AppManager.cs | 5 ----- DangerousD/GameCore/Managers/GameManager.cs | 1 - 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index eaae151..4343570 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -247,11 +247,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } } } - if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) - { - NetworkTask task = new NetworkTask(id, Pos); - AppManager.Instance.NetworkTasks.Add(task); - } } public void MoveDown() { diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index d311095..78ea17c 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -1,4 +1,6 @@ -using Microsoft.Xna.Framework; +using DangerousD.GameCore.GameObjects.LivingEntities; +using DangerousD.GameCore.Network; +using Microsoft.Xna.Framework; namespace DangerousD.GameCore.GameObjects; @@ -15,6 +17,14 @@ public abstract class LivingEntity : Entity public override void SetPosition(Vector2 position) { _pos = position; + if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) + { + NetworkTask task = new NetworkTask(id, _pos); + if (this is Player || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) + { + AppManager.Instance.NetworkTasks.Add(task); + } + } } //TODO befrend targetpos and physics engine diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index 27eeea8..1ac6aa8 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -1,4 +1,6 @@ -using DangerousD.GameCore.Managers; +using DangerousD.GameCore.GameObjects; +using DangerousD.GameCore.GameObjects.LivingEntities; +using DangerousD.GameCore.Managers; using DangerousD.GameCore.Network; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; @@ -107,13 +109,13 @@ namespace DangerousD.GameCore.Graphics public void StartAnimation(string startedanimationId) { - if (startedanimationId == "playerShootRight" && parentId == 17) - { - string a = "2"; - } - if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer && startedanimationId != GetCurrentAnimation) + if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) { + LivingEntity entity = AppManager.Instance.GameManager.livingEntities.Find(x => x.id == parentId); + if (((entity is Player) || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) && startedanimationId != GetCurrentAnimation) + { AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero)); + } } currentFrame = 0; currentAnimation = animations.Find(x => x.Id == startedanimationId); diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 3ad6cc3..5a2cf29 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -242,11 +242,6 @@ namespace DangerousD.GameCore case NetworkTaskOperationEnum.ChangeState: if (networkTask.objId != GameManager.GetPlayer1.id) { - List gcs = new List(); - foreach (var player in GameManager.players) - { - gcs.Add(player.GetGraphicsComponent()); - } LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId); if (entity != null) { diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index ae7bf59..8d1c7c4 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -149,7 +149,6 @@ namespace DangerousD.GameCore } } else - { for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++) {