updateAnimations

This commit is contained in:
Kaktus200020 2024-08-18 19:27:38 +03:00
parent 122dada6ea
commit ba4fce8c24
7 changed files with 37 additions and 9 deletions

View file

@ -196,7 +196,6 @@
#begin Textures/Animations/testAnimationExample.animation #begin Textures/Animations/testAnimationExample.animation
/copy:Textures/Animations/testAnimationExample.animation /copy:Textures/Animations/testAnimationExample.animation
<<<<<<< HEAD
#begin Textures/Animations/zombie_attack.animation #begin Textures/Animations/zombie_attack.animation
/copy:Textures/Animations/zombie_attack.animation /copy:Textures/Animations/zombie_attack.animation
@ -212,8 +211,6 @@
#begin Textures/Animations/zombie_walk.animation #begin Textures/Animations/zombie_walk.animation
/copy:Textures/Animations/zombie_walk.animation /copy:Textures/Animations/zombie_walk.animation
=======
>>>>>>> 46c28524c7c601856e78b88316c9caa71da724d3
#begin Textures/AnimationTextures/Character/hr-level1_idle.png #begin Textures/AnimationTextures/Character/hr-level1_idle.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

View file

@ -24,6 +24,7 @@ using ZoFo.GameCore.GUI;
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects; using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies; using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore namespace ZoFo.GameCore
{ {
public class Client public class Client
@ -157,8 +158,14 @@ namespace ZoFo.GameCore
{ {
var ent = FindEntityById(update.IdEntity); var ent = FindEntityById(update.IdEntity);
ent.position = (update as UpdatePosition).NewPosition; ent.position = (update as UpdatePosition).NewPosition;
DebugHUD.Instance.Log("newPosition " + ent.position); }
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);
} }
} }

View file

@ -12,5 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
public class UpdateAnimation : UpdateData public class UpdateAnimation : UpdateData
{ {
public UpdateAnimation() { UpdateType = "UpdateAnimation"; } public UpdateAnimation() { UpdateType = "UpdateAnimation"; }
public string animationId { get; set; }
} }
} }

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager; using ZoFo.GameCore.GameManagers.CollisionManager;
namespace ZoFo.GameCore.GameObjects.Entities namespace ZoFo.GameCore.GameObjects.Entities
@ -36,6 +37,17 @@ namespace ZoFo.GameCore.GameObjects.Entities
Update(); Update();
base.UpdateLogic(); 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
});
}
} }
} }

View file

@ -11,7 +11,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
{ {
class Zombie : Enemy class Zombie : Enemy
{ {
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged" }, "zombie_damaged"); public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged","zombie_walk","zombie_idle","zombie_attack","zombie_death" }, "zombie_walk");
public Zombie(Vector2 position) : base(position) public Zombie(Vector2 position) : base(position)
{ {
health = 5; health = 5;
@ -26,8 +26,17 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
AppManager.Instance.server.players[0].position - position AppManager.Instance.server.players[0].position - position
); );
velocity=new Vector2(duration.X * speed, duration.Y*speed); 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");
}
} }
} }
} }

View file

@ -40,6 +40,7 @@ public class Player : LivingEntity
float t; float t;
public void MovementLogic() public void MovementLogic()
{ {
StartAnimation("player_look_down");//gslkjfsnblkjsdfnnlkjbn;zkcjnb;kkjnzx;cjkb;kzjxb;kSErgo
//velocity.X = 3+(float)Math.Sin(t); //velocity.X = 3+(float)Math.Sin(t);
t++; t++;
if (InputPlayerRotation.X > 0.9) if (InputPlayerRotation.X > 0.9)

View file

@ -125,8 +125,9 @@ namespace ZoFo.GameCore.Graphics
buildSourceRectangle(); buildSourceRectangle();
SetInterval(); SetInterval();
}
}
public void StopAnimation() public void StopAnimation()
{ {
currentFrame = 0; currentFrame = 0;