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>
</objectgroup>
<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/>
</object>
</objectgroup>

View file

@ -36,7 +36,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
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)
@ -56,17 +56,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isAttaking = true;
if (isGoRight)
{
if (animation != "HunchmanDaggerRight")
if (animation != "HunchmanAttackRight")
{
GraphicsComponent.StartAnimation("HunchmanDaggerRight");
GraphicsComponent.StartAnimation("HunchmanAttackRight");
}
HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos,isGoRight);
}
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()
{
@ -136,18 +127,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (physicsManager.RayCast(this, player) == null)
{
if(this._pos.X <= player.Pos.X)
{
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;
}
Attack();
}
}
}

View file

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