diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index 8caaf29..ba94670 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -196,7 +196,6 @@ #begin Textures/Animations/testAnimationExample.animation /copy:Textures/Animations/testAnimationExample.animation -<<<<<<< HEAD #begin Textures/Animations/zombie_attack.animation /copy:Textures/Animations/zombie_attack.animation @@ -212,8 +211,6 @@ #begin Textures/Animations/zombie_walk.animation /copy:Textures/Animations/zombie_walk.animation -======= ->>>>>>> 46c28524c7c601856e78b88316c9caa71da724d3 #begin Textures/AnimationTextures/Character/hr-level1_idle.png /importer:TextureImporter /processor:TextureProcessor diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index 626f732..686400a 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -24,6 +24,7 @@ using ZoFo.GameCore.GUI; using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; using ZoFo.GameCore.GameObjects.MapObjects.StopObjects; using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies; +using ZoFo.GameCore.Graphics; namespace ZoFo.GameCore { public class Client @@ -157,8 +158,14 @@ namespace ZoFo.GameCore { var ent = FindEntityById(update.IdEntity); - ent.position = (update as UpdatePosition).NewPosition; - DebugHUD.Instance.Log("newPosition " + ent.position); + ent.position = (update as UpdatePosition).NewPosition; + } + else if (update is UpdateAnimation) + { + var ent = FindEntityById(update.IdEntity); + + ((ent as Entity).graphicsComponent as AnimatedGraphicsComponent).StartAnimation((update as UpdateAnimation).animationId); + DebugHUD.Instance.Log("new Animation " + ent.position); } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs index 4e9b972..108e4ba 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs @@ -12,5 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient public class UpdateAnimation : UpdateData { public UpdateAnimation() { UpdateType = "UpdateAnimation"; } + public string animationId { get; set; } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Entity.cs b/ZoFo/GameCore/GameObjects/Entities/Entity.cs index 456d8da..3b88ad8 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Entity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Entity.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers.CollisionManager; namespace ZoFo.GameCore.GameObjects.Entities @@ -36,6 +37,17 @@ namespace ZoFo.GameCore.GameObjects.Entities Update(); base.UpdateLogic(); } + + public void StartAnimation(string animationId) + { + (graphicsComponent as Graphics.AnimatedGraphicsComponent).StartAnimation(animationId); + AppManager.Instance.server.AddData(new GameManagers.NetworkManager.Updates.ServerToClient.UpdateAnimation() + { + animationId = animationId, + IdEntity = Id + }); + + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs index a82a70c..4e2ce66 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs @@ -11,7 +11,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies { class Zombie : Enemy { - public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "zombie_damaged" }, "zombie_damaged"); + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List { "zombie_damaged","zombie_walk","zombie_idle","zombie_attack","zombie_death" }, "zombie_walk"); public Zombie(Vector2 position) : base(position) { health = 5; @@ -26,8 +26,17 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies AppManager.Instance.server.players[0].position - position ); velocity=new Vector2(duration.X * speed, duration.Y*speed); - - + if (Random.Shared.NextDouble() > 0.9) + { + + StartAnimation("zombie_damaged"); + } + if (Random.Shared.NextDouble() > 0.9) + { + + StartAnimation("zombie_idle"); + } + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index 42d89c2..9ecec00 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -40,6 +40,7 @@ public class Player : LivingEntity float t; public void MovementLogic() { + StartAnimation("player_look_down");//gslkjfsnblkjsdfnnlkjbn;zkcjnb;kkjnzx;cjkb;kzjxb;kSErgo //velocity.X = 3+(float)Math.Sin(t); t++; if (InputPlayerRotation.X > 0.9) diff --git a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs index d590462..484ad90 100644 --- a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs @@ -125,8 +125,9 @@ namespace ZoFo.GameCore.Graphics buildSourceRectangle(); SetInterval(); - } + } + public void StopAnimation() { currentFrame = 0;