This commit is contained in:
AnloGames 2023-08-17 17:39:43 +03:00
commit d77766d503
34 changed files with 575 additions and 58 deletions

View file

@ -0,0 +1 @@
{"id":"SlimeJumpLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":176,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeJumpLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":151,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeJumpRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":176,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeJumpRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":151,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeMoveLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":182,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeMoveLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":51,"Y":182,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeMoveRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":165,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeMoveRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":51,"Y":165,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeReadyJumpLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeReadyJumpLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeReadyJumpRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"SlimeReadyJumpRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}

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

@ -55,7 +55,8 @@ namespace DangerousD.GameCore
{
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
//debug
// spriteBatch.Draw(debugTexture, Rectangle, Color.White);
//wdaspriteBatch.Draw(debugTexture,new Rectangle(Rectangle.X-GraphicsComponent.CameraPosition.X,Rectangle.Y-GraphicsComponent.CameraPosition.Y,Rectangle.Width,Rectangle.Height), Color.White);
}
}
}

View file

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

View file

@ -18,10 +18,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 40;
monster_speed = 3;
name = "Skull";
acceleration = Vector2.Zero;
}
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()
{
@ -33,8 +44,41 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
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)
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -12,24 +12,25 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
internal class Frank : CoreEnemy
{
private Vector2 position;
private bool isGoRight = false;
public Vector2 Position
{
get { return position; }
}
public Frank(Vector2 position) : base(position)
{
this.position = position;
isGoRight = false;
Width = 112;
Height = 160;
leftBoarder = 50;
rightBoarder = 300;
GraphicsComponent.StartAnimation("FrankMoveLeft");
monster_speed = 1;
monster_speed = 2;
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()
{
@ -43,12 +44,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
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 (GraphicsComponent.GetCurrentAnimation != "FrankMoveRight")
@ -65,6 +60,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
}
public override void Attack(GameTime gameTime)
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -44,7 +44,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
base.Update(gameTime);
}
public override void Attack()
{
collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
@ -82,5 +81,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
velocity.Y -= monster_speed;
}
}
public override void Attack(GameTime gameTime)
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -12,16 +12,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public Ghost(Vector2 position) : base(position)
{
monster_speed = 1;
isGoRight = true;
monster_speed = 3;
name = "Ghost";
Width = 48;
Height = 62;
GraphicsComponent.StartAnimation("GhostSpawn");
acceleration = Vector2.Zero;
}
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()
{
@ -33,8 +45,45 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
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)
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -23,6 +23,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void Attack(GameTime gameTime)
{
}
public override void Death()
{
@ -32,5 +37,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -27,6 +27,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void Attack(GameTime gameTime)
{
}
public override void Death()
{
@ -36,5 +41,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -27,7 +27,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack()
{
throw new NotImplementedException();
}
public override void Attack(GameTime gameTime)
{
}
public override void Death()
@ -55,6 +60,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
velocity.X = monster_speed;
}
}
public override void Target()
{
throw new NotImplementedException();
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);

View file

@ -61,6 +61,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
currentTime++;
}
private void SpawnAttackBall()
{
for (int i = 0; i < balls.Count; i++)
@ -70,9 +71,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void Attack(GameTime gameTime)
{
}
public override void Death()
{
throw new NotImplementedException();
}
public override void Move(GameTime gameTime)
@ -105,6 +112,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isGoRight = true;
}
}
public override void Target()
{
throw new NotImplementedException();
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);

View file

@ -12,25 +12,233 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Slime : CoreEnemy
{
private bool isGoRight = true;
private bool isDown = false;
int leftBorder;
int rightBorder;
bool isAttaking = false;
int delay;
bool isJumping = false;
public Slime(Vector2 position) : base(position)
{
Width = 48;
Height = 16;
name = "Slime";
monster_speed = 3;
monster_health = 2;
leftBorder = 100;
rightBorder = 400;
//acceleration = Vector2.Zero;
delay = 30;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
"SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "");
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "SlimeMoveRightTop");
public override void Attack()
{
}
public void Jump()
{
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100));
velocity.X = 0;
Height = 32;
if (isGoRight && isDown)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpLeftBottom")
{
GraphicsComponent.StartAnimation("SlimeReadyJumpLeftBottom");
}
delay--;
if (delay <= 0)
{
isJumping = true;
velocity = new Vector2(5, -3);
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom")
{
GraphicsComponent.StartAnimation("SlimeJumpLeftBottom");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
if (getCols.Count > 0)
{
isJumping = false;
isDown = false;
}
}
}
else if (!isGoRight && isDown)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpRightTop")
{
GraphicsComponent.StartAnimation("SlimeReadyJumpRightTop");
}
delay--;
if (delay <= 0)
{
velocity = new Vector2(-5, -3);
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
{
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
if (getCols.Count > 0)
{
isJumping = false;
isDown = false;
}
}
}
else if (isGoRight && !isDown)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpLeftTop")
{
GraphicsComponent.StartAnimation("SlimeReadyJumpLeftTop");
}
delay--;
if (delay <= 0)
{
isJumping = true;
velocity = new Vector2(5, 3);
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
{
GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5));
if (getCols.Count > 0)
{
isJumping = false;
isDown = true;
}
}
}
else if (!isGoRight && !isDown)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpRightTop")
{
GraphicsComponent.StartAnimation("SlimeReadyJumpRightTop");
}
delay--;
if (delay <= 0)
{
velocity = new Vector2(-5, 3);
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
{
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5));
if (getCols.Count > 0)
{
isJumping = false;
isDown = true;
}
}
}
}
public override void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(debugTexture, new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5), Color.White);
spriteBatch.Draw(debugTexture, new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5), Color.White);
base.Draw(spriteBatch);
}
public override void Death()
{
}
public override void Move(GameTime gameTime)
{
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
delay = 30;
Height = 16;
if (isGoRight && isDown)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveRightBottom")
{
GraphicsComponent.StartAnimation("SlimeMoveRightBottom");
}
velocity.X = monster_speed;
}
else if (!isGoRight && isDown)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveLeftBottom")
{
GraphicsComponent.StartAnimation("SlimeMoveLeftBottom");
}
velocity.X = -monster_speed;
}
else if (!isDown && isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveRightTop")
{
GraphicsComponent.StartAnimation("SlimeMoveRightTop");
}
velocity.X = monster_speed;
}
else if (!isDown && !isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveLeftTop")
{
GraphicsComponent.StartAnimation("SlimeMoveLeftTop");
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBorder)
{
isGoRight = false;
}
else if (Pos.X <= leftBorder)
{
isGoRight = true;
}
}
public override void Update(GameTime gameTime)
{
if (isDown)
{
if (acceleration.Y < 0)
{
acceleration.Y = -acceleration.Y;
}
}
else
{
if (acceleration.Y > 0)
{
acceleration.Y = -acceleration.Y;
}
}
//if (!isAttaking){ Move(gameTime); }
base.Update(gameTime);
}
public override void Target()
{
}
public override void Attack(GameTime gameTime)
{
}

View file

@ -17,6 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
protected int webLength;
protected bool isDown;
protected bool isDownUp;
public Spider(Vector2 position) : base(position)
{
isDownUp = true;
@ -27,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 24;
delay = 0;
webLength = 0;
monster_speed = 1;
monster_speed = 2;
acceleration = Vector2.Zero;
}
@ -35,6 +36,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
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)
{
Width = 48;
@ -46,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
webLength++;
_pos.Y += 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 4)
{
@ -59,7 +83,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
webLength--;
_pos.Y -= 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 0)
{
@ -72,12 +96,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 24;
}
}
base.Update(gameTime);
}
public override void Attack()
{ //48 72
}
public override void Draw(SpriteBatch spriteBatch)
@ -100,7 +118,35 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
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;
}
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -28,6 +28,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void Attack(GameTime gameTime)
{
}
public override void Death()
{
@ -37,5 +42,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -15,13 +15,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public Werewolf(Vector2 position) : base(position)
{
name = "Wolf";
monster_speed = 1;
monster_speed = 4;
Width = 78;
Height = 96;
}
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()
{
@ -34,7 +44,39 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
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)
{
}
public override void Target()
{
throw new NotImplementedException();
}
}
}

View file

@ -23,7 +23,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
Width = 24;
Height = 40;
monster_speed = 1;
monster_speed = 3;
name = "Zombie";
leftBorder = (int)position.X - 100;
rightBorder = (int)position.X + 100;
@ -111,8 +111,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
base.OnCollision(gameObject);
}
public void Target()
public override void Target()
{
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)) != null)
{
@ -131,5 +130,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
}
}
public override void Attack(GameTime gameTime)
{
throw new NotImplementedException();
}
}
}

View file

@ -22,8 +22,10 @@ public abstract class MapObject : GameObject
}
public void Draw(SpriteBatch spriteBatch)
public virtual void Draw(SpriteBatch spriteBatch)
{
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch, _sourceRectangle);
//spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.White);
}
}

View file

@ -1,5 +1,6 @@
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects.MapObjects;
@ -9,5 +10,12 @@ public class Platform : MapObject
public Platform(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
{
}
public override void Draw(SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
//debug
//spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.Blue);
}
}

View file

@ -1,5 +1,6 @@
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects.MapObjects;
@ -9,4 +10,11 @@ public class StopTile : MapObject
public StopTile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
{
}
public override void Draw(SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
//debug
// spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.White);
}
}

View file

@ -64,7 +64,6 @@ namespace DangerousD.GameCore
protected override void Initialize()
{
GameManager.Initialize();
AnimationBuilder.LoadAnimations();
MenuGUI.Initialize();
LoginGUI.Initialize();

View file

@ -14,6 +14,7 @@ namespace DangerousD.GameCore
public class GameManager
{
public List<GameObject> GetAllGameObjects { get; private set; }
public List<LivingEntity> livingEntities;
public List<Entity> entities;
public List<MapObject> mapObjects;
@ -23,6 +24,7 @@ namespace DangerousD.GameCore
public PhysicsManager physicsManager;
public List<Player> players;
public List<GameObject> otherObjects = new();
public Player GetPlayer1 { get; private set; }
public GameManager()
{
@ -35,20 +37,14 @@ namespace DangerousD.GameCore
players = new List<Player>();
mapManager = new MapManager(1);
physicsManager = new PhysicsManager();
}
public void Initialize()
{
//mapManager.LoadLevel("Level1");
}
public void LoadContent()
{
}
internal void Register(GameObject gameObject)
{
//GetAllGameObjects.Add(gameObject);
GetAllGameObjects.Add(gameObject);
if (gameObject is Player objPl)
{
livingEntities.Add(gameObject as LivingEntity);

View file

@ -48,7 +48,7 @@ namespace DangerousD.GameCore.Managers
oldRect.Offset((int)currentEntity.velocity.X, 0);
for (int j = 0; j < mapObjects.Count; j++)
{
if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X)< currentEntity.velocity.X*2 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 50)
if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 550)
{
if (oldRect.Intersects(mapObjects[j].Rectangle))
{
@ -156,6 +156,7 @@ namespace DangerousD.GameCore.Managers
}
return gameObject;
}
public GameObject RayCast(LivingEntity entity1, Vector2 targetCast)
{
Rectangle rectangle;
@ -196,7 +197,6 @@ namespace DangerousD.GameCore.Managers
}
return gameObject;
}
public List<GameObject> CheckRectangle(Rectangle rectangle, Type type)
{
var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects;
@ -213,5 +213,20 @@ namespace DangerousD.GameCore.Managers
}
return intersected;
}
public List<GameObject> CheckRectangle(Rectangle rectangle)
{
var gameObjects = AppManager.Instance.GameManager.mapObjects;
List<GameObject> intersected = new List<GameObject>();
for (int i = 0; i < gameObjects.Count; i++)
{
if (gameObjects[i].Rectangle.Intersects(rectangle) && gameObjects[i].IsColliderOn)
{
intersected.Add(gameObjects[i]);
}
}
return intersected;
}
}
}