SlimeJumper

This commit is contained in:
Kaktus200020 2023-08-18 13:11:49 +03:00
parent 8e71a3c732
commit ab0947ed69
3 changed files with 58 additions and 21 deletions

View file

@ -12,8 +12,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Slime : CoreEnemy
{
private bool isGoRight = true;
private bool isDown = true;
int leftBorder;
int rightBorder;
bool isAttaking = false;
@ -30,6 +34,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 400;
//acceleration = Vector2.Zero;
delay = 30;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
@ -40,7 +45,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
public void Jump()
public void Jump(GameTime gameTime)
{
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100));
velocity.X = 0;
@ -56,8 +61,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0)
{
velocity = new Vector2(5, -3);
velocity = new Vector2(5, -4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom")
{
GraphicsComponent.StartAnimation("SlimeJumpLeftBottom");
@ -67,6 +73,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isJumping = false;
isDown = false;
isAttaking = false;
}
}
@ -81,7 +88,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0)
{
velocity = new Vector2(-5, -3);
velocity = new Vector2(-5, -4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightBottom")
{
@ -92,6 +99,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isJumping = false;
isDown = false;
isAttaking = false;
}
}
}
@ -106,8 +114,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0)
{
velocity = new Vector2(5, 3);
velocity = new Vector2(5, 4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
{
GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
@ -118,7 +127,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isJumping = false;
isDown = true;
isAttaking = false;
acceleration.Y = 10;
Move(gameTime);
}
}
@ -132,8 +143,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
delay--;
if (delay <= 0)
{
velocity = new Vector2(-5, 3);
velocity = new Vector2(-5, 4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
{
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
@ -143,7 +155,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isJumping = false;
isDown = true;
isAttaking = false;
acceleration.Y = 10;
Move(gameTime);
}
}
@ -151,6 +165,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
}
public override void Draw(SpriteBatch spriteBatch)
{
@ -246,24 +261,26 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
acceleration.Y = -acceleration.Y;
}
}
Attack();
AppManager.Instance.DebugHUD.Set(name, isAttaking.ToString());
if(!isJumping)
{
if (isDown)
{
Jump();
Jump(gameTime);
}
else if(IsInAim())
{
Jump();
Jump(gameTime);
isAttaking = true;
}
else
else if(!isAttaking)
{
Move(gameTime);
}
}
else { Jump(gameTime); }
}
base.Update(gameTime);
@ -283,6 +300,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X + Width, (int)Pos.Y + Height, 200, 500), false);
if (getCols.Count > 0)
{
return true;
}
}
@ -291,9 +309,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y + Height, 200, 500), false);
if (getCols.Count > 0)
{
return true;
}
}
/*/else if (isGoRight && isDown)
{
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X +Width, (int)Pos.Y -500, 200, 500), false);
if (getCols.Count > 0)
{
isAttaking = true;
return true;
}
}
else if (!isGoRight && isDown)
{
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y - 500, 200, 500), false);
if (getCols.Count > 0)
{
isAttaking = true;
return true;
}
}/*/
return false;

View file

@ -30,11 +30,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isDownUp = true;
isDown = true;
physicsManager = AppManager.Instance.GameManager.physicsManager;
web = new SpiderWeb(Pos);
name = "Spider";
Width = 112;
Height = 24;
delay = 0;
web = new SpiderWeb(new Vector2(Pos.X-Width/2,Pos.Y));
webLength = 0;
monster_speed = 3;
acceleration = new Vector2(0, -50);

View file

@ -205,12 +205,12 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
<<<<<<< HEAD
GameManager.mapManager.LoadLevel("map");
=======
GameManager.mapManager.LoadLevel("lvl");
GameManager.FindBorders();
>>>>>>> main
break;
case GameState.Death:
break;