diff --git a/DangerousD/Content/animations/SlimeJumpLeftBottom b/DangerousD/Content/animations/SlimeJumpLeftBottom new file mode 100644 index 0000000..876f587 --- /dev/null +++ b/DangerousD/Content/animations/SlimeJumpLeftBottom @@ -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"} diff --git a/DangerousD/Content/animations/SlimeJumpLeftTop b/DangerousD/Content/animations/SlimeJumpLeftTop new file mode 100644 index 0000000..e73565f --- /dev/null +++ b/DangerousD/Content/animations/SlimeJumpLeftTop @@ -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"} diff --git a/DangerousD/Content/animations/SlimeJumpRightBottom b/DangerousD/Content/animations/SlimeJumpRightBottom new file mode 100644 index 0000000..3a0d067 --- /dev/null +++ b/DangerousD/Content/animations/SlimeJumpRightBottom @@ -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"} diff --git a/DangerousD/Content/animations/SlimeJumpRightTop b/DangerousD/Content/animations/SlimeJumpRightTop new file mode 100644 index 0000000..6e75357 --- /dev/null +++ b/DangerousD/Content/animations/SlimeJumpRightTop @@ -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"} diff --git a/DangerousD/Content/animations/SlimeMoveLeftBottom b/DangerousD/Content/animations/SlimeMoveLeftBottom new file mode 100644 index 0000000..c2477cc --- /dev/null +++ b/DangerousD/Content/animations/SlimeMoveLeftBottom @@ -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"} diff --git a/DangerousD/Content/animations/SlimeMoveLeftTop b/DangerousD/Content/animations/SlimeMoveLeftTop new file mode 100644 index 0000000..90723bf --- /dev/null +++ b/DangerousD/Content/animations/SlimeMoveLeftTop @@ -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"} diff --git a/DangerousD/Content/animations/SlimeMoveRightBottom b/DangerousD/Content/animations/SlimeMoveRightBottom new file mode 100644 index 0000000..2caee25 --- /dev/null +++ b/DangerousD/Content/animations/SlimeMoveRightBottom @@ -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"} diff --git a/DangerousD/Content/animations/SlimeMoveRightTop b/DangerousD/Content/animations/SlimeMoveRightTop new file mode 100644 index 0000000..ff14358 --- /dev/null +++ b/DangerousD/Content/animations/SlimeMoveRightTop @@ -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"} diff --git a/DangerousD/Content/animations/SlimeReadyJumpLeftBottom b/DangerousD/Content/animations/SlimeReadyJumpLeftBottom new file mode 100644 index 0000000..aba1149 --- /dev/null +++ b/DangerousD/Content/animations/SlimeReadyJumpLeftBottom @@ -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"} diff --git a/DangerousD/Content/animations/SlimeReadyJumpLeftTop b/DangerousD/Content/animations/SlimeReadyJumpLeftTop new file mode 100644 index 0000000..896a29d --- /dev/null +++ b/DangerousD/Content/animations/SlimeReadyJumpLeftTop @@ -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"} diff --git a/DangerousD/Content/animations/SlimeReadyJumpRightBottom b/DangerousD/Content/animations/SlimeReadyJumpRightBottom new file mode 100644 index 0000000..16f8e64 --- /dev/null +++ b/DangerousD/Content/animations/SlimeReadyJumpRightBottom @@ -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"} diff --git a/DangerousD/Content/animations/SlimeReadyJumpRightTop b/DangerousD/Content/animations/SlimeReadyJumpRightTop new file mode 100644 index 0000000..95fb101 --- /dev/null +++ b/DangerousD/Content/animations/SlimeReadyJumpRightTop @@ -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"} diff --git a/DangerousD/Content/animations/WolfMoveLeft b/DangerousD/Content/animations/WolfMoveLeft index 924a49c..74a3dd0 100644 --- a/DangerousD/Content/animations/WolfMoveLeft +++ b/DangerousD/Content/animations/WolfMoveLeft @@ -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"} diff --git a/DangerousD/GameCore/.DS_Store b/DangerousD/GameCore/.DS_Store new file mode 100644 index 0000000..e6c817c Binary files /dev/null and b/DangerousD/GameCore/.DS_Store differ diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index ae5cd2c..d276984 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -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); + } } } \ No newline at end of file diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs index 4fbe6ff..22ea566 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs @@ -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(); } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs index cd00606..f7591ac 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs @@ -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 { "FlameSkullMoveRight" , "FlameSkullMoveLeft"}, "FlameSkullMoveRight"); + public override void Update(GameTime gameTime) + { + if (!isAttack) + { + Move(gameTime); + } + + base.Update(gameTime); + } + public override void Attack() { @@ -34,7 +45,40 @@ 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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs index b0b3429..807473e 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs @@ -12,16 +12,38 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { internal class Frank : CoreEnemy { +<<<<<<< HEAD + private Vector2 position; private bool isGoRight = false; + + public Vector2 Position + { + get { return position; } + } + public Frank(Vector2 position) : base(position) { + this.position = position; +======= + public Frank(Vector2 position) : base(position) + { + isGoRight = false; +>>>>>>> livingEntitiesVlad 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 { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight"); + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveLeft"); + + public override void Update(GameTime gameTime) + { + Move(gameTime); + base.Update(gameTime); + } public override void Attack() { @@ -35,14 +57,8 @@ 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") { GraphicsComponent.StartAnimation("FrankMoveRight"); @@ -57,6 +73,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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs index 7101da2..85d124e 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs @@ -12,19 +12,58 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { 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) { + this.position = position; name = "FrankBalls"; Width = 40; Height = 40; - monster_speed = 1; + monster_speed = 3; acceleration = Vector2.Zero; } protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "BallMoveRight" }, "BallMoveRight"); + public override void Update(GameTime gameTime) + { +<<<<<<< HEAD + if(!isAttacking) + { + Move(gameTime); + } + + base.Update(gameTime); + } + +======= + + base.Update(gameTime); + } +>>>>>>> livingEntitiesVlad 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) { + 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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs index 1e47e99..6236554 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs @@ -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 { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight"); + public override void Update(GameTime gameTime) + { + if (!isAttack) + { + Move(gameTime); + } + + base.Update(gameTime); + } + public override void Attack() { @@ -34,7 +46,44 @@ 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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs index cc6ecd5..e309d9e 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs @@ -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(); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs index 9e616ed..9cd2b4f 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs @@ -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(); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs index d16936a..16c06e1 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs @@ -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); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs index d4fb5d2..dfecd2d 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs @@ -61,6 +61,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters } currentTime++; } +<<<<<<< HEAD private void SpawnAttackBall() { 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() { - throw new NotImplementedException(); + } public override void Move(GameTime gameTime) @@ -105,6 +114,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); diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs index 9f3f936..07e0600 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs @@ -12,19 +12,151 @@ 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 { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop", - "SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom", - "SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, ""); + "SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom", + "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"); +<<<<<<< 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() { @@ -32,7 +164,87 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters 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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs index bffa5f6..0d797aa 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs @@ -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); + } + /// + /// НИЧЕГО НЕ ДЕЛАЕТ! НУЖЕН ДЛЯ ПЕРЕОПРЕДЕЛЕНИЯ + /// + public override void Attack() + { + } + /// + /// Атака паука РАБОЧАЯ + /// + /// + 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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs index d91ccaf..cde2ab0 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs @@ -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(); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs index 9d5acb8..2d9ebae 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs @@ -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 { "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(); } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index b679a37..534cbd1 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -17,13 +17,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters float leftBorder; float rightBorder; bool isAttaking = false; +<<<<<<< HEAD bool isTarget = false; PhysicsManager physicsManager; +======= + +>>>>>>> livingEntitiesVlad public Zombie(Vector2 position) : base(position) { Width = 24; Height = 40; - monster_speed = 3; + monster_speed = 1; name = "Zombie"; leftBorder = (int)position.X - 100; rightBorder = (int)position.X + 100; @@ -48,7 +52,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters isAttaking = true; if (isGoRight) { - if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight") + if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack") { GraphicsComponent.StartAnimation("ZombieAttackRight"); } @@ -112,9 +116,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters base.OnCollision(gameObject); } +<<<<<<< HEAD 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) { @@ -130,6 +135,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters 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 } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs index f035c0d..85a3750 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs @@ -18,9 +18,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities { Width = 32; Height = 64; +<<<<<<< HEAD AppManager.Instance.InputManager.MovEventJump += Jump; AppManager.Instance.InputManager.ShootEvent += Shoot; +======= + AppManager.Instance.InputManager.MovEventJump += AnimationJump; +>>>>>>> 833da68a4e42a47ab035a220c049aa9937eb1969 } 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); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs index 8341080..5620568 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntity.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -19,12 +19,12 @@ public abstract class LivingEntity : Entity public override void Update(GameTime gameTime) { - if (Vector2.Distance(Pos, targetPosition) > 0.5f) - { - Vector2 dir = targetPosition - Pos; - dir.Normalize(); - _pos += dir * velocity; - } + //if (Vector2.DistanceSquared(Pos, targetPosition) > 0.25f) + //{ + // Vector2 dir = targetPosition - Pos; + // dir.Normalize(); + // _pos += dir * velocity; + //} base.Update(gameTime); } diff --git a/DangerousD/GameCore/GameObjects/MapObject.cs b/DangerousD/GameCore/GameObjects/MapObject.cs index 24add79..02576ef 100644 --- a/DangerousD/GameCore/GameObjects/MapObject.cs +++ b/DangerousD/GameCore/GameObjects/MapObject.cs @@ -7,7 +7,7 @@ namespace DangerousD.GameCore.GameObjects; public abstract class MapObject : GameObject { - public bool IsColliderOn; + public virtual bool IsColliderOn { get; protected set; } = true; private Rectangle _sourceRectangle; protected override GraphicsComponent GraphicsComponent { get; } = new("tiles"); 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); + //spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.White); + } } \ No newline at end of file diff --git a/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs b/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs index f3648f9..f69d7c9 100644 --- a/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs +++ b/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs @@ -1,12 +1,21 @@ using DangerousD.GameCore.Graphics; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; namespace DangerousD.GameCore.GameObjects.MapObjects; public class Platform : MapObject { + public override bool IsColliderOn { get; protected set; } = true; 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); + + } + } \ No newline at end of file diff --git a/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs b/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs index 096973b..b4fb7a5 100644 --- a/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs +++ b/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs @@ -1,12 +1,20 @@ using DangerousD.GameCore.Graphics; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; namespace DangerousD.GameCore.GameObjects.MapObjects; public class StopTile : MapObject { + public override bool IsColliderOn { get; protected set; } = true; 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); + } } \ No newline at end of file diff --git a/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs b/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs index 2b11dda..5f36075 100644 --- a/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs +++ b/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs @@ -5,8 +5,8 @@ namespace DangerousD.GameCore.GameObjects.MapObjects; public class Tile : MapObject { + public override bool IsColliderOn { get; protected set; } = false; public Tile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle) - { - IsColliderOn = false; + { } } \ No newline at end of file diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index beb6928..32851e2 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -164,8 +164,9 @@ namespace DangerousD.GameCore.Graphics scale = destinationRectangle.Width / sourceRectangle.Width; destinationRectangle.Height = (int)(sourceRectangle.Height * scale); } - - + + destinationRectangle.X -= CameraPosition.X; + destinationRectangle.Y -= CameraPosition.Y; _spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, Color.White); } @@ -187,6 +188,8 @@ namespace DangerousD.GameCore.Graphics destinationRectangle.Height = (int)(sourceRectangle.Height * scale); } + destinationRectangle.X -= CameraPosition.X; + destinationRectangle.Y -= CameraPosition.Y; _spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, Color.White); @@ -215,5 +218,6 @@ namespace DangerousD.GameCore.Graphics interval = lastInterval; } } + public static Point CameraPosition = new Point(0, 0); } } diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs new file mode 100644 index 0000000..29f1a6e --- /dev/null +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -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)); + } + } +} diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index f800998..bda0c27 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -64,7 +64,6 @@ namespace DangerousD.GameCore protected override void Initialize() { - GameManager.Initialize(); AnimationBuilder.LoadAnimations(); MenuGUI.Initialize(); LoginGUI.Initialize(); @@ -179,6 +178,7 @@ namespace DangerousD.GameCore { foreach (NetworkTask networkTask in networkTasks) { +<<<<<<< HEAD switch (networkTask.operation) { case NetworkTaskOperationEnum.TakeDamage: @@ -199,6 +199,25 @@ namespace DangerousD.GameCore default: 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 } } diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index f2ce8c8..b12f88c 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -14,55 +14,68 @@ namespace DangerousD.GameCore public class GameManager { public List GetAllGameObjects { get; private set; } + public List livingEntities; public List entities; public List mapObjects; + public List BackgroundObjects; public List others; public MapManager mapManager; public PhysicsManager physicsManager; public List players; public List otherObjects = new(); + public Player GetPlayer1 { get; private set; } public GameManager() { +<<<<<<< HEAD others = new List(); +======= + +>>>>>>> livingEntitiesVlad GetAllGameObjects = new List(); livingEntities = new List(); mapObjects = new List(); + BackgroundObjects = new List(); entities = new List(); players = new List(); mapManager = new MapManager(1); physicsManager = new PhysicsManager(); + } - public void Initialize() - { - //mapManager.LoadLevel("Level1"); - } - - public void LoadContent() - { - } + internal void Register(GameObject gameObject) { +<<<<<<< HEAD + + + GetAllGameObjects.Add(gameObject); + if (gameObject is Player objPl) +======= + GetAllGameObjects.Add(gameObject); if (gameObject is Player) +>>>>>>> livingEntitiesVlad { livingEntities.Add(gameObject as LivingEntity); - players.Add(gameObject as Player); + players.Add(objPl); 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 { @@ -72,6 +85,8 @@ namespace DangerousD.GameCore public void Draw(SpriteBatch _spriteBatch) { + foreach (var item in BackgroundObjects) + item.Draw(_spriteBatch); foreach (var item in mapObjects) item.Draw(_spriteBatch); foreach (var item in entities) @@ -84,15 +99,15 @@ namespace DangerousD.GameCore public void Update(GameTime gameTime) { + foreach (var item in BackgroundObjects) + item.Update(gameTime); foreach (var item in mapObjects) item.Update(gameTime); foreach (var item in entities) item.Update(gameTime); - + for (int i = 0; i < livingEntities.Count; i++) - { livingEntities[i].Update(gameTime); - } foreach (var item in otherObjects) item.Update(gameTime); diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs index 36a0f6b..5d7d6fc 100644 --- a/DangerousD/GameCore/Managers/MapManager.cs +++ b/DangerousD/GameCore/Managers/MapManager.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Xml.Serialization; using DangerousD.GameCore.GameObjects; +using System.Globalization; namespace DangerousD.GameCore.Managers { @@ -46,8 +47,8 @@ namespace DangerousD.GameCore.Managers private void InstantiateTiles(XmlNode layer, Vector2 tileSize) { string tileType = layer.Attributes["class"].Value; - float offsetX = layer.Attributes["offsetx"] is not null ? float.Parse(layer.Attributes["offsetx"].Value) : 0; - float offsetY = layer.Attributes["offsety"] is not null ? float.Parse(layer.Attributes["offsety"].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, CultureInfo.InvariantCulture) : 0; Debug.Write(layer.SelectNodes("data/chunk").Count); @@ -105,7 +106,7 @@ namespace DangerousD.GameCore.Managers foreach (XmlNode entity in group.ChildNodes) { 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.Height *= _scale; inst.Width *= _scale; diff --git a/DangerousD/GameCore/Managers/PhysicsManager.cs b/DangerousD/GameCore/Managers/PhysicsManager.cs index 28ecf14..980d7b3 100644 --- a/DangerousD/GameCore/Managers/PhysicsManager.cs +++ b/DangerousD/GameCore/Managers/PhysicsManager.cs @@ -36,33 +36,24 @@ namespace DangerousD.GameCore.Managers public void CheckCollisions(List livingEntities, List mapObjects) { + LivingEntity currentEntity; + Rectangle oldRect; for (int i = 0; i < livingEntities.Count; i++) { - var currentEntity = livingEntities[i]; - Rectangle oldRect = currentEntity.Rectangle; + currentEntity = livingEntities[i]; + oldRect = currentEntity.Rectangle; 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++) { - if (oldRect.Intersects(mapObjects[j].Rectangle)) - { - 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 (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)) { isXNormalise = false; - oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0); + oldRect.Offset(-(int)currentEntity.velocity.X, 0); break; } } @@ -71,29 +62,17 @@ namespace DangerousD.GameCore.Managers 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++) { + if (oldRect.Intersects(mapObjects[j].Rectangle)) { isYNormalise = false; - oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2); + oldRect.Offset(0, -(int)currentEntity.velocity.Y); 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) currentEntity.velocity.Y = 0; currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y)); @@ -177,6 +156,7 @@ namespace DangerousD.GameCore.Managers } return gameObject; } + public GameObject RayCast(LivingEntity entity1, Vector2 targetCast) { Rectangle rectangle; @@ -217,7 +197,6 @@ namespace DangerousD.GameCore.Managers } return gameObject; } - public List CheckRectangle(Rectangle rectangle, Type type) { var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects; @@ -234,5 +213,20 @@ namespace DangerousD.GameCore.Managers } return intersected; } + public List CheckRectangle(Rectangle rectangle) + { + var gameObjects = AppManager.Instance.GameManager.mapObjects; + List intersected = new List(); + for (int i = 0; i < gameObjects.Count; i++) + { + + if (gameObjects[i].Rectangle.Intersects(rectangle) && gameObjects[i].IsColliderOn) + { + intersected.Add(gameObjects[i]); + } + + } + return intersected; + } } } \ No newline at end of file diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs index 75758e8..e1e982e 100644 --- a/DangerousD/GameCore/Managers/SoundManager.cs +++ b/DangerousD/GameCore/Managers/SoundManager.cs @@ -20,6 +20,7 @@ namespace DangerousD.GameCore public void LoadSounds() // метод для загрузки звуков из папки { var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3")); + if (k.Count() > 0) { @@ -31,6 +32,10 @@ namespace DangerousD.GameCore } + if (k.Count()>0) + { + + } } public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции