From 6b55b595c51ca36c8de55ff7f6d89b4a04bcab58 Mon Sep 17 00:00:00 2001 From: Lev Date: Tue, 20 Aug 2024 03:57:05 +0300 Subject: [PATCH 1/5] commit for merge fich for create StartCycledAnimation at AnimatedGraficsComponent --- ZoFo/Content/Content.mgcb | 161 ++++++++++-------- .../Animations/player_run_down.animation | 1 + .../Animations/player_run_left.animation | 1 + .../Animations/player_run_left_down.animation | 1 + .../Animations/player_run_left_up.animation | 1 + .../Animations/player_run_right.animation | 1 + .../Textures/Animations/player_run_right.zip | Bin 0 -> 2717 bytes .../player_run_right_down.animation | 1 + .../Animations/player_run_right_up.animation | 1 + .../Animations/player_run_up.animation | 1 + .../Entities/LivingEntities/Player/Player.cs | 31 ++-- 11 files changed, 116 insertions(+), 84 deletions(-) create mode 100644 ZoFo/Content/Textures/Animations/player_run_down.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_left.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_left_down.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_left_up.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_right.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_right.zip create mode 100644 ZoFo/Content/Textures/Animations/player_run_right_down.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_right_up.animation create mode 100644 ZoFo/Content/Textures/Animations/player_run_up.animation diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index b3a43e3..ee889c5 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -134,57 +134,84 @@ #begin Textures/Animations/player_left_idle.animation /copy:Textures/Animations/player_left_idle.animation -#begin Textures/Animations/player_look_down.animation -/copy:Textures/Animations/player_look_down.animation - #begin Textures/Animations/player_look_down_weapon.animation /copy:Textures/Animations/player_look_down_weapon.animation -#begin Textures/Animations/player_look_left.animation -/copy:Textures/Animations/player_look_left.animation - -#begin Textures/Animations/player_look_left_down.animation -/copy:Textures/Animations/player_look_left_down.animation +#begin Textures/Animations/player_look_down.animation +/copy:Textures/Animations/player_look_down.animation #begin Textures/Animations/player_look_left_down_weapon.animation /copy:Textures/Animations/player_look_left_down_weapon.animation -#begin Textures/Animations/player_look_left_up.animation -/copy:Textures/Animations/player_look_left_up.animation +#begin Textures/Animations/player_look_left_down.animation +/copy:Textures/Animations/player_look_left_down.animation #begin Textures/Animations/player_look_left_up_weapon.animation /copy:Textures/Animations/player_look_left_up_weapon.animation +#begin Textures/Animations/player_look_left_up.animation +/copy:Textures/Animations/player_look_left_up.animation + #begin Textures/Animations/player_look_left_weapon.animation /copy:Textures/Animations/player_look_left_weapon.animation -#begin Textures/Animations/player_look_right.animation -/copy:Textures/Animations/player_look_right.animation - -#begin Textures/Animations/player_look_right_down.animation -/copy:Textures/Animations/player_look_right_down.animation +#begin Textures/Animations/player_look_left.animation +/copy:Textures/Animations/player_look_left.animation #begin Textures/Animations/player_look_right_down_weapon.animation /copy:Textures/Animations/player_look_right_down_weapon.animation -#begin Textures/Animations/player_look_right_up.animation -/copy:Textures/Animations/player_look_right_up.animation +#begin Textures/Animations/player_look_right_down.animation +/copy:Textures/Animations/player_look_right_down.animation #begin Textures/Animations/player_look_right_up_weapon.animation /copy:Textures/Animations/player_look_right_up_weapon.animation +#begin Textures/Animations/player_look_right_up.animation +/copy:Textures/Animations/player_look_right_up.animation + #begin Textures/Animations/player_look_right_weapon.animation /copy:Textures/Animations/player_look_right_weapon.animation -#begin Textures/Animations/player_look_up.animation -/copy:Textures/Animations/player_look_up.animation +#begin Textures/Animations/player_look_right.animation +/copy:Textures/Animations/player_look_right.animation #begin Textures/Animations/player_look_up_weapon.animation /copy:Textures/Animations/player_look_up_weapon.animation +#begin Textures/Animations/player_look_up.animation +/copy:Textures/Animations/player_look_up.animation + #begin Textures/Animations/player_right_idle.animation /copy:Textures/Animations/player_right_idle.animation +#begin Textures/Animations/player_run_down.animation +/copy:Textures/Animations/player_run_down.animation + +#begin Textures/Animations/player_run_left_down.animation +/copy:Textures/Animations/player_run_left_down.animation + +#begin Textures/Animations/player_run_left_up.animation +/copy:Textures/Animations/player_run_left_up.animation + +#begin Textures/Animations/player_run_left.animation +/copy:Textures/Animations/player_run_left.animation + +#begin Textures/Animations/player_run_right_down.animation +/copy:Textures/Animations/player_run_right_down.animation + +#begin Textures/Animations/player_run_right_up.animation +/copy:Textures/Animations/player_run_right_up.animation + +#begin Textures/Animations/player_run_right.animation +/copy:Textures/Animations/player_run_right.animation + +#begin Textures/Animations/player_run_right.zip +/copy:Textures/Animations/player_run_right.zip + +#begin Textures/Animations/player_run_up.animation +/copy:Textures/Animations/player_run_up.animation + #begin Textures/Animations/player_running_top_rotate.animation /copy:Textures/Animations/player_running_top_rotate.animation @@ -221,18 +248,6 @@ #begin Textures/Animations/zombie_walk.animation /copy:Textures/Animations/zombie_walk.animation -#begin Textures/AnimationTextures/Character/hr-level1_idle.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:Textures/AnimationTextures/Character/hr-level1_idle.png - #begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png /importer:TextureImporter /processor:TextureProcessor @@ -245,6 +260,18 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png +#begin Textures/AnimationTextures/Character/hr-level1_idle.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:Textures/AnimationTextures/Character/hr-level1_idle.png + #begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png /importer:TextureImporter /processor:TextureProcessor @@ -269,18 +296,6 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png -#begin Textures/AnimationTextures/Character/hr-level1_running.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:Textures/AnimationTextures/Character/hr-level1_running.png - #begin Textures/AnimationTextures/Character/hr-level1_running_gun.png /importer:TextureImporter /processor:TextureProcessor @@ -293,6 +308,18 @@ /processorParam:TextureFormat=Color /build:Textures/AnimationTextures/Character/hr-level1_running_gun.png +#begin Textures/AnimationTextures/Character/hr-level1_running.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:Textures/AnimationTextures/Character/hr-level1_running.png + #begin Textures/AnimationTextures/unicorn.png /importer:TextureImporter /processor:TextureProcessor @@ -413,18 +440,6 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/background/waiting.png -#begin Textures/GUI/checkboxs_off.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:Textures/GUI/checkboxs_off.png - #begin Textures/GUI/checkboxs_off-on.png /importer:TextureImporter /processor:TextureProcessor @@ -437,6 +452,18 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/checkboxs_off-on.png +#begin Textures/GUI/checkboxs_off.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:Textures/GUI/checkboxs_off.png + #begin Textures/GUI/checkboxs_on.png /importer:TextureImporter /processor:TextureProcessor @@ -473,18 +500,6 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/mouse.png -#begin Textures/GUI/switch.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:Textures/GUI/switch.png - #begin Textures/GUI/Switch_backgrownd.png /importer:TextureImporter /processor:TextureProcessor @@ -497,6 +512,18 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/Switch_backgrownd.png +#begin Textures/GUI/switch.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:Textures/GUI/switch.png + #begin Textures/icons/12.png /importer:TextureImporter /processor:TextureProcessor diff --git a/ZoFo/Content/Textures/Animations/player_run_down.animation b/ZoFo/Content/Textures/Animations/player_run_down.animation new file mode 100644 index 0000000..6dfae3f --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_down.animation @@ -0,0 +1 @@ +{"id":"player_run_down","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":528,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_left.animation b/ZoFo/Content/Textures/Animations/player_run_left.animation new file mode 100644 index 0000000..382a37c --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_left.animation @@ -0,0 +1 @@ +{"id":"player_run_left","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":792,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_left_down.animation b/ZoFo/Content/Textures/Animations/player_run_left_down.animation new file mode 100644 index 0000000..4fc1ba6 --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_left_down.animation @@ -0,0 +1 @@ +{"id":"player_run_left_down","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":660,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_left_up.animation b/ZoFo/Content/Textures/Animations/player_run_left_up.animation new file mode 100644 index 0000000..2ce06d9 --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_left_up.animation @@ -0,0 +1 @@ +{"id":"player_run_left_up","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":924,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_right.animation b/ZoFo/Content/Textures/Animations/player_run_right.animation new file mode 100644 index 0000000..f326ea9 --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_right.animation @@ -0,0 +1 @@ +{"id":"player_run_right","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":264,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_right.zip b/ZoFo/Content/Textures/Animations/player_run_right.zip new file mode 100644 index 0000000000000000000000000000000000000000..ca73be1b07bcd660399a1b7833cb28dfc4b72c8f GIT binary patch literal 2717 zcmaKuc{r47AIHZ`V;fy$OhlF}32~fsEX5ehD~%;h9m`8$vTq|#d{BvK=AJ6Bx?$7=E{(iTW8RUQn2n6B< zC1t|x2#3`QJ^*imTp-X9VD%yE2c!%crE;=Zd#U$9fA-KjYm=G(Z1%Dn2ka7KHU%xNlBWDEM0A}5)( zYUG4s+L*i*)qhOGvFyimFN)R28V{QFhkvP-!G$#@-h6ATc9j34(s6>jPPR60BUbg% z>!WkCVfg-)#>5q&G_W z3|FkRQZyH752&w%pRrQX{D@rQjv%@4D`q^fDPzv5^)~xx@-sfsOq`ahr4Y)Nti;Q~ z$Er7_p2NLXbk10an{TydK?EoTslBDJV_{!Cbnd8#W#Ai)hN{p$P{ZyrG4zeOJigP% zMC9hHRg-L-t1Tt&j_XyzbQZ=t=Cz`Uq~_LPiGX*IG${!sI@9biig|(i?Siiar;gW!vxqY!uyXH|YT^2m>~ba3f%*ZIA zxSec_t)Nr-jYjSHes5Uq=2w<=KCk$$#SQMJ*ebj{K59JciyRA`c}V@BE>_QjqEFov} zsjgQTnpl37-3%7HpLCB*sfkPH7-LqoGkCh%IGE=Iu73N<$oAPQ6C@Q;$o{%NP*jJ zGclVxJwgajA--2dfTz31zI+J8F=86Y-9rWO_9jbZ2i}IwpH?Zn zym;x}-XScvqvy zCs*=Mhj3yme8y2;t@2AJ+f;Z+ko3utg!d9uxPu!NmVN7rgf^aVnyM)QVQ9l@BV5lx z5cDm%bjgyLbo8u#Ot?HfGj%kRUNReo$*<-%R9>8Rkr^q7DlZkL ziMq__#9Uum`cC6IMC%Qsm9|ekuHy zr-Z3uyUXj>soNnb{NY)NA&)}c{8h!YL&FWqL-RAQ=$nqlNrR!$O{act{PWNy+Cmc{ zOYc?B9avz_oqz^7phJ?AjvobNroLDH>iaQy ztNGR##AV}_WXoiHr+mkU!)BDo5KTke%F=JTu)j5IGh*swwX&Z&j|=ubIU>NjjmAa< z$(7D*MH1@VmkZ$fJqsAYgexkPx+rPLRrORIg6^6)ytN|R?MpQ7&pQQ3k1=qr6Aa?$ z)L#6)`L=#LD7Z&HFdFuhC{hJ z_#5JRGOH@_bE98Ud-_-it!Jb)>k*;F+|nu^?_*z zWh05;Q091^sB3M+KXlO>DoV6(_ykkLh-Dtf#92Kp2Cqz!rLD}kz#^a@-yZ-2ATE&1 z&H_9?yiM%JaGJn7AAiR{0k69-d*|_P45tys#=yY)F#ibbZWgBjz-AqR>}Tyh>)j+y z{gX|SKd^`Nk8Zk~!>I$YIm*!eod2^uPWffSbhtUdezZSM5n!VXc=n+7LZHBZcCMkk Np!2}tAbEG*{tKd)Q5OIJ literal 0 HcmV?d00001 diff --git a/ZoFo/Content/Textures/Animations/player_run_right_down.animation b/ZoFo/Content/Textures/Animations/player_run_right_down.animation new file mode 100644 index 0000000..400a15d --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_right_down.animation @@ -0,0 +1 @@ +{"id":"player_run_right_down","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":396,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_right_up.animation b/ZoFo/Content/Textures/Animations/player_run_right_up.animation new file mode 100644 index 0000000..2470613 --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_right_up.animation @@ -0,0 +1 @@ +{"id":"player_run_right_up","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":132,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/Content/Textures/Animations/player_run_up.animation b/ZoFo/Content/Textures/Animations/player_run_up.animation new file mode 100644 index 0000000..7837205 --- /dev/null +++ b/ZoFo/Content/Textures/Animations/player_run_up.animation @@ -0,0 +1 @@ +{"id":"player_run_up","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":0,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"} diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index 8c3310a..c76c1bc 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -33,8 +33,8 @@ public class Player : LivingEntity public Player(Vector2 position) : base(position) { graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30); - collisionComponent.stopRectangle = new Rectangle(0, 20, 30, 10); - speed = 5; + collisionComponent.stopRectangle = new Rectangle(0, 15, 30, 15); + speed = 2.5f; StartAnimation("player_look_down"); } @@ -46,28 +46,29 @@ public class Player : LivingEntity switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation)) { case ScopeState.Top: - + //if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_up") + //(graphicsComponent as AnimatedGraphicsComponent).Star ("player_run_up"); break; case ScopeState.Down: - + StartAnimation("player_run_down"); break; case ScopeState.Right: - //StartAnimation("player_running_top_rotate"); + StartAnimation("player_run_right"); break; case ScopeState.Left: - + StartAnimation("left"); break; case ScopeState.TopRight: - + StartAnimation("player_run_right_up"); break; case ScopeState.TopLeft: - + StartAnimation("player_run_left_up"); break; case ScopeState.DownRight: - + StartAnimation("player_run_right_down"); break; case ScopeState.DownLeft: - + StartAnimation("player_run_left_down"); break; } #endregion @@ -95,15 +96,11 @@ public class Player : LivingEntity rect.Width += 100; rect.Height += 100; Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(rect, this); - if (entities.Length>0) + if (entities != null) { - DebugHUD.DebugSet("ent[0]", entities[0].ToString()); - if (entities != null) + foreach (Entity entity in entities) { - foreach (Entity entity in entities) - { - AppManager.Instance.server.DeleteObject(entity); - } + AppManager.Instance.server.DeleteObject(entity); } } } From b14e869e443ed025aea56b7d7f37d1275acc3d92 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Tue, 20 Aug 2024 04:19:02 +0300 Subject: [PATCH 2/5] Add cycling animation --- .../GameManagers/AssetsManager/AssetManager.cs | 2 +- .../Entities/LivingEntities/Player/Player.cs | 4 ++-- ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs index 334957f..78fbf78 100644 --- a/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs +++ b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs @@ -12,7 +12,7 @@ public class AssetManager public AssetContainer Player = new() { - Animations = [ "player_look_down" ], + Animations = [ "player_look_down", "player_run_up"], IdleAnimation = "player_look_down" }; } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index c76c1bc..baec6d3 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -46,8 +46,8 @@ public class Player : LivingEntity switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation)) { case ScopeState.Top: - //if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_up") - //(graphicsComponent as AnimatedGraphicsComponent).Star ("player_run_up"); + if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_up") + (graphicsComponent as AnimatedGraphicsComponent).StartCyclingAnimation("player_run_up"); break; case ScopeState.Down: StartAnimation("player_run_down"); diff --git a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs index 85c4a7e..86af079 100644 --- a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs @@ -138,6 +138,17 @@ namespace ZoFo.GameCore.Graphics SetInterval(); } + + public void StartCyclingAnimation(string startedanimationId) + { + currentFrame = 0; + currentAnimation = animations.Find(x => x.Id == startedanimationId); + currentAnimation.IsCycle = true; + + buildSourceRectangle(); + SetInterval(); + + } public void StopAnimation() { From f2c73bb3afc198875f1f07c3d52243d70ad3d1dc Mon Sep 17 00:00:00 2001 From: Lev Date: Tue, 20 Aug 2024 04:51:29 +0300 Subject: [PATCH 3/5] try to add to Player logic animate move --- .../AssetsManager/AssetManager.cs | 4 ++- .../Entities/LivingEntities/Player/Player.cs | 28 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs index 78fbf78..5fd12ba 100644 --- a/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs +++ b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs @@ -12,7 +12,9 @@ public class AssetManager public AssetContainer Player = new() { - Animations = [ "player_look_down", "player_run_up"], + Animations = [ "player_look_down", "player_run_up", "player_run_down", "player_run_right", + "player_run_left", "player_run_right_up", "player_run_left_up", "player_run_right_down", + "player_run_left_down" ], IdleAnimation = "player_look_down" }; } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index baec6d3..a3e6022 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -43,32 +43,42 @@ public class Player : LivingEntity public override void Update() { #region анимация управления, стрельбы + var textureName = (graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName; + var animatedGraphicsComponent = graphicsComponent as AnimatedGraphicsComponent; switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation)) { case ScopeState.Top: - if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_up") - (graphicsComponent as AnimatedGraphicsComponent).StartCyclingAnimation("player_run_up"); + + if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_right") + (graphicsComponent as AnimatedGraphicsComponent).StartCyclingAnimation("player_run_right"); break; case ScopeState.Down: - StartAnimation("player_run_down"); + if (textureName!="player_run_down") + animatedGraphicsComponent.StartCyclingAnimation("player_run_down"); break; case ScopeState.Right: - StartAnimation("player_run_right"); + if (textureName!="player_run_up") + animatedGraphicsComponent.StartCyclingAnimation("player_run_up"); break; case ScopeState.Left: - StartAnimation("left"); + if (textureName!="player_run_left") + animatedGraphicsComponent.StartCyclingAnimation("player_run_left"); break; case ScopeState.TopRight: - StartAnimation("player_run_right_up"); + if (textureName!="player_run_right_up") + animatedGraphicsComponent.StartCyclingAnimation("player_run_right_up"); break; case ScopeState.TopLeft: - StartAnimation("player_run_left_up"); + if (textureName!="player_run_left_up") + animatedGraphicsComponent.StartCyclingAnimation("player_run_left_up"); break; case ScopeState.DownRight: - StartAnimation("player_run_right_down"); + if (textureName!="player_run_right_down") + animatedGraphicsComponent.StartCyclingAnimation("player_run_right_down"); break; case ScopeState.DownLeft: - StartAnimation("player_run_left_down"); + if (textureName!="player_run_left_down") + animatedGraphicsComponent.StartCyclingAnimation("player_run_left_down"); break; } #endregion From 0ffad2cac7448448541d7a36786eb47b6898e0bd Mon Sep 17 00:00:00 2001 From: Lev Date: Tue, 20 Aug 2024 14:31:01 +0300 Subject: [PATCH 4/5] add Animation of movement player --- .../player_down-left_idle.animation | 0 .../player_down-right_idle.animation | 0 .../player_down_idle.animation | 0 .../player_left_idle.animation | 0 .../player_right_idle.animation | 0 .../player_top-left_idle.animation | 0 .../player_top-right_idle.animation | 0 ZoFo/GameCore/GameManagers/InputManager.cs | 40 +++--- .../Player/IPlayerWeaponAttack.cs | 2 +- .../Entities/LivingEntities/Player/Player.cs | 116 ++++++++++++++---- .../Player/PlayerAttacks/SwordAttack.cs | 12 ++ .../Graphics/AnimatedGraphicsComponent.cs | 2 - ZoFo/GameSettings.txt | 2 +- 13 files changed, 130 insertions(+), 44 deletions(-) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_down-left_idle.animation (100%) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_down-right_idle.animation (100%) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_down_idle.animation (100%) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_left_idle.animation (100%) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_right_idle.animation (100%) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_top-left_idle.animation (100%) rename ZoFo/Content/Textures/Animations/{ => Simple Idles}/player_top-right_idle.animation (100%) diff --git a/ZoFo/Content/Textures/Animations/player_down-left_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_down-left_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_down-left_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_down-left_idle.animation diff --git a/ZoFo/Content/Textures/Animations/player_down-right_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_down-right_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_down-right_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_down-right_idle.animation diff --git a/ZoFo/Content/Textures/Animations/player_down_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_down_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_down_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_down_idle.animation diff --git a/ZoFo/Content/Textures/Animations/player_left_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_left_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_left_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_left_idle.animation diff --git a/ZoFo/Content/Textures/Animations/player_right_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_right_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_right_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_right_idle.animation diff --git a/ZoFo/Content/Textures/Animations/player_top-left_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_top-left_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_top-left_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_top-left_idle.animation diff --git a/ZoFo/Content/Textures/Animations/player_top-right_idle.animation b/ZoFo/Content/Textures/Animations/Simple Idles/player_top-right_idle.animation similarity index 100% rename from ZoFo/Content/Textures/Animations/player_top-right_idle.animation rename to ZoFo/Content/Textures/Animations/Simple Idles/player_top-right_idle.animation diff --git a/ZoFo/GameCore/GameManagers/InputManager.cs b/ZoFo/GameCore/GameManagers/InputManager.cs index 2524e5a..3ac93f3 100644 --- a/ZoFo/GameCore/GameManagers/InputManager.cs +++ b/ZoFo/GameCore/GameManagers/InputManager.cs @@ -5,18 +5,11 @@ using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Formats.Tar; -using System.Linq; -using System.Reflection.Metadata.Ecma335; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; using ZoFo.GameCore.GUI; namespace ZoFo.GameCore.GameManagers { public enum ScopeState { Idle, Left, Right, Top, Down, TopLeft, TopRight, DownLeft, DownRight } - public class InputManager { public event Action ShootEvent; // событие удара(когда нажат X, событие срабатывает) @@ -176,7 +169,6 @@ namespace ZoFo.GameCore.GameManagers #region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract if (keyBoardState.IsKeyDown(Keys.E) && !isInteract) { - OnInteract?.Invoke(); Debug.WriteLine("взаимодействие с Collectable"); } @@ -203,18 +195,33 @@ namespace ZoFo.GameCore.GameManagers DebugHUD.Instance.Set("controls", currentScopeState.ToString()); } #region работа с ScopeState и Vector2 + /// + /// возвращает число от -14 до 16, начиная с + /// + /// + /// + public int ConvertAttackVector2ToState(Vector2 vector){ + int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, + vector.X) * (180 / Math.PI) / 360 * 32); + return currentSection; + } public ScopeState ConvertVector2ToState(Vector2 vector) { - //if() - int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, + int currentSection = 0; + if(vector.X == 0f && vector.Y == 0f){ + currentScopeState = ScopeState.Idle; + } + else + { + currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, vector.X) * (180 / Math.PI) / 360 * 16); - - DebugHUD.DebugSet("current section", currentSection.ToString()); - //DebugHUD.DebugSet("y", InputMovementDirection.Y.ToString()); - //DebugHUD.DebugSet("x", InputMovementDirection.X.ToString()); + switch(currentSection) { + case -1: + currentScopeState = ScopeState.Idle; + break; case 0 or 1: currentScopeState = ScopeState.Right; break; @@ -242,6 +249,11 @@ namespace ZoFo.GameCore.GameManagers default: break; } + + DebugHUD.DebugSet("current section", currentSection.ToString()); + DebugHUD.DebugSet("y", vector.Y.ToString()); + DebugHUD.DebugSet("x", vector.X.ToString()); + } return currentScopeState; } #endregion diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/IPlayerWeaponAttack.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/IPlayerWeaponAttack.cs index 3fafa2b..daaa390 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/IPlayerWeaponAttack.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/IPlayerWeaponAttack.cs @@ -8,6 +8,6 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player { internal interface IPlayerWeaponAttack { - + } } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index a3e6022..ce865ba 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -11,6 +11,7 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.Graphics; using System.Diagnostics; using ZoFo.GameCore.GUI; +using System.Runtime.InteropServices; namespace ZoFo.GameCore.GameObjects; @@ -25,7 +26,9 @@ public class Player : LivingEntity private float speed; private int health; - public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player); + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player.Animations, AppManager.Instance.AssetManager.Player.IdleAnimation); + + public AnimatedGraphicsComponent animatedGraphicsComponent => graphicsComponent as AnimatedGraphicsComponent; private LootData lootData; public bool IsTryingToInteract { get; set; } @@ -42,47 +45,103 @@ public class Player : LivingEntity public override void Update() { - #region анимация управления, стрельбы - var textureName = (graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName; - var animatedGraphicsComponent = graphicsComponent as AnimatedGraphicsComponent; + #region название current текстуры + var idName = animatedGraphicsComponent.CurrentAnimation.Id; + #endregion + + #region анимация управления подбора лута + DebugHUD.DebugSet("texture name", idName); switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation)) { case ScopeState.Top: - - if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_right") - (graphicsComponent as AnimatedGraphicsComponent).StartCyclingAnimation("player_run_right"); + if (idName!="player_run_up") + StartAnimation("player_run_up"); break; case ScopeState.Down: - if (textureName!="player_run_down") - animatedGraphicsComponent.StartCyclingAnimation("player_run_down"); - break; + if (idName!="player_run_down") + StartAnimation("player_run_down"); + break; case ScopeState.Right: - if (textureName!="player_run_up") - animatedGraphicsComponent.StartCyclingAnimation("player_run_up"); - break; case ScopeState.Left: - if (textureName!="player_run_left") - animatedGraphicsComponent.StartCyclingAnimation("player_run_left"); - break; + if (idName!="player_run_right") + StartAnimation("player_run_right"); + break; case ScopeState.TopRight: - if (textureName!="player_run_right_up") - animatedGraphicsComponent.StartCyclingAnimation("player_run_right_up"); - break; case ScopeState.TopLeft: - if (textureName!="player_run_left_up") - animatedGraphicsComponent.StartCyclingAnimation("player_run_left_up"); + if (idName!="player_run_right_up") + StartAnimation("player_run_right_up"); break; case ScopeState.DownRight: - if (textureName!="player_run_right_down") - animatedGraphicsComponent.StartCyclingAnimation("player_run_right_down"); - break; case ScopeState.DownLeft: - if (textureName!="player_run_left_down") - animatedGraphicsComponent.StartCyclingAnimation("player_run_left_down"); + if (idName!="player_run_right_down") + StartAnimation("player_run_right_down"); + break; + case ScopeState.Idle: + if (idName!="player_look_down") + StartAnimation("player_look_down"); break; } #endregion + + #region анимация поворота оружия + int currentAttackSection = AppManager.Instance.InputManager.ConvertAttackVector2ToState(InputWeaponRotation); + switch(currentAttackSection) + { + case 0 or 1: + //right + break; + case 2 or 3: + //down_right_right + break; + case 4 or 5: + //down_right + break; + case 6 or 7: + //down_right_left + break; + case 8 or 9: + //down + break; + case 10 or 11: + //down_left_right + break; + case 12 or 13: + //down_left + break; + case 14 or 15: + //down_left_left + break; + case 16 or -14: + //left + break; + case -13 or -12: + //top_left_left + break; + case -11 or -10: + //top_left + break; + case -9 or -8: + //top_left_right + break; + case -7 or -6: + //top + break; + case -5 or -4: + //top_right_left + break; + case -3 or -2: + //top_right + break; + case -1 or 0: + //top_right_right + break; + } + #endregion + MovementLogic(); + } + public void WeaponAttack(){ + } public void MovementLogic() { @@ -114,4 +173,9 @@ public class Player : LivingEntity } } } + public override void Draw(SpriteBatch spriteBatch) + { + //DrawDebugRectangle(spriteBatch, collisionComponent.stopRectangle.SetOrigin(position + new Vector2(10,10)), Color.Green); + base.Draw(spriteBatch); + } } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/PlayerAttacks/SwordAttack.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/PlayerAttacks/SwordAttack.cs index 508f02f..9136797 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/PlayerAttacks/SwordAttack.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/PlayerAttacks/SwordAttack.cs @@ -1,13 +1,25 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; +using System.Numerics; using System.Text; using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.GameManagers.CollisionManager; +using ZoFo.GameCore.GameObjects.MapObjects.StopObjects; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player.PlayerAttacks { internal class SwordAttack : IPlayerWeaponAttack { + Rectangle rectangle; + public SwordAttack(){ + } + public Rectangle Attack(Vector2 position){ + rectangle = new Rectangle((int)position.X, (int)position.Y, 30, 10); + return rectangle; + } } } diff --git a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs index 86af079..b171d4c 100644 --- a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs @@ -136,7 +136,6 @@ namespace ZoFo.GameCore.Graphics buildSourceRectangle(); SetInterval(); - } public void StartCyclingAnimation(string startedanimationId) @@ -147,7 +146,6 @@ namespace ZoFo.GameCore.Graphics buildSourceRectangle(); SetInterval(); - } public void StopAnimation() diff --git a/ZoFo/GameSettings.txt b/ZoFo/GameSettings.txt index f5dcd93..5c15cbb 100644 --- a/ZoFo/GameSettings.txt +++ b/ZoFo/GameSettings.txt @@ -1 +1 @@ -{"IsFullScreen":false,"MainVolume":1.0,"MusicVolume":1.0,"SoundEffectsVolume":1.0,"Resolution":{"X":1440,"Y":900}} \ No newline at end of file +{"IsFullScreen":false,"MainVolume":1.0,"MusicVolume":0.0,"SoundEffectsVolume":1.0,"Resolution":{"X":1440,"Y":900}} \ No newline at end of file From f317fb512d22acaef68f42628abb83eaa4b7fa35 Mon Sep 17 00:00:00 2001 From: MARKPRO44 <119742977+MARKPRO4444@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:32:25 +0300 Subject: [PATCH 5/5] PlayerAttack --- ZoFo/GameCore/GUI/AbstractGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZoFo/GameCore/GUI/AbstractGUI.cs b/ZoFo/GameCore/GUI/AbstractGUI.cs index e8ceb33..6aafbb2 100644 --- a/ZoFo/GameCore/GUI/AbstractGUI.cs +++ b/ZoFo/GameCore/GUI/AbstractGUI.cs @@ -38,7 +38,7 @@ public abstract class AbstractGUI public virtual void LoadContent() { - Manager.LoadContent(AppManager.Instance.Content, "Font"); + Manager.LoadContent(AppManager.Instance.Content, "Fonts/Font"); mouse = AppManager.Instance.Content.Load("Textures/GUI/mouse"); }