diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..e7ffd96
Binary files /dev/null and b/.DS_Store differ
diff --git a/AnimationsFileCreator/AnimationsFileCreator.csproj b/AnimationsFileCreator/AnimationsFileCreator.csproj
index 9e982a1..296b0a7 100644
--- a/AnimationsFileCreator/AnimationsFileCreator.csproj
+++ b/AnimationsFileCreator/AnimationsFileCreator.csproj
@@ -2,8 +2,7 @@
Exe
- net6.0-windows
- true
+ net6.0
diff --git a/AnimationsFileCreator/Program.cs b/AnimationsFileCreator/Program.cs
index 9a712a0..1fc3f13 100644
--- a/AnimationsFileCreator/Program.cs
+++ b/AnimationsFileCreator/Program.cs
@@ -2,7 +2,6 @@
using Microsoft.Xna.Framework;
using Newtonsoft.Json;
using System;
-using System.Windows.Forms;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
@@ -17,13 +16,6 @@ namespace AnimationsFileCreator
Console.WriteLine("Добро пожаловать в костыльную программу по созданию файлов анимации для игры DungerousD");
Console.Write("Введите название текстуры (нажмите enter, чтобы выбрать файл во всплывающем окошке): ");
string textureName = Console.ReadLine();
- if (textureName == "")
- {
- OpenFileDialog dialog = new OpenFileDialog();
- dialog.ShowDialog();
- textureName = dialog.FileName.Split('\\').Last();
- textureName = textureName.Split('.')[0];
- }
Console.WriteLine("Введите количество кадров анимации: ");
int framesCount = int.Parse(Console.ReadLine());
Console.WriteLine("Введите длительность кадра в анимации: ");
diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb
index ea7bb60..b3ce6cc 100644
--- a/DangerousD/Content/Content.mgcb
+++ b/DangerousD/Content/Content.mgcb
@@ -140,7 +140,7 @@
/processorParam:TextureFormat=Color
/build:menuFon.jpg
-#begin MenuFon2.jpg
+#begin menuFon2.jpg
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -150,7 +150,7 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
-/build:MenuFon2.jpg
+/build:menuFon2.jpg
#begin menuFon3.jpg
/importer:TextureImporter
@@ -255,7 +255,7 @@
/processorParam:Quality=Best
/build:sounds/shotgun_shot.mp3
-#begin SmokeAnimation2.png
+#begin smokeAnimation2.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
@@ -265,7 +265,7 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
-/build:SmokeAnimation2.png
+/build:smokeAnimation2.png
#begin textboxbackground1-1.png
/importer:TextureImporter
diff --git a/DangerousD/Content/animations/DeathFromGhost b/DangerousD/Content/animations/DeathFromGhost
new file mode 100644
index 0000000..b4ef48e
--- /dev/null
+++ b/DangerousD/Content/animations/DeathFromGhost
@@ -0,0 +1 @@
+{"id":"DeathFromGhost","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":246,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/DeathFromHunchman b/DangerousD/Content/animations/DeathFromHunchman
new file mode 100644
index 0000000..a00ed27
--- /dev/null
+++ b/DangerousD/Content/animations/DeathFromHunchman
@@ -0,0 +1 @@
+{"id":"DeathFromHunchman","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/DeathFromSilasMaster b/DangerousD/Content/animations/DeathFromSilasMaster
new file mode 100644
index 0000000..3f9a76b
--- /dev/null
+++ b/DangerousD/Content/animations/DeathFromSilasMaster
@@ -0,0 +1 @@
+{"id":"DeathFromSilasMaster","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":295,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/DeathFromSlime b/DangerousD/Content/animations/DeathFromSlime
new file mode 100644
index 0000000..5a692f6
--- /dev/null
+++ b/DangerousD/Content/animations/DeathFromSlime
@@ -0,0 +1 @@
+{"id":"DeathFromSlime","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":50,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/DeathFromSpider b/DangerousD/Content/animations/DeathFromSpider
new file mode 100644
index 0000000..98a08a5
--- /dev/null
+++ b/DangerousD/Content/animations/DeathFromSpider
@@ -0,0 +1 @@
+{"id":"DeathFromSpider","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":148,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/DeathFromWerewolf b/DangerousD/Content/animations/DeathFromWerewolf
new file mode 100644
index 0000000..8f0b150
--- /dev/null
+++ b/DangerousD/Content/animations/DeathFromWerewolf
@@ -0,0 +1 @@
+{"id":"DeathFromWerewolf","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":197,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/GhostAttack b/DangerousD/Content/animations/GhostAttack
index 7ada2dc..8425c93 100644
--- a/DangerousD/Content/animations/GhostAttack
+++ b/DangerousD/Content/animations/GhostAttack
@@ -1 +1 @@
-{"id":"GhostAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":503,"Width":24,"Height":31},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"}
+{"id":"GhostAttack","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":503,"Width":24,"Height":31},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":50,"framesCount":2,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/HunchmanMoveLeft.crash b/DangerousD/Content/animations/HunchmanMoveLeft.crash
new file mode 100644
index 0000000..d924010
--- /dev/null
+++ b/DangerousD/Content/animations/HunchmanMoveLeft.crash
@@ -0,0 +1 @@
+{"id":"HunchmanMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":124,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/HunchmanMoveRight.crash b/DangerousD/Content/animations/HunchmanMoveRight.crash
new file mode 100644
index 0000000..0fc3798
--- /dev/null
+++ b/DangerousD/Content/animations/HunchmanMoveRight.crash
@@ -0,0 +1 @@
+{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":100,"Width":24,"Height":23},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/playerShootBoomUpLeft b/DangerousD/Content/animations/playerShootBoomUpLeft
new file mode 100644
index 0000000..093eb3c
--- /dev/null
+++ b/DangerousD/Content/animations/playerShootBoomUpLeft
@@ -0,0 +1 @@
+{"id":"playerShootBoomUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/playerShootBoomUpRight b/DangerousD/Content/animations/playerShootBoomUpRight
new file mode 100644
index 0000000..3f70e03
--- /dev/null
+++ b/DangerousD/Content/animations/playerShootBoomUpRight
@@ -0,0 +1,24 @@
+{
+ "id": "playerShootBoomUpRight",
+ "textureName": "playerAnimation",
+ "startSpriteRectangle": {
+ "X": 267,
+ "Y": 1,
+ "Width": 24,
+ "Height": 32
+ },
+ "frameSecond": [
+ {
+ "Item1": 0,
+ "Item2": 3
+ },
+ {
+ "Item1": 1,
+ "Item2": 20
+ }
+ ],
+ "textureFrameInterval": 1,
+ "framesCount": 2,
+ "isCycle": false,
+ "offset": "0, 0"
+}
diff --git a/DangerousD/Content/lvl.tmx b/DangerousD/Content/lvl.tmx
index 5d448e5..ed2ac61 100644
--- a/DangerousD/Content/lvl.tmx
+++ b/DangerousD/Content/lvl.tmx
@@ -734,7 +734,7 @@
-
diff --git a/DangerousD/Content/map.tmx b/DangerousD/Content/map.tmx
index 18bf11c..bdb520f 100644
--- a/DangerousD/Content/map.tmx
+++ b/DangerousD/Content/map.tmx
@@ -1,3 +1,64 @@
+<<<<<<< HEAD
+
+
+=======
+>>>>>>> main
diff --git a/DangerousD/Content/MenuFon2.jpg b/DangerousD/Content/menuFon2.jpg
similarity index 100%
rename from DangerousD/Content/MenuFon2.jpg
rename to DangerousD/Content/menuFon2.jpg
diff --git a/DangerousD/Content/SmokeAnimation2.png b/DangerousD/Content/smokeAnimation2.png
similarity index 100%
rename from DangerousD/Content/SmokeAnimation2.png
rename to DangerousD/Content/smokeAnimation2.png
diff --git a/DangerousD/DangerousD.sln b/DangerousD/DangerousD.sln
new file mode 100644
index 0000000..29f2a38
--- /dev/null
+++ b/DangerousD/DangerousD.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 25.0.1705.7
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DangerousD", "DangerousD.csproj", "{A51FB3C2-D16C-42DF-B65A-6EC67AF07506}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F6C9C555-FA45-4C6A-BEB3-8352B2653CB0}
+ EndGlobalSection
+EndGlobal
diff --git a/DangerousD/GameCore/GUI/DeathGUI.cs b/DangerousD/GameCore/GUI/DeathGUI.cs
index 31bff02..ce73850 100644
--- a/DangerousD/GameCore/GUI/DeathGUI.cs
+++ b/DangerousD/GameCore/GUI/DeathGUI.cs
@@ -23,7 +23,7 @@ internal class DeathGUI : AbstractGui
Elements.Add(butMenu);
butMenu.LeftButtonPressed += () =>
{
- AppManager.Instance.ChangeGameState(GameState.Menu);
+ AppManager.Instance.Restart("lvl");
};
foreach (var item in Elements)
{
diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs
index 9a37c58..de4e214 100644
--- a/DangerousD/GameCore/GameObjects/GameObject.cs
+++ b/DangerousD/GameCore/GameObjects/GameObject.cs
@@ -38,6 +38,12 @@ namespace DangerousD.GameCore
{
}
+ protected int obsticles = 0;
+ public virtual void OnCollisionWithObsticle(GameObject gameObject)
+ {
+ obsticles++;//SD
+ }
+
public virtual void Initialize()
{
}
@@ -53,6 +59,7 @@ namespace DangerousD.GameCore
public virtual void Update(GameTime gameTime)
{
+ obsticles = 0;
GraphicsComponent.Update();
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
index 62923ba..e06b177 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
@@ -36,9 +36,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract void Move(GameTime gameTime);
- public void TakeDamage(int damage)
+ public virtual void TakeDamage()
{
- monster_health -= damage;
+ monster_health--;
if (monster_health <= 0)
{
Death();
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
index f9d2cfa..7108020 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using DangerousD.GameCore.GameObjects.MapObjects;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
@@ -17,21 +18,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private bool isFlyRight = true;
private bool isFlyUp = true;
private bool isAttacking = false;
+ private int hp;
public Rectangle Collision
{
get { return collision; }
}
- public FrankBalls(Vector2 position) : base(position)
+ public FrankBalls(Vector2 position) : base(new Vector2(300, 200))
{
- this.position = position;
+
name = "FrankBalls";
Width = 40;
Height = 40;
monster_speed = 3;
velocity = new Vector2(3,-3);
acceleration = Vector2.Zero;
+ velocity = new Vector2(monster_speed, monster_speed);
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "BallMoveRight" }, "BallMoveRight");
@@ -39,7 +42,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime)
{
Move(gameTime);
- AppManager.Instance.DebugHUD.Set(name, velocity.ToString());
+
+ Death();
+
base.Update(gameTime);
}
public override void Attack()
@@ -60,12 +65,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death()
{
-
+ if (hp <= 0)
+ {
+ AppManager.Instance.GameManager.Remove(this);
+ }
}
public override void Move(GameTime gameTime)
{
-
var getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
var getColsVer= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ;
if (isFlyRight)
@@ -75,6 +82,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isFlyRight = false;
velocity.X = -velocity.X;
+ hp--;
}
}
else
@@ -84,6 +92,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isFlyRight = true;
velocity.X = -velocity.X;
+ hp--;
}
}
if (isFlyUp)
@@ -94,6 +103,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isFlyUp = false;
velocity.Y = -velocity.Y;
+ hp--;
}
}
else
@@ -103,6 +113,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isFlyUp = true;
velocity.Y = -velocity.Y;
+ hp--;
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
index 20d6161..4101386 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
@@ -17,11 +17,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isGoRight = true;
monster_speed = 3;
name = "Ghost";
- Width = 48;
- Height = 62;
+ Width = 24;
+ Height = 30;
GraphicsComponent.StartAnimation("GhostSpawn");
- acceleration = Vector2.Zero;
-
+ acceleration = new Vector2(0,1);
+ monster_health = 1;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
@@ -38,13 +38,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack()
{
-
+ velocity.X = 0;
+ isAttack = true;
+ if (GraphicsComponent.GetCurrentAnimation != "GhostAttack")
+ {
+ GraphicsComponent.StartAnimation("GhostAttack");
+ }
+
+ AppManager.Instance.GameManager.players[0].Death(name);
}
public override void Death()
{
}
+ public override void OnCollision(GameObject gameObject)
+ {
+ if (gameObject is Player)
+ {
+ if (AppManager.Instance.GameManager.players[0].IsAlive)
+ {
+ Attack();
+
+ }
+ }
+ base.OnCollision(gameObject);
+ }
public override void Move(GameTime gameTime)
{
@@ -64,17 +83,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
velocity.X = -monster_speed;
}
- if (Pos.X >= rightBoarder)
+ var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
+ if (isGoRight)
{
- isGoRight = false;
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, Width + 4, 2));
}
- else if (Pos.X <= leftBoarder)
+ else
{
- isGoRight = true;
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 3, (int)Pos.Y + Height / 2 - 2, Width + 3, 2));
}
- if (true)
- {
+
+ foreach (var item in getCols)
+ {
+ if (item is MapObject)
+ {
+ isGoRight = !isGoRight;
+ break;
+ }
}
}
@@ -82,8 +108,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
+ public void TakeDamage()
+ {
+ monster_health--;
+<<<<<<< HEAD
public override void Target()
+=======
+
+ if (monster_health <= 0)
+ {
+ Death();
+ }
+ }
+ public void Target()
+>>>>>>> f415b47fc4b84d2c5aaa94f02641c9b075f9f3f8
{
throw new NotImplementedException();
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
index b0fa2b0..7894683 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
@@ -9,129 +9,130 @@ using System.Linq;
using System.Security.Authentication.ExtendedProtection;
using System.Text;
using System.Threading.Tasks;
+using DangerousD.GameCore.Managers;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Hunchman : CoreEnemy
{
- GameManager gameManager;
- bool isAttacking;
+ private bool isGoRight = false;
+ private bool isAttaking = false;
+ private bool isTarget = false;
+ private bool isVisible = true;
+ float leftBoarder;
+ float rightBoarder;
+
+ PhysicsManager physicsManager;
public Hunchman(Vector2 position) : base(position)
{
- Width = 48;
- Height = 48;
- monster_speed = -2;
- monster_health = 1;
- name = "HunchMan";
- velocity = new Vector2(monster_speed, 0);
- gameManager = AppManager.Instance.GameManager;
- isAttacking = false;
- isAlive = true;
+ Width = 20;
+ Height = 30;
+ leftBoarder = (int)position.X - 100;
+ rightBoarder = (int)position.X + 100;
+ name = "Hunchman";
+ GraphicsComponent.StartAnimation("HunchmanMoveLeft");
+ monster_speed = 3;
+ physicsManager = new PhysicsManager();
}
- protected override GraphicsComponent GraphicsComponent { get; } = new(new List
+ protected override GraphicsComponent GraphicsComponent { get; } = new(new List
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft");
+
public override void Update(GameTime gameTime)
{
- // P.S. Всё в классе можешь смело удалять и переписывать с нуля.
- gameManager = AppManager.Instance.GameManager;
-
- if (!isAttacking)
+ if (!isAttaking)
{
- Attack();
+ Target();
Move(gameTime);
}
- else
- {
- velocity.X = 0;
- }
- Death();
+ base.Update(gameTime);
}
public override void Attack()
{
- GameObject gameObject;
- foreach (var player in gameManager.players)
+ var animation = GraphicsComponent.GetCurrentAnimation;
+ isAttaking = true;
+ if (isGoRight)
{
- if (player.Pos.Y + player.Height >= Pos.Y && player.Pos.Y <= Pos.Y + Height)
+ if (animation != "HunchmanAttackRight")
{
- gameObject = gameManager.physicsManager.RayCast(this, player);
- if (gameObject is null)
- {
- isAttacking = true;
- GraphicsComponent.StopAnimation();
- if (velocity.X > 0)
- {
- if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackRight")
- {
- GraphicsComponent.StartAnimation("HunchmanAttackRight");
- }
- }
- else if (velocity.X < 0)
- {
- if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackLeft")
- {
- GraphicsComponent.StartAnimation("HunchmanAttackLeft");
- }
- }
- }
+ GraphicsComponent.StartAnimation("HunchmanAttackRight");
}
+ HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos,isGoRight);
+ }
+ else
+ {
+ if (animation != "HunchmanAttackLeft")
+ {
+ GraphicsComponent.StartAnimation("HunchmanAttackLeft");
+ }
+ HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos, isGoRight);
}
}
public override void Attack(GameTime gameTime)
- {
-
- }
+ {}
public override void Death()
{
+ for (int i = 0; i < 3; i++)
+ {
+ Particle particle = new Particle(Pos);
+ }
+
if (monster_health <= 0)
{
-
+ isVisible = false;
}
}
public override void Move(GameTime gameTime)
{
- if (gameManager.physicsManager.RayCast(this, new Vector2(Pos.X + Width + 10, Pos.Y + Height)) is not null)
+ velocity.X = 0;
+ var animation = GraphicsComponent.GetCurrentAnimation;
+ if (isGoRight)
{
- monster_speed *= -1;
- }
-
- velocity.X = monster_speed;
-
- if (velocity.X > 0)
- {
- if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
+ if (animation != "HunchmanMoveRight")
{
GraphicsComponent.StartAnimation("HunchmanMoveRight");
}
-
+ velocity.X = monster_speed;
}
-
- else if (velocity.X < 0)
+ else
{
- if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
+ if (animation != "HunchmanMoveLeft")
{
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
}
+ velocity.X = -monster_speed;
}
+ if (_pos.X >= rightBoarder)
+ {
+ isGoRight = false;
+ }
+ else if (_pos.X <= leftBoarder)
+ {
+ isGoRight = true;
+ }
}
- public override void OnCollision(GameObject gameObject)
- {
- monster_speed *= -1;
- _pos.X += 5 * monster_speed;
- Debug.WriteLine("Collision");
- }
+
public override void Target()
{
+<<<<<<< HEAD
+=======
+ var player = AppManager.Instance.GameManager.players[0];
+
+ if (physicsManager.RayCast(this, player) == null)
+ {
+ Attack();
+ }
+>>>>>>> f415b47fc4b84d2c5aaa94f02641c9b075f9f3f8
}
}
-}
+}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
index 3d1bc3a..0140352 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
@@ -12,10 +12,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class HunchmanDagger : CoreEnemy
{
- public HunchmanDagger(Vector2 position) : base(position)
+ private bool isGoRight = false;
+
+ public HunchmanDagger(Vector2 position, bool isGoRight) : base(position)
{
+ this.isGoRight = isGoRight;
name = "Hunchman";
- monster_speed = 1;
+ monster_speed = 4;
Width = 9;
Height = 6;
}
@@ -34,12 +37,46 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death()
{
-
+ AppManager.Instance.GameManager.Remove(this);
}
public override void Move(GameTime gameTime)
{
+ velocity.X = 0;
+ var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 0, 0));
+ if (isGoRight)
+ {
+ StartCicycleAnimation("HunchmanDaggerRight");
+ velocity.X = monster_speed;
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width+5, Height));
+ if(getCols.Count>0)
+ {
+ Death();
+ }
+ }
+ else if (!isGoRight)
+ {
+ StartCicycleAnimation("HunchmanDaggerLeft");
+ velocity.X = -monster_speed;
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-5, (int)Pos.Y, Width + 5, Height));
+ if (getCols.Count > 0)
+ {
+ Death();
+ }
+ }
+
+
+ }
+
+ public override void OnCollision(GameObject gameObject)
+ {
+ if (gameObject is Player)
+ {
+ AppManager.Instance.GameManager.players[0].Death(name);
+ }
+
+ base.OnCollision(gameObject);
}
public override void Target()
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
index e77804c..5a60037 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
@@ -173,7 +173,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void Death()
{
+
+ Particle particle = new Particle(Pos);
+
+ AppManager.Instance.GameManager.Remove(this);
}
public override void Move(GameTime gameTime)
@@ -220,7 +224,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
velocity.X = -monster_speed;
}
- var getCols= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ;
+ var getCols= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
if (isGoRight)
{
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 51, 2));
@@ -348,5 +352,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
base.OnCollision(gameObject);
}
+ public void TakeDamage()
+ {
+ monster_health--;
+
+ Particle particle = new Particle(Pos);
+ if (monster_health <= 0)
+ {
+ Death();
+ }
+ }
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
index 846aefa..3259f9a 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
@@ -12,24 +12,33 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Werewolf : CoreEnemy
{
- private bool isAttack;
+ private bool isJump;
+ int delay;
public Werewolf(Vector2 position) : base(position)
{
name = "Wolf";
- monster_speed = 4;
- Width = 78;
- Height = 96;
+ monster_speed = 3;
+ Width = 39;
+ Height = 48;
+ delay = 10;
+ monster_health = 3;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight");
public override void Update(GameTime gameTime)
{
- if (!isAttack)
+ if(!isJump )
+ {
+ Jump();
+ }
+ if(isOnGround)
{
Move(gameTime);
+
}
+
base.Update(gameTime);
}
@@ -41,11 +50,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death()
{
+ for (int i = 0; i < 5; i++)
+ {
+ Particle particle = new Particle(Pos);
+ }
+ AppManager.Instance.GameManager.Remove(this);
}
public override void Move(GameTime gameTime)
{
+ isJump = false;
+
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight")
@@ -62,23 +78,94 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
velocity.X = -monster_speed;
}
- if (Pos.X >= rightBoarder)
+ var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
+ if (isGoRight)
{
- isGoRight = false;
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, Width+4, 2));
}
- else if (Pos.X <= leftBoarder)
+ else
{
- isGoRight = true;
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 3, (int)Pos.Y + Height / 2 - 2, Width +3, 2));
+ }
+
+
+ foreach (var item in getCols)
+ {
+ if (item is MapObject)
+ {
+ isGoRight = !isGoRight;
+ break;
+ }
}
}
public override void Attack(GameTime gameTime)
{
}
+<<<<<<< HEAD
public override void Target()
+=======
+ public void Jump()
+ {
+ var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
+ if (isGoRight)
+ {
+ getCols= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width+100, Height),false);
+ if(getCols.Count > 0)
+ {
+ isJump = true;
+ if (GraphicsComponent.GetCurrentAnimation != "WolfJumpRight")
+ {
+ GraphicsComponent.StartAnimation("WolfJumpRight");
+ }
+ velocity.Y = -7;
+ velocity.X = 6;
+ }
+
+ }
+ else
+ {
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-100, (int)Pos.Y, 100, Height), false);
+ if (getCols.Count > 0)
+ {
+ isJump = true;
+ if (GraphicsComponent.GetCurrentAnimation != "WolfJumpLeft")
+ {
+ GraphicsComponent.StartAnimation("WolfJumpLeft");
+ }
+ velocity.Y = -7;
+ velocity.X = -6;
+ }
+
+ }
+
+ }
+ public override void OnCollision(GameObject gameObject)
+ {
+ /*/if (gameObject is Player)
+ {
+ if (AppManager.Instance.GameManager.players[0].IsAlive)
+ {
+ AppManager.Instance.GameManager.players[0].Death(name);
+ }
+ }
+ base.OnCollision(gameObject);/*/
+ }
+ public void Target()
+>>>>>>> f415b47fc4b84d2c5aaa94f02641c9b075f9f3f8
{
}
+ public void TakeDamage()
+ {
+ monster_health--;
+
+ Particle particle = new Particle(Pos);
+ if (monster_health <= 0)
+ {
+ Death();
+ }
+ }
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
index 60e02d6..206b9a7 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
@@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Zombie : CoreEnemy
{
- private bool isAttack;
float leftBorder;
float rightBorder;
@@ -32,6 +31,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = (int)position.X + 100;
physicsManager = new PhysicsManager();
Random random = new Random();
+ monster_health = 2;
if(random.Next(0, 2) == 0)
{
isGoRight = true;
@@ -58,18 +58,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Target();
Move(gameTime);
}
- fixBorder();
+ //fixBorder();
base.Update(gameTime);
}
public override void Attack()
{
- AppManager.Instance.GameManager.GetPlayer1.Death(name);
+ isAttaking = true;
+ PlayAttackAnimation();
+ AppManager.Instance.GameManager.GetClosestPlayer(Pos).Death(name);
}
public void PlayAttackAnimation()
{
velocity.X = 0;
- isAttaking = true;
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
@@ -123,7 +124,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void OnCollision(GameObject gameObject)
{
- if (gameObject.id == AppManager.Instance.GameManager.GetPlayer1.id && AppManager.Instance.GameManager.GetPlayer1.IsAlive)
+ if (gameObject.id == AppManager.Instance.GameManager.GetClosestPlayer(Pos).id && AppManager.Instance.GameManager.GetClosestPlayer(Pos).IsAlive)
{
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client)
{
@@ -183,10 +184,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack(GameTime gameTime)
{}
- public void TakeDamage()
+ public override void TakeDamage()
{
monster_health--;
- GraphicsComponent.StartAnimation("ZombieRightAttack");
Particle particle = new Particle(Pos);
if (monster_health <= 0)
{
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs
index 8644b77..e199e4d 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/AnimationRectangle.cs
@@ -25,14 +25,15 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath
private void PlayDeath(string deathName)
{
- if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie")
- {
- GraphicsComponent.StartAnimation("DeathFromZombie");
- }
- if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand")
- {
- GraphicsComponent.StartAnimation("DeathFromSilasHand");
- }
+ //if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie")
+ //{
+ // GraphicsComponent.StartAnimation("DeathFromZombie");
+ //}
+ //if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand")
+ //{
+ // GraphicsComponent.StartAnimation("DeathFromSilasHand");
+ //}
+ GraphicsComponent.StartAnimation(deathName);
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
index fc34e25..ac868db 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
@@ -10,6 +10,7 @@ using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
using DangerousD.GameCore.Network;
+using DangerousD.GameCore.GameObjects.MapObjects;
namespace DangerousD.GameCore.GameObjects.LivingEntities
{
@@ -65,6 +66,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{
bullets++;
}
+ if(a == "playerShootBoomUpRight" || a == "playerShootBoomUpLeft")
+ {
+ isShooting = false;
+ }
};
}
@@ -73,7 +78,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public bool IsAlive { get { return isAlive; } }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
- "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload");
+ "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft", "playerShootBoomUpRight",
+ "playerShootBoomUpLeft"}, "playerReload");
public void Attack()
{
@@ -184,41 +190,45 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
bullets--;
if (isRight)
{
- StartCicycleAnimation("playerShootRight");
- var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
- if (targets.Count() > 0)
+ if (!isUping)
{
- Zombie targetZombie = (Zombie)targets.First();
- targetZombie.TakeDamage();
-
- }
- targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands)).OrderBy(x => (x.Pos - Pos).LengthSquared());
- if (targets.Count() > 0)
- {
- SilasHands targetHand = (SilasHands)targets.First();
- targetHand.TakeDamage();
- }
- SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
- }
- else
- {
- StartCicycleAnimation("playerShootLeft");
- var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie));
- if (targets != null)
- {
- foreach (var target in targets)
+ StartCicycleAnimation("playerShootRight");
+ var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
+ if (targets.Count() > 0)
{
- Zombie targetZombie = (Zombie)target;
+ Zombie targetZombie = (Zombie)targets.First();
targetZombie.TakeDamage();
}
+ SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
}
- targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(GetShootRectangle(isRight), typeof(SilasHands));
- if (targets.Count() > 0)
+ else
{
- SilasHands targetHand = (SilasHands)targets.First();
- targetHand.TakeDamage();
+ StartCicycleAnimation("playerShootBoomUpRight");
+ Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y));
+ bullet.ShootUpRight();
+ SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8));
+ }
+ }
+ else if(!isRight)
+ {
+ if (!isUping)
+ {
+ StartCicycleAnimation("playerShootLeft");
+ var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
+ if (targets.Count() > 0)
+ {
+ Zombie targetZombie = (Zombie)targets.First();
+ targetZombie.TakeDamage();
+ }
+ SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
+ }
+ else
+ {
+ StartCicycleAnimation("playerShootBoomUpLeft");
+ Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y));
+ bullet.ShootUpLeft();
+ SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7));
}
- SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
}
}
}
@@ -282,14 +292,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
{
- if(bullets < 5)
- {
- if (GraphicsComponent.GetCurrentAnimation != "playerReload")
- {
- GraphicsComponent.StartAnimation("playerReload");
- }
- }
- else if (isRight)
+ if (isRight)
{
if (isUping)
{
@@ -298,6 +301,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
GraphicsComponent.StartAnimation("playerShootUpRight");
}
}
+ else if (bullets < 5)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "playerReload")
+ {
+ GraphicsComponent.StartAnimation("playerReload");
+ }
+ }
else
{
GraphicsComponent.StartAnimation("playerRightStay");
@@ -312,6 +322,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
GraphicsComponent.StartAnimation("playerShootUpLeft");
}
}
+ else if (bullets < 5)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "playerReload")
+ {
+ GraphicsComponent.StartAnimation("playerReload");
+ }
+ }
else
{
GraphicsComponent.StartAnimation("playerStayLeft");
@@ -331,13 +348,51 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isOnGround = false;
}
- public class Bullet : GameObjects.LivingEntity
+ public class Bullet : LivingEntity
{
public Bullet(Vector2 position) : base(position)
{
+ Height = 5;
+ Width = 5;
+ }
+ protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft"}, "playerMoveLeft");
+ Vector2 direction;
+ Vector2 maindirection;
+ public void ShootUpRight()
+ {
+ direction = new Vector2(1, -1);
+ acceleration = Vector2.Zero;
+ velocity = new Vector2(10, 10) * direction;
+ maindirection = velocity;
+ }
+ public void ShootUpLeft()
+ {
+ direction = new Vector2(-1, -1);
+ acceleration = Vector2.Zero;
+ velocity = new Vector2(10, 10) * direction;
+ maindirection = velocity;
+ }
+ public override void OnCollision(GameObject gameObject)
+ {
+ if (gameObject is not Player)
+ {
+ if (gameObject is CoreEnemy)
+ {
+ CoreEnemy enemy = (CoreEnemy)gameObject;
+ enemy.TakeDamage();
+ AppManager.Instance.GameManager.Remove(this);
+ }
+ base.OnCollision(gameObject);
+ }
+ }
+ public override void Update(GameTime gameTime)
+ {
+ if (maindirection!=velocity)
+ {
+ AppManager.Instance.GameManager.Remove(this);
+ }
+ base.Update(gameTime);
}
- protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft");
-
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs
index c496696..1523401 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntity.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs
@@ -10,6 +10,8 @@ public abstract class LivingEntity : Entity
public Vector2 velocity;
public Vector2 acceleration;
+ public Vector2 Acceleration { get; private set; }
+
public LivingEntity(Vector2 position) : base(position)
{
acceleration = new Vector2(0, 30);
diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs
index 9b6a8df..2b5079c 100644
--- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs
+++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs
@@ -236,7 +236,7 @@ namespace DangerousD.GameCore.Graphics
private void SetInterval()
{
- Tuple i = currentAnimation.FrameTime.Find(x => x.Item1 == currentFrame);
+ Tuple i = currentAnimation.FrameTime.Find(x => x.Item1 == currentFrame);
if (i != null)
{
interval = i.Item2;
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index 5bf5986..6b11ed1 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -209,6 +209,7 @@ namespace DangerousD.GameCore
break;
case GameState.Game:
<<<<<<< HEAD
+<<<<<<< HEAD
<<<<<<< HEAD
GameManager.mapManager.LoadLevel("map");
=======
@@ -220,6 +221,9 @@ namespace DangerousD.GameCore
=======
GameManager.mapManager.LoadLevel("lvl");
>>>>>>> 211eac278c07f06a177b7be1fc84dd05cbf5c449
+=======
+ GameManager.mapManager.LoadLevel(currentMap);
+>>>>>>> f415b47fc4b84d2c5aaa94f02641c9b075f9f3f8
GameManager.FindBorders();
break;
case GameState.Death:
@@ -337,7 +341,9 @@ namespace DangerousD.GameCore
}
public void Restart(string map)
{
-
+ GameManager = new();
+ ChangeGameState(GameState.Menu);
+ currentMap = map;
}
}
}
diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs
index 8d1c7c4..24f42af 100644
--- a/DangerousD/GameCore/Managers/GameManager.cs
+++ b/DangerousD/GameCore/Managers/GameManager.cs
@@ -49,6 +49,7 @@ namespace DangerousD.GameCore
internal void Register(GameObject gameObject)
{
GetAllGameObjects.Add(gameObject);
+
if (gameObject is Entity)
{
gameObject.id = currentEntityId;
@@ -192,5 +193,10 @@ namespace DangerousD.GameCore
}
}
}
+
+ public Player GetClosestPlayer(Vector2 position)
+ {
+ return players.OrderBy(x => (x.Pos - position).Length()).First();
+ }
}
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs
index 9087d97..cee44d3 100644
--- a/DangerousD/GameCore/Managers/MapManager.cs
+++ b/DangerousD/GameCore/Managers/MapManager.cs
@@ -68,7 +68,7 @@ namespace DangerousD.GameCore.Managers
{
if (tiles[i] != 0)
{
- Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale,
+ Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale + 400,
((chunkY + i / chunkW) * tileSize.Y + offsetY) * _scale);
//pos *= _scale;
Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint());
diff --git a/DangerousD/GameCore/Managers/PhysicsManager.cs b/DangerousD/GameCore/Managers/PhysicsManager.cs
index 6ae5474..509b500 100644
--- a/DangerousD/GameCore/Managers/PhysicsManager.cs
+++ b/DangerousD/GameCore/Managers/PhysicsManager.cs
@@ -135,7 +135,6 @@ namespace DangerousD.GameCore.Managers
player.isOnGround = true;
player.velocity.Y = 0;
}
-
player.SetPosition(new Vector2(newRect.X, newRect.Y));
}