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 5412e4c..0941181 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -246,11 +246,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++) {