started vertical shoot

This commit is contained in:
bmvolf 2023-08-18 13:53:18 +03:00
parent 5db6cee0fa
commit 5bd2b7d93b
4 changed files with 44 additions and 13 deletions

View file

@ -0,0 +1 @@
{"id":"playerShootUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"playerShootUpRight","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -8,6 +8,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DangerousD.GameCore.Managers; using DangerousD.GameCore.Managers;
using DangerousD.GameCore.GameObjects;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
@ -24,7 +25,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
Width = 24; Width = 24;
Height = 40; Height = 40;
monster_speed = 3; monster_speed = 2;
name = "Zombie"; name = "Zombie";
monster_health = 2; monster_health = 2;
leftBorder = (int)position.X - 100; leftBorder = (int)position.X - 100;
@ -133,7 +134,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public void Target() public void Target()
{ {
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0) if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 200, Height), typeof(Player)).Count > 0)
{ {
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X) if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
{ {
@ -184,4 +185,4 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
} }
} }
} }

View file

@ -70,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public bool IsAlive { get { return isAlive; } } public bool IsAlive { get { return isAlive; } }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
"playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot"}, "playerReload"); "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload");
public void Attack() public void Attack()
{ {
@ -98,7 +98,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
return; return;
} }
isAttacked = true; isAttacked = true;
if(monsterName == "Zombie") if (monsterName == "Zombie")
{ {
AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) => deathRectangle.Gr.actionOfAnimationEnd += (a) =>
@ -109,7 +109,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
}; };
} }
else if(monsterName == "Spider") else if (monsterName == "Spider")
{ {
AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName); AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) => deathRectangle.Gr.actionOfAnimationEnd += (a) =>
@ -144,7 +144,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
StartCicycleAnimation("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()); 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) if (targets.Count() > 0)
{ {
Zombie targetZombie = (Zombie)targets.First(); Zombie targetZombie = (Zombie)targets.First();
targetZombie.TakeDamage(); targetZombie.TakeDamage();
@ -227,7 +227,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
{ {
if(bullets < 5) if (bullets < 5)
{ {
if (GraphicsComponent.GetCurrentAnimation != "playerReload") if (GraphicsComponent.GetCurrentAnimation != "playerReload")
{ {
@ -235,15 +235,35 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
} }
else if (isRight) else if (isRight)
{
if (isUping)
{
if (GraphicsComponent.GetCurrentAnimation != "playerShootUpRight")
{
GraphicsComponent.StartAnimation("playerShootUpRight");
}
}
else
{ {
GraphicsComponent.StartAnimation("playerRightStay"); GraphicsComponent.StartAnimation("playerRightStay");
} }
}
else if (!isRight) else if (!isRight)
{
if (isUping)
{
if (GraphicsComponent.GetCurrentAnimation != "playerShootUpLeft")
{
GraphicsComponent.StartAnimation("playerShootUpLeft");
}
}
else
{ {
GraphicsComponent.StartAnimation("playerStayLeft"); GraphicsComponent.StartAnimation("playerStayLeft");
} }
} }
} }
}
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
{ {
NetworkTask task = new NetworkTask(id, Pos); NetworkTask task = new NetworkTask(id, Pos);
@ -256,5 +276,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isOnGround = false; isOnGround = false;
} }
public class Bullet : GameObjects.LivingEntity
{
public Bullet(Vector2 position) : base(position)
{
}
protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft");
}
} }
} }