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

View file

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