fix Bags
This commit is contained in:
commit
e3879697f0
42 changed files with 779 additions and 100 deletions
1
DangerousD/Content/animations/SlimeJumpLeftBottom
Normal file
1
DangerousD/Content/animations/SlimeJumpLeftBottom
Normal 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"}
|
1
DangerousD/Content/animations/SlimeJumpLeftTop
Normal file
1
DangerousD/Content/animations/SlimeJumpLeftTop
Normal 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"}
|
1
DangerousD/Content/animations/SlimeJumpRightBottom
Normal file
1
DangerousD/Content/animations/SlimeJumpRightBottom
Normal 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"}
|
1
DangerousD/Content/animations/SlimeJumpRightTop
Normal file
1
DangerousD/Content/animations/SlimeJumpRightTop
Normal 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"}
|
1
DangerousD/Content/animations/SlimeMoveLeftBottom
Normal file
1
DangerousD/Content/animations/SlimeMoveLeftBottom
Normal 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"}
|
1
DangerousD/Content/animations/SlimeMoveLeftTop
Normal file
1
DangerousD/Content/animations/SlimeMoveLeftTop
Normal 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"}
|
1
DangerousD/Content/animations/SlimeMoveRightBottom
Normal file
1
DangerousD/Content/animations/SlimeMoveRightBottom
Normal 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"}
|
1
DangerousD/Content/animations/SlimeMoveRightTop
Normal file
1
DangerousD/Content/animations/SlimeMoveRightTop
Normal 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"}
|
1
DangerousD/Content/animations/SlimeReadyJumpLeftBottom
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpLeftBottom
Normal 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"}
|
1
DangerousD/Content/animations/SlimeReadyJumpLeftTop
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpLeftTop
Normal 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"}
|
1
DangerousD/Content/animations/SlimeReadyJumpRightBottom
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpRightBottom
Normal 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"}
|
1
DangerousD/Content/animations/SlimeReadyJumpRightTop
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpRightTop
Normal 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"}
|
|
@ -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"}
|
||||||
|
|
BIN
DangerousD/GameCore/.DS_Store
vendored
Normal file
BIN
DangerousD/GameCore/.DS_Store
vendored
Normal file
Binary file not shown.
|
@ -55,7 +55,8 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
|
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
|
||||||
//debug
|
//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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,9 +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 = false;
|
||||||
|
protected bool isGoRight;
|
||||||
|
protected int leftBoarder = 0;
|
||||||
|
protected int rightBoarder = 700;
|
||||||
|
|
||||||
public CoreEnemy(Vector2 position) : base(position)
|
public CoreEnemy(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
@ -29,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);
|
||||||
|
|
||||||
|
@ -41,5 +46,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void Target();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -34,7 +45,40 @@ 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,38 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
internal class Frank : CoreEnemy
|
internal class Frank : CoreEnemy
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
|
private Vector2 position;
|
||||||
private bool isGoRight = false;
|
private bool isGoRight = false;
|
||||||
|
|
||||||
|
public Vector2 Position
|
||||||
|
{
|
||||||
|
get { return position; }
|
||||||
|
}
|
||||||
|
|
||||||
public Frank(Vector2 position) : base(position)
|
public Frank(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
this.position = position;
|
||||||
|
=======
|
||||||
|
public Frank(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
isGoRight = false;
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
Width = 112;
|
Width = 112;
|
||||||
Height = 160;
|
Height = 160;
|
||||||
|
leftBoarder = 50;
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
|
@ -35,14 +57,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");
|
||||||
|
@ -57,6 +73,24 @@ 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,19 +12,58 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class FrankBalls : CoreEnemy
|
public class FrankBalls : CoreEnemy
|
||||||
{
|
{
|
||||||
|
private Rectangle collision;
|
||||||
|
private Vector2 position;
|
||||||
|
private int healthBall;
|
||||||
|
private bool isFlyRight = true;
|
||||||
|
private bool isAttacking = false;
|
||||||
|
|
||||||
|
public Rectangle Collision
|
||||||
|
{
|
||||||
|
get { return collision; }
|
||||||
|
}
|
||||||
|
|
||||||
public FrankBalls(Vector2 position) : base(position)
|
public FrankBalls(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
this.position = position;
|
||||||
name = "FrankBalls";
|
name = "FrankBalls";
|
||||||
Width = 40;
|
Width = 40;
|
||||||
Height = 40;
|
Height = 40;
|
||||||
monster_speed = 1;
|
monster_speed = 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)
|
||||||
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
|
if(!isAttacking)
|
||||||
|
{
|
||||||
|
Move(gameTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
{
|
{
|
||||||
|
collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
|
||||||
|
isAttacking = true;
|
||||||
|
|
||||||
|
if(isFlyRight)
|
||||||
|
{
|
||||||
|
AppManager.Instance.GameManager.players[0].Death(name);
|
||||||
|
}
|
||||||
|
else if(!isFlyRight)
|
||||||
|
{
|
||||||
|
AppManager.Instance.GameManager.players[0].Death(name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +74,29 @@ 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)
|
||||||
|
{
|
||||||
|
velocity.X += monster_speed;
|
||||||
|
velocity.Y += monster_speed;
|
||||||
|
}
|
||||||
|
else if(!isFlyRight)
|
||||||
|
{
|
||||||
|
velocity.X -= monster_speed;
|
||||||
|
velocity.Y -= monster_speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -34,7 +46,44 @@ 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -32,5 +37,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -36,5 +41,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
@ -55,6 +60,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
velocity.X = monster_speed;
|
velocity.X = monster_speed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
currentTime++;
|
currentTime++;
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
private void SpawnAttackBall()
|
private void SpawnAttackBall()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < balls.Count; i++)
|
for (int i = 0; i < balls.Count; i++)
|
||||||
|
@ -70,9 +71,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
|
@ -105,6 +114,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
isGoRight = true;
|
isGoRight = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
|
|
@ -12,19 +12,151 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Slime : CoreEnemy
|
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)
|
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",
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
|
||||||
"SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
|
"SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
|
||||||
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "");
|
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "SlimeMoveRightTop");
|
||||||
|
|
||||||
public override void Attack()
|
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");
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
}
|
||||||
|
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 Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -32,7 +164,87 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
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()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
protected int webLength;
|
protected int webLength;
|
||||||
protected bool isDown;
|
protected bool isDown;
|
||||||
protected bool isDownUp;
|
protected bool isDownUp;
|
||||||
|
|
||||||
public Spider(Vector2 position) : base(position)
|
public Spider(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
isDownUp = true;
|
isDownUp = true;
|
||||||
|
@ -27,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,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;
|
||||||
|
@ -46,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
webLength++;
|
webLength++;
|
||||||
_pos.Y += 25;
|
_pos.Y += 25;
|
||||||
web.Height = webLength * 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;
|
delay = 0;
|
||||||
if (webLength == 4)
|
if (webLength == 4)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +83,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
webLength--;
|
webLength--;
|
||||||
_pos.Y -= 25;
|
_pos.Y -= 25;
|
||||||
web.Height = webLength * 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;
|
delay = 0;
|
||||||
if (webLength == 0)
|
if (webLength == 0)
|
||||||
{
|
{
|
||||||
|
@ -72,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)
|
||||||
|
@ -100,7 +118,35 @@ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -37,5 +42,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,39 @@ 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
float leftBorder;
|
float leftBorder;
|
||||||
float rightBorder;
|
float rightBorder;
|
||||||
bool isAttaking = false;
|
bool isAttaking = false;
|
||||||
|
<<<<<<< HEAD
|
||||||
bool isTarget = false;
|
bool isTarget = false;
|
||||||
PhysicsManager physicsManager;
|
PhysicsManager physicsManager;
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
public Zombie(Vector2 position) : base(position)
|
public Zombie(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
Width = 24;
|
Width = 24;
|
||||||
Height = 40;
|
Height = 40;
|
||||||
monster_speed = 3;
|
monster_speed = 1;
|
||||||
name = "Zombie";
|
name = "Zombie";
|
||||||
leftBorder = (int)position.X - 100;
|
leftBorder = (int)position.X - 100;
|
||||||
rightBorder = (int)position.X + 100;
|
rightBorder = (int)position.X + 100;
|
||||||
|
@ -48,7 +52,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
isAttaking = true;
|
isAttaking = true;
|
||||||
if (isGoRight)
|
if (isGoRight)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieAttackRight");
|
GraphicsComponent.StartAnimation("ZombieAttackRight");
|
||||||
}
|
}
|
||||||
|
@ -112,9 +116,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
base.OnCollision(gameObject);
|
base.OnCollision(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public void Target()
|
public void Target()
|
||||||
{
|
{
|
||||||
if(physicsManager.RayCast(this, AppManager.Instance.GameManager.players[0]) == null)
|
if(AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-50, (int)Pos.Y, Width+100, Height), typeof(Player))!=null)
|
||||||
{
|
{
|
||||||
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
||||||
{
|
{
|
||||||
|
@ -130,6 +135,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
|
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
public override void Attack(GameTime gameTime)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Target()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
{
|
{
|
||||||
Width = 32;
|
Width = 32;
|
||||||
Height = 64;
|
Height = 64;
|
||||||
|
<<<<<<< HEAD
|
||||||
AppManager.Instance.InputManager.MovEventJump += Jump;
|
AppManager.Instance.InputManager.MovEventJump += Jump;
|
||||||
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||||
|
|
||||||
|
=======
|
||||||
|
AppManager.Instance.InputManager.MovEventJump += AnimationJump;
|
||||||
|
>>>>>>> 833da68a4e42a47ab035a220c049aa9937eb1969
|
||||||
}
|
}
|
||||||
public bool IsAlive { get { return isAlive; } }
|
public bool IsAlive { get { return isAlive; } }
|
||||||
|
|
||||||
|
@ -58,5 +62,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
||||||
|
velocity.X = 0.5f;
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ public abstract class LivingEntity : Entity
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
if (Vector2.Distance(Pos, targetPosition) > 0.5f)
|
//if (Vector2.DistanceSquared(Pos, targetPosition) > 0.25f)
|
||||||
{
|
//{
|
||||||
Vector2 dir = targetPosition - Pos;
|
// Vector2 dir = targetPosition - Pos;
|
||||||
dir.Normalize();
|
// dir.Normalize();
|
||||||
_pos += dir * velocity;
|
// _pos += dir * velocity;
|
||||||
}
|
//}
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace DangerousD.GameCore.GameObjects;
|
||||||
|
|
||||||
public abstract class MapObject : GameObject
|
public abstract class MapObject : GameObject
|
||||||
{
|
{
|
||||||
public bool IsColliderOn;
|
public virtual bool IsColliderOn { get; protected set; } = true;
|
||||||
private Rectangle _sourceRectangle;
|
private Rectangle _sourceRectangle;
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new("tiles");
|
protected override GraphicsComponent GraphicsComponent { get; } = new("tiles");
|
||||||
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position)
|
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position)
|
||||||
|
@ -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);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,21 @@
|
||||||
using DangerousD.GameCore.Graphics;
|
using DangerousD.GameCore.Graphics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GameObjects.MapObjects;
|
namespace DangerousD.GameCore.GameObjects.MapObjects;
|
||||||
|
|
||||||
public class Platform : MapObject
|
public class Platform : MapObject
|
||||||
{
|
{
|
||||||
|
public override bool IsColliderOn { get; protected set; } = true;
|
||||||
public Platform(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
|
public Platform(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
|
||||||
{
|
{
|
||||||
IsColliderOn = true;
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,20 @@
|
||||||
using DangerousD.GameCore.Graphics;
|
using DangerousD.GameCore.Graphics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GameObjects.MapObjects;
|
namespace DangerousD.GameCore.GameObjects.MapObjects;
|
||||||
|
|
||||||
public class StopTile : MapObject
|
public class StopTile : MapObject
|
||||||
{
|
{
|
||||||
|
public override bool IsColliderOn { get; protected set; } = true;
|
||||||
public StopTile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
|
public StopTile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
|
||||||
{
|
{
|
||||||
IsColliderOn = true;
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@ namespace DangerousD.GameCore.GameObjects.MapObjects;
|
||||||
|
|
||||||
public class Tile : MapObject
|
public class Tile : MapObject
|
||||||
{
|
{
|
||||||
|
public override bool IsColliderOn { get; protected set; } = false;
|
||||||
public Tile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
|
public Tile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
|
||||||
{
|
{
|
||||||
IsColliderOn = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -164,8 +164,9 @@ namespace DangerousD.GameCore.Graphics
|
||||||
scale = destinationRectangle.Width / sourceRectangle.Width;
|
scale = destinationRectangle.Width / sourceRectangle.Width;
|
||||||
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +188,8 @@ namespace DangerousD.GameCore.Graphics
|
||||||
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
|
@ -215,5 +218,6 @@ namespace DangerousD.GameCore.Graphics
|
||||||
interval = lastInterval;
|
interval = lastInterval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static Point CameraPosition = new Point(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
33
DangerousD/GameCore/Levels/Level1.cs
Normal file
33
DangerousD/GameCore/Levels/Level1.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||||
|
using DangerousD.GameCore.GameObjects.MapObjects;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.Levels
|
||||||
|
{
|
||||||
|
public class Level1 : ILevel
|
||||||
|
{
|
||||||
|
public void InitLevel()
|
||||||
|
{
|
||||||
|
new Player(new Vector2(80,0));
|
||||||
|
var Zombie = new Zombie(new Vector2(140, 128));
|
||||||
|
var Frank = new Frank(new Vector2(300, 0));
|
||||||
|
|
||||||
|
var Spider = new Spider(new Vector2(112, 0));
|
||||||
|
var FlameSkull = new FlameSkull(new Vector2(512, 0));
|
||||||
|
var Werewolf = new Werewolf(new Vector2(640, 0));
|
||||||
|
var Ghost = new Ghost(new Vector2(300, 0));
|
||||||
|
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
|
||||||
|
|
||||||
|
var SilasHand = new SilasHands(new Vector2(200,64));
|
||||||
|
var SilasMaster = new SilasMaster(new Vector2(400, 64));
|
||||||
|
new GrassBlock(new Vector2(0, 224));
|
||||||
|
for (int i = 0; i < 50; i++)
|
||||||
|
{
|
||||||
|
new GrassBlock(new Vector2(i*32, 256));
|
||||||
|
}
|
||||||
|
new GrassBlock(new Vector2(500, 224));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,7 +64,6 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
GameManager.Initialize();
|
|
||||||
AnimationBuilder.LoadAnimations();
|
AnimationBuilder.LoadAnimations();
|
||||||
MenuGUI.Initialize();
|
MenuGUI.Initialize();
|
||||||
LoginGUI.Initialize();
|
LoginGUI.Initialize();
|
||||||
|
@ -179,6 +178,7 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
foreach (NetworkTask networkTask in networkTasks)
|
foreach (NetworkTask networkTask in networkTasks)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
switch (networkTask.operation)
|
switch (networkTask.operation)
|
||||||
{
|
{
|
||||||
case NetworkTaskOperationEnum.TakeDamage:
|
case NetworkTaskOperationEnum.TakeDamage:
|
||||||
|
@ -199,6 +199,25 @@ namespace DangerousD.GameCore
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
case NetworkTaskOperationEnum.TakeDamage:
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.SendSound:
|
||||||
|
// SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos);
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.CreateEntity:
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.SendPosition:
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.ChangeState:
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.ConnectToHost:
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.GetClientPlayerId:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,55 +14,68 @@ namespace DangerousD.GameCore
|
||||||
public class GameManager
|
public class GameManager
|
||||||
{
|
{
|
||||||
public List<GameObject> GetAllGameObjects { get; private set; }
|
public List<GameObject> GetAllGameObjects { get; private set; }
|
||||||
|
|
||||||
public List<LivingEntity> livingEntities;
|
public List<LivingEntity> livingEntities;
|
||||||
public List<Entity> entities;
|
public List<Entity> entities;
|
||||||
public List<MapObject> mapObjects;
|
public List<MapObject> mapObjects;
|
||||||
|
public List<MapObject> BackgroundObjects;
|
||||||
public List<GameObject> others;
|
public List<GameObject> others;
|
||||||
public MapManager mapManager;
|
public MapManager mapManager;
|
||||||
public PhysicsManager physicsManager;
|
public PhysicsManager physicsManager;
|
||||||
public List<Player> players;
|
public List<Player> players;
|
||||||
public List<GameObject> otherObjects = new();
|
public List<GameObject> otherObjects = new();
|
||||||
|
|
||||||
public Player GetPlayer1 { get; private set; }
|
public Player GetPlayer1 { get; private set; }
|
||||||
public GameManager()
|
public GameManager()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
others = new List<GameObject>();
|
others = new List<GameObject>();
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
GetAllGameObjects = new List<GameObject>();
|
GetAllGameObjects = new List<GameObject>();
|
||||||
livingEntities = new List<LivingEntity>();
|
livingEntities = new List<LivingEntity>();
|
||||||
mapObjects = new List<MapObject>();
|
mapObjects = new List<MapObject>();
|
||||||
|
BackgroundObjects = new List<MapObject>();
|
||||||
entities = new List<Entity>();
|
entities = new List<Entity>();
|
||||||
players = new List<Player>();
|
players = new List<Player>();
|
||||||
mapManager = new MapManager(1);
|
mapManager = new MapManager(1);
|
||||||
physicsManager = new PhysicsManager();
|
physicsManager = new PhysicsManager();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
|
||||||
{
|
|
||||||
//mapManager.LoadLevel("Level1");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadContent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Register(GameObject gameObject)
|
internal void Register(GameObject gameObject)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
|
||||||
|
GetAllGameObjects.Add(gameObject);
|
||||||
|
if (gameObject is Player objPl)
|
||||||
|
=======
|
||||||
|
GetAllGameObjects.Add(gameObject);
|
||||||
if (gameObject is Player)
|
if (gameObject is Player)
|
||||||
|
>>>>>>> livingEntitiesVlad
|
||||||
{
|
{
|
||||||
livingEntities.Add(gameObject as LivingEntity);
|
livingEntities.Add(gameObject as LivingEntity);
|
||||||
players.Add(gameObject as Player);
|
players.Add(objPl);
|
||||||
GetPlayer1 = players[0];
|
GetPlayer1 = players[0];
|
||||||
}
|
}
|
||||||
else if (gameObject is LivingEntity)
|
else if (gameObject is LivingEntity objLE)
|
||||||
{
|
{
|
||||||
livingEntities.Add(gameObject as LivingEntity);
|
livingEntities.Add(objLE);
|
||||||
}
|
}
|
||||||
else if (gameObject is Entity)
|
else if (gameObject is Entity objE)
|
||||||
{
|
{
|
||||||
entities.Add(gameObject as Entity);
|
entities.Add(objE);
|
||||||
}
|
}
|
||||||
else if (gameObject is MapObject)
|
else if (gameObject is MapObject obj)
|
||||||
{
|
{
|
||||||
mapObjects.Add(gameObject as MapObject);
|
if (obj.IsColliderOn)
|
||||||
|
mapObjects.Add(obj);
|
||||||
|
else
|
||||||
|
BackgroundObjects.Add(obj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -72,6 +85,8 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
public void Draw(SpriteBatch _spriteBatch)
|
public void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
|
foreach (var item in BackgroundObjects)
|
||||||
|
item.Draw(_spriteBatch);
|
||||||
foreach (var item in mapObjects)
|
foreach (var item in mapObjects)
|
||||||
item.Draw(_spriteBatch);
|
item.Draw(_spriteBatch);
|
||||||
foreach (var item in entities)
|
foreach (var item in entities)
|
||||||
|
@ -84,15 +99,15 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
foreach (var item in BackgroundObjects)
|
||||||
|
item.Update(gameTime);
|
||||||
foreach (var item in mapObjects)
|
foreach (var item in mapObjects)
|
||||||
item.Update(gameTime);
|
item.Update(gameTime);
|
||||||
foreach (var item in entities)
|
foreach (var item in entities)
|
||||||
item.Update(gameTime);
|
item.Update(gameTime);
|
||||||
|
|
||||||
for (int i = 0; i < livingEntities.Count; i++)
|
for (int i = 0; i < livingEntities.Count; i++)
|
||||||
{
|
|
||||||
livingEntities[i].Update(gameTime);
|
livingEntities[i].Update(gameTime);
|
||||||
}
|
|
||||||
foreach (var item in otherObjects)
|
foreach (var item in otherObjects)
|
||||||
item.Update(gameTime);
|
item.Update(gameTime);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using DangerousD.GameCore.GameObjects;
|
using DangerousD.GameCore.GameObjects;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.Managers
|
namespace DangerousD.GameCore.Managers
|
||||||
{
|
{
|
||||||
|
@ -46,8 +47,8 @@ namespace DangerousD.GameCore.Managers
|
||||||
private void InstantiateTiles(XmlNode layer, Vector2 tileSize)
|
private void InstantiateTiles(XmlNode layer, Vector2 tileSize)
|
||||||
{
|
{
|
||||||
string tileType = layer.Attributes["class"].Value;
|
string tileType = layer.Attributes["class"].Value;
|
||||||
float offsetX = layer.Attributes["offsetx"] is not null ? float.Parse(layer.Attributes["offsetx"].Value) : 0;
|
float offsetX = layer.Attributes["offsetx"] is not null ? float.Parse(layer.Attributes["offsetx"].Value, CultureInfo.InvariantCulture) : 0;
|
||||||
float offsetY = layer.Attributes["offsety"] is not null ? float.Parse(layer.Attributes["offsety"].Value) : 0;
|
float offsetY = layer.Attributes["offsety"] is not null ? float.Parse(layer.Attributes["offsety"].Value, CultureInfo.InvariantCulture) : 0;
|
||||||
|
|
||||||
|
|
||||||
Debug.Write(layer.SelectNodes("data/chunk").Count);
|
Debug.Write(layer.SelectNodes("data/chunk").Count);
|
||||||
|
@ -105,7 +106,7 @@ namespace DangerousD.GameCore.Managers
|
||||||
foreach (XmlNode entity in group.ChildNodes)
|
foreach (XmlNode entity in group.ChildNodes)
|
||||||
{
|
{
|
||||||
Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityType}");
|
Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityType}");
|
||||||
Entity inst = (Entity)Activator.CreateInstance(type, new Vector2(float.Parse(entity.Attributes["x"].Value) + offsetX, float.Parse(entity.Attributes["y"].Value) + offsetY) * _scale);
|
Entity inst = (Entity)Activator.CreateInstance(type, new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale);
|
||||||
inst.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height));
|
inst.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height));
|
||||||
inst.Height *= _scale;
|
inst.Height *= _scale;
|
||||||
inst.Width *= _scale;
|
inst.Width *= _scale;
|
||||||
|
|
|
@ -36,33 +36,24 @@ namespace DangerousD.GameCore.Managers
|
||||||
public void CheckCollisions(List<LivingEntity> livingEntities,
|
public void CheckCollisions(List<LivingEntity> livingEntities,
|
||||||
List<MapObject> mapObjects)
|
List<MapObject> mapObjects)
|
||||||
{
|
{
|
||||||
|
LivingEntity currentEntity;
|
||||||
|
Rectangle oldRect;
|
||||||
for (int i = 0; i < livingEntities.Count; i++)
|
for (int i = 0; i < livingEntities.Count; i++)
|
||||||
{
|
{
|
||||||
var currentEntity = livingEntities[i];
|
currentEntity = livingEntities[i];
|
||||||
Rectangle oldRect = currentEntity.Rectangle;
|
oldRect = currentEntity.Rectangle;
|
||||||
bool isXNormalise = true;
|
bool isXNormalise = true;
|
||||||
bool isYNormalise = true;
|
bool isYNormalise = true;
|
||||||
|
|
||||||
oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
|
oldRect.Offset((int)currentEntity.velocity.X, 0);
|
||||||
for (int j = 0; j < mapObjects.Count; j++)
|
for (int j = 0; j < mapObjects.Count; j++)
|
||||||
{
|
{
|
||||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 550)
|
||||||
{
|
|
||||||
isXNormalise = false;
|
|
||||||
oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (isXNormalise)
|
|
||||||
{
|
|
||||||
oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
|
|
||||||
for (int j = 0; j < mapObjects.Count; j++)
|
|
||||||
{
|
{
|
||||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||||
{
|
{
|
||||||
isXNormalise = false;
|
isXNormalise = false;
|
||||||
oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
|
oldRect.Offset(-(int)currentEntity.velocity.X, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,29 +62,17 @@ namespace DangerousD.GameCore.Managers
|
||||||
currentEntity.velocity.X = 0;
|
currentEntity.velocity.X = 0;
|
||||||
|
|
||||||
|
|
||||||
oldRect.Offset(0, (int)currentEntity.velocity.Y/2);
|
oldRect.Offset(0, (int)currentEntity.velocity.Y);
|
||||||
for (int j = 0; j < mapObjects.Count; j++)
|
for (int j = 0; j < mapObjects.Count; j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
||||||
{
|
{
|
||||||
isYNormalise = false;
|
isYNormalise = false;
|
||||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
|
oldRect.Offset(0, -(int)currentEntity.velocity.Y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isYNormalise)
|
|
||||||
{
|
|
||||||
oldRect.Offset(0, (int)currentEntity.velocity.Y / 2);
|
|
||||||
for (int j = 0; j < mapObjects.Count; j++)
|
|
||||||
{
|
|
||||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
|
||||||
{
|
|
||||||
isYNormalise = false;
|
|
||||||
oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isYNormalise)
|
if (!isYNormalise)
|
||||||
currentEntity.velocity.Y = 0;
|
currentEntity.velocity.Y = 0;
|
||||||
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
||||||
|
@ -177,6 +156,7 @@ namespace DangerousD.GameCore.Managers
|
||||||
}
|
}
|
||||||
return gameObject;
|
return gameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject RayCast(LivingEntity entity1, Vector2 targetCast)
|
public GameObject RayCast(LivingEntity entity1, Vector2 targetCast)
|
||||||
{
|
{
|
||||||
Rectangle rectangle;
|
Rectangle rectangle;
|
||||||
|
@ -217,7 +197,6 @@ namespace DangerousD.GameCore.Managers
|
||||||
}
|
}
|
||||||
return gameObject;
|
return gameObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GameObject> CheckRectangle(Rectangle rectangle, Type type)
|
public List<GameObject> CheckRectangle(Rectangle rectangle, Type type)
|
||||||
{
|
{
|
||||||
var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects;
|
var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects;
|
||||||
|
@ -234,5 +213,20 @@ namespace DangerousD.GameCore.Managers
|
||||||
}
|
}
|
||||||
return intersected;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ namespace DangerousD.GameCore
|
||||||
public void LoadSounds() // метод для загрузки звуков из папки
|
public void LoadSounds() // метод для загрузки звуков из папки
|
||||||
{
|
{
|
||||||
var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
|
var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
|
||||||
|
|
||||||
if (k.Count() > 0)
|
if (k.Count() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -31,6 +32,10 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (k.Count()>0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
||||||
|
|
Loading…
Add table
Reference in a new issue