From 7b16ad9543cbccba508bafbaf48500628f90ca94 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 00:02:44 +0300 Subject: [PATCH 01/18] 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 02/18] 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 03/18] 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 04/18] 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 05/18] 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 71dc642a1dce6a0cb0b751cd21202501a02e16c3 Mon Sep 17 00:00:00 2001 From: bmvolf Date: Thu, 17 Aug 2023 15:10:08 +0300 Subject: [PATCH 06/18] started work wirk with player --- DangerousD/Content/Content.mgcb | 46 +++++++++++------- DangerousD/Content/animations/playerMoveLeft | 1 + DangerousD/Content/animations/playerMoveRight | 1 + DangerousD/Content/animations/playerRightStay | 1 + DangerousD/Content/animations/playerStayLeft | 1 + DangerousD/Content/playerAnimation.png | Bin 0 -> 12892 bytes .../LivingEntities/Monsters/Zombie.cs | 9 ++-- .../LivingEntities/Player/DeathRectangle.cs | 4 +- .../LivingEntities/Player/Player.cs | 18 +++++-- DangerousD/GameCore/Levels/Level1.cs | 6 +-- 10 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 DangerousD/Content/animations/playerMoveLeft create mode 100644 DangerousD/Content/animations/playerMoveRight create mode 100644 DangerousD/Content/animations/playerRightStay create mode 100644 DangerousD/Content/animations/playerStayLeft create mode 100644 DangerousD/Content/playerAnimation.png diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 0ea387f..24e8d23 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -13,17 +13,12 @@ #---------------------------------- Content ---------------------------------# -#begin MonstersAnimations.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False +#begin ButtonFont.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor /processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:MonstersAnimations.png +/processorParam:TextureFormat=Compressed +/build:ButtonFont.spritefont #begin deathAnimation.png /importer:TextureImporter @@ -37,13 +32,6 @@ /processorParam:TextureFormat=Color /build:deathAnimation.png -#begin ButtonFont.spritefont -/importer:FontDescriptionImporter -/processor:FontDescriptionProcessor -/processorParam:PremultiplyAlpha=True -/processorParam:TextureFormat=Compressed -/build:ButtonFont.spritefont - #begin DoomTestSong.mp3 /importer:Mp3Importer /processor:SoundEffectProcessor @@ -107,6 +95,18 @@ /processorParam:TextureFormat=Color /build:menuFon3.jpg +#begin MonstersAnimations.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:MonstersAnimations.png + #begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png /importer:TextureImporter /processor:TextureProcessor @@ -119,6 +119,18 @@ /processorParam:TextureFormat=Color /build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png +#begin playerAnimation.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:playerAnimation.png + #begin wall.jpg /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/animations/playerMoveLeft b/DangerousD/Content/animations/playerMoveLeft new file mode 100644 index 0000000..404639c --- /dev/null +++ b/DangerousD/Content/animations/playerMoveLeft @@ -0,0 +1 @@ +{"id":"playerMoveLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":26,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerMoveRight b/DangerousD/Content/animations/playerMoveRight new file mode 100644 index 0000000..5ed3010 --- /dev/null +++ b/DangerousD/Content/animations/playerMoveRight @@ -0,0 +1 @@ +{"id":"playerMoveRight","textureName":"playerAnimation","startSpriteRectangle":{"X":26,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerRightStay b/DangerousD/Content/animations/playerRightStay new file mode 100644 index 0000000..bbeb120 --- /dev/null +++ b/DangerousD/Content/animations/playerRightStay @@ -0,0 +1 @@ +{"id":"playerRightStay","textureName":"playerAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerStayLeft b/DangerousD/Content/animations/playerStayLeft new file mode 100644 index 0000000..993f1e1 --- /dev/null +++ b/DangerousD/Content/animations/playerStayLeft @@ -0,0 +1 @@ +{"id":"playerStayLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":1,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/playerAnimation.png b/DangerousD/Content/playerAnimation.png new file mode 100644 index 0000000000000000000000000000000000000000..ed061f33849682ebbc3185570f321e015897662d GIT binary patch literal 12892 zcmZ9zWmH^E(=`miA$V{Z5-bVs?jD>ZxI@rE26qpxgJ;kH!QI^E%5J6aD30l|#<^@<4Xg zQjkWfnxH;>DWFIgyX;@VU;rm5#P(~-1<$9?5{vbsd0+4?uOh`SFApq zM_(VDh58*_#i$<&q)Z{D98DXYpjVcH9X0#u#$XuO>_`MniyzDDt#TkHg3v5?cg z2bib-O@B>IYWD4PKnnL<_!Zev@oyPQj+4*v)l=+DpJ5n6wQ(CG!}gbscuE_sne8x^ z{W^dD{_~6HCj;9l|E~7?`zgXKkB5ydM};z!=6p?aB~Sf+ZAn{B-;9i>9zig94@6u) zj1W&cZp+eML&oIXW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uZ_Ql(U(_w}zzR3o%v!AT9kvzP z>QHVUBU~r^xh924$lGRrX2uo6+%t;(n%#=Ui_?d7ceZT3aYB8cFvO>>P2rRocLoV< z;dF$)hjw1){OzZ)Mbx{qG=~J};rtoqI&FzVLQeC@={$j~E!IpaQKf|#o9ca)R-`}V)9dXdC{M79BX}>wB@`u=>wBCFHoG@2^KPBF5 zBXW(jp_bAFraNgB;4rEklPT;dm8&1ntlPbAD>ehAc2W&QggKh$RD>{e{YyO<23#jvcFIM$;q{qAeeUM1Z?sy@Kdl+@eH~;O9 zN|u>m;XE+Q7(a4#=d7V%~c#rXTxHRu$GMz`bLW) zS64guLV?@b3zT&R`t~$Ic^jjh1W;$ndmT5WamTJ_>{iuHsC~+W(_n(d`&PLA>(pSP7%xK(@;D+6OO|0BV^tXv6V-(}M?0 zxbH&YC7Zy%5o$SSaoS~v^cmL9@S15%lu%sm!;_!y0$CvZy$HyOUn1GuV^fk=iMGU1 zMy9X5Sbfp?k$=ITh^BF^u5}6cl*1ax^_8V}j47A-7Ek=eFyo&ui_;`xQ!`=zbvW;} zPTvdDAIINy61Z4@`79Cq|Fek4`G3^_#q)4Ri6W_oV!nW7W`zRc zm#1cc@RZdYOl)6txbr1e@c)qC09J{4XiLk^bd`cVtT&qAK3x21`ioGH{{Qei4t{y@ h?TejTSoJenzR|$>L0$Xl%O4>~N^)wlRnn#*{||2+i$nkb literal 0 HcmV?d00001 diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index b679a37..b5402e8 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -25,8 +25,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Height = 40; monster_speed = 3; name = "Zombie"; - leftBorder = (int)position.X - 100; - rightBorder = (int)position.X + 100; + leftBorder = (int)position.X - 50; + rightBorder = (int)position.X + 50; physicsManager = new PhysicsManager(); } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft"); @@ -48,9 +48,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters isAttaking = true; if (isGoRight) { - if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight") + if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack") { - GraphicsComponent.StartAnimation("ZombieAttackRight"); + GraphicsComponent.StartAnimation("ZombieRightAttack"); } AppManager.Instance.GameManager.players[0].Death(name); } @@ -71,7 +71,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Move(GameTime gameTime) { - float delta = (float)gameTime.ElapsedGameTime.TotalSeconds; if (isGoRight) { if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight") diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs index 1867b60..7dda1b1 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs @@ -13,8 +13,8 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath { public DeathRectangle(Vector2 pos, string DeathType) : base(pos) { - Height = 128; - Width = 128; + Height = 48; + Width = 48; PlayDeath(DeathType); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 0122b50..df59603 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -12,16 +12,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public class Player : LivingEntity { bool isAlive = true; + bool isRight; + string stayAnimation; public Player(Vector2 position) : base(position) { - Width = 32; - Height = 64; - AppManager.Instance.InputManager.MovEventJump += AnimationJump; + Width = 24; + Height = 32; + AppManager.Instance.InputManager.MovEventJump += Jump; } public bool IsAlive { get { return isAlive; } } - protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack", "DeathFromZombie" }, "ZombieMoveLeft");//TODO: Change to player + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft" }, "playerStayLeft"); public void Kill() { @@ -43,9 +45,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } isAlive = false; } - public void AnimationJump() + public override void Update(GameTime gameTime) + { + + base.Update(gameTime); + } + public void Jump() { velocity.Y = -300; + //сюда анимацию и доделать } } } diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index 7bf184b..7a0f8d9 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -10,8 +10,8 @@ namespace DangerousD.GameCore.Levels { public void InitLevel() { - new Player(new Vector2(80,0)); - var Zombie = new Zombie(new Vector2(250, 128)); + new Player(new Vector2(350,0)); + var Zombie = new Zombie(new Vector2(100, 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)); @@ -27,7 +27,7 @@ namespace DangerousD.GameCore.Levels } new GrassBlock(new Vector2(500, 224)); Player player = new Player(new Vector2(400, 64)); - player.AnimationJump(); + player.Jump(); //new GrassBlock(new Vector2(500, 224)); } From 0a2e3d6b1f2d0376c2f30aa4e4c0155eb87260d8 Mon Sep 17 00:00:00 2001 From: bmvolf Date: Thu, 17 Aug 2023 15:27:10 +0300 Subject: [PATCH 07/18] player animation changed --- DangerousD/Content/animations/playerJumpLeft | 1 + DangerousD/Content/animations/playerJumpRight | 1 + .../GameCore/GameObjects/LivingEntities/Player/Player.cs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 DangerousD/Content/animations/playerJumpLeft create mode 100644 DangerousD/Content/animations/playerJumpRight diff --git a/DangerousD/Content/animations/playerJumpLeft b/DangerousD/Content/animations/playerJumpLeft new file mode 100644 index 0000000..763ccd7 --- /dev/null +++ b/DangerousD/Content/animations/playerJumpLeft @@ -0,0 +1 @@ +{"id":"playerJumpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":101,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/playerJumpRight b/DangerousD/Content/animations/playerJumpRight new file mode 100644 index 0000000..816b2d3 --- /dev/null +++ b/DangerousD/Content/animations/playerJumpRight @@ -0,0 +1 @@ +{"id":"playerJumpRight","textureName":"playerAnimation","startSpriteRectangle":{"X":126,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index df59603..f7be1a0 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -23,7 +23,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public bool IsAlive { get { return isAlive; } } - protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft" }, "playerStayLeft"); + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", + "playerJumpRight" , "playerJumpLeft"}, "playerStayLeft"); public void Kill() { From 06be965359b4ee42b492b70a6da390603451056a Mon Sep 17 00:00:00 2001 From: bmvolf Date: Thu, 17 Aug 2023 16:10:20 +0300 Subject: [PATCH 08/18] started huch animation --- DangerousD/Content/animations/HunchmanMoveRight | 1 + 1 file changed, 1 insertion(+) create mode 100644 DangerousD/Content/animations/HunchmanMoveRight diff --git a/DangerousD/Content/animations/HunchmanMoveRight b/DangerousD/Content/animations/HunchmanMoveRight new file mode 100644 index 0000000..614e684 --- /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":12}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} From 69c5ea29b95fd919779bff2308387cef6a11b913 Mon Sep 17 00:00:00 2001 From: polten0 Date: Thu, 17 Aug 2023 16:12:25 +0300 Subject: [PATCH 09/18] 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 10/18] 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) From c1538670ba812ed4919bdf57f0788ac084285d77 Mon Sep 17 00:00:00 2001 From: bmvolf Date: Thu, 17 Aug 2023 18:22:43 +0300 Subject: [PATCH 11/18] start work for hanchman --- .../GameObjects/LivingEntities/Monsters/Zombie.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index b5402e8..6597527 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -38,7 +38,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Target(); Move(gameTime); } - + fixBorder(); base.Update(gameTime); } @@ -130,5 +130,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } } } + public void fixBorder() + { + if(leftBorder <= 0) + { + leftBorder = 0; + } + if(rightBorder >= 800) + { + rightBorder = 760; + } + } } } From 180fdae2ec9315f23395ba07f5525da72b446b19 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 17 Aug 2023 21:25:56 +0300 Subject: [PATCH 12/18] fix collisions --- .../GameCore/Managers/PhysicsManager.cs | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/DangerousD/GameCore/Managers/PhysicsManager.cs b/DangerousD/GameCore/Managers/PhysicsManager.cs index 980d7b3..7e257e0 100644 --- a/DangerousD/GameCore/Managers/PhysicsManager.cs +++ b/DangerousD/GameCore/Managers/PhysicsManager.cs @@ -20,9 +20,9 @@ namespace DangerousD.GameCore.Managers item.velocity = item.velocity + item.acceleration * delta; } - CheckCollisions(livingEntities, mapObjects); - OnCollision(entities, livingEntities); - OnCollision(livingEntities); + CheckCollisionsLE_MO(livingEntities, mapObjects); + CheckCollisionsE_LE(entities, livingEntities); + CheckCollisionsLE_LE(livingEntities); //entities dont move //Living entities dont move @@ -33,29 +33,27 @@ namespace DangerousD.GameCore.Managers //OnCollision } - public void CheckCollisions(List livingEntities, + private void CheckCollisionsLE_MO(List livingEntities, List mapObjects) { - LivingEntity currentEntity; - Rectangle oldRect; - for (int i = 0; i < livingEntities.Count; i++) + foreach (var currentEntity in livingEntities) { - currentEntity = livingEntities[i]; - oldRect = currentEntity.Rectangle; + Rectangle oldRect = currentEntity.Rectangle; bool isXNormalise = true; bool isYNormalise = true; oldRect.Offset((int)currentEntity.velocity.X, 0); - for (int j = 0; j < mapObjects.Count; j++) + foreach (var mapObject in mapObjects) { - if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 550) + if ( + Math.Abs(mapObject.Pos.X - currentEntity.Pos.X) < 550 + && Math.Abs(mapObject.Pos.Y - currentEntity.Pos.Y) < 550 + && oldRect.Intersects(mapObject.Rectangle) + ) { - if (oldRect.Intersects(mapObjects[j].Rectangle)) - { - isXNormalise = false; - oldRect.Offset(-(int)currentEntity.velocity.X, 0); - break; - } + isXNormalise = false; + oldRect.Offset(-(int)currentEntity.velocity.X, 0); + break; } } if (!isXNormalise) @@ -63,10 +61,9 @@ namespace DangerousD.GameCore.Managers oldRect.Offset(0, (int)currentEntity.velocity.Y); - for (int j = 0; j < mapObjects.Count; j++) + foreach (var mapObject in mapObjects) { - - if (oldRect.Intersects(mapObjects[j].Rectangle)) + if (oldRect.Intersects(mapObject.Rectangle)) { isYNormalise = false; oldRect.Offset(0, -(int)currentEntity.velocity.Y); @@ -79,22 +76,21 @@ namespace DangerousD.GameCore.Managers } } - public void OnCollision(List entities, List livingEntities) + private void CheckCollisionsE_LE(List entities, List livingEntities) { - for (int i = 0; i < entities.Count; i++) + foreach (var entity in entities) { - for (int j = 0; j < livingEntities.Count; j++) + foreach (var livingEntity in livingEntities) { - if (livingEntities[j].Rectangle.Intersects(entities[i].Rectangle)) + if (livingEntity.Rectangle.Intersects(entity.Rectangle)) { - livingEntities[j].OnCollision(entities[i]); - entities[i].OnCollision(livingEntities[j]); + livingEntity.OnCollision(entity); + entity.OnCollision(livingEntity); } } } - } - public void OnCollision(List livingEntities) + private void CheckCollisionsLE_LE(List livingEntities) { for (int i = 0; i < livingEntities.Count; i++) { From cbdabf794f5aaa19ff3f862527e3e0eeeb882535 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 17 Aug 2023 21:53:17 +0300 Subject: [PATCH 13/18] DebugHUD --- DangerousD/Content/Content.mgcb | 7 ++ DangerousD/Content/Font_12.spritefont | 64 +++++++++++++++++++ DangerousD/GameCore/GUI/DebugHUD.cs | 50 +++++++++++++++ .../GameCore/GameObjects/IDrawableObject.cs | 2 +- DangerousD/GameCore/Managers/AppManager.cs | 8 ++- 5 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 DangerousD/Content/Font_12.spritefont create mode 100644 DangerousD/GameCore/GUI/DebugHUD.cs diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index c977303..713c20a 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -87,6 +87,13 @@ /processorParam:Quality=Best /build:DoomTestSong.mp3 +#begin Font_12.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Font_12.spritefont + #begin Font_25.spritefont /importer:FontDescriptionImporter /processor:FontDescriptionProcessor diff --git a/DangerousD/Content/Font_12.spritefont b/DangerousD/Content/Font_12.spritefont new file mode 100644 index 0000000..4cffaf7 --- /dev/null +++ b/DangerousD/Content/Font_12.spritefont @@ -0,0 +1,64 @@ + + + + + + + Arial + + + 12 + + + 0 + + + true + + + + + + + + + + + + ~ + + + а + я + + + + diff --git a/DangerousD/GameCore/GUI/DebugHUD.cs b/DangerousD/GameCore/GUI/DebugHUD.cs new file mode 100644 index 0000000..c37626e --- /dev/null +++ b/DangerousD/GameCore/GUI/DebugHUD.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MonogameLibrary.UI.Elements; +using static System.String; + +namespace DangerousD.GameCore.GUI +{ + public class DebugHUD : IDrawableObject + { + private SpriteFont _spriteFont; + private Dictionary _text = new(); + + public void Initialize() + { + } + + public void LoadContent() + { + _spriteFont = AppManager.Instance.Content.Load("Font_12"); + } + + public void Update(GameTime gameTime) + { + } + + public void Draw(SpriteBatch spriteBatch) + { + spriteBatch.Begin(); + spriteBatch.DrawString( + _spriteFont, + Join(",", _text.Select(el => el.Key + ": " + el.Value).ToList()), + new Vector2(10, 10), + Color.Cyan, + 0, + Vector2.Zero, + 1, + SpriteEffects.None, + 0 + ); + spriteBatch.End(); + } + + public void Set(string key, string value) + { + _text[key] = value; + } + } +} \ No newline at end of file diff --git a/DangerousD/GameCore/GameObjects/IDrawableObject.cs b/DangerousD/GameCore/GameObjects/IDrawableObject.cs index 1d9ca5c..42d8320 100644 --- a/DangerousD/GameCore/GameObjects/IDrawableObject.cs +++ b/DangerousD/GameCore/GameObjects/IDrawableObject.cs @@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics; namespace DangerousD.GameCore.GUI { - interface IDrawableObject + public interface IDrawableObject { void Initialize(); void LoadContent(); diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index d5bf99c..a4a1063 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -24,12 +24,13 @@ namespace DangerousD.GameCore public GameState gameState { get; private set; } public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer; public Point resolution = new Point(1920, 1080); - public Point inGameResolution = new Point(1920, 1080); + public Point inGameResolution = new Point(1366, 768); IDrawableObject MenuGUI; IDrawableObject OptionsGUI; IDrawableObject LoginGUI; IDrawableObject LobbyGUI; IDrawableObject DeathGUI; + public DebugHUD DebugHUD; public GameManager GameManager { get; private set; } = new(); public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder(); @@ -62,6 +63,7 @@ namespace DangerousD.GameCore OptionsGUI = new OptionsGUI(); LobbyGUI = new LobbyGUI(); DeathGUI = new DeathGUI(); + DebugHUD = new DebugHUD(); UIManager.resolution = resolution; UIManager.resolutionInGame = inGameResolution; } @@ -72,6 +74,7 @@ namespace DangerousD.GameCore MenuGUI.Initialize(); LoginGUI.Initialize(); + DebugHUD.Initialize(); OptionsGUI.Initialize(); LobbyGUI.Initialize(); @@ -82,6 +85,7 @@ namespace DangerousD.GameCore protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); + DebugHUD.LoadContent(); MenuGUI.LoadContent(); LoginGUI.LoadContent(); OptionsGUI.LoadContent(); @@ -125,6 +129,7 @@ namespace DangerousD.GameCore default: break; } + DebugHUD.Update(gameTime); base.Update(gameTime); } @@ -165,6 +170,7 @@ namespace DangerousD.GameCore _spriteBatch.End(); + DebugHUD.Draw(_spriteBatch); base.Draw(gameTime); } From 12d44ff9f1e1f1833eebc1fb47a42ebd0bdcca19 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 17 Aug 2023 22:19:45 +0300 Subject: [PATCH 14/18] fix debug hud --- DangerousD/GameCore/GUI/DebugHUD.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DangerousD/GameCore/GUI/DebugHUD.cs b/DangerousD/GameCore/GUI/DebugHUD.cs index c37626e..b56d90a 100644 --- a/DangerousD/GameCore/GUI/DebugHUD.cs +++ b/DangerousD/GameCore/GUI/DebugHUD.cs @@ -30,7 +30,7 @@ namespace DangerousD.GameCore.GUI spriteBatch.Begin(); spriteBatch.DrawString( _spriteFont, - Join(",", _text.Select(el => el.Key + ": " + el.Value).ToList()), + Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()), new Vector2(10, 10), Color.Cyan, 0, From b48bec2d6d849acfd2353811bfef961894572574 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 17 Aug 2023 22:32:39 +0300 Subject: [PATCH 15/18] fix jump --- DangerousD/GameCore/GameObjects/GameObject.cs | 2 - .../LivingEntities/Player/Player.cs | 21 +++---- .../GameCore/GameObjects/LivingEntity.cs | 4 +- .../GameCore/Managers/PhysicsManager.cs | 57 +++++++++++++------ DangerousD/GameCore/Managers/SoundManager.cs | 1 + 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index d276984..96ff4ad 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -17,8 +17,6 @@ namespace DangerousD.GameCore public int Width { get; set; } public int Height { get; set; } public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height); - public Vector2 velocity; - public Vector2 acceleration; protected abstract GraphicsComponent GraphicsComponent { get; } public GameObject(Vector2 pos) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 9a9cc5e..122f360 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -81,8 +81,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public void AnimationJump() { - velocity.Y = -11; - isJump = true; + if (isOnGround) + { + velocity.Y = -11; + } // здесь будет анимация } public void Shoot() @@ -93,11 +95,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public override void Update(GameTime gameTime) { GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint(); - velocity.X = 0.5f; - if (velocity.Y == 0) - { - isJump = false; - } base.Update(gameTime); Move(gameTime); } @@ -105,21 +102,20 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public void Move(GameTime gameTime) { float delta = (float)gameTime.ElapsedGameTime.TotalSeconds; - if (AppManager.Instance.InputManager.VectorMovementDirection.X==1) + velocity.X = 5 * AppManager.Instance.InputManager.VectorMovementDirection.X; + if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0) { if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")//идёт направо { GraphicsComponent.StartAnimation("ZombieMoveRight"); } - velocity.X = 5; } - else if (AppManager.Instance.InputManager.VectorMovementDirection.X == -1)//идёт налево + else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево { if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft") { GraphicsComponent.StartAnimation("ZombieMoveLeft"); } - velocity.X = -5; } else if(AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { @@ -127,13 +123,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { GraphicsComponent.StartAnimation("ZombieMoveLeft"); } - velocity.X = 0; } } public void MoveDown() { + // ПОЧЕМУ velocity.Y = -11; - isJump = true; } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index 5620568..90a2170 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -4,7 +4,7 @@ namespace DangerousD.GameCore.GameObjects; public abstract class LivingEntity : Entity { - private Vector2 targetPosition; + public bool isOnGround = true; public Vector2 velocity; public Vector2 acceleration; public LivingEntity(Vector2 position) : base(position) @@ -13,7 +13,7 @@ public abstract class LivingEntity : Entity } public override void SetPosition(Vector2 position) { - targetPosition = position; _pos = position; + _pos = position; } //TODO befrend targetpos and physics engine diff --git a/DangerousD/GameCore/Managers/PhysicsManager.cs b/DangerousD/GameCore/Managers/PhysicsManager.cs index 7e257e0..7899c98 100644 --- a/DangerousD/GameCore/Managers/PhysicsManager.cs +++ b/DangerousD/GameCore/Managers/PhysicsManager.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using DangerousD.GameCore.GameObjects.LivingEntities; using Microsoft.Xna.Framework; namespace DangerousD.GameCore.Managers @@ -38,41 +39,65 @@ namespace DangerousD.GameCore.Managers { foreach (var currentEntity in livingEntities) { - Rectangle oldRect = currentEntity.Rectangle; - bool isXNormalise = true; - bool isYNormalise = true; + var currentRect = currentEntity.Rectangle; + var newRect = currentRect; - oldRect.Offset((int)currentEntity.velocity.X, 0); + #region x collision + var collidedX = false; + var tryingRectX = currentRect; + tryingRectX.Offset((int)Math.Ceiling(currentEntity.velocity.X), 0); foreach (var mapObject in mapObjects) { if ( Math.Abs(mapObject.Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObject.Pos.Y - currentEntity.Pos.Y) < 550 - && oldRect.Intersects(mapObject.Rectangle) + && tryingRectX.Intersects(mapObject.Rectangle) ) { - isXNormalise = false; - oldRect.Offset(-(int)currentEntity.velocity.X, 0); + collidedX = true; break; } } - if (!isXNormalise) + if (collidedX) + { currentEntity.velocity.X = 0; - - - oldRect.Offset(0, (int)currentEntity.velocity.Y); + } + else + { + newRect.X = tryingRectX.X; + } + #endregion + + #region y collision + var collidedY = false; + var tryingRectY = currentRect; + tryingRectY.Offset(0, (int)Math.Ceiling(currentEntity.velocity.Y)); + if (currentEntity is Player) + { + AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString()); + AppManager.Instance.DebugHUD.Set("intersects y", ""); + } foreach (var mapObject in mapObjects) { - if (oldRect.Intersects(mapObject.Rectangle)) + if (tryingRectY.Intersects(mapObject.Rectangle)) { - isYNormalise = false; - oldRect.Offset(0, -(int)currentEntity.velocity.Y); + if (currentEntity is Player) AppManager.Instance.DebugHUD.Set("intersects y", mapObject.GetType().ToString()); + collidedY = true; break; } } - if (!isYNormalise) + currentEntity.isOnGround = collidedY && currentEntity.velocity.Y > 0; + if (collidedY) + { currentEntity.velocity.Y = 0; - currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y)); + } + else + { + newRect.Y = tryingRectY.Y; + } + #endregion + + currentEntity.SetPosition(new Vector2(newRect.X, newRect.Y)); } } diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs index 3a1e03f..7da1b17 100644 --- a/DangerousD/GameCore/Managers/SoundManager.cs +++ b/DangerousD/GameCore/Managers/SoundManager.cs @@ -40,6 +40,7 @@ namespace DangerousD.GameCore public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции { + return; var sound = new Sound(Sounds[soundName]); sound.SoundEffect.IsLooped = false; sound.SoundEffect.Play(); From dd4a5c7fb2da15ff2e6c1bea4ea5235abb84b585 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 17 Aug 2023 22:40:30 +0300 Subject: [PATCH 16/18] GameManager.Remove(GameObject) --- DangerousD/GameCore/Managers/GameManager.cs | 32 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 342813b..7f19fd3 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -25,7 +25,7 @@ namespace DangerousD.GameCore public List players; public List otherObjects = new(); - public Player GetPlayer1 { get; private set; } + public Player GetPlayer1 => players[0]; public GameManager() { others = new List(); @@ -49,7 +49,6 @@ namespace DangerousD.GameCore { livingEntities.Add(gameObject as LivingEntity); players.Add(objPl); - GetPlayer1 = players[0]; } else if (gameObject is LivingEntity objLE) { @@ -72,6 +71,35 @@ namespace DangerousD.GameCore } } + public void Remove(GameObject gameObject) + { + GetAllGameObjects.Remove(gameObject); + if (gameObject is Player objPl) + { + livingEntities.Remove(gameObject as LivingEntity); + players.Remove(objPl); + } + else if (gameObject is LivingEntity objLE) + { + livingEntities.Remove(objLE); + } + else if (gameObject is Entity objE) + { + entities.Remove(objE); + } + else if (gameObject is MapObject obj) + { + if (obj.IsColliderOn) + mapObjects.Remove(obj); + else + BackgroundObjects.Remove(obj); + } + else + { + otherObjects.Remove(gameObject); + } + } + public void Draw(SpriteBatch _spriteBatch) { foreach (var item in BackgroundObjects) From 9a149199ace69d7c6ac997fa09402824d198df41 Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Thu, 17 Aug 2023 23:44:41 +0300 Subject: [PATCH 17/18] fix --- DangerousD/GameCore/Managers/GameManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 7f19fd3..8664666 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -25,7 +25,7 @@ namespace DangerousD.GameCore public List players; public List otherObjects = new(); - public Player GetPlayer1 => players[0]; + public Player GetPlayer1; public GameManager() { others = new List(); @@ -49,6 +49,7 @@ namespace DangerousD.GameCore { livingEntities.Add(gameObject as LivingEntity); players.Add(objPl); + GetPlayer1 = players[0]; } else if (gameObject is LivingEntity objLE) { From 801f0e97d87d4daa7ca78f6416b168b2d7fa6c7a Mon Sep 17 00:00:00 2001 From: bmvolf Date: Thu, 17 Aug 2023 23:53:50 +0300 Subject: [PATCH 18/18] updated death --- .../GameObjects/LivingEntities/Player/Player.cs | 12 +++++++++++- DangerousD/GameCore/Managers/GameManager.cs | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index d0e65e1..39b1926 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -23,6 +23,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public int rightBorder; public int leftBorder; public bool isVisible = true; + private bool isAttacked = false; public GameObject objectAttack; public Player(Vector2 position) : base(position) @@ -70,6 +71,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public void Death(string monsterName) { + isAttacked = true; if(monsterName == "Zombie") { DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); @@ -77,7 +79,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { if (a == "DeathFrom" + monsterName) { - AppManager.Instance.ChangeGameState(GameState.GameOver); + AppManager.Instance.ChangeGameState(GameState.Death); } }; } @@ -99,6 +101,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public override void Update(GameTime gameTime) { GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint(); + if (!isAttacked) + { + Move(gameTime); + } + else + { + velocity.X = 0; + } base.Update(gameTime); } diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 7f19fd3..8664666 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -25,7 +25,7 @@ namespace DangerousD.GameCore public List players; public List otherObjects = new(); - public Player GetPlayer1 => players[0]; + public Player GetPlayer1; public GameManager() { others = new List(); @@ -49,6 +49,7 @@ namespace DangerousD.GameCore { livingEntities.Add(gameObject as LivingEntity); players.Add(objPl); + GetPlayer1 = players[0]; } else if (gameObject is LivingEntity objLE) {