From 5bd2b7d93ba018cbf3e840af115c05fbf7090c57 Mon Sep 17 00:00:00 2001 From: bmvolf Date: Fri, 18 Aug 2023 13:53:18 +0300 Subject: [PATCH] started vertical shoot --- .../Content/animations/playerShootUpLeft | 1 + .../Content/animations/playerShootUpRight | 1 + .../LivingEntities/Monsters/Zombie.cs | 7 +-- .../LivingEntities/Player/Player.cs | 48 +++++++++++++++---- 4 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 DangerousD/Content/animations/playerShootUpLeft create mode 100644 DangerousD/Content/animations/playerShootUpRight diff --git a/DangerousD/Content/animations/playerShootUpLeft b/DangerousD/Content/animations/playerShootUpLeft new file mode 100644 index 0000000..ac72a72 --- /dev/null +++ b/DangerousD/Content/animations/playerShootUpLeft @@ -0,0 +1 @@ +{"id":"playerShootUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"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/animations/playerShootUpRight b/DangerousD/Content/animations/playerShootUpRight new file mode 100644 index 0000000..5bdb07a --- /dev/null +++ b/DangerousD/Content/animations/playerShootUpRight @@ -0,0 +1 @@ +{"id":"playerShootUpRight","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index c1737f2..90fdfc2 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using DangerousD.GameCore.Managers; +using DangerousD.GameCore.GameObjects; namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { @@ -24,7 +25,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { Width = 24; Height = 40; - monster_speed = 3; + monster_speed = 2; name = "Zombie"; monster_health = 2; leftBorder = (int)position.X - 100; @@ -133,7 +134,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public void Target() { - if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0) + if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 200, Height), typeof(Player)).Count > 0) { if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X) { @@ -183,5 +184,5 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Death(); } } + } } -} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index b8e68ba..8b14436 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -32,7 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public bool isUping = false; private int shootLength = 160; - + public int Bullets { get { return bullets; } } @@ -49,7 +49,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities AppManager.Instance.InputManager.MovEventDown += MoveDown; } - velocity = new Vector2(0, 0); + velocity = new Vector2(0, 0); rightBorder = (int)position.X + 100; leftBorder = (int)position.X - 100; bullets = 5; @@ -70,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public bool IsAlive { get { return isAlive; } } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", - "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot"}, "playerReload"); + "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload"); public void Attack() { @@ -98,7 +98,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities return; } isAttacked = true; - if(monsterName == "Zombie") + if (monsterName == "Zombie") { AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => @@ -109,7 +109,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } }; } - else if(monsterName == "Spider") + else if (monsterName == "Spider") { AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => @@ -144,7 +144,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { StartCicycleAnimation("playerShootRight"); var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); - if (targets != null) + if (targets.Count() > 0) { Zombie targetZombie = (Zombie)targets.First(); targetZombie.TakeDamage(); @@ -184,7 +184,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities FallingThroughPlatform = false; } GraphicsComponent.SetCameraPosition(Pos); - if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) + if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) { if (!isShooting) { @@ -227,7 +227,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит { - if(bullets < 5) + if (bullets < 5) { if (GraphicsComponent.GetCurrentAnimation != "playerReload") { @@ -236,11 +236,31 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if (isRight) { - GraphicsComponent.StartAnimation("playerRightStay"); + if (isUping) + { + if (GraphicsComponent.GetCurrentAnimation != "playerShootUpRight") + { + GraphicsComponent.StartAnimation("playerShootUpRight"); + } + } + else + { + GraphicsComponent.StartAnimation("playerRightStay"); + } } else if (!isRight) { - GraphicsComponent.StartAnimation("playerStayLeft"); + if (isUping) + { + if (GraphicsComponent.GetCurrentAnimation != "playerShootUpLeft") + { + GraphicsComponent.StartAnimation("playerShootUpLeft"); + } + } + else + { + GraphicsComponent.StartAnimation("playerStayLeft"); + } } } } @@ -256,5 +276,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities isOnGround = false; } + public class Bullet : GameObjects.LivingEntity + { + public Bullet(Vector2 position) : base(position) + { + } + protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft"); + + } } }