From 8e464223de39a308f9ca0695583f5d6fc6661c9a Mon Sep 17 00:00:00 2001
From: MARKPRO44 <119742977+MARKPRO4444@users.noreply.github.com>
Date: Thu, 17 Aug 2023 16:24:35 +0300
Subject: [PATCH 01/10] FrankB
---
.../LivingEntities/Monsters/FrankBalls.cs | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
index a235c3b..6ae475d 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
@@ -29,7 +29,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
name = "FrankBalls";
Width = 40;
Height = 40;
- monster_speed = 3;
+ monster_speed = 2;
acceleration = Vector2.Zero;
}
@@ -37,17 +37,27 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime)
{
- if(!isAttacking)
+ collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
+
+ if (!isAttacking)
{
Move(gameTime);
}
+ if(GraphicsComponent.GetCurrentAnimation == "FrankMoveRight")
+ {
+ isFlyRight = true;
+ }
+ else if(GraphicsComponent.GetCurrentAnimation == "FrankMoveLeft")
+ {
+ isFlyRight = false;
+ }
+
base.Update(gameTime);
}
public override void Attack()
{
- collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
isAttacking = true;
if(isFlyRight)
From 89ae5551029696023b722449a701b2f900aae349 Mon Sep 17 00:00:00 2001
From: MARKPRO44 <119742977+MARKPRO4444@users.noreply.github.com>
Date: Fri, 18 Aug 2023 00:31:46 +0300
Subject: [PATCH 02/10] Huchman_1
---
.../AnimationsFileCreator.csproj | 3 +-
AnimationsFileCreator/Program.cs | 8 ---
DangerousD/Content/map.tmx | 59 +++++++++++++++++++
DangerousD/GameCore/GameObjects/GameObject.cs | 7 +++
.../LivingEntities/Monsters/Frank.cs | 6 +-
.../LivingEntities/Monsters/FrankBalls.cs | 45 ++++++++------
.../LivingEntities/Monsters/Hunchman.cs | 12 ++++
DangerousD/GameCore/Managers/AppManager.cs | 2 +-
DangerousD/GameCore/Managers/GameManager.cs | 1 +
DangerousD/GameCore/Managers/MapManager.cs | 2 +-
.../GameCore/Managers/PhysicsManager.cs | 4 ++
11 files changed, 115 insertions(+), 34 deletions(-)
create mode 100644 DangerousD/Content/map.tmx
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/map.tmx b/DangerousD/Content/map.tmx
new file mode 100644
index 0000000..b6b3b95
--- /dev/null
+++ b/DangerousD/Content/map.tmx
@@ -0,0 +1,59 @@
+
+
diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs
index ae5cd2c..777e096 100644
--- a/DangerousD/GameCore/GameObjects/GameObject.cs
+++ b/DangerousD/GameCore/GameObjects/GameObject.cs
@@ -36,6 +36,12 @@ namespace DangerousD.GameCore
{
}
+ protected int obsticles = 0;
+ public virtual void OnCollisionWithObsticle(GameObject gameObject)
+ {
+ obsticles++;//SD
+ }
+
public virtual void Initialize()
{
}
@@ -47,6 +53,7 @@ namespace DangerousD.GameCore
public virtual void Update(GameTime gameTime)
{
+ obsticles = 0;
GraphicsComponent.Update();
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs
index b67dd12..27ab55f 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs
@@ -20,13 +20,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
get { return position; }
}
- public Frank(Vector2 position) : base(position)
+ public Frank(Vector2 position) : base(new Vector2(300, 200))
{
- this.position = position;
+ //position = new Vector2(300, 200);
Width = 112;
Height = 160;
GraphicsComponent.StartAnimation("FrankMoveLeft");
- monster_speed = 1;
+ monster_speed = 3;
name = "Frank";
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight");
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
index 6ae475d..0538c4b 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
@@ -7,37 +7,37 @@ 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
{
public class FrankBalls : CoreEnemy
{
private Rectangle collision;
- private Vector2 position;
- private int healthBall;
private bool isFlyRight = true;
private bool isAttacking = false;
-
public Rectangle Collision
{
get { return collision; }
}
- public FrankBalls(Vector2 position) : base(position)
+ public FrankBalls(Vector2 position) : base(new Vector2(300, 200))
{
- this.position = position;
+
name = "FrankBalls";
Width = 40;
Height = 40;
monster_speed = 2;
+ monster_health = 13;
acceleration = Vector2.Zero;
+ velocity = new Vector2(monster_speed, monster_speed);
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "BallMoveRight" }, "BallMoveRight");
public override void Update(GameTime gameTime)
{
- collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
+ collision = new Rectangle((int)_pos.X, (int)_pos.Y, 40, 40);
if (!isAttacking)
{
@@ -53,6 +53,25 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isFlyRight = false;
}
+ var foundObj = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)_pos.X-1, (int)_pos.Y-1, Width+2, Height+2), typeof(StopTile));
+
+ if (foundObj != null && foundObj.Count > 0)
+ {
+
+ float av = foundObj.Sum(x => x.Rectangle.X)/foundObj.Count;
+ float avy = foundObj.Sum(x => x.Rectangle.Y)/foundObj.Count;
+
+ if (avy <= _pos.Y)
+ velocity.Y = monster_speed;
+ else if (avy >= _pos.Y)
+ velocity.Y = -monster_speed;
+ if (av <= _pos.X)
+ velocity.X = -monster_speed;
+ else if (av >= _pos.X)
+ velocity.X = monster_speed;
+ monster_health--;
+ }
+
base.Update(gameTime);
}
@@ -78,19 +97,7 @@ 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;
- }
+
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
index cc6ecd5..7d3e939 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
@@ -12,8 +12,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Hunchman : CoreEnemy
{
+ private bool isGoRight = true;
+
public Hunchman(Vector2 position) : base(position)
{
+ Width = 20;
+ Height = 30;
+ name = "Hunchman";
+ GraphicsComponent.StartAnimation("");
+ monster_speed = 3;
+
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
@@ -30,7 +38,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ var player = AppManager.Instance.GameManager.players[0];
+ if(player.Pos.X > 0)
+ {
+ }
}
}
}
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index f800998..0993679 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -166,7 +166,7 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
- GameManager.mapManager.LoadLevel("lvl");
+ GameManager.mapManager.LoadLevel("map");
break;
case GameState.GameOver:
break;
diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs
index f2ce8c8..caae816 100644
--- a/DangerousD/GameCore/Managers/GameManager.cs
+++ b/DangerousD/GameCore/Managers/GameManager.cs
@@ -46,6 +46,7 @@ namespace DangerousD.GameCore
internal void Register(GameObject gameObject)
{
+ GetAllGameObjects.Add(gameObject);
if (gameObject is Player)
{
livingEntities.Add(gameObject as LivingEntity);
diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs
index 36a0f6b..593383c 100644
--- a/DangerousD/GameCore/Managers/MapManager.cs
+++ b/DangerousD/GameCore/Managers/MapManager.cs
@@ -63,7 +63,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 28ecf14..edaad38 100644
--- a/DangerousD/GameCore/Managers/PhysicsManager.cs
+++ b/DangerousD/GameCore/Managers/PhysicsManager.cs
@@ -97,6 +97,10 @@ namespace DangerousD.GameCore.Managers
if (!isYNormalise)
currentEntity.velocity.Y = 0;
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
+ if (!isXNormalise || !isYNormalise)
+ {
+ currentEntity.OnCollisionWithObsticle(mapObjects[i]);
+ }
}
}
From 323932e945718f615ef0a8a775aaf38af3d187c2 Mon Sep 17 00:00:00 2001
From: MARKPRO44 <119742977+MARKPRO4444@users.noreply.github.com>
Date: Fri, 18 Aug 2023 13:54:31 +0300
Subject: [PATCH 03/10] Prepare for Merge
---
.../Content/animations/HunchmanMoveLeft.crash | 1 +
.../animations/HunchmanMoveRight.crash | 1 +
DangerousD/Content/map.tmx | 6 +-
DangerousD/DangerousD.sln | 25 ++++
.../LivingEntities/Monsters/Hunchman.cs | 115 ++++++++++++++++--
.../LivingEntities/Monsters/HunchmanDagger.cs | 28 ++++-
.../GameCore/Graphics/GraphicsComponent.cs | 2 +-
7 files changed, 165 insertions(+), 13 deletions(-)
create mode 100644 DangerousD/Content/animations/HunchmanMoveLeft.crash
create mode 100644 DangerousD/Content/animations/HunchmanMoveRight.crash
create mode 100644 DangerousD/DangerousD.sln
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/map.tmx b/DangerousD/Content/map.tmx
index b6b3b95..ec7c203 100644
--- a/DangerousD/Content/map.tmx
+++ b/DangerousD/Content/map.tmx
@@ -42,7 +42,7 @@
-
@@ -51,8 +51,8 @@
-
-
+
+
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/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
index 7d3e939..7ac5e02 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
@@ -4,45 +4,144 @@ using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
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
{
- private bool isGoRight = true;
+ 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 = 20;
Height = 30;
+ leftBoarder = (int)position.X - 100;
+ rightBoarder = (int)position.X + 100;
name = "Hunchman";
- GraphicsComponent.StartAnimation("");
+ GraphicsComponent.StartAnimation("HunchmanMoveLeft");
monster_speed = 3;
-
+ physicsManager = new PhysicsManager();
}
- protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
+ protected override GraphicsComponent GraphicsComponent { get; } = new(new List
+ { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanDaggerLeft", "HunchmanDaggerRight" }, "HunchmanMoveLeft");
+
+
+ public override void Update(GameTime gameTime)
+ {
+ if (!isAttaking)
+ {
+ Target();
+ Move(gameTime);
+ }
+ base.Update(gameTime);
+ }
public override void Attack()
{
+ var animation = GraphicsComponent.GetCurrentAnimation;
+ isAttaking = true;
+ if (isGoRight)
+ {
+ if (animation != "HunchmanDaggerRight")
+ {
+ GraphicsComponent.StartAnimation("HunchmanDaggerRight");
+ }
+ }
+ else
+ {
+ if (animation != "HunchmanDaggerLeft")
+ {
+ GraphicsComponent.StartAnimation("HunchmanDaggerLeft");
+ }
+ }
}
public override void Death()
{
-
+ if (monster_health <= 0)
+ {
+ isVisible = false;
+ }
}
public override void Move(GameTime gameTime)
{
- var player = AppManager.Instance.GameManager.players[0];
- if(player.Pos.X > 0)
+ velocity.X = 0;
+ var animation = GraphicsComponent.GetCurrentAnimation;
+ if (isGoRight)
{
+ if (animation != "HunchmanMoveRight")
+ {
+ GraphicsComponent.StartAnimation("HunchmanMoveRight");
+ }
+ velocity.X = monster_speed;
+ }
+ else
+ {
+ 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)
+ {
+ if (gameObject is Player)
+ {
+ if (AppManager.Instance.GameManager.players[0].IsAlive)
+ {
+ Attack();
+ }
+ }
+
+ base.OnCollision(gameObject);
+ }
+
+ public void Target()
+ {
+ var player = AppManager.Instance.GameManager.players[0];
+
+ if (physicsManager.RayCast(this, player) == null)
+ {
+ if(this._pos.X <= player.Pos.X)
+ {
+ isTarget = true;
+ leftBoarder = Pos.X - 10;
+ rightBoarder = player.Pos.X;
+ }
+ else if(this._pos.X >= player.Pos.X)
+ {
+ isTarget = true;
+ rightBoarder = Pos.X + 10;
+ leftBoarder = player.Pos.X;
+ }
+ }
+ }
+
}
-}
+}
\ 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 9e616ed..9a83189 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
@@ -12,10 +12,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class HunchmanDagger : CoreEnemy
{
+ private bool isGoRight = false;
+
public HunchmanDagger(Vector2 position) : base(position)
{
name = "Hunchman";
- monster_speed = 1;
+ monster_speed = 4;
Width = 9;
Height = 6;
}
@@ -34,7 +36,31 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ velocity.X = 0;
+ var animation = GraphicsComponent.GetCurrentAnimation;
+ if (animation == "HunchmanDaggerRight")
+ {
+ velocity.X = monster_speed;
+ }
+ else if (animation == "HunchmanDaggerLeft")
+ {
+ velocity.X = -monster_speed;
+ }
+ }
+
+ public override void OnCollision(GameObject gameObject)
+ {
+ if (gameObject is Player)
+ {
+ AppManager.Instance.GameManager.players[0].Death(name);
+ }
+ else
+ {
+ Death();
+ }
+
+ base.OnCollision(gameObject);
}
}
}
diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs
index beb6928..54b87f1 100644
--- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs
+++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs
@@ -204,7 +204,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;
From b43c3a457dc6caefccd9c28e0e3a76ad4013d55d Mon Sep 17 00:00:00 2001
From: bmvolf
Date: Fri, 18 Aug 2023 16:52:38 +0300
Subject: [PATCH 04/10] added up shooting
---
.../Content/animations/playerShootBoomUpLeft | 1 +
.../Content/animations/playerShootBoomUpRight | 24 ++++
.../LivingEntities/Monsters/CoreEnemy.cs | 4 +-
.../LivingEntities/Monsters/Zombie.cs | 4 +-
.../LivingEntities/Player/Player.cs | 126 ++++++++++++++----
.../GameCore/GameObjects/LivingEntity.cs | 2 +
6 files changed, 128 insertions(+), 33 deletions(-)
create mode 100644 DangerousD/Content/animations/playerShootBoomUpLeft
create mode 100644 DangerousD/Content/animations/playerShootBoomUpRight
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/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
index 38b1cc0..5f33df9 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/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
index 90fdfc2..dd4463b 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
@@ -32,6 +32,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;
@@ -174,10 +175,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/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
index e076bc0..55e6a7b 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()
{
@@ -145,28 +151,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();
- }
- 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));
+ }
+ else
+ {
+ 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));
}
}
}
@@ -230,14 +253,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)
{
@@ -246,6 +262,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
GraphicsComponent.StartAnimation("playerShootUpRight");
}
}
+ else if (bullets < 5)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "playerReload")
+ {
+ GraphicsComponent.StartAnimation("playerReload");
+ }
+ }
else
{
GraphicsComponent.StartAnimation("playerRightStay");
@@ -260,6 +283,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
GraphicsComponent.StartAnimation("playerShootUpLeft");
}
}
+ else if (bullets < 5)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "playerReload")
+ {
+ GraphicsComponent.StartAnimation("playerReload");
+ }
+ }
else
{
GraphicsComponent.StartAnimation("playerStayLeft");
@@ -279,13 +309,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 78ea17c..72d61f4 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);
From 91db8f92d005a96848d2ad3b17565cc50d7abd10 Mon Sep 17 00:00:00 2001
From: polten0
Date: Fri, 18 Aug 2023 17:37:48 +0300
Subject: [PATCH 05/10] AddDeathAnimations
---
DangerousD/Content/animations/DeathFromGhost | 1 +
DangerousD/Content/animations/DeathFromHunchman | 1 +
DangerousD/Content/animations/DeathFromSilasMaster | 1 +
DangerousD/Content/animations/DeathFromSlime | 1 +
DangerousD/Content/animations/DeathFromSpider | 1 +
DangerousD/Content/animations/DeathFromWerewolf | 1 +
6 files changed, 6 insertions(+)
create mode 100644 DangerousD/Content/animations/DeathFromGhost
create mode 100644 DangerousD/Content/animations/DeathFromHunchman
create mode 100644 DangerousD/Content/animations/DeathFromSilasMaster
create mode 100644 DangerousD/Content/animations/DeathFromSlime
create mode 100644 DangerousD/Content/animations/DeathFromSpider
create mode 100644 DangerousD/Content/animations/DeathFromWerewolf
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"}
From a47f73d52380ce83db1ed5f96da606f5535211f3 Mon Sep 17 00:00:00 2001
From: Ivan Filipenkov
Date: Fri, 18 Aug 2023 17:38:59 +0300
Subject: [PATCH 06/10] fix texture names
---
DangerousD/Content/Content.mgcb | 8 ++++----
DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} | Bin
.../{SmokeAnimation2.png => smokeAnimation2.png} | Bin
3 files changed, 4 insertions(+), 4 deletions(-)
rename DangerousD/Content/{MenuFon2.jpg => menuFon2.jpg} (100%)
rename DangerousD/Content/{SmokeAnimation2.png => smokeAnimation2.png} (100%)
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/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
From 4386e9db8b21bbca3eb93ad7923ae3efe69e8214 Mon Sep 17 00:00:00 2001
From: Timofey06
Date: Fri, 18 Aug 2023 17:48:08 +0300
Subject: [PATCH 07/10] RestartAdded
---
DangerousD/GameCore/GUI/DeathGUI.cs | 2 +-
.../LivingEntities/Player/AnimationRectangle.cs | 17 +++++++++--------
DangerousD/GameCore/Managers/AppManager.cs | 6 ++++--
3 files changed, 14 insertions(+), 11 deletions(-)
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/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/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index aedb493..06c6f79 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -208,7 +208,7 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
- GameManager.mapManager.LoadLevel("lvl");
+ GameManager.mapManager.LoadLevel(currentMap);
GameManager.FindBorders();
break;
case GameState.Death:
@@ -326,7 +326,9 @@ namespace DangerousD.GameCore
}
public void Restart(string map)
{
-
+ GameManager = new();
+ ChangeGameState(GameState.Menu);
+ currentMap = map;
}
}
}
From d87770f9ec15069794438bf2237eadbf66be1d5a Mon Sep 17 00:00:00 2001
From: Kaktus200020
Date: Fri, 18 Aug 2023 17:19:44 +0300
Subject: [PATCH 08/10] WereWolfAdding
---
DangerousD/Content/map.tmx | 5 +
.../LivingEntities/Monsters/FrankBalls.cs | 15 ++-
.../LivingEntities/Monsters/Slime.cs | 16 ++-
.../LivingEntities/Monsters/Werewolf.cs | 102 ++++++++++++++++--
DangerousD/GameCore/Managers/AppManager.cs | 2 +-
5 files changed, 126 insertions(+), 14 deletions(-)
diff --git a/DangerousD/Content/map.tmx b/DangerousD/Content/map.tmx
index 9afca4d..bcc7b83 100644
--- a/DangerousD/Content/map.tmx
+++ b/DangerousD/Content/map.tmx
@@ -71,5 +71,10 @@
+
+
+
+
+
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
index 9400485..720fd96 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
@@ -17,6 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private bool isFlyRight = true;
private bool isFlyUp = true;
private bool isAttacking = false;
+ private int hp;
public Rectangle Collision
{
@@ -32,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
monster_speed = 3;
velocity = new Vector2(3,-3);
acceleration = Vector2.Zero;
+ hp = 10;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "BallMoveRight" }, "BallMoveRight");
@@ -39,7 +41,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,7 +64,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death()
{
-
+ if (hp <= 0)
+ {
+ AppManager.Instance.GameManager.Remove(this);
+ }
}
public override void Move(GameTime gameTime)
@@ -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/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
index 41a2fcc..afdbf9b 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 837932f..bb6cd6f 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,89 @@ 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)
{
}
-
+ 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()
{
throw new NotImplementedException();
}
+ public void TakeDamage()
+ {
+ monster_health--;
+
+ Particle particle = new Particle(Pos);
+ if (monster_health <= 0)
+ {
+ Death();
+ }
+ }
}
}
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index 9a1e46a..8bb94c1 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -201,7 +201,7 @@ namespace DangerousD.GameCore
break;
case GameState.Game:
- GameManager.mapManager.LoadLevel("lvl");
+ GameManager.mapManager.LoadLevel("map");
GameManager.FindBorders();
From 1ed1dd635f7147b56573a377bf23502c4efcdb5b Mon Sep 17 00:00:00 2001
From: Kaktus200020
Date: Fri, 18 Aug 2023 17:42:26 +0300
Subject: [PATCH 09/10] GhostAdding
---
DangerousD/Content/animations/GhostAttack | 2 +-
DangerousD/Content/map.tmx | 2 +-
.../LivingEntities/Monsters/Ghost.cs | 57 +++++++++++++++----
3 files changed, 48 insertions(+), 13 deletions(-)
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/map.tmx b/DangerousD/Content/map.tmx
index bcc7b83..a02975a 100644
--- a/DangerousD/Content/map.tmx
+++ b/DangerousD/Content/map.tmx
@@ -71,7 +71,7 @@
-
+
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
index 214a4c2..57ab2c4 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,7 +108,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
+ public void TakeDamage()
+ {
+ monster_health--;
+
+ if (monster_health <= 0)
+ {
+ Death();
+ }
+ }
public void Target()
{
throw new NotImplementedException();
From 33331e83ee597b3526b34630898da600ef5b14b8 Mon Sep 17 00:00:00 2001
From: MARKPRO44 <119742977+MARKPRO4444@users.noreply.github.com>
Date: Fri, 18 Aug 2023 18:14:01 +0300
Subject: [PATCH 10/10] Hunchman
---
DangerousD/Content/lvl.tmx | 2 +-
.../LivingEntities/Monsters/Hunchman.cs | 38 +++++--------------
.../LivingEntities/Monsters/HunchmanDagger.cs | 31 ++++++++++-----
3 files changed, 31 insertions(+), 40 deletions(-)
diff --git a/DangerousD/Content/lvl.tmx b/DangerousD/Content/lvl.tmx
index 5fcea6a..e03bd77 100644
--- a/DangerousD/Content/lvl.tmx
+++ b/DangerousD/Content/lvl.tmx
@@ -700,7 +700,7 @@
-
+
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
index 1ca0b17..9ba700b 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
@@ -36,7 +36,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List
- { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanDaggerLeft", "HunchmanDaggerRight" }, "HunchmanMoveLeft");
+ { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft");
public override void Update(GameTime gameTime)
@@ -56,17 +56,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isAttaking = true;
if (isGoRight)
{
- if (animation != "HunchmanDaggerRight")
+ if (animation != "HunchmanAttackRight")
{
- GraphicsComponent.StartAnimation("HunchmanDaggerRight");
+ GraphicsComponent.StartAnimation("HunchmanAttackRight");
}
+ HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos,isGoRight);
}
else
{
- if (animation != "HunchmanDaggerLeft")
+ if (animation != "HunchmanAttackLeft")
{
- GraphicsComponent.StartAnimation("HunchmanDaggerLeft");
+ GraphicsComponent.StartAnimation("HunchmanAttackLeft");
}
+ HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos, isGoRight);
}
}
@@ -117,18 +119,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
}
- public override void OnCollision(GameObject gameObject)
- {
- if (gameObject is Player)
- {
- if (AppManager.Instance.GameManager.players[0].IsAlive)
- {
- Attack();
- }
- }
-
- base.OnCollision(gameObject);
- }
+
public void Target()
{
@@ -136,18 +127,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (physicsManager.RayCast(this, player) == null)
{
- if(this._pos.X <= player.Pos.X)
- {
- isTarget = true;
- leftBoarder = Pos.X - 10;
- rightBoarder = player.Pos.X;
- }
- else if(this._pos.X >= player.Pos.X)
- {
- isTarget = true;
- rightBoarder = Pos.X + 10;
- leftBoarder = player.Pos.X;
- }
+ Attack();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
index 9699ad6..11cfe8a 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
@@ -14,8 +14,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
private bool isGoRight = false;
- public HunchmanDagger(Vector2 position) : base(position)
+ public HunchmanDagger(Vector2 position, bool isGoRight) : base(position)
{
+ this.isGoRight = isGoRight;
name = "Hunchman";
monster_speed = 4;
Width = 9;
@@ -36,22 +37,36 @@ 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 animation = GraphicsComponent.GetCurrentAnimation;
-
- if (animation == "HunchmanDaggerRight")
+ 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 (animation == "HunchmanDaggerLeft")
+
+ 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)
@@ -60,10 +75,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
AppManager.Instance.GameManager.players[0].Death(name);
}
- else
- {
- Death();
- }
base.OnCollision(gameObject);
}