From f2c73bb3afc198875f1f07c3d52243d70ad3d1dc Mon Sep 17 00:00:00 2001 From: Lev Date: Tue, 20 Aug 2024 04:51:29 +0300 Subject: [PATCH] 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