diff --git a/DangerousD/Content/animations/HunchmanAttackRight b/DangerousD/Content/animations/HunchmanAttackRight index 2252c3b..482d7f3 100644 --- a/DangerousD/Content/animations/HunchmanAttackRight +++ b/DangerousD/Content/animations/HunchmanAttackRight @@ -1 +1 @@ -{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"} +{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index cc6ecd5..f180842 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -14,9 +14,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { public Hunchman(Vector2 position) : base(position) { + Width = 72; + Height = 72; + monster_speed = 5; + name = "HunchMan"; + velocity = new Vector2(monster_speed, 0); } - protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight"); + protected override GraphicsComponent GraphicsComponent { get; } = new(new List + { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight"); + + public override void Update(GameTime gameTime) + { + Move(gameTime); + base.Update(gameTime); + } public override void Attack() { @@ -30,7 +42,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Move(GameTime gameTime) { + if (velocity.X > 0) + { + if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight") + GraphicsComponent.StartAnimation("HunchmanMoveRight"); + } + else if (velocity.X < 0) + { + if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft") + GraphicsComponent.StartAnimation("HunchmanMoveRight"); + } + } + public override void OnCollision() + { + monster_speed *= -1; } } } diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index 165c006..fd7ff14 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -11,7 +11,7 @@ namespace DangerousD.GameCore.Levels public void InitLevel() { new Player(new Vector2(0,0)); - + /* var Spider = new Spider(new Vector2(112, 0)); var Zombie = new Zombie(new Vector2(256, 0)); var Frank = new Frank(new Vector2(384, 0)); @@ -19,6 +19,8 @@ namespace DangerousD.GameCore.Levels var Werewolf = new Werewolf(new Vector2(640, 0)); var Ghost = new Ghost(new Vector2(730, 0)); var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y)); + */ + var HunchMan = new Hunchman(new Vector2(100, 100)); //Spider down-up