fixed some bags

This commit is contained in:
bmvolf 2023-08-18 11:39:54 +03:00
parent b30a8515d2
commit 5db6cee0fa
4 changed files with 84 additions and 37 deletions

View file

@ -1 +1,24 @@
{"id":"playerShootLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":201,"Y":34,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"4, 0"} {
"id": "playerShootLeft",
"textureName": "playerAnimation",
"startSpriteRectangle": {
"X": 201,
"Y": 34,
"Width": 32,
"Height": 32
},
"frameSecond": [
{
"Item1": 0,
"Item2": 3
},
{
"Item1": 1,
"Item2": 20
}
],
"textureFrameInterval": 1,
"framesCount": 2,
"isCycle": false,
"offset": "4, 0"
}

View file

@ -1 +1,24 @@
{"id":"playerShootRight","textureName":"playerAnimation","startSpriteRectangle":{"X":201,"Y":1,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"4, 0"} {
"id": "playerShootRight",
"textureName": "playerAnimation",
"startSpriteRectangle": {
"X": 201,
"Y": 1,
"Width": 32,
"Height": 32
},
"frameSecond": [
{
"Item1": 0,
"Item2": 3
},
{
"Item1": 1,
"Item2": 20
}
],
"textureFrameInterval": 1,
"framesCount": 2,
"isCycle": false,
"offset": "4, 0"
}

View file

@ -98,19 +98,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
if (isGoRight) if (isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight") StartCicycleAnimation("ZombieMoveRight");
{
GraphicsComponent.StartAnimation("ZombieMoveRight");
}
velocity.X = monster_speed; velocity.X = monster_speed;
} }
else if (!isGoRight) else if (!isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft") StartCicycleAnimation("ZombieMoveLeft");
{
GraphicsComponent.StartAnimation("ZombieMoveLeft");
}
velocity.X = -monster_speed; velocity.X = -monster_speed;
} }
@ -167,6 +161,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 760; rightBorder = 760;
} }
} }
public void SwitchToRight()
{
isGoRight = true;
}
public void SwitchToLeft()
{
isGoRight = false;
}
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{} {}

View file

@ -133,6 +133,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public void Shoot() public void Shoot()
{ {
if (bullets > 0) if (bullets > 0)
{
if (!isAttacked)
{ {
if (!isShooting) if (!isShooting)
{ {
@ -140,27 +142,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
bullets--; bullets--;
if (isRight) if (isRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "playerShootRight") StartCicycleAnimation("playerShootRight");
{ var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
GraphicsComponent.StartAnimation("playerShootRight");
}
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie));
if (targets != null) if (targets != null)
{ {
foreach (var target in targets) Zombie targetZombie = (Zombie)targets.First();
{
Zombie targetZombie = (Zombie)target;
targetZombie.TakeDamage(); targetZombie.TakeDamage();
} }
}
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
} }
else else
{ {
if (GraphicsComponent.GetCurrentAnimation != "playerShootLeft") StartCicycleAnimation("playerShootLeft");
{
GraphicsComponent.StartAnimation("playerShootLeft");
}
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie)); var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie));
if (targets != null) if (targets != null)
{ {
@ -175,6 +168,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
} }
} }
}
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (AppManager.Instance.InputManager.ScopeState == ScopeState.Up) if (AppManager.Instance.InputManager.ScopeState == ScopeState.Up)
@ -201,6 +195,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
velocity.X = 0; velocity.X = 0;
} }
} }
else
{
velocity.X = 0;
}
base.Update(gameTime); base.Update(gameTime);
} }