diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index 262f3e2..bb8a054 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -185,6 +185,33 @@ #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 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/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 0000000..ca73be1 Binary files /dev/null and b/ZoFo/Content/Textures/Animations/player_run_right.zip differ 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/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"); } diff --git a/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs b/ZoFo/GameCore/GameManagers/AssetsManager/AssetManager.cs index 334957f..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" ], + 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/GameManagers/InputManager.cs b/ZoFo/GameCore/GameManagers/InputManager.cs index a49dfde..cec9e23 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, событие срабатывает) @@ -177,7 +170,6 @@ namespace ZoFo.GameCore.GameManagers #region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract if (keyBoardState.IsKeyDown(Keys.E) && !isInteract) { - OnInteract?.Invoke(); Debug.WriteLine("взаимодействие с Collectable"); } @@ -204,18 +196,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; @@ -243,6 +250,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 d8910fc..a7d0632 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; @@ -23,13 +24,16 @@ public class Player : LivingEntity public int reloading; public float health= 100; public float MaxHealth = 100; + + public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player.Animations, AppManager.Instance.AssetManager.Player.IdleAnimation); + public AnimatedGraphicsComponent animatedGraphicsComponent => graphicsComponent as AnimatedGraphicsComponent; + public float rad = 0; public float MaxRad = 100; public LootData lootData; - - public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player); + public bool IsTryingToInteract { get; set; } @@ -42,51 +46,118 @@ public class Player : LivingEntity lootData = new LootData(); lootData.loots = new Dictionary(); 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"); } public override void Update() - { + { + #region название current текстуры + var idName = animatedGraphicsComponent.CurrentAnimation.Id; + #endregion + + #region анимация управления подбора лута + DebugHUD.DebugSet("texture name", idName); if (reloading>0) { reloading--; } - - #region анимация управления, стрельбы + switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation)) { case ScopeState.Top: - + if (idName!="player_run_up") + StartAnimation("player_run_up"); break; case ScopeState.Down: - - break; + if (idName!="player_run_down") + StartAnimation("player_run_down"); + break; case ScopeState.Right: - //StartAnimation("player_running_top_rotate"); - break; case ScopeState.Left: - - break; + if (idName!="player_run_right") + StartAnimation("player_run_right"); + break; case ScopeState.TopRight: - - break; case ScopeState.TopLeft: - + if (idName!="player_run_right_up") + StartAnimation("player_run_right_up"); break; case ScopeState.DownRight: - - break; case ScopeState.DownLeft: - + 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() { @@ -131,21 +202,21 @@ public class Player : LivingEntity var rect = collisionComponent.stopRectangle.SetOrigin(position); rect.Width += 100; rect.Height += 100; - Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(rect, this); - AppManager.Instance.server.RegisterGameObject(new Particle(rect.Location.ToVector2())); - if (entities.Length>0) + Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(rect, this); + if (entities != null) { - DebugHUD.DebugSet("ent[0]", entities[0].ToString()); - if (entities != null) + foreach (Entity entity in entities) { - foreach (Entity entity in entities) - { if (entity is Enemy) { (entity as Enemy).TakeDamage(1); } - } } } } + 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 85c4a7e..b171d4c 100644 --- a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs @@ -136,7 +136,16 @@ namespace ZoFo.GameCore.Graphics buildSourceRectangle(); SetInterval(); + } + + public void StartCyclingAnimation(string startedanimationId) + { + currentFrame = 0; + currentAnimation = animations.Find(x => x.Id == startedanimationId); + currentAnimation.IsCycle = true; + 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