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/map.tmx b/DangerousD/Content/map.tmx
index 9afca4d..a02975a 100644
--- a/DangerousD/Content/map.tmx
+++ b/DangerousD/Content/map.tmx
@@ -71,5 +71,10 @@
+
+
+
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
index 9400485..720fd96 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 214a4c2..57ab2c4 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,7 +108,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
+ public void TakeDamage()
+ {
+ monster_health--;
+
+ 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 41a2fcc..afdbf9b 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 837932f..bb6cd6f 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
@@ -12,24 +12,33 @@ 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";
- monster_speed = 4;
- Width = 78;
- Height = 96;
+ 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 +50,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 +78,89 @@ 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)
{
}
-
+ 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()
{
throw new NotImplementedException();
}
+ 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 bed7ef5..60bad2c 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)
{
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index 62c57b8..f5d334e 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -208,7 +208,14 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
+<<<<<<< HEAD
+
+ GameManager.mapManager.LoadLevel("map");
+
+
+=======
GameManager.mapManager.LoadLevel(currentMap);
+>>>>>>> main
GameManager.FindBorders();
break;
case GameState.Death:
diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs
index f4eed81..33f4191 100644
--- a/DangerousD/GameCore/Managers/GameManager.cs
+++ b/DangerousD/GameCore/Managers/GameManager.cs
@@ -201,5 +201,10 @@ namespace DangerousD.GameCore
}
}
}
+
+ public Player GetClosestPlayer(Vector2 position)
+ {
+ return players.OrderBy(x => (x.Pos - position).Length()).First();
+ }
}
}
\ No newline at end of file