updateAnimations
This commit is contained in:
parent
122dada6ea
commit
ba4fce8c24
7 changed files with 37 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -158,7 +159,13 @@ namespace ZoFo.GameCore
|
|||
var ent = FindEntityById(update.IdEntity);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,5 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
|||
public class UpdateAnimation : UpdateData
|
||||
{
|
||||
public UpdateAnimation() { UpdateType = "UpdateAnimation"; }
|
||||
public string animationId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
|
|||
{
|
||||
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)
|
||||
{
|
||||
health = 5;
|
||||
|
@ -26,7 +26,16 @@ 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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -125,6 +125,7 @@ namespace ZoFo.GameCore.Graphics
|
|||
|
||||
buildSourceRectangle();
|
||||
SetInterval();
|
||||
|
||||
}
|
||||
|
||||
public void StopAnimation()
|
||||
|
|
Loading…
Add table
Reference in a new issue