Main Hunch
This commit is contained in:
commit
f415b47fc4
6 changed files with 172 additions and 25 deletions
|
@ -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"}
|
||||||
|
|
|
@ -132,6 +132,11 @@
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
<objectgroup id="6" name="Слой объектов 1" class="LivingEntities.Monsters.Ghost">
|
||||||
|
<object id="5" x="150" y="200">
|
||||||
|
<point/>
|
||||||
|
</object>
|
||||||
|
</objectgroup>
|
||||||
|
|
||||||
</map>
|
</map>
|
||||||
>>>>>>> main
|
>>>>>>> main
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
private bool isFlyRight = true;
|
private bool isFlyRight = true;
|
||||||
private bool isFlyUp = true;
|
private bool isFlyUp = true;
|
||||||
private bool isAttacking = false;
|
private bool isAttacking = false;
|
||||||
|
private int hp;
|
||||||
|
|
||||||
public Rectangle Collision
|
public Rectangle Collision
|
||||||
{
|
{
|
||||||
get { return collision; }
|
get { return collision; }
|
||||||
|
@ -40,7 +42,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
AppManager.Instance.DebugHUD.Set(name, velocity.ToString());
|
|
||||||
|
Death();
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
|
@ -61,7 +65,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
if (hp <= 0)
|
||||||
|
{
|
||||||
|
AppManager.Instance.GameManager.Remove(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
|
@ -75,6 +82,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
isFlyRight = false;
|
isFlyRight = false;
|
||||||
velocity.X = -velocity.X;
|
velocity.X = -velocity.X;
|
||||||
|
hp--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -84,6 +92,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
isFlyRight = true;
|
isFlyRight = true;
|
||||||
velocity.X = -velocity.X;
|
velocity.X = -velocity.X;
|
||||||
|
hp--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isFlyUp)
|
if (isFlyUp)
|
||||||
|
@ -94,6 +103,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
isFlyUp = false;
|
isFlyUp = false;
|
||||||
velocity.Y = -velocity.Y;
|
velocity.Y = -velocity.Y;
|
||||||
|
hp--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -103,6 +113,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
isFlyUp = true;
|
isFlyUp = true;
|
||||||
velocity.Y = -velocity.Y;
|
velocity.Y = -velocity.Y;
|
||||||
|
hp--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
isGoRight = true;
|
isGoRight = true;
|
||||||
monster_speed = 3;
|
monster_speed = 3;
|
||||||
name = "Ghost";
|
name = "Ghost";
|
||||||
Width = 48;
|
Width = 24;
|
||||||
Height = 62;
|
Height = 30;
|
||||||
GraphicsComponent.StartAnimation("GhostSpawn");
|
GraphicsComponent.StartAnimation("GhostSpawn");
|
||||||
acceleration = Vector2.Zero;
|
acceleration = new Vector2(0,1);
|
||||||
|
monster_health = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
|
||||||
|
@ -38,13 +38,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Attack()
|
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 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)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
@ -64,17 +83,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
velocity.X = -monster_speed;
|
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()
|
public void Target()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
|
@ -174,6 +174,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Particle particle = new Particle(Pos);
|
||||||
|
|
||||||
|
|
||||||
|
AppManager.Instance.GameManager.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
|
@ -220,7 +224,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
velocity.X = -monster_speed;
|
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)
|
if (isGoRight)
|
||||||
{
|
{
|
||||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 51, 2));
|
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);
|
base.OnCollision(gameObject);
|
||||||
}
|
}
|
||||||
|
public void TakeDamage()
|
||||||
|
{
|
||||||
|
monster_health--;
|
||||||
|
|
||||||
|
Particle particle = new Particle(Pos);
|
||||||
|
if (monster_health <= 0)
|
||||||
|
{
|
||||||
|
Death();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,25 +12,34 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Werewolf : CoreEnemy
|
public class Werewolf : CoreEnemy
|
||||||
{
|
{
|
||||||
private bool isAttack;
|
private bool isJump;
|
||||||
|
int delay;
|
||||||
|
|
||||||
public Werewolf(Vector2 position) : base(position)
|
public Werewolf(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
name = "Wolf";
|
name = "Wolf";
|
||||||
monster_speed = 4;
|
monster_speed = 3;
|
||||||
Width = 78;
|
Width = 39;
|
||||||
Height = 96;
|
Height = 48;
|
||||||
|
delay = 10;
|
||||||
|
monster_health = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight");
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
if (!isAttack)
|
if(!isJump )
|
||||||
|
{
|
||||||
|
Jump();
|
||||||
|
}
|
||||||
|
if(isOnGround)
|
||||||
{
|
{
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +50,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Death()
|
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)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
isJump = false;
|
||||||
|
|
||||||
if (isGoRight)
|
if (isGoRight)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight")
|
if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight")
|
||||||
|
@ -62,23 +78,89 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
velocity.X = -monster_speed;
|
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 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()
|
public void Target()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
public void TakeDamage()
|
||||||
|
{
|
||||||
|
monster_health--;
|
||||||
|
|
||||||
|
Particle particle = new Particle(Pos);
|
||||||
|
if (monster_health <= 0)
|
||||||
|
{
|
||||||
|
Death();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue