This commit is contained in:
MARKPRO44 2023-08-18 18:14:01 +03:00
parent a8d30ca8be
commit 33331e83ee
3 changed files with 31 additions and 40 deletions

View file

@ -700,7 +700,7 @@
</object> </object>
</objectgroup> </objectgroup>
<objectgroup id="10" name="Player" class="LivingEntities.Player"> <objectgroup id="10" name="Player" class="LivingEntities.Player">
<object id="47" x="-500" y="461.333"> <object id="47" x="0" y="461.333">
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>

View file

@ -36,7 +36,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanDaggerLeft", "HunchmanDaggerRight" }, "HunchmanMoveLeft"); { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft");
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
@ -56,17 +56,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isAttaking = true; isAttaking = true;
if (isGoRight) if (isGoRight)
{ {
if (animation != "HunchmanDaggerRight") if (animation != "HunchmanAttackRight")
{ {
GraphicsComponent.StartAnimation("HunchmanDaggerRight"); GraphicsComponent.StartAnimation("HunchmanAttackRight");
} }
HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos,isGoRight);
} }
else else
{ {
if (animation != "HunchmanDaggerLeft") if (animation != "HunchmanAttackLeft")
{ {
GraphicsComponent.StartAnimation("HunchmanDaggerLeft"); GraphicsComponent.StartAnimation("HunchmanAttackLeft");
} }
HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos, isGoRight);
} }
} }
@ -117,18 +119,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
} }
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
if (AppManager.Instance.GameManager.players[0].IsAlive)
{
Attack();
}
}
base.OnCollision(gameObject);
}
public void Target() public void Target()
{ {
@ -136,18 +127,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (physicsManager.RayCast(this, player) == null) if (physicsManager.RayCast(this, player) == null)
{ {
if(this._pos.X <= player.Pos.X) Attack();
{
isTarget = true;
leftBoarder = Pos.X - 10;
rightBoarder = player.Pos.X;
}
else if(this._pos.X >= player.Pos.X)
{
isTarget = true;
rightBoarder = Pos.X + 10;
leftBoarder = player.Pos.X;
}
} }
} }
} }

View file

@ -14,8 +14,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
private bool isGoRight = false; private bool isGoRight = false;
public HunchmanDagger(Vector2 position) : base(position) public HunchmanDagger(Vector2 position, bool isGoRight) : base(position)
{ {
this.isGoRight = isGoRight;
name = "Hunchman"; name = "Hunchman";
monster_speed = 4; monster_speed = 4;
Width = 9; Width = 9;
@ -36,22 +37,36 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death() public override void Death()
{ {
AppManager.Instance.GameManager.Remove(this);
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
velocity.X = 0; velocity.X = 0;
var animation = GraphicsComponent.GetCurrentAnimation; var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 0, 0));
if (isGoRight)
if (animation == "HunchmanDaggerRight")
{ {
StartCicycleAnimation("HunchmanDaggerRight");
velocity.X = monster_speed; velocity.X = monster_speed;
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width+5, Height));
if(getCols.Count>0)
{
Death();
}
} }
else if (animation == "HunchmanDaggerLeft")
else if (!isGoRight)
{ {
StartCicycleAnimation("HunchmanDaggerLeft");
velocity.X = -monster_speed; velocity.X = -monster_speed;
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-5, (int)Pos.Y, Width + 5, Height));
if (getCols.Count > 0)
{
Death();
}
} }
} }
public override void OnCollision(GameObject gameObject) public override void OnCollision(GameObject gameObject)
@ -60,10 +75,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
AppManager.Instance.GameManager.players[0].Death(name); AppManager.Instance.GameManager.players[0].Death(name);
} }
else
{
Death();
}
base.OnCollision(gameObject); base.OnCollision(gameObject);
} }