diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 37d9842..5988f41 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -223,6 +223,18 @@ /processorParam:TextureFormat=Color /build:sliderBackground.png +#begin SmokeAnimation2.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:SmokeAnimation2.png + #begin textboxbackground1-1.png /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/SmokeAnimation2.png b/DangerousD/Content/SmokeAnimation2.png new file mode 100644 index 0000000..b414b01 Binary files /dev/null and b/DangerousD/Content/SmokeAnimation2.png differ diff --git a/DangerousD/Content/animations/smokeAfterShoot b/DangerousD/Content/animations/smokeAfterShoot new file mode 100644 index 0000000..1377656 --- /dev/null +++ b/DangerousD/Content/animations/smokeAfterShoot @@ -0,0 +1 @@ +{"id":"smokeAfterShoot","textureName":"smokeAnimation2","startSpriteRectangle":{"X":0,"Y":0,"Width":64,"Height":64},"frameSecond":[{"Item1":0,"Item2":3}],"textureFrameInterval":1,"framesCount":10,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/smokeAnimation.png b/DangerousD/Content/smokeAnimation.png new file mode 100644 index 0000000..3483481 Binary files /dev/null and b/DangerousD/Content/smokeAnimation.png differ diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 3828b1e..74671c5 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -39,6 +39,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { isGoRight = false; } + + this.GraphicsComponent.actionOfAnimationEnd += (a) => + { + if (a == "ZombieRightAttack" || a == "ZombieLeftAttack") + { + isAttaking = false; + } + }; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft"); @@ -123,7 +131,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters if (AppManager.Instance.GameManager.players[0].IsAlive) { Attack(); - isAttack = false; } } base.OnCollision(gameObject); @@ -136,14 +143,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X) { isTarget = true; - leftBorder = Pos.X - 10; + leftBorder = Pos.X - 100; rightBorder = Pos.X + AppManager.Instance.GameManager.players[0].Pos.X; } else if(!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X) { isTarget = true; - rightBorder = Pos.X + 10; + rightBorder = Pos.X + 100; leftBorder = AppManager.Instance.GameManager.players[0].Pos.X; } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs similarity index 87% rename from DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs rename to DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs index 7dda1b1..25e01f0 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/DeathRectangle.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs @@ -9,9 +9,9 @@ using Microsoft.Xna.Framework; namespace DangerousD.GameCore.GameObjects.PlayerDeath { - public class DeathRectangle : GameObject + public class AnimationRectangle : GameObject { - public DeathRectangle(Vector2 pos, string DeathType) : base(pos) + public AnimationRectangle(Vector2 pos, string DeathType) : base(pos) { Height = 48; Width = 48; diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index d0c144a..380d3bb 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -16,11 +16,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public class Player : LivingEntity { bool isAlive = true; - bool isRight; + bool isRight = true; string stayAnimation; bool isJump = false; public int health; - public bool isGoRight = false; public Vector2 playerVelocity; public int rightBorder; public int leftBorder; @@ -32,6 +31,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities private int bullets; public bool FallingThroughPlatform = false; public bool isUping = false; + private int shootLength = 160; @@ -71,7 +71,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"}, "playerReload"); + "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot"}, "playerReload"); public void Attack() { @@ -94,11 +94,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public void Death(string monsterName) { - return; //godmode isAttacked = true; if(monsterName == "Zombie") { - DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); + AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => { if (a == "DeathFrom" + monsterName) @@ -109,7 +108,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } else if(monsterName == "Spider") { - DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); + AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); deathRectangle.Gr.actionOfAnimationEnd += (a) => { if (a == "DeathFrom" + monsterName) @@ -142,7 +141,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { GraphicsComponent.StartAnimation("playerShootRight"); } - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), 100, 10), typeof(Zombie)); + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)); if (targets != null) { foreach (var target in targets) @@ -151,14 +150,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities targetZombie.TakeDamage(); } } + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); } else { - if (GraphicsComponent.GetCurrentAnimation != "playerShootRight") + if (GraphicsComponent.GetCurrentAnimation != "playerShootLeft") { - GraphicsComponent.StartAnimation("playerShootRight"); + GraphicsComponent.StartAnimation("playerShootLeft"); } - var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), -100, 10), typeof(Zombie)); + var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie)); if (targets != null) { foreach (var target in targets) @@ -167,13 +167,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities targetZombie.TakeDamage(); } } + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); } } } } public override void Update(GameTime gameTime) { - if (AppManager.Instance.InputManager.ScopeState==ScopeState.Up) + if (AppManager.Instance.InputManager.ScopeState == ScopeState.Up) { isUping = true; } @@ -189,12 +190,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities GraphicsComponent.SetCameraPosition(Pos); if (!isAttacked || isInvincible) { - Move(gameTime); - } - else - { - velocity.X = 0; + if (!isShooting) + { + Move(gameTime); + } + else + { + velocity.X = 0; + } } + base.Update(gameTime); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/SmokeAfterShoot.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/SmokeAfterShoot.cs new file mode 100644 index 0000000..b401ffc --- /dev/null +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/SmokeAfterShoot.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DangerousD.GameCore.GameObjects; +using DangerousD.GameCore.Graphics; +using Microsoft.Xna.Framework; + +namespace DangerousD.GameCore.GameObjects.PlayerDeath +{ + public class SmokeAfterShoot : GameObject + { + public SmokeAfterShoot(Vector2 pos) : base(pos) + { + Height = 6; + Width = 6; + PlaySmoke(); + this.GraphicsComponent.actionOfAnimationEnd += (a) => + { + if (a == "smokeAfterShoot") + { + AppManager.Instance.GameManager.Remove(this); + } + }; + } + + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "smokeAfterShoot" }, + "smokeAfterShoot"); + + public GraphicsComponent Gr => GraphicsComponent; + + private void PlaySmoke() + { + if (GraphicsComponent.GetCurrentAnimation != "smokeAfterShoot") + { + GraphicsComponent.StartAnimation("smokeAfterShoot"); + } + } + + } +} \ No newline at end of file diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 53ffa61..615bd3b 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -158,8 +158,10 @@ namespace DangerousD.GameCore } } GetPlayer1.Update(gameTime); - foreach (var item in otherObjects) - item.Update(gameTime); + for(int i = 0; i < otherObjects.Count; i++) + { + otherObjects[i].Update(gameTime); + } physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, players, gameTime); }