diff --git a/DangerousD/Content/MonstersAnimations.png b/DangerousD/Content/MonstersAnimations.png index 5bc9cca..97e3e11 100644 Binary files a/DangerousD/Content/MonstersAnimations.png and b/DangerousD/Content/MonstersAnimations.png differ 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 813425e..98f3653 100644 --- a/DangerousD/Content/map.tmx +++ b/DangerousD/Content/map.tmx @@ -62,14 +62,17 @@ - + +<<<<<<< HEAD +======= +>>>>>>> ea55e2b4f2b2b9af627579f3c4b82bdf0171d80b diff --git a/DangerousD/GameCore/GUI/AbstractGui.cs b/DangerousD/GameCore/GUI/AbstractGui.cs index feb3294..2e30de0 100644 --- a/DangerousD/GameCore/GUI/AbstractGui.cs +++ b/DangerousD/GameCore/GUI/AbstractGui.cs @@ -19,7 +19,11 @@ public abstract class AbstractGui : IDrawableObject private GraphicsDevice graphicsDevice; public virtual void Initialize() { +<<<<<<< HEAD + Manager.Initialize(AppManager.Instance.GraphicsDevice); +======= Manager.Initialize(AppManager.Instance.GraphicsDevice); +>>>>>>> ea55e2b4f2b2b9af627579f3c4b82bdf0171d80b CreateUI(); } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs index 06fed0f..b7b4351 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs @@ -17,7 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities protected string name; protected bool isAlive = true; 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/Frank.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs index fd25246..2afe14b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs @@ -17,7 +17,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public Frank(Vector2 position) : base(position) { isGoRight = false; - Width = 112; Height = 160; leftBoarder = 50; diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs index 4c37e6a..031d594 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs @@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { private Rectangle collision; private Vector2 position; - private int healthBall; private bool isFlyRight = true; private bool isAttacking = false; diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs index 34069af..1b502be 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs @@ -16,7 +16,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters private int attackTime = 60; private int moveTime = 360; private int currentTime = 0; - private bool isGoRight = true; int leftBorder; int rightBorder; List hands = new List(); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs index 1cdf9bb..c263a25 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs @@ -12,7 +12,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { public class Slime : CoreEnemy { - private bool isGoRight = true; private bool isDown = false; int leftBorder; int rightBorder; diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs index 93f3ef4..8bc703b 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs @@ -1,4 +1,6 @@ -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; using Microsoft.Xna.Framework.Graphics; @@ -20,19 +22,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters protected int webLength; protected bool isDown; protected bool isDownUp; + protected PhysicsManager physicsManager; + protected Player player; public Spider(Vector2 position) : base(position) { + player = AppManager.Instance.GameManager.players[0]; isDownUp = true; isDown = true; + physicsManager = AppManager.Instance.GameManager.physicsManager; web = new SpiderWeb(Pos); name = "Spider"; Width = 112; Height = 24; delay = 0; webLength = 0; - monster_speed = 2; - acceleration = Vector2.Zero; + monster_speed = 3; + acceleration = new Vector2(0, -50); + isGoRight = true; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "SpiderMoveRight", "SpiderMoveLeft", "SpiderOnWeb" }, "SpiderMoveRight"); @@ -47,6 +54,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { Attack(gameTime); } + Target(); base.Update(gameTime); } @@ -62,18 +70,20 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters /// public void Attack(GameTime gameTime) { //48 72 - if (isDownUp) + velocity.X = 0; + delay += (float)gameTime.ElapsedGameTime.TotalSeconds; + if (isAttack) { - Width = 48; - Height = 72; - delay += (float)gameTime.ElapsedGameTime.TotalSeconds; if (delay > 0.5 && webLength <= 4 && isDown) { + 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 + 2, Pos.Y - 25 * webLength)); + web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength)); delay = 0; if (webLength == 4) { @@ -82,23 +92,35 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } else if (delay > 0.5 && webLength != 0 && !isDown) { + 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 + 2, Pos.Y - 25 * webLength)); + web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength)); delay = 0; if (webLength == 0) { isDown = true; } } - else + var entitiesInter = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 200, 600)); + if (entitiesInter.Count > 0) { - Width = 112; - Height = 24; + foreach (var entity in entitiesInter) + { + if (entity.GetType() == typeof(Player)) + { + player.Death(name); + } + } } } + if (webLength == 0) + { + isAttack = false; + } } public override void Draw(SpriteBatch spriteBatch) @@ -121,6 +143,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Move(GameTime gameTime) { + Width = 112; + Height = 24; + foreach (var entity in physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 7, (int)Pos.Y, 126, 10))) + { + if (entity.GetType() == typeof(StopTile)) + { + isGoRight = !isGoRight; + } + } if (isGoRight) { if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight") @@ -137,19 +168,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } velocity.X = -monster_speed; } - if (Pos.X >= rightBoarder) - { - isGoRight = false; - } - else if (Pos.X <= leftBoarder) - { - isGoRight = true; - } } public void Target() { - throw new NotImplementedException(); + if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width) + { + isAttack = true; + } } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 82dcc2a..b1f8405 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -128,22 +128,27 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } base.OnCollision(gameObject); } +<<<<<<< HEAD + + public override void Target() +======= public void Target() +>>>>>>> ea55e2b4f2b2b9af627579f3c4b82bdf0171d80b { if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0) { - if (isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X) + if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X) { isTarget = true; leftBorder = Pos.X - 10; rightBorder = Pos.X + AppManager.Instance.GameManager.players[0].Pos.X; } - else if (!isGoRight && this._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; - leftBorder = AppManager.Instance.GameManager.players[0].Pos.X; + leftBorder = AppManager.Instance.GameManager.players[0].Pos.X; } } } @@ -159,6 +164,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } } +<<<<<<< HEAD + public override void Attack(GameTime gameTime) { } +======= public void Attack(GameTime gameTime) {} @@ -172,5 +180,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters Death(); } } +>>>>>>> ea55e2b4f2b2b9af627579f3c4b82bdf0171d80b } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index 455a92b..2caf474 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -107,6 +107,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/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index 90a2170..d311095 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -7,6 +7,7 @@ public abstract class LivingEntity : Entity public bool isOnGround = true; public Vector2 velocity; public Vector2 acceleration; + public LivingEntity(Vector2 position) : base(position) { acceleration = new Vector2(0, 30); diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index 33327c7..7b79e45 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -205,8 +205,12 @@ namespace DangerousD.GameCore case GameState.Lobby: break; case GameState.Game: +<<<<<<< HEAD + GameManager.mapManager.LoadLevel("map"); +======= GameManager.mapManager.LoadLevel("lvl"); GameManager.FindBorders(); +>>>>>>> main break; case GameState.Death: break; diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs index 6ab49b0..a97a2f5 100644 --- a/DangerousD/GameCore/Managers/MapManager.cs +++ b/DangerousD/GameCore/Managers/MapManager.cs @@ -92,6 +92,10 @@ namespace DangerousD.GameCore.Managers float offsetY = group.Attributes["offsety"] is not null ? float.Parse(group.Attributes["offsety"].Value) : 0; foreach (XmlNode entity in group.ChildNodes) { +<<<<<<< HEAD + Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityType}"); + Entity inst = (Entity)Activator.CreateInstance(type, new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY ) * _scale); +======= string entityType = entity.Attributes["type"] is not null ? "." + entity.Attributes["type"].Value : ""; Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityGroup}{entityType}"); Vector2 pos = @@ -106,6 +110,7 @@ namespace DangerousD.GameCore.Managers { inst = (Entity)Activator.CreateInstance(type, pos); } +>>>>>>> ea55e2b4f2b2b9af627579f3c4b82bdf0171d80b inst.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height)); inst.Height *= _scale; inst.Width *= _scale; 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();