diff --git a/DangerousD/Content/animations/GibsMoveLeftBottom b/DangerousD/Content/animations/GibsMoveLeftBottom new file mode 100644 index 0000000..b0f96f0 --- /dev/null +++ b/DangerousD/Content/animations/GibsMoveLeftBottom @@ -0,0 +1 @@ +{"id":"GibsMoveLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":70,"Y":724,"Width":14,"Height":11},"frameSecond":[{"Item1":0,"Item2":6}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/GibsMoveLeftTop b/DangerousD/Content/animations/GibsMoveLeftTop new file mode 100644 index 0000000..e80c714 --- /dev/null +++ b/DangerousD/Content/animations/GibsMoveLeftTop @@ -0,0 +1 @@ +{"id":"GibsMoveLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":2,"Y":721,"Width":14,"Height":12},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/GibsMoveRightBottom b/DangerousD/Content/animations/GibsMoveRightBottom new file mode 100644 index 0000000..246ab34 --- /dev/null +++ b/DangerousD/Content/animations/GibsMoveRightBottom @@ -0,0 +1 @@ +{"id":"GibsMoveRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":106,"Y":722,"Width":13,"Height":12},"frameSecond":[{"Item1":0,"Item2":6}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/GibsMoveRightTop b/DangerousD/Content/animations/GibsMoveRightTop new file mode 100644 index 0000000..4b193fd --- /dev/null +++ b/DangerousD/Content/animations/GibsMoveRightTop @@ -0,0 +1 @@ +{"id":"GibsMoveRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":37,"Y":721,"Width":14,"Height":13},"frameSecond":[{"Item1":0,"Item2":6}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/GibsNotMove b/DangerousD/Content/animations/GibsNotMove new file mode 100644 index 0000000..e5333b8 --- /dev/null +++ b/DangerousD/Content/animations/GibsNotMove @@ -0,0 +1 @@ +{"id":"GibsNotMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":137,"Y":731,"Width":16,"Height":5},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/HunchmanAttackLeft b/DangerousD/Content/animations/HunchmanAttackLeft index f6b0634..a84b54b 100644 --- a/DangerousD/Content/animations/HunchmanAttackLeft +++ b/DangerousD/Content/animations/HunchmanAttackLeft @@ -1 +1 @@ -{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":124,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"} +{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":112,"Y":124,"Width":27,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"4, 0"} diff --git a/DangerousD/Content/animations/HunchmanAttackRight b/DangerousD/Content/animations/HunchmanAttackRight index 482d7f3..b4e8552 100644 --- a/DangerousD/Content/animations/HunchmanAttackRight +++ b/DangerousD/Content/animations/HunchmanAttackRight @@ -1 +1 @@ -{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"} +{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":102,"Y":99,"Width":31,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"8, 0"} diff --git a/DangerousD/Content/animations/HunchmanMoveRight b/DangerousD/Content/animations/HunchmanMoveRight index a289fa5..2719ebe 100644 --- a/DangerousD/Content/animations/HunchmanMoveRight +++ b/DangerousD/Content/animations/HunchmanMoveRight @@ -1,3 +1 @@ - -{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} - +{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":100,"Width":24,"Height":23},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/map.tmx b/DangerousD/Content/map.tmx index cd29fd9..71275ca 100644 --- a/DangerousD/Content/map.tmx +++ b/DangerousD/Content/map.tmx @@ -62,7 +62,7 @@ - + diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs index 22ea566..5fcbe7d 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs @@ -19,7 +19,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities protected bool isAttack = false; protected bool isGoRight; protected int leftBoarder = 0; - protected int rightBoarder = 700; + protected int rightBoarder = 800; public CoreEnemy(Vector2 position) : base(position) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs index dd60669..c0835dc 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs @@ -1,4 +1,5 @@ -using DangerousD.GameCore.Graphics; +using DangerousD.GameCore.GameObjects.MapObjects; +using DangerousD.GameCore.Graphics; using DangerousD.GameCore.Managers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; @@ -35,6 +36,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters webLength = 0; monster_speed = 3; acceleration = new Vector2(0, -50); + isGoRight = true; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "SpiderMoveRight", "SpiderMoveLeft", "SpiderOnWeb" }, "SpiderMoveRight"); @@ -66,34 +68,50 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Attack(GameTime gameTime) { //48 72 velocity.X = 0; - Width = 48; - Height = 72; delay += (float)gameTime.ElapsedGameTime.TotalSeconds; - if (delay > 0.5 && webLength <= 4 && isDown) + if (isAttack) { - StartCicycleAnimation("SpiderOnWeb"); - acceleration = Vector2.Zero; - webLength++; - _pos.Y += 25; - web.Height = webLength * 25; - web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength)); - delay = 0; - if (webLength == 4) + if (delay > 0.5 && webLength <= 4 && isDown) { - isDown = false; + Width = 48; + Height = 72; + StartCicycleAnimation("SpiderOnWeb"); + acceleration = Vector2.Zero; + webLength++; + _pos.Y += 25; + web.Height = webLength * 25; + web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength)); + delay = 0; + if (webLength == 4) + { + isDown = false; + } } - } - else if (delay > 0.5 && webLength != 0 && !isDown) - { - StartCicycleAnimation("SpiderOnWeb"); - webLength--; - _pos.Y -= 25; - web.Height = webLength * 25; - web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength)); - delay = 0; - if (webLength == 0) + else if (delay > 0.5 && webLength != 0 && !isDown) { - isDown = true; + Width = 48; + Height = 72; + StartCicycleAnimation("SpiderOnWeb"); + webLength--; + _pos.Y -= 25; + web.Height = webLength * 25; + web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength)); + delay = 0; + if (webLength == 0) + { + isDown = true; + } + } + var entitiesInter = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 200, 600)); + if (entitiesInter.Count > 0) + { + foreach (var entity in entitiesInter) + { + if (entity.GetType() == typeof(Player)) + { + player.Death(name); + } + } } } if (webLength == 0) @@ -101,7 +119,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters isAttack = false; } } - //сделать условие с Артемом + public override void Draw(SpriteBatch spriteBatch) { if (GraphicsComponent.GetCurrentAnimation == "SpiderOnWeb") @@ -124,11 +142,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { Width = 112; Height = 24; - - int wallCheck = physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 10, (int)Pos.Y, 150, 10)).Count; - if (wallCheck > 0) + foreach (var entity in physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 7, (int)Pos.Y, 126, 10))) { - isGoRight = !isGoRight; + if (entity.GetType() == typeof(StopTile)) + { + isGoRight = !isGoRight; + } } if (isGoRight) { @@ -146,31 +165,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } velocity.X = -monster_speed; } - if (Pos.X >= rightBoarder) - { - isGoRight = false; - } - else if (Pos.X <= leftBoarder) - { - isGoRight = true; - } } public override void Target() { - if (physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 300, 600), typeof(Player)) != null) + if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width) { - if (player.Pos.X - Pos.X <= 30) - { - isAttack = true; - } - } - if (physicsManager.CheckRectangle(new Rectangle((int)Pos.X-300, (int)Pos.Y, 300, 600), typeof(Player)) != null) - { - if (player.Pos.X - Pos.X <= 30) - { - isAttack = true; - } + isAttack = true; } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 03c24b6..f3008b2 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -80,6 +80,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities } }; } + else if(monsterName == "Spider") + { + DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); + deathRectangle.Gr.actionOfAnimationEnd += (a) => + { + if (a == "DeathFrom" + monsterName) + { + AppManager.Instance.ChangeGameState(GameState.Death); + } + }; + } isAlive = false; } public void Jump() diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 84d6b07..2ec40c9 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -202,7 +202,7 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: - GameManager.mapManager.LoadLevel("lvl"); + GameManager.mapManager.LoadLevel("map"); break; case GameState.Death: break; diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs index 8e2df9e..ab9a5d8 100644 --- a/DangerousD/GameCore/Managers/SoundManager.cs +++ b/DangerousD/GameCore/Managers/SoundManager.cs @@ -40,7 +40,6 @@ namespace DangerousD.GameCore public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции { - return; var sound = new Sound(Sounds[soundName]); sound.SoundEffect.IsLooped = false; sound.SoundEffect.Play();