little changes

This commit is contained in:
N4K 2023-08-17 16:41:16 +03:00
parent d7312c4c62
commit a21ef22451
18 changed files with 250 additions and 36 deletions

View file

@ -1 +1 @@
{"id":"WolfMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":292,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"} {"id":"WolfMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":291,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}

View file

@ -13,12 +13,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract class CoreEnemy : LivingEntity public abstract class CoreEnemy : LivingEntity
{ {
protected int monster_health; protected int monster_health;
protected int monster_speed; protected float monster_speed = 2;
protected string name; protected string name;
protected bool isAlive = true; protected bool isAlive = true;
protected bool isAttack; protected bool isAttack = false;
protected int leftBoarder; protected bool isGoRight;
protected int rightBoarder; protected int leftBoarder = 0;
protected int rightBoarder = 700;
public CoreEnemy(Vector2 position) : base(position) public CoreEnemy(Vector2 position) : base(position)
{ {
@ -32,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract void Death(); public abstract void Death();
public abstract void Attack(); public abstract void Attack();
public abstract void Attack(GameTime gameTime);
public abstract void Move(GameTime gameTime); public abstract void Move(GameTime gameTime);
@ -44,5 +46,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isAlive = false; isAlive = false;
} }
} }
public abstract void Target();
} }
} }

View file

@ -18,10 +18,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 40; Height = 40;
monster_speed = 3; monster_speed = 3;
name = "Skull"; name = "Skull";
acceleration = Vector2.Zero;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FlameSkullMoveRight" , "FlameSkullMoveLeft"}, "FlameSkullMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FlameSkullMoveRight" , "FlameSkullMoveLeft"}, "FlameSkullMoveRight");
public override void Update(GameTime gameTime)
{
if (!isAttack)
{
Move(gameTime);
}
base.Update(gameTime);
}
public override void Attack() public override void Attack()
{ {
@ -33,6 +44,34 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "FlameSkullMoveRight")
{
GraphicsComponent.StartAnimation("FlameSkullMoveRight");
}
velocity.X = monster_speed;
}
else
{
if (GraphicsComponent.GetCurrentAnimation != "FlameSkullMoveLeft")
{
GraphicsComponent.StartAnimation("FlameSkullMoveLeft");
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
}
public override void Attack(GameTime gameTime)
{ {
} }

View file

@ -12,21 +12,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
internal class Frank : CoreEnemy internal class Frank : CoreEnemy
{ {
private bool isGoRight = false;
private int leftBoarder;
private int rightBoarder;
public Frank(Vector2 position) : base(position) public Frank(Vector2 position) : base(position)
{ {
isGoRight = false;
Width = 112; Width = 112;
Height = 160; Height = 160;
leftBoarder = 50; leftBoarder = 50;
rightBoarder = 500; rightBoarder = 300;
GraphicsComponent.StartAnimation("FrankMoveLeft"); GraphicsComponent.StartAnimation("FrankMoveLeft");
monster_speed = 1; monster_speed = 2;
name = "Frank"; name = "Frank";
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveLeft");
public override void Update(GameTime gameTime)
{
Move(gameTime);
base.Update(gameTime);
}
public override void Attack() public override void Attack()
{ {
@ -40,14 +43,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
var player = AppManager.Instance.GameManager.players[0];
if (player.Pos.X - _pos.X <= 20 || player.Pos.X - _pos.X <= -20)
{
player.Death(name);
}
if (isGoRight) if (isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "FrankMoveRight") if (GraphicsComponent.GetCurrentAnimation != "FrankMoveRight")
{ {
GraphicsComponent.StartAnimation("FrankMoveRight"); GraphicsComponent.StartAnimation("FrankMoveRight");
@ -62,6 +59,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
velocity.X = -monster_speed; velocity.X = -monster_speed;
} }
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
}
public override void Attack(GameTime gameTime)
{
} }
} }
} }

View file

@ -42,5 +42,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
} }
public override void Attack(GameTime gameTime)
{
}
} }
} }

View file

@ -12,16 +12,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public Ghost(Vector2 position) : base(position) public Ghost(Vector2 position) : base(position)
{ {
monster_speed = 1; isGoRight = true;
monster_speed = 3;
name = "Ghost"; name = "Ghost";
Width = 48; Width = 48;
Height = 62; Height = 62;
GraphicsComponent.StartAnimation("GhostSpawn"); GraphicsComponent.StartAnimation("GhostSpawn");
acceleration = Vector2.Zero;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
public override void Update(GameTime gameTime)
{
if (!isAttack)
{
Move(gameTime);
}
base.Update(gameTime);
}
public override void Attack() public override void Attack()
{ {
@ -33,6 +45,38 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "GhostMoveRight")
{
GraphicsComponent.StartAnimation("GhostMoveRight");
}
velocity.X = monster_speed;
}
else
{
if (GraphicsComponent.GetCurrentAnimation != "GhostMoveLeft")
{
GraphicsComponent.StartAnimation("GhostMoveLeft");
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
if (true)
{
}
}
public override void Attack(GameTime gameTime)
{ {
} }

View file

@ -23,6 +23,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void Attack(GameTime gameTime)
{
}
public override void Death() public override void Death()
{ {

View file

@ -27,6 +27,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void Attack(GameTime gameTime)
{
}
public override void Death() public override void Death()
{ {

View file

@ -27,7 +27,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack() public override void Attack()
{ {
throw new NotImplementedException();
}
public override void Attack(GameTime gameTime)
{
} }
public override void Death() public override void Death()

View file

@ -39,9 +39,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
currentTime++; currentTime++;
} }
public override void Attack(GameTime gameTime)
{
}
public override void Death() public override void Death()
{ {
throw new NotImplementedException();
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)

View file

@ -25,6 +25,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void Attack(GameTime gameTime)
{
}
public override void Death() public override void Death()
{ {

View file

@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 24; Height = 24;
delay = 0; delay = 0;
webLength = 0; webLength = 0;
monster_speed = 1; monster_speed = 2;
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
} }
@ -36,6 +36,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (!isAttack)
{
Move(gameTime);
}
else
{
Attack(gameTime);
}
base.Update(gameTime);
}
/// <summary>
/// НИЧЕГО НЕ ДЕЛАЕТ! НУЖЕН ДЛЯ ПЕРЕОПРЕДЕЛЕНИЯ
/// </summary>
public override void Attack()
{
}
/// <summary>
/// Атака паука РАБОЧАЯ
/// </summary>
/// <param name="gameTime"></param>
public override void Attack(GameTime gameTime)
{ //48 72
if (isDownUp) if (isDownUp)
{ {
Width = 48; Width = 48;
@ -73,12 +96,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 24; Height = 24;
} }
} }
base.Update(gameTime);
}
public override void Attack()
{ //48 72
} }
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
@ -101,7 +118,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight")
{
GraphicsComponent.StartAnimation("SpiderMoveRight");
}
velocity.X = monster_speed;
}
else
{
if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveLeft")
{
GraphicsComponent.StartAnimation("SpiderMoveLeft");
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
} }
} }
} }

View file

@ -28,6 +28,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void Attack(GameTime gameTime)
{
}
public override void Death() public override void Death()
{ {

View file

@ -15,13 +15,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public Werewolf(Vector2 position) : base(position) public Werewolf(Vector2 position) : base(position)
{ {
name = "Wolf"; name = "Wolf";
monster_speed = 1; monster_speed = 4;
Width = 78; Width = 78;
Height = 96; Height = 96;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight");
public override void Update(GameTime gameTime)
{
if (!isAttack)
{
Move(gameTime);
}
base.Update(gameTime);
}
public override void Attack() public override void Attack()
{ {
@ -34,7 +44,34 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight")
{
GraphicsComponent.StartAnimation("WolfMoveRight");
}
velocity.X = monster_speed;
}
else
{
if (GraphicsComponent.GetCurrentAnimation != "WolfMoveLeft")
{
GraphicsComponent.StartAnimation("WolfMoveLeft");
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
}
public override void Attack(GameTime gameTime)
{
} }
} }
} }

View file

@ -107,5 +107,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
base.OnCollision(gameObject); base.OnCollision(gameObject);
} }
public override void Attack(GameTime gameTime)
{
throw new NotImplementedException();
}
} }
} }

View file

@ -12,15 +12,13 @@ namespace DangerousD.GameCore.Levels
{ {
new Player(new Vector2(80,0)); new Player(new Vector2(80,0));
var Zombie = new Zombie(new Vector2(140, 128)); var Zombie = new Zombie(new Vector2(140, 128));
var Frank = new Frank(new Vector2(384, 128)); var Frank = new Frank(new Vector2(300, 0));
var Spider = new Spider(new Vector2(112, 0)); var Spider = new Spider(new Vector2(112, 0));
var FlameSkull = new FlameSkull(new Vector2(512, 0)); var FlameSkull = new FlameSkull(new Vector2(512, 0));
var Werewolf = new Werewolf(new Vector2(640, 0)); var Werewolf = new Werewolf(new Vector2(640, 0));
var Ghost = new Ghost(new Vector2(730, 0)); var Ghost = new Ghost(new Vector2(300, 0));
var Frank = new Frank(new Vector2(100, 64));
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y)); var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
var Zombie = new Zombie(new Vector2(300, 64));
var SilasHand = new SilasHands(new Vector2(200,64)); var SilasHand = new SilasHands(new Vector2(200,64));
var SilasMaster = new SilasMaster(new Vector2(400, 64)); var SilasMaster = new SilasMaster(new Vector2(400, 64));

View file

@ -21,7 +21,6 @@ namespace DangerousD.GameCore
public List<Player> players; public List<Player> players;
public List<GameObject> otherObjects = new(); public List<GameObject> otherObjects = new();
public List<GameObject> GetAllGameObjects { get; private set; }
public Player GetPlayer1 { get; private set; } public Player GetPlayer1 { get; private set; }
public GameManager() public GameManager()
{ {

View file

@ -170,6 +170,7 @@ namespace DangerousD.GameCore.Managers
return null; return null;
} }
public GameObject RayCast(LivingEntity entity1, Vector2 targetCast) public GameObject RayCast(LivingEntity entity1, Vector2 targetCast)
{ {
Rectangle rectangle; Rectangle rectangle;