diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index f16b512..2b4d072 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -81,6 +81,18 @@ /processorParam:TextureFormat=Color /build:deathBackground.jpg +#begin Diamond.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:Diamond.png + #begin door.png /importer:TextureImporter /processor:TextureProcessor @@ -121,6 +133,18 @@ /processorParam:TextureFormat=Compressed /build:Font2.spritefont +#begin GetScore.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:GetScore.png + #begin menuFon.jpg /importer:TextureImporter /processor:TextureProcessor @@ -273,6 +297,36 @@ /processorParam:TextureFormat=Color /build:textboxbackground1-1.png +#begin sounds/collected_coins.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:sounds/collected_coins.mp3 + +#begin sounds/DoomTestSong.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:sounds/DoomTestSong.mp3 + +#begin sounds/shotgun_shot.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:sounds/shotgun_shot.mp3 + +#begin sounds/z1.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:sounds/z1.mp3 + +#begin sounds/z3.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:sounds/z3.mp3 + #begin textboxbackground2-1.png /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/Diamond.png b/DangerousD/Content/Diamond.png new file mode 100644 index 0000000..7813fb5 Binary files /dev/null and b/DangerousD/Content/Diamond.png differ diff --git a/DangerousD/Content/GetScore.png b/DangerousD/Content/GetScore.png new file mode 100644 index 0000000..354d341 Binary files /dev/null and b/DangerousD/Content/GetScore.png differ diff --git a/DangerousD/Content/animations/Diamond b/DangerousD/Content/animations/Diamond new file mode 100644 index 0000000..23959bf --- /dev/null +++ b/DangerousD/Content/animations/Diamond @@ -0,0 +1 @@ +{"id":"Diamond","textureName":"Diamond","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":15}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/GhostAttack b/DangerousD/Content/animations/GhostAttack index 7ada2dc..8425c93 100644 --- a/DangerousD/Content/animations/GhostAttack +++ b/DangerousD/Content/animations/GhostAttack @@ -1 +1 @@ -{"id":"GhostAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":503,"Width":24,"Height":31},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"} +{"id":"GhostAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":503,"Width":24,"Height":31},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":50,"framesCount":2,"isCycle":false,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/score100 b/DangerousD/Content/animations/score100 new file mode 100644 index 0000000..ee240b5 --- /dev/null +++ b/DangerousD/Content/animations/score100 @@ -0,0 +1,20 @@ +{ + "id": "score100", + "textureName": "GetScore", + "startSpriteRectangle": { + "X": 0, + "Y": 0, + "Width": 32, + "Height": 32 + }, + "frameSecond": [ + { + "Item1": 0, + "Item2": 10 + } + ], + "textureFrameInterval": 1, + "framesCount": 3, + "isCycle": false, + "offset": "1, 0" +} diff --git a/DangerousD/Content/animations/score600 b/DangerousD/Content/animations/score600 new file mode 100644 index 0000000..48e7e2b --- /dev/null +++ b/DangerousD/Content/animations/score600 @@ -0,0 +1,20 @@ +{ + "id": "score600", + "textureName": "GetScore", + "startSpriteRectangle": { + "X": 0, + "Y": 33, + "Width": 32, + "Height": 32 + }, + "frameSecond": [ + { + "Item1": 0, + "Item2": 10 + } + ], + "textureFrameInterval": 1, + "framesCount": 3, + "isCycle": false, + "offset": "1, 0" +} diff --git a/DangerousD/Content/map.tmx b/DangerousD/Content/map.tmx index 18bf11c..a038ff5 100644 --- a/DangerousD/Content/map.tmx +++ b/DangerousD/Content/map.tmx @@ -71,5 +71,10 @@ + + + + + diff --git a/DangerousD/Content/sounds/collected_coins.mp3 b/DangerousD/Content/sounds/collected_coins.mp3 new file mode 100644 index 0000000..380dfaf Binary files /dev/null and b/DangerousD/Content/sounds/collected_coins.mp3 differ diff --git a/DangerousD/Content/sounds/z1.mp3 b/DangerousD/Content/sounds/z1.mp3 new file mode 100644 index 0000000..605cf92 Binary files /dev/null and b/DangerousD/Content/sounds/z1.mp3 differ diff --git a/DangerousD/Content/sounds/z3.mp3 b/DangerousD/Content/sounds/z3.mp3 new file mode 100644 index 0000000..b9bc108 Binary files /dev/null and b/DangerousD/Content/sounds/z3.mp3 differ diff --git a/DangerousD/GameCore/GUI/DebugHUD.cs b/DangerousD/GameCore/GUI/DebugHUD.cs index c4e3e55..d864f75 100644 --- a/DangerousD/GameCore/GUI/DebugHUD.cs +++ b/DangerousD/GameCore/GUI/DebugHUD.cs @@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GUI public void Draw(SpriteBatch spriteBatch) { - var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()); + /*var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()); spriteBatch.Begin(); spriteBatch.DrawString( _spriteFont, @@ -52,7 +52,7 @@ namespace DangerousD.GameCore.GUI SpriteEffects.None, 0 ); - spriteBatch.End(); + spriteBatch.End();*/ } public void Set(string key, string value) diff --git a/DangerousD/GameCore/GameObjects/Entities/Door.cs b/DangerousD/GameCore/GameObjects/Entities/Door.cs index 0584251..5a8dd2f 100644 --- a/DangerousD/GameCore/GameObjects/Entities/Door.cs +++ b/DangerousD/GameCore/GameObjects/Entities/Door.cs @@ -7,13 +7,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework.Graphics; +using DangerousD.GameCore.GameObjects.Entities.Items; namespace DangerousD.GameCore.GameObjects.Entities { public class Door : Entity { private Rectangle _sourceRectangle; - + Random random = new Random(); public Door(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position) { _sourceRectangle = sourceRectangle; @@ -46,6 +47,11 @@ namespace DangerousD.GameCore.GameObjects.Entities { AppManager.Instance.GameManager.Remove(this); //тут спавн лута + for (int i = 0; i < random.Next(0,15); i++) + { + var d = new Diamond(Vector2.Zero); + d.SetPosition(Pos + new Vector2(random.Next(-30, 30), Height - d.Height)); + } } } } diff --git a/DangerousD/GameCore/GameObjects/Entities/Items/Diamond.cs b/DangerousD/GameCore/GameObjects/Entities/Items/Diamond.cs index 7f81c6b..b8caec4 100644 --- a/DangerousD/GameCore/GameObjects/Entities/Items/Diamond.cs +++ b/DangerousD/GameCore/GameObjects/Entities/Items/Diamond.cs @@ -1,13 +1,32 @@ +using DangerousD.GameCore.GameObjects.LivingEntities; using DangerousD.GameCore.Graphics; using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using static System.Formats.Asn1.AsnWriter; namespace DangerousD.GameCore.GameObjects.Entities.Items; public class Diamond : Entity { + Random random = new Random(); public Diamond(Vector2 position) : base(position) { + int scal = random.Next(3, 12); + Width = scal; + Height = scal; + GraphicsComponent.StartAnimation("Diamond"); } - protected override GraphicsComponent GraphicsComponent { get; } + protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List() { "Diamond" }, "Diamond"); + public override void OnCollision(GameObject gameObject) + { + if (gameObject is Player) + { + AppManager.Instance.GameManager.Remove(this); + new ScoreText(Pos, ScoreText.scores[random.Next(0, ScoreText.scores.Length-1)]); + AppManager.Instance.SoundManager.StartSound("collected_coins", Pos, Pos); + } + base.OnCollision(gameObject); + } } \ No newline at end of file diff --git a/DangerousD/GameCore/GameObjects/Entities/Items/ScoreText.cs b/DangerousD/GameCore/GameObjects/Entities/Items/ScoreText.cs new file mode 100644 index 0000000..2a0d35d --- /dev/null +++ b/DangerousD/GameCore/GameObjects/Entities/Items/ScoreText.cs @@ -0,0 +1,34 @@ +using DangerousD.GameCore.GameObjects.LivingEntities; +using DangerousD.GameCore.Graphics; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DangerousD.GameCore.GameObjects.Entities.Items +{ + internal class ScoreText : Entity + { + public static int[] scores = new int[] { 100, 600}; + public ScoreText(Vector2 position, int score) : base(position) + { + Width = 32; + Height = 32; + GraphicsComponent.StartAnimation("score"+ score); + GraphicsComponent.actionOfAnimationEnd += (a) => { AppManager.Instance.GameManager.Remove(this); }; + } + public override void Initialize() + { + } + public override void Update(GameTime gameTime) + { + _pos.Y -= 1.0f; + base.Update(gameTime); + } + + protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List() { "score100", "score600" }, "score100"); + + } +} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs index 4c74098..6e999d4 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs @@ -17,6 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters private bool isFlyRight = true; private bool isFlyUp = true; private bool isAttacking = false; + private int hp; public Rectangle Collision { @@ -32,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters monster_speed = 3; velocity = new Vector2(3,-3); acceleration = Vector2.Zero; + hp = 10; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "BallMoveRight" }, "BallMoveRight"); @@ -39,7 +41,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Update(GameTime gameTime) { Move(gameTime); - AppManager.Instance.DebugHUD.Set(name, velocity.ToString()); + + Death(); + base.Update(gameTime); } public override void Attack() @@ -60,7 +64,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Death() { - + if (hp <= 0) + { + AppManager.Instance.GameManager.Remove(this); + } } public override void Move(GameTime gameTime) @@ -75,6 +82,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { isFlyRight = false; velocity.X = -velocity.X; + hp--; } } else @@ -84,6 +92,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { isFlyRight = true; velocity.X = -velocity.X; + hp--; } } if (isFlyUp) @@ -94,6 +103,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { isFlyUp = false; velocity.Y = -velocity.Y; + hp--; } } else @@ -103,6 +113,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { isFlyUp = true; velocity.Y = -velocity.Y; + hp--; } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs index 20d6161..c8878cd 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs @@ -17,11 +17,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters isGoRight = true; monster_speed = 3; name = "Ghost"; - Width = 48; - Height = 62; + Width = 24; + Height = 30; GraphicsComponent.StartAnimation("GhostSpawn"); - acceleration = Vector2.Zero; - + acceleration = new Vector2(0,1); + monster_health = 1; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight"); @@ -38,13 +38,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Attack() { - + velocity.X = 0; + isAttack = true; + if (GraphicsComponent.GetCurrentAnimation != "GhostAttack") + { + GraphicsComponent.StartAnimation("GhostAttack"); + } + + AppManager.Instance.GameManager.players[0].Death(name); } public override void Death() { } + public override void OnCollision(GameObject gameObject) + { + if (gameObject is Player) + { + if (AppManager.Instance.GameManager.players[0].IsAlive) + { + Attack(); + + } + } + base.OnCollision(gameObject); + } public override void Move(GameTime gameTime) { @@ -64,17 +83,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } velocity.X = -monster_speed; } - if (Pos.X >= rightBoarder) + var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); + if (isGoRight) { - isGoRight = false; + getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, Width + 4, 2)); } - else if (Pos.X <= leftBoarder) + else { - isGoRight = true; + getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 3, (int)Pos.Y + Height / 2 - 2, Width + 3, 2)); } - if (true) - { + + foreach (var item in getCols) + { + if (item is MapObject) + { + isGoRight = !isGoRight; + break; + } } } @@ -82,8 +108,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { } + public void TakeDamage() + { + monster_health--; +<<<<<<< HEAD public override void Target() +======= + + if (monster_health <= 0) + { + Death(); + } + } + public void Target() +>>>>>>> черешня { throw new NotImplementedException(); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs index e77804c..5a60037 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs @@ -173,7 +173,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } public override void Death() { + + Particle particle = new Particle(Pos); + + AppManager.Instance.GameManager.Remove(this); } public override void Move(GameTime gameTime) @@ -220,7 +224,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters velocity.X = -monster_speed; } - var getCols= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ; + var getCols= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); if (isGoRight) { getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 51, 2)); @@ -348,5 +352,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } base.OnCollision(gameObject); } + public void TakeDamage() + { + monster_health--; + + Particle particle = new Particle(Pos); + if (monster_health <= 0) + { + Death(); + } + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs index 7f9b3ec..3ef7a9d 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs @@ -12,24 +12,39 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { public class Werewolf : CoreEnemy { - private bool isAttack; + private bool isJump; + int delay; public Werewolf(Vector2 position) : base(position) { name = "Wolf"; +<<<<<<< HEAD monster_speed = 4; Width = 39; Height = 48; +======= + monster_speed = 3; + Width = 39; + Height = 48; + delay = 10; + monster_health = 3; +>>>>>>> черешня } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight"); public override void Update(GameTime gameTime) { - if (!isAttack) + if(!isJump ) + { + Jump(); + } + if(isOnGround) { Move(gameTime); + } + base.Update(gameTime); } @@ -41,11 +56,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Death() { + for (int i = 0; i < 5; i++) + { + Particle particle = new Particle(Pos); + } + AppManager.Instance.GameManager.Remove(this); } public override void Move(GameTime gameTime) { + isJump = false; + if (isGoRight) { if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight") @@ -62,23 +84,94 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } velocity.X = -monster_speed; } - if (Pos.X >= rightBoarder) + var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); + if (isGoRight) { - isGoRight = false; + getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, Width+4, 2)); } - else if (Pos.X <= leftBoarder) + else { - isGoRight = true; + getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 3, (int)Pos.Y + Height / 2 - 2, Width +3, 2)); + } + + + foreach (var item in getCols) + { + if (item is MapObject) + { + isGoRight = !isGoRight; + break; + } } } public override void Attack(GameTime gameTime) { } +<<<<<<< HEAD public override void Target() +======= + public void Jump() + { + var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); + if (isGoRight) + { + getCols= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width+100, Height),false); + if(getCols.Count > 0) + { + isJump = true; + if (GraphicsComponent.GetCurrentAnimation != "WolfJumpRight") + { + GraphicsComponent.StartAnimation("WolfJumpRight"); + } + velocity.Y = -7; + velocity.X = 6; + } + + } + else + { + getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-100, (int)Pos.Y, 100, Height), false); + if (getCols.Count > 0) + { + isJump = true; + if (GraphicsComponent.GetCurrentAnimation != "WolfJumpLeft") + { + GraphicsComponent.StartAnimation("WolfJumpLeft"); + } + velocity.Y = -7; + velocity.X = -6; + } + + } + + } + public override void OnCollision(GameObject gameObject) + { + /*/if (gameObject is Player) + { + if (AppManager.Instance.GameManager.players[0].IsAlive) + { + AppManager.Instance.GameManager.players[0].Death(name); + } + } + base.OnCollision(gameObject);/*/ + } + public void Target() +>>>>>>> черешня { } + public void TakeDamage() + { + monster_health--; + + Particle particle = new Particle(Pos); + if (monster_health <= 0) + { + Death(); + } + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index fee2677..d589a74 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { public class Zombie : CoreEnemy { - private bool isAttack; float leftBorder; float rightBorder; @@ -59,18 +58,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Target(); Move(gameTime); } - fixBorder(); + //fixBorder(); base.Update(gameTime); } public override void Attack() { - AppManager.Instance.GameManager.GetPlayer1.Death(name); + isAttaking = true; + PlayAttackAnimation(); + AppManager.Instance.GameManager.GetClosestPlayer(Pos).Death(name); } public void PlayAttackAnimation() { velocity.X = 0; - isAttaking = true; if (isGoRight) { if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack") @@ -124,7 +124,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } public override void OnCollision(GameObject gameObject) { - if (gameObject.id == AppManager.Instance.GameManager.GetPlayer1.id && AppManager.Instance.GameManager.GetPlayer1.IsAlive) + if (gameObject.id == AppManager.Instance.GameManager.GetClosestPlayer(Pos).id && AppManager.Instance.GameManager.GetClosestPlayer(Pos).IsAlive) { if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client) { @@ -186,6 +186,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void TakeDamage() { + if (monster_health == 3) + AppManager.Instance.SoundManager.StartSound("z3", Pos, Pos); + if (monster_health == 2) + AppManager.Instance.SoundManager.StartSound("z1", Pos, Pos); + if (monster_health == 1) + AppManager.Instance.SoundManager.StartSound("z3", Pos, Pos); monster_health--; Particle particle = new Particle(Pos); if (monster_health <= 0) diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index deb8ae4..40bc6cb 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -33,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public bool isUping = false; public bool isNetworkPlayer; private int shootLength = 160; + public int score = 0; @@ -186,6 +187,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { if (!isShooting) { + AppManager.Instance.SoundManager.StartSound("shotgun_shot", Pos, Pos); isShooting = true; bullets--; if (isRight) @@ -195,14 +197,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities StartCicycleAnimation("playerShootRight"); Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); bullet.ShootRight(); - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y)); } else { StartCicycleAnimation("playerShootBoomUpRight"); Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); bullet.ShootUpRight(); - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y)); } } else if(!isRight) @@ -212,14 +214,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities StartCicycleAnimation("playerShootBoomUpLeft"); Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); bullet.ShootLeft(); - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y)); } else { StartCicycleAnimation("playerShootBoomUpLeft"); Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); bullet.ShootUpLeft(); - SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); + SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y)); } } } @@ -344,7 +346,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft" }, "playerMoveLeft"); Vector2 direction; - Vector2 maindirection; + public Vector2 maindirection; public void ShootUpRight() { direction = new Vector2(1, -1); @@ -412,10 +414,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } public override void Update(GameTime gameTime) { - if (maindirection != velocity) - { - AppManager.Instance.GameManager.Remove(this); - } base.Update(gameTime); } } diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 62c57b8..116c8a4 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -241,6 +241,7 @@ namespace DangerousD.GameCore Player.Bullet bullet = new Player.Bullet(networkTask.position); bullet.id = networkTask.objId; bullet.velocity = networkTask.velocity; + bullet.maindirection = bullet.velocity; } break; case NetworkTaskOperationEnum.SendPosition: diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index f4eed81..79fd32d 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -87,7 +87,7 @@ namespace DangerousD.GameCore otherObjects.Add(gameObject); } } - + public void Remove(GameObject gameObject) { GetAllGameObjects.Remove(gameObject); @@ -148,8 +148,10 @@ namespace DangerousD.GameCore item.Update(gameTime); foreach (var item in mapObjects) item.Update(gameTime); - foreach (var item in entities) - item.Update(gameTime); + for (int i = 0; i < entities.Count; i++) + { + entities[i].Update(gameTime); + } if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client) { for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++) @@ -172,7 +174,7 @@ namespace DangerousD.GameCore } } GetPlayer1.Update(gameTime); - for(int i = 0; i < otherObjects.Count; i++) + for (int i = 0; i < otherObjects.Count; i++) { otherObjects[i].Update(gameTime); } @@ -183,7 +185,7 @@ namespace DangerousD.GameCore { foreach (var item in GetAllGameObjects) { - if (item.Pos.X (x.Pos - position).Length()).First(); + } } } \ No newline at end of file diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs index 70352c4..e6f1993 100644 --- a/DangerousD/GameCore/Managers/SoundManager.cs +++ b/DangerousD/GameCore/Managers/SoundManager.cs @@ -13,7 +13,7 @@ namespace DangerousD.GameCore { public class SoundManager { - public Dictionary Sounds = new Dictionary(); // словарь со звуками где строка - название файла + public Dictionary Sounds = new Dictionary(); // словарь со звуками где строка - название файла public List PlayingSounds = new List(); // список со всеми звуками, которые проигрываются public float MaxSoundDistance = 1500; // максимальная дальность звука @@ -27,7 +27,7 @@ namespace DangerousD.GameCore string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe foreach (var soundFile in soundFiles) { - Sounds.Add(soundFile, AppManager.Instance.Content.Load("sounds//" + soundFile).CreateInstance()); + Sounds.Add(soundFile, AppManager.Instance.Content.Load("sounds//" + soundFile)); } } @@ -40,7 +40,7 @@ namespace DangerousD.GameCore public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции { - var sound = new Sound(Sounds[soundName]); + var sound = new Sound(Sounds[soundName].CreateInstance()); sound.SoundEffect.IsLooped = false; sound.SoundEffect.Play(); PlayingSounds.Add(sound); @@ -51,7 +51,7 @@ namespace DangerousD.GameCore } public void StartSound(string soundName, Vector2 soundPos, Vector2 playerPos) // запустить звук у которого есть позиция { - var sound = new Sound(Sounds[soundName], soundPos); + var sound = new Sound(Sounds[soundName].CreateInstance(), soundPos); sound.SoundEffect.IsLooped = false; sound.SoundEffect.Volume = (float)(MaxSoundDistance-sound.GetDistance(playerPos)) / MaxSoundDistance; sound.SoundEffect.Play(); @@ -71,7 +71,7 @@ namespace DangerousD.GameCore public void Update() // апдейт, тут происходит изменение громкости { - + return; var player = AppManager.Instance.GameManager.GetPlayer1; if (player != null)