NiceBalls
This commit is contained in:
parent
9a6b2a0856
commit
2cb30ab0f3
1 changed files with 55 additions and 26 deletions
|
@ -15,6 +15,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
private Rectangle collision;
|
private Rectangle collision;
|
||||||
private Vector2 position;
|
private Vector2 position;
|
||||||
private bool isFlyRight = true;
|
private bool isFlyRight = true;
|
||||||
|
private bool isFlyUp = true;
|
||||||
private bool isAttacking = false;
|
private bool isAttacking = false;
|
||||||
|
|
||||||
public Rectangle Collision
|
public Rectangle Collision
|
||||||
|
@ -29,34 +30,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
Width = 40;
|
Width = 40;
|
||||||
Height = 40;
|
Height = 40;
|
||||||
monster_speed = 3;
|
monster_speed = 3;
|
||||||
|
velocity = new Vector2(3,-3);
|
||||||
acceleration = Vector2.Zero;
|
acceleration = Vector2.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
|
||||||
if(!isAttacking)
|
|
||||||
{
|
{
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
}
|
AppManager.Instance.DebugHUD.Set(name, velocity.ToString());
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
{
|
{
|
||||||
collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
|
|
||||||
isAttacking = true;
|
|
||||||
|
|
||||||
if(isFlyRight)
|
}
|
||||||
|
public override void OnCollision(GameObject gameObject)
|
||||||
|
{
|
||||||
|
if (gameObject is Player)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.GameManager.players[0].IsAlive)
|
||||||
{
|
{
|
||||||
AppManager.Instance.GameManager.players[0].Death(name);
|
AppManager.Instance.GameManager.players[0].Death(name);
|
||||||
}
|
}
|
||||||
else if(!isFlyRight)
|
|
||||||
{
|
|
||||||
AppManager.Instance.GameManager.players[0].Death(name);
|
|
||||||
}
|
}
|
||||||
|
base.OnCollision(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
|
@ -66,20 +65,50 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
velocity.X = 0;
|
|
||||||
velocity.Y = 0;
|
|
||||||
|
|
||||||
if(isFlyRight)
|
var getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
|
||||||
|
var getColsVer= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ;
|
||||||
|
if (isFlyRight)
|
||||||
{
|
{
|
||||||
velocity.X += monster_speed;
|
getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y , 42, 40));
|
||||||
velocity.Y += monster_speed;
|
if(getColsHor.Count > 0)
|
||||||
}
|
|
||||||
else if(!isFlyRight)
|
|
||||||
{
|
{
|
||||||
velocity.X -= monster_speed;
|
isFlyRight = false;
|
||||||
velocity.Y -= monster_speed;
|
velocity.X = -velocity.X;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-2, (int)Pos.Y, 42, 40));
|
||||||
|
if (getColsHor.Count > 0)
|
||||||
|
{
|
||||||
|
isFlyRight = true;
|
||||||
|
velocity.X = -velocity.X;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isFlyUp)
|
||||||
|
{
|
||||||
|
|
||||||
|
getColsVer = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X , (int)Pos.Y-3, 40, 43));
|
||||||
|
if (getColsVer.Count > 0)
|
||||||
|
{
|
||||||
|
isFlyUp = false;
|
||||||
|
velocity.Y = -velocity.Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getColsVer = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 40, 43));
|
||||||
|
if (getColsVer.Count > 0)
|
||||||
|
{
|
||||||
|
isFlyUp = true;
|
||||||
|
velocity.Y = -velocity.Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void Target()
|
public void Target()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
Loading…
Add table
Reference in a new issue