From 7b16ad9543cbccba508bafbaf48500628f90ca94 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 00:02:44 +0300 Subject: [PATCH 1/7] createAnimFiles --- DangerousD/Content/animations/HunchmanAttackLeft | 1 + DangerousD/Content/animations/HunchmanAttackRight | 1 + DangerousD/Content/animations/HunchmanMoveLeft | 1 + DangerousD/Content/animations/HunchmanMoveRight | 1 + 4 files changed, 4 insertions(+) create mode 100644 DangerousD/Content/animations/HunchmanAttackLeft create mode 100644 DangerousD/Content/animations/HunchmanAttackRight create mode 100644 DangerousD/Content/animations/HunchmanMoveLeft create mode 100644 DangerousD/Content/animations/HunchmanMoveRight diff --git a/DangerousD/Content/animations/HunchmanAttackLeft b/DangerousD/Content/animations/HunchmanAttackLeft new file mode 100644 index 0000000..f6b0634 --- /dev/null +++ b/DangerousD/Content/animations/HunchmanAttackLeft @@ -0,0 +1 @@ +{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":124,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/HunchmanAttackRight b/DangerousD/Content/animations/HunchmanAttackRight new file mode 100644 index 0000000..2252c3b --- /dev/null +++ b/DangerousD/Content/animations/HunchmanAttackRight @@ -0,0 +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"} diff --git a/DangerousD/Content/animations/HunchmanMoveLeft b/DangerousD/Content/animations/HunchmanMoveLeft new file mode 100644 index 0000000..47d627e --- /dev/null +++ b/DangerousD/Content/animations/HunchmanMoveLeft @@ -0,0 +1 @@ +{"id":"HunchmanMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":124,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/HunchmanMoveRight b/DangerousD/Content/animations/HunchmanMoveRight new file mode 100644 index 0000000..d1691bb --- /dev/null +++ b/DangerousD/Content/animations/HunchmanMoveRight @@ -0,0 +1 @@ +{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} From 38257457a96ef1b1b5b2674ee0798050cbfdd7e5 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 11:18:22 +0300 Subject: [PATCH 2/7] StartSomething --- .../Content/animations/HunchmanAttackRight | 2 +- .../LivingEntities/Monsters/Hunchman.cs | 28 ++++++++++++++++++- DangerousD/GameCore/Levels/Level1.cs | 4 ++- 3 files changed, 31 insertions(+), 3 deletions(-) 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 From b9d259bfa0d00ad141d16a0a2a10e40004d96209 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 13:05:16 +0300 Subject: [PATCH 3/7] fixesAdnSomeHunchManAdditions --- .../LivingEntities/Monsters/Hunchman.cs | 73 ++++++++++++++++--- .../LivingEntities/Monsters/Knife.cs | 19 +++++ DangerousD/GameCore/Levels/Level1.cs | 11 +-- 3 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index f180842..be5563b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -4,7 +4,9 @@ using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Security.Authentication.ExtendedProtection; using System.Text; using System.Threading.Tasks; @@ -12,51 +14,104 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { public class Hunchman : CoreEnemy { + GameManager gameManager; + bool isAttacking; public Hunchman(Vector2 position) : base(position) { - Width = 72; - Height = 72; - monster_speed = 5; + Width = 48; + Height = 48; + monster_speed = -2; + monster_health = 1; name = "HunchMan"; velocity = new Vector2(monster_speed, 0); + gameManager = AppManager.Instance.GameManager; + isAttacking = false; + isAlive = true; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List - { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight"); + { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft"); public override void Update(GameTime gameTime) { - Move(gameTime); + gameManager = AppManager.Instance.GameManager; + + if (!isAttacking) + { + Attack(); + Move(gameTime); + + } + Death(); base.Update(gameTime); + } public override void Attack() { - + GameObject gameObject; + foreach (var player in gameManager.players) + { + if (player.Pos.Y + player.Height >= Pos.Y && player.Pos.Y <= Pos.Y + Height) + { + gameObject = gameManager.physicsManager.RayCast(this, player); + if (gameObject is null) + { + isAttacking = true; + if (velocity.X > 0) + { + if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackRight") + { + GraphicsComponent.StartAnimation("HunchmanAttackRight"); + } + } + else if (velocity.X < 0) + { + if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackLeft") + { + GraphicsComponent.StartAnimation("HunchmanAttackLeft"); + } + } + } + } + } } public override void Death() { + if (monster_health <= 0) + { + } } public override void Move(GameTime gameTime) { + velocity.X = monster_speed; if (velocity.X > 0) { if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight") + { GraphicsComponent.StartAnimation("HunchmanMoveRight"); + } + } + else if (velocity.X < 0) { if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft") - GraphicsComponent.StartAnimation("HunchmanMoveRight"); + { + GraphicsComponent.StartAnimation("HunchmanMoveLeft"); + } } + } - public override void OnCollision() - { + public override void OnCollision(GameObject gameObject) + { monster_speed *= -1; + _pos.X += 5 * monster_speed; + Debug.WriteLine("Collision"); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs new file mode 100644 index 0000000..cba749d --- /dev/null +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs @@ -0,0 +1,19 @@ +using DangerousD.GameCore.Graphics; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters +{ + class Knife : Entity + { + public Knife(Vector2 position) : base(position) + { + } + + protected override GraphicsComponent GraphicsComponent => throw new NotImplementedException(); + } +} diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index 1b4fb03..8295e68 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -10,17 +10,12 @@ namespace DangerousD.GameCore.Levels { public void InitLevel() { - new Player(new Vector2(0,0)); + new Player(new Vector2(50,100)); var Zombie = new Zombie(new Vector2(140, 128)); - var Frank = new Frank(new Vector2(384, 128)); - var Spider = new Spider(new Vector2(112, 0)); - var FlameSkull = new FlameSkull(new Vector2(512, 0)); - 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)); + + var HunchMan = new Hunchman(new Vector2(300, 100)); //Spider down-up new GrassBlock(new Vector2(0, 224)); From 00b71fc64548c80cbcde7f118bb7b360b3f22998 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 13:07:05 +0300 Subject: [PATCH 4/7] fixesAdnSomeHunchManAdditions2 --- .../GameObjects/LivingEntities/Monsters/Hunchman.cs | 6 ++++++ DangerousD/GameCore/Levels/Level1.cs | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index be5563b..0dc0d6f 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -87,7 +87,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Move(GameTime gameTime) { + if (gameManager.physicsManager.RayCast(this, new Vector2(Pos.X + Width + 10, Pos.Y + Height)) is not null) + { + monster_speed *= -1; + } + velocity.X = monster_speed; + if (velocity.X > 0) { if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight") diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index 8295e68..e22111b 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -13,7 +13,12 @@ namespace DangerousD.GameCore.Levels new Player(new Vector2(50,100)); var Zombie = new Zombie(new Vector2(140, 128)); - + var Frank = new Frank(new Vector2(384, 128)); + var Spider = new Spider(new Vector2(112, 0)); + var FlameSkull = new FlameSkull(new Vector2(512, 0)); + 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(300, 100)); //Spider down-up From 8581af20b9da1d6635b219b613deb4f301ca78da Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 13:09:42 +0300 Subject: [PATCH 5/7] fix3 --- .../LivingEntities/Monsters/Knife.cs | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs deleted file mode 100644 index cba749d..0000000 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Knife.cs +++ /dev/null @@ -1,19 +0,0 @@ -using DangerousD.GameCore.Graphics; -using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters -{ - class Knife : Entity - { - public Knife(Vector2 position) : base(position) - { - } - - protected override GraphicsComponent GraphicsComponent => throw new NotImplementedException(); - } -} From 69c5ea29b95fd919779bff2308387cef6a11b913 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 16:12:25 +0300 Subject: [PATCH 6/7] fixanother --- .../GameObjects/LivingEntities/Monsters/Hunchman.cs | 7 +++++-- DangerousD/GameCore/Levels/Level1.cs | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index 0dc0d6f..1bdee25 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -40,10 +40,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { Attack(); Move(gameTime); - + } + else + { + velocity.X = 0; } Death(); - base.Update(gameTime); } @@ -58,6 +60,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters if (gameObject is null) { isAttacking = true; + GraphicsComponent.StopAnimation(); if (velocity.X > 0) { if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackRight") diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index dba3016..0a7947b 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -12,8 +12,8 @@ namespace DangerousD.GameCore.Levels { //Spider down-up - new Player(new Vector2(80,0)); - var Zombie = new Zombie(new Vector2(250, 128)); + //new Player(new Vector2(80,0)); + //var Zombie = new Zombie(new Vector2(250, 128)); //var Frank = new Frank(new Vector2(384, 128)); //var Spider = new Spider(new Vector2(112, 0)); //var FlameSkull = new FlameSkull(new Vector2(512, 0)); @@ -32,7 +32,7 @@ namespace DangerousD.GameCore.Levels } new GrassBlock(new Vector2(500, 224)); Player player = new Player(new Vector2(400, 64)); - player.AnimationJump(); + //player.AnimationJump(); //new GrassBlock(new Vector2(500, 224)); } From d569489cd42a8ed888eb479cf816effa3e402f3d Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 16:13:49 +0300 Subject: [PATCH 7/7] fixaaa3 --- .../GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index 1bdee25..ed8a92c 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -34,6 +34,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Update(GameTime gameTime) { + // P.S. Всё в классе можешь смело удалять и переписывать с нуля. gameManager = AppManager.Instance.GameManager; if (!isAttacking)