Merge branch 'NetworkLivingEntitiesSupport'

This commit is contained in:
AnloGames 2023-08-18 14:26:07 +03:00
commit 221f5f15a2
5 changed files with 19 additions and 18 deletions

View file

@ -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() public void MoveDown()
{ {

View file

@ -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; namespace DangerousD.GameCore.GameObjects;
@ -15,6 +17,14 @@ public abstract class LivingEntity : Entity
public override void SetPosition(Vector2 position) public override void SetPosition(Vector2 position)
{ {
_pos = 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 } //TODO befrend targetpos and physics engine

View file

@ -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 DangerousD.GameCore.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
@ -107,14 +109,14 @@ namespace DangerousD.GameCore.Graphics
public void StartAnimation(string startedanimationId) public void StartAnimation(string startedanimationId)
{ {
if (startedanimationId == "playerShootRight" && parentId == 17) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
{ {
string a = "2"; LivingEntity entity = AppManager.Instance.GameManager.livingEntities.Find(x => x.id == parentId);
} if (((entity is Player) || AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) && startedanimationId != GetCurrentAnimation)
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer && startedanimationId != GetCurrentAnimation)
{ {
AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero)); AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero));
} }
}
currentFrame = 0; currentFrame = 0;
currentAnimation = animations.Find(x => x.Id == startedanimationId); currentAnimation = animations.Find(x => x.Id == startedanimationId);

View file

@ -246,11 +246,6 @@ namespace DangerousD.GameCore
case NetworkTaskOperationEnum.ChangeState: case NetworkTaskOperationEnum.ChangeState:
if (networkTask.objId != GameManager.GetPlayer1.id) if (networkTask.objId != GameManager.GetPlayer1.id)
{ {
List<GraphicsComponent> gcs = new List<GraphicsComponent>();
foreach (var player in GameManager.players)
{
gcs.Add(player.GetGraphicsComponent());
}
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId); LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
if (entity != null) if (entity != null)
{ {

View file

@ -149,7 +149,6 @@ namespace DangerousD.GameCore
} }
} }
else else
{ {
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++) for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
{ {