diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb
index 24e8d23..fe77d67 100644
--- a/DangerousD/Content/Content.mgcb
+++ b/DangerousD/Content/Content.mgcb
@@ -10,6 +10,7 @@
#-------------------------------- References --------------------------------#
+/reference:references/MonoGame.Extended.Content.Pipeline.dll
#---------------------------------- Content ---------------------------------#
@@ -71,6 +72,19 @@
/processorParam:TextureFormat=Color
/build:menuFon.jpg
+#begin MonstersAnimations.png
+#begin menuFon.jpg
+/importer:TextureImporter
+/processor:TextureProcessor
+/processorParam:ColorKeyColor=255,0,255,255
+/processorParam:ColorKeyEnabled=True
+/processorParam:GenerateMipmaps=False
+/processorParam:PremultiplyAlpha=True
+/processorParam:ResizeToPowerOfTwo=False
+/processorParam:MakeSquare=False
+/processorParam:TextureFormat=Color
+/build:menuFon.jpg
+
#begin MenuFon2.jpg
/importer:TextureImporter
/processor:TextureProcessor
@@ -117,7 +131,7 @@
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
-/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
+/build:tiles.png
#begin playerAnimation.png
/importer:TextureImporter
diff --git a/DangerousD/Content/animations/SilasBallMove b/DangerousD/Content/animations/SilasBallMove
new file mode 100644
index 0000000..9a0b5f4
--- /dev/null
+++ b/DangerousD/Content/animations/SilasBallMove
@@ -0,0 +1 @@
+{"id":"SilasBallMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":147,"Y":618,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeJumpLeftBottom b/DangerousD/Content/animations/SlimeJumpLeftBottom
new file mode 100644
index 0000000..876f587
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeJumpLeftBottom
@@ -0,0 +1 @@
+{"id":"SlimeJumpLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":176,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeJumpLeftTop b/DangerousD/Content/animations/SlimeJumpLeftTop
new file mode 100644
index 0000000..e73565f
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeJumpLeftTop
@@ -0,0 +1 @@
+{"id":"SlimeJumpLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":151,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeJumpRightBottom b/DangerousD/Content/animations/SlimeJumpRightBottom
new file mode 100644
index 0000000..3a0d067
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeJumpRightBottom
@@ -0,0 +1 @@
+{"id":"SlimeJumpRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":176,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeJumpRightTop b/DangerousD/Content/animations/SlimeJumpRightTop
new file mode 100644
index 0000000..6e75357
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeJumpRightTop
@@ -0,0 +1 @@
+{"id":"SlimeJumpRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":151,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeMoveLeftBottom b/DangerousD/Content/animations/SlimeMoveLeftBottom
new file mode 100644
index 0000000..c2477cc
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeMoveLeftBottom
@@ -0,0 +1 @@
+{"id":"SlimeMoveLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":182,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeMoveLeftTop b/DangerousD/Content/animations/SlimeMoveLeftTop
new file mode 100644
index 0000000..90723bf
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeMoveLeftTop
@@ -0,0 +1 @@
+{"id":"SlimeMoveLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":51,"Y":182,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeMoveRightBottom b/DangerousD/Content/animations/SlimeMoveRightBottom
new file mode 100644
index 0000000..2caee25
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeMoveRightBottom
@@ -0,0 +1 @@
+{"id":"SlimeMoveRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":165,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeMoveRightTop b/DangerousD/Content/animations/SlimeMoveRightTop
new file mode 100644
index 0000000..ff14358
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeMoveRightTop
@@ -0,0 +1 @@
+{"id":"SlimeMoveRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":51,"Y":165,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeReadyJumpLeftBottom b/DangerousD/Content/animations/SlimeReadyJumpLeftBottom
new file mode 100644
index 0000000..aba1149
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeReadyJumpLeftBottom
@@ -0,0 +1 @@
+{"id":"SlimeReadyJumpLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeReadyJumpLeftTop b/DangerousD/Content/animations/SlimeReadyJumpLeftTop
new file mode 100644
index 0000000..896a29d
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeReadyJumpLeftTop
@@ -0,0 +1 @@
+{"id":"SlimeReadyJumpLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeReadyJumpRightBottom b/DangerousD/Content/animations/SlimeReadyJumpRightBottom
new file mode 100644
index 0000000..16f8e64
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeReadyJumpRightBottom
@@ -0,0 +1 @@
+{"id":"SlimeReadyJumpRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/SlimeReadyJumpRightTop b/DangerousD/Content/animations/SlimeReadyJumpRightTop
new file mode 100644
index 0000000..95fb101
--- /dev/null
+++ b/DangerousD/Content/animations/SlimeReadyJumpRightTop
@@ -0,0 +1 @@
+{"id":"SlimeReadyJumpRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
diff --git a/DangerousD/Content/animations/WolfMoveLeft b/DangerousD/Content/animations/WolfMoveLeft
index 924a49c..74a3dd0 100644
--- a/DangerousD/Content/animations/WolfMoveLeft
+++ b/DangerousD/Content/animations/WolfMoveLeft
@@ -1 +1 @@
-{"id":"WolfMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":292,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
+{"id":"WolfMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":291,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
diff --git a/DangerousD/Content/lvl.tmx b/DangerousD/Content/lvl.tmx
new file mode 100644
index 0000000..b81ea88
--- /dev/null
+++ b/DangerousD/Content/lvl.tmx
@@ -0,0 +1,759 @@
+
+
diff --git a/DangerousD/Content/map.tsx b/DangerousD/Content/map.tsx
new file mode 100644
index 0000000..288bb53
--- /dev/null
+++ b/DangerousD/Content/map.tsx
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/DangerousD/Content/tiles.png b/DangerousD/Content/tiles.png
new file mode 100644
index 0000000..3e35587
Binary files /dev/null and b/DangerousD/Content/tiles.png differ
diff --git a/DangerousD/Desktop/DangerousD map/map_0.mgcontent b/DangerousD/Desktop/DangerousD map/map_0.mgcontent
new file mode 100644
index 0000000..acc2649
--- /dev/null
+++ b/DangerousD/Desktop/DangerousD map/map_0.mgcontent
@@ -0,0 +1,16 @@
+
+
+ C:/Users/Semejkin_AV/Desktop/DangerousD map/map.tsx
+ 2023-08-16T13:04:13.796245+03:00
+ C:/Users/Semejkin_AV/Documents/Github_repos/DangerousD/DangerousD/Content/bin/DesktopGL/Content/../../../../../Desktop/DangerousD map/map_0.xnb
+ 2023-08-16T15:38:41.8125207+03:00
+ TiledMapTilesetImporter
+ 2023-07-14T20:14:40+03:00
+ TiledMapTilesetProcessor
+ 2023-07-14T20:14:40+03:00
+
+
+ C:/Users/Semejkin_AV/Documents/Github_repos/DangerousD/DangerousD/Content/bin/DesktopGL/Content/../../../../../Desktop/DangerousD map/tiles_0.xnb
+
+
+
\ No newline at end of file
diff --git a/DangerousD/Desktop/DangerousD map/tiles_0.mgcontent b/DangerousD/Desktop/DangerousD map/tiles_0.mgcontent
new file mode 100644
index 0000000..4cfff75
--- /dev/null
+++ b/DangerousD/Desktop/DangerousD map/tiles_0.mgcontent
@@ -0,0 +1,22 @@
+
+
+ C:/Users/Semejkin_AV/Desktop/DangerousD map/tiles.BMP
+ 2023-08-16T12:47:16.3453923+03:00
+ C:/Users/Semejkin_AV/Documents/Github_repos/DangerousD/DangerousD/Content/bin/DesktopGL/Content/../../../../../Desktop/DangerousD map/tiles_0.xnb
+ 2023-08-16T15:38:41.7865192+03:00
+ TextureImporter
+ 2022-07-26T14:44:56+03:00
+ TextureProcessor
+ 2022-07-26T14:44:56+03:00
+
+ ColorKeyColor
+ 0,0,0,0
+
+
+ ColorKeyEnabled
+ True
+
+
+
+
+
\ No newline at end of file
diff --git a/DangerousD/GameCore/.DS_Store b/DangerousD/GameCore/.DS_Store
new file mode 100644
index 0000000..e6c817c
Binary files /dev/null and b/DangerousD/GameCore/.DS_Store differ
diff --git a/DangerousD/GameCore/GUI/AbstractGui.cs b/DangerousD/GameCore/GUI/AbstractGui.cs
index 24af331..7f7b212 100644
--- a/DangerousD/GameCore/GUI/AbstractGui.cs
+++ b/DangerousD/GameCore/GUI/AbstractGui.cs
@@ -17,9 +17,9 @@ public abstract class AbstractGui : IDrawableObject
protected abstract void CreateUI();
private GraphicsDevice graphicsDevice;
- public virtual void Initialize(GraphicsDevice graphicsDevice)
+ public virtual void Initialize()
{
- Manager.Initialize(graphicsDevice);
+ Manager.Initialize(AppManager.Instance.GraphicsDevice);
this.graphicsDevice = graphicsDevice;
CreateUI();
}
diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs
index 2927758..41aaeeb 100644
--- a/DangerousD/GameCore/GUI/LobbyGUI.cs
+++ b/DangerousD/GameCore/GUI/LobbyGUI.cs
@@ -80,7 +80,7 @@ namespace DangerousD.GameCore.GUI
fontName = "font2"
};
hostButton.LeftButtonPressed += () => {
-
+ AppManager.Instance.ChangeGameState(GameState.Game);
AppManager.Instance.NetworkManager.HostInit(AppManager.Instance.IpAddress);
};
@@ -106,6 +106,7 @@ namespace DangerousD.GameCore.GUI
fontName = "font2"
};
joinSelectedButton.LeftButtonPressed += () => {
+ AppManager.Instance.ChangeGameState(GameState.Game);
AppManager.Instance.NetworkManager.ClientInit(AppManager.Instance.IpAddress);
};
Button joinByIpButton = new ButtonText(Manager)
diff --git a/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs b/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs
new file mode 100644
index 0000000..b14d8af
--- /dev/null
+++ b/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs
@@ -0,0 +1,36 @@
+using DangerousD.GameCore.Graphics;
+using Microsoft.Xna.Framework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DangerousD.GameCore.GameObjects.Entities
+{
+ public class SilasBall : LivingEntity
+ {
+ public SilasBall(Vector2 position) : base(position)
+ {
+ Height = 60;
+ Width = 60;
+ acceleration = Vector2.Zero;
+
+ }
+ public SilasBall(Vector2 position, Vector2 velosity) : base(position)
+ {
+ Height = 60;
+ Width = 60;
+ acceleration = Vector2.Zero;
+ velocity = velosity;
+
+ }
+
+ protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "SilasBallMove" }, "SilasBallMove");
+ public override void Update(GameTime gameTime)
+ {
+ base.Update(gameTime);
+
+ }
+ }
+}
diff --git a/DangerousD/GameCore/GameObjects/Entity.cs b/DangerousD/GameCore/GameObjects/Entity.cs
index cf2caa9..8876e2c 100644
--- a/DangerousD/GameCore/GameObjects/Entity.cs
+++ b/DangerousD/GameCore/GameObjects/Entity.cs
@@ -7,12 +7,9 @@ using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects
{
public abstract class Entity : GameObject
- {
-
-
+ {
public Entity(Vector2 position) : base(position) {}
-
+ public virtual void SetPosition(Vector2 position) { _pos = position; }
-
}
}
diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs
index c354e3e..d276984 100644
--- a/DangerousD/GameCore/GameObjects/GameObject.cs
+++ b/DangerousD/GameCore/GameObjects/GameObject.cs
@@ -22,10 +22,12 @@ namespace DangerousD.GameCore
protected abstract GraphicsComponent GraphicsComponent { get; }
public GameObject(Vector2 pos)
{
+ Initialize();
_pos = pos;
Width = 500;
Height = 101;
//Animator = new GraphicsComponent(new() { "playerIdle" });
+
LoadContent();
AppManager.Instance.GameManager.Register(this);
}
@@ -34,7 +36,7 @@ namespace DangerousD.GameCore
{
}
- public virtual void Initialize(GraphicsDevice graphicsDevice)
+ public virtual void Initialize()
{
}
@@ -53,7 +55,8 @@ namespace DangerousD.GameCore
{
GraphicsComponent.DrawAnimation(Rectangle, spriteBatch);
//debug
- // spriteBatch.Draw(debugTexture, Rectangle, Color.White);
+ //wdaspriteBatch.Draw(debugTexture,new Rectangle(Rectangle.X-GraphicsComponent.CameraPosition.X,Rectangle.Y-GraphicsComponent.CameraPosition.Y,Rectangle.Width,Rectangle.Height), Color.White);
+
}
}
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/IDrawableObject.cs b/DangerousD/GameCore/GameObjects/IDrawableObject.cs
index f157dcb..1d9ca5c 100644
--- a/DangerousD/GameCore/GameObjects/IDrawableObject.cs
+++ b/DangerousD/GameCore/GameObjects/IDrawableObject.cs
@@ -6,7 +6,7 @@ namespace DangerousD.GameCore.GUI
{
interface IDrawableObject
{
- void Initialize(GraphicsDevice graphicsDevice);
+ void Initialize();
void LoadContent();
void Update(GameTime gameTime);
void Draw(SpriteBatch spriteBatch);
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
index 4fbe6ff..22ea566 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/CoreEnemy.cs
@@ -13,9 +13,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract class CoreEnemy : LivingEntity
{
protected int monster_health;
- protected int monster_speed;
+ protected float monster_speed = 2;
protected string name;
protected bool isAlive = true;
+ protected bool isAttack = false;
+ protected bool isGoRight;
+ protected int leftBoarder = 0;
+ protected int rightBoarder = 700;
public CoreEnemy(Vector2 position) : base(position)
{
@@ -29,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract void Death();
public abstract void Attack();
+ public abstract void Attack(GameTime gameTime);
public abstract void Move(GameTime gameTime);
@@ -41,5 +46,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isAlive = false;
}
}
+
+ public abstract void Target();
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs
index cd00606..f7591ac 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FlameSkull.cs
@@ -18,10 +18,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 40;
monster_speed = 3;
name = "Skull";
+ acceleration = Vector2.Zero;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "FlameSkullMoveRight" , "FlameSkullMoveLeft"}, "FlameSkullMoveRight");
+ public override void Update(GameTime gameTime)
+ {
+ if (!isAttack)
+ {
+ Move(gameTime);
+ }
+
+ base.Update(gameTime);
+ }
+
public override void Attack()
{
@@ -34,7 +45,40 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ if (isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "FlameSkullMoveRight")
+ {
+ GraphicsComponent.StartAnimation("FlameSkullMoveRight");
+ }
+ velocity.X = monster_speed;
+ }
+ else
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "FlameSkullMoveLeft")
+ {
+ GraphicsComponent.StartAnimation("FlameSkullMoveLeft");
+ }
+ velocity.X = -monster_speed;
+ }
+ if (Pos.X >= rightBoarder)
+ {
+ isGoRight = false;
+ }
+ else if (Pos.X <= leftBoarder)
+ {
+ isGoRight = true;
+ }
+ }
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs
index b0b3429..8ecddcd 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Frank.cs
@@ -12,16 +12,25 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
internal class Frank : CoreEnemy
{
- private bool isGoRight = false;
public Frank(Vector2 position) : base(position)
{
+ isGoRight = false;
+
Width = 112;
Height = 160;
+ leftBoarder = 50;
+ rightBoarder = 300;
GraphicsComponent.StartAnimation("FrankMoveLeft");
- monster_speed = 1;
+ monster_speed = 2;
name = "Frank";
}
- protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight");
+ protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveLeft");
+
+ public override void Update(GameTime gameTime)
+ {
+ Move(gameTime);
+ base.Update(gameTime);
+ }
public override void Attack()
{
@@ -35,14 +44,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
- var player = AppManager.Instance.GameManager.players[0];
- if (player.Pos.X - _pos.X <= 20 || player.Pos.X - _pos.X <= -20)
- {
- player.Death(name);
- }
-
if (isGoRight)
- {
+ {
if (GraphicsComponent.GetCurrentAnimation != "FrankMoveRight")
{
GraphicsComponent.StartAnimation("FrankMoveRight");
@@ -57,6 +60,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
velocity.X = -monster_speed;
}
+ if (Pos.X >= rightBoarder)
+ {
+ isGoRight = false;
+ }
+ else if (Pos.X <= leftBoarder)
+ {
+ isGoRight = true;
+ }
+ }
+
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
index 7101da2..bc28f6b 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/FrankBalls.cs
@@ -12,19 +12,51 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class FrankBalls : CoreEnemy
{
+ private Rectangle collision;
+ private Vector2 position;
+ private int healthBall;
+ private bool isFlyRight = true;
+ private bool isAttacking = false;
+
+ public Rectangle Collision
+ {
+ get { return collision; }
+ }
+
public FrankBalls(Vector2 position) : base(position)
{
+ this.position = position;
name = "FrankBalls";
Width = 40;
Height = 40;
- monster_speed = 1;
+ monster_speed = 3;
acceleration = Vector2.Zero;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "BallMoveRight" }, "BallMoveRight");
+ public override void Update(GameTime gameTime)
+ {
+ if(!isAttacking)
+ {
+ Move(gameTime);
+ }
+
+ base.Update(gameTime);
+ }
public override void Attack()
{
+ collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
+ isAttacking = true;
+
+ if(isFlyRight)
+ {
+ AppManager.Instance.GameManager.players[0].Death(name);
+ }
+ else if(!isFlyRight)
+ {
+ AppManager.Instance.GameManager.players[0].Death(name);
+ }
}
@@ -35,7 +67,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ velocity.X = 0;
+ velocity.Y = 0;
+ if(isFlyRight)
+ {
+ velocity.X += monster_speed;
+ velocity.Y += monster_speed;
+ }
+ else if(!isFlyRight)
+ {
+ velocity.X -= monster_speed;
+ velocity.Y -= monster_speed;
+ }
+ }
+
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
index 1e47e99..6236554 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Ghost.cs
@@ -12,16 +12,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public Ghost(Vector2 position) : base(position)
{
- monster_speed = 1;
+ isGoRight = true;
+ monster_speed = 3;
name = "Ghost";
Width = 48;
Height = 62;
GraphicsComponent.StartAnimation("GhostSpawn");
+ acceleration = Vector2.Zero;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
+ public override void Update(GameTime gameTime)
+ {
+ if (!isAttack)
+ {
+ Move(gameTime);
+ }
+
+ base.Update(gameTime);
+ }
+
public override void Attack()
{
@@ -34,7 +46,44 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ if (isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "GhostMoveRight")
+ {
+ GraphicsComponent.StartAnimation("GhostMoveRight");
+ }
+ velocity.X = monster_speed;
+ }
+ else
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "GhostMoveLeft")
+ {
+ GraphicsComponent.StartAnimation("GhostMoveLeft");
+ }
+ velocity.X = -monster_speed;
+ }
+ if (Pos.X >= rightBoarder)
+ {
+ isGoRight = false;
+ }
+ else if (Pos.X <= leftBoarder)
+ {
+ isGoRight = true;
+ }
+ if (true)
+ {
+ }
+ }
+
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
index ed8a92c..ba342ec 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Hunchman.cs
@@ -81,6 +81,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
}
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
public override void Death()
{
if (monster_health <= 0)
@@ -123,5 +128,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
_pos.X += 5 * monster_speed;
Debug.WriteLine("Collision");
}
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
index 9e616ed..9cd2b4f 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/HunchmanDagger.cs
@@ -27,6 +27,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
public override void Death()
{
@@ -36,5 +41,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs
index cf33f30..16c06e1 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs
@@ -27,7 +27,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack()
{
- throw new NotImplementedException();
+
+ }
+
+ public override void Attack(GameTime gameTime)
+ {
+
}
public override void Death()
@@ -39,12 +44,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
if (Pos.Y> AppManager.Instance.GameManager.GetPlayer1.Pos.Y)
{
- velocity.Y = monster_speed;
+ velocity.Y = -monster_speed;
}
else
{
- velocity.Y = 0;
+ velocity.Y = monster_speed;
}
if (Pos.X> AppManager.Instance.GameManager.GetPlayer1.Pos.X)
{
@@ -55,9 +60,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
velocity.X = monster_speed;
}
}
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
+ }
+
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
+ Move(gameTime);
if ((Pos.X + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.X || Pos.X - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.X)&&(Pos.Y + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.Y || Pos.Y - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.Y))
{
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs
index 09a3928..5dc8df2 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs
@@ -1,4 +1,5 @@
-using DangerousD.GameCore.Graphics;
+using DangerousD.GameCore.GameObjects.Entities;
+using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@@ -15,6 +16,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private int attackTime = 60;
private int moveTime = 360;
private int currentTime = 0;
+ private bool isGoRight = true;
+ int leftBorder;
+ int rightBorder;
+ List hands = new List();
+ List balls = new List();
public SilasMaster(Vector2 position) : base(position)
{
name = "SilasMaster";
@@ -23,25 +29,57 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
monster_health = 15;
monster_speed = 4;
acceleration = Vector2.Zero;
+ leftBorder = (int)position.X - 60;
+ rightBorder = (int)position.X + 120;
+ acceleration = Vector2.Zero;
+ hands.Add(new SilasHands(new Vector2(Pos.X+60,Pos.Y+120)));
+ hands.Add(new SilasHands(new Vector2(Pos.X + 90, Pos.Y + 120)));
+ for (int i = 0; i < 4; i++)
+ {
+ SilasBall silasball = new SilasBall(new Vector2(Pos.X + i * 40, Pos.Y + 120), new Vector2((i - 2) * 4, 6));
+ balls.Add(silasball);
+ }
}
protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List() { "SilasMove", "SilasAttack" }, "SilasMove");
public override void Attack()
{
- if (currentTime==0)
+
+ if (currentTime == 0)
{
GraphicsComponent.StartAnimation("SilasAttack");
+
+ }
+ else if (currentTime == attackTime / 2)
+ {
+ SpawnAttackBall();
}
else if (currentTime >= attackTime)
{
+
GraphicsComponent.StartAnimation("SilasMove");
currentTime = 0;
}
currentTime++;
}
+ private void SpawnAttackBall()
+ {
+ for (int i = 0; i < balls.Count; i++)
+ {
+ balls[i].SetPosition(new Vector2(Pos.X + i * 40, Pos.Y + 120));
+ }
+
+
+ }
+
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
public override void Death()
{
- throw new NotImplementedException();
+
}
public override void Move(GameTime gameTime)
@@ -56,16 +94,44 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
currentTime = 0;
}
currentTime++;
+ if (isGoRight)
+ {
+ velocity.X = monster_speed;
+ }
+ else if (!isGoRight)
+ {
+ velocity.X = -monster_speed;
+ }
+
+ if (Pos.X >= rightBorder)
+ {
+ isGoRight = false;
+ }
+ else if (Pos.X <= leftBorder)
+ {
+ isGoRight = true;
+ }
}
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
+ }
+
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
- if (GraphicsComponent.CurrentAnimation.Id=="SilasMove")
+ if (hands.Count<2)
+ {
+ hands.Add(new SilasHands(new Vector2(Pos.X + 60, Pos.Y + 120)));
+ }
+ if (GraphicsComponent.CurrentAnimation.Id == "SilasMove")
{
Move(gameTime);
}
else
{
+ velocity = Vector2.Zero;
Attack();
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
index 9f3f936..0e5e954 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Slime.cs
@@ -12,25 +12,233 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Slime : CoreEnemy
{
+ private bool isGoRight = true;
+ private bool isDown = false;
+ int leftBorder;
+ int rightBorder;
+ bool isAttaking = false;
+ int delay;
+ bool isJumping = false;
public Slime(Vector2 position) : base(position)
{
+ Width = 48;
+ Height = 16;
+ name = "Slime";
+ monster_speed = 3;
+ monster_health = 2;
+ leftBorder = 100;
+ rightBorder = 400;
+ //acceleration = Vector2.Zero;
+ delay = 30;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
- "SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
- "SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "");
+ "SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
+ "SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "SlimeMoveRightTop");
public override void Attack()
{
}
+ public void Jump()
+ {
+ var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100));
+ velocity.X = 0;
+ Height = 32;
+ if (isGoRight && isDown)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpLeftBottom")
+ {
+ GraphicsComponent.StartAnimation("SlimeReadyJumpLeftBottom");
+ }
+ delay--;
+ if (delay <= 0)
+ {
+ isJumping = true;
+ velocity = new Vector2(5, -3);
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom")
+ {
+ GraphicsComponent.StartAnimation("SlimeJumpLeftBottom");
+ }
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
+ if (getCols.Count > 0)
+ {
+ isJumping = false;
+ isDown = false;
+ }
+ }
+ }
+ else if (!isGoRight && isDown)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpRightTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeReadyJumpRightTop");
+ }
+ delay--;
+ if (delay <= 0)
+ {
+ velocity = new Vector2(-5, -3);
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeJumpRightTop");
+ }
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
+ if (getCols.Count > 0)
+ {
+ isJumping = false;
+ isDown = false;
+ }
+ }
+ }
+ else if (isGoRight && !isDown)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpLeftTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeReadyJumpLeftTop");
+
+ }
+ delay--;
+ if (delay <= 0)
+ {
+ isJumping = true;
+ velocity = new Vector2(5, 3);
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
+ }
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5));
+ if (getCols.Count > 0)
+ {
+ isJumping = false;
+ isDown = true;
+ }
+ }
+
+ }
+ else if (!isGoRight && !isDown)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpRightTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeReadyJumpRightTop");
+ }
+ delay--;
+ if (delay <= 0)
+ {
+ velocity = new Vector2(-5, 3);
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeJumpRightTop");
+ }
+ getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5));
+ if (getCols.Count > 0)
+ {
+ isJumping = false;
+ isDown = true;
+ }
+ }
+
+
+ }
+
+ }
+ public override void Draw(SpriteBatch spriteBatch)
+ {
+ spriteBatch.Draw(debugTexture, new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5), Color.White);
+ spriteBatch.Draw(debugTexture, new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5), Color.White);
+ base.Draw(spriteBatch);
+ }
public override void Death()
{
}
public override void Move(GameTime gameTime)
+ {
+ float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
+ delay = 30;
+ Height = 16;
+ if (isGoRight && isDown)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveRightBottom")
+ {
+ GraphicsComponent.StartAnimation("SlimeMoveRightBottom");
+ }
+ velocity.X = monster_speed;
+
+ }
+
+ else if (!isGoRight && isDown)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveLeftBottom")
+ {
+ GraphicsComponent.StartAnimation("SlimeMoveLeftBottom");
+ }
+ velocity.X = -monster_speed;
+
+ }
+ else if (!isDown && isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveRightTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeMoveRightTop");
+
+ }
+ velocity.X = monster_speed;
+
+
+ }
+ else if (!isDown && !isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveLeftTop")
+ {
+ GraphicsComponent.StartAnimation("SlimeMoveLeftTop");
+ }
+ velocity.X = -monster_speed;
+
+ }
+
+ if (Pos.X >= rightBorder)
+ {
+ isGoRight = false;
+ }
+
+ else if (Pos.X <= leftBorder)
+ {
+ isGoRight = true;
+ }
+ }
+ public override void Update(GameTime gameTime)
+ {
+
+ if (isDown)
+ {
+
+ if (acceleration.Y < 0)
+ {
+ acceleration.Y = -acceleration.Y;
+ }
+ }
+ else
+ {
+
+ if (acceleration.Y > 0)
+ {
+ acceleration.Y = -acceleration.Y;
+ }
+ }
+ //if (!isAttaking){ Move(gameTime); }
+
+
+ base.Update(gameTime);
+ }
+
+ public override void Target()
+ {
+
+ }
+
+ public override void Attack(GameTime gameTime)
{
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs
index bffa5f6..0d797aa 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Spider.cs
@@ -17,6 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
protected int webLength;
protected bool isDown;
protected bool isDownUp;
+
public Spider(Vector2 position) : base(position)
{
isDownUp = true;
@@ -27,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 24;
delay = 0;
webLength = 0;
- monster_speed = 1;
+ monster_speed = 2;
acceleration = Vector2.Zero;
}
@@ -35,6 +36,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime)
{
+ if (!isAttack)
+ {
+ Move(gameTime);
+ }
+ else
+ {
+ Attack(gameTime);
+ }
+
+ base.Update(gameTime);
+ }
+ ///
+ /// НИЧЕГО НЕ ДЕЛАЕТ! НУЖЕН ДЛЯ ПЕРЕОПРЕДЕЛЕНИЯ
+ ///
+ public override void Attack()
+ {
+ }
+ ///
+ /// Атака паука РАБОЧАЯ
+ ///
+ ///
+ public override void Attack(GameTime gameTime)
+ { //48 72
if (isDownUp)
{
Width = 48;
@@ -46,7 +70,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
webLength++;
_pos.Y += 25;
web.Height = webLength * 25;
- web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
+ web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 4)
{
@@ -59,7 +83,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
webLength--;
_pos.Y -= 25;
web.Height = webLength * 25;
- web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
+ web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 0)
{
@@ -72,12 +96,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Height = 24;
}
}
-
- base.Update(gameTime);
- }
- public override void Attack()
- { //48 72
-
}
public override void Draw(SpriteBatch spriteBatch)
@@ -100,7 +118,35 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ if (isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight")
+ {
+ GraphicsComponent.StartAnimation("SpiderMoveRight");
+ }
+ velocity.X = monster_speed;
+ }
+ else
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveLeft")
+ {
+ GraphicsComponent.StartAnimation("SpiderMoveLeft");
+ }
+ velocity.X = -monster_speed;
+ }
+ if (Pos.X >= rightBoarder)
+ {
+ isGoRight = false;
+ }
+ else if (Pos.X <= leftBoarder)
+ {
+ isGoRight = true;
+ }
+ }
+ public override void Target()
+ {
+ throw new NotImplementedException();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs
index d91ccaf..cde2ab0 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SpiderWeb.cs
@@ -28,6 +28,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
+ public override void Attack(GameTime gameTime)
+ {
+
+ }
+
public override void Death()
{
@@ -37,5 +42,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
}
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
index 9d5acb8..2d9ebae 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Werewolf.cs
@@ -15,13 +15,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public Werewolf(Vector2 position) : base(position)
{
name = "Wolf";
- monster_speed = 1;
+ monster_speed = 4;
Width = 78;
Height = 96;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight");
+ public override void Update(GameTime gameTime)
+ {
+ if (!isAttack)
+ {
+ Move(gameTime);
+ }
+
+ base.Update(gameTime);
+ }
+
public override void Attack()
{
@@ -34,7 +44,39 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
+ if (isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight")
+ {
+ GraphicsComponent.StartAnimation("WolfMoveRight");
+ }
+ velocity.X = monster_speed;
+ }
+ else
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "WolfMoveLeft")
+ {
+ GraphicsComponent.StartAnimation("WolfMoveLeft");
+ }
+ velocity.X = -monster_speed;
+ }
+ if (Pos.X >= rightBoarder)
+ {
+ isGoRight = false;
+ }
+ else if (Pos.X <= leftBoarder)
+ {
+ isGoRight = true;
+ }
+ }
+ public override void Attack(GameTime gameTime)
+ {
+ }
+
+ public override void Target()
+ {
+ throw new NotImplementedException();
}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
index 6597527..f4d636c 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs
@@ -110,23 +110,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
base.OnCollision(gameObject);
}
-
- public void Target()
+ public override void Target()
{
- if(physicsManager.RayCast(this, AppManager.Instance.GameManager.players[0]) == null)
+ if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)) != null)
{
- if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
+ if (isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
{
isTarget = true;
leftBorder = Pos.X - 10;
rightBorder = Pos.X + AppManager.Instance.GameManager.players[0].Pos.X;
}
- else if(!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X)
+ else if (!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X)
{
isTarget = true;
rightBorder = Pos.X + 10;
- leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
+ leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
}
}
}
@@ -141,5 +140,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 760;
}
}
+
+ public override void Attack(GameTime gameTime)
+ {}
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
index f7be1a0..67e8845 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
@@ -6,6 +6,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DangerousD.GameCore.GameObjects.PlayerDeath;
+using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects.LivingEntities
{
@@ -14,23 +16,62 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
bool isAlive = true;
bool isRight;
string stayAnimation;
+ public int health;
+ public bool isGoRight = false;
+ public Vector2 playerVelocity;
+ public int rightBorder;
+ public int leftBorder;
+ public bool isVisible = true;
+ public GameObject objectAttack;
+
public Player(Vector2 position) : base(position)
{
- Width = 24;
- Height = 32;
- AppManager.Instance.InputManager.MovEventJump += Jump;
-
+ Width = 32;
+ Height = 64;
+
+ AppManager.Instance.InputManager.ShootEvent += Shoot;
+
+ AppManager.Instance.InputManager.MovEventJump += AnimationJump;
+ AppManager.Instance.InputManager.MovEventDown += MoveDown;
+
+ playerVelocity = new Vector2(100, 0);
+ rightBorder = (int)position.X + 100;
+ leftBorder = (int)position.X - 100;
+
}
+
+ private void AnimationJump()
+ {
+ velocity.Y = -300;
+ }
+
public bool IsAlive { get { return isAlive; } }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
"playerJumpRight" , "playerJumpLeft"}, "playerStayLeft");
- public void Kill()
+ public void Attack()
{
-
+ if (objectAttack.Rectangle.Intersects(this.Rectangle))
+ {
+ isVisible = false;
+ }
+ }
+ public override void OnCollision(GameObject gameObject)
+ {
+ if (gameObject is Player)
+ {
+ isVisible = false;
+ }
+ base.OnCollision(gameObject);
+ }
+ public override void Draw(SpriteBatch spriteBatch)
+ {
+ if (isVisible)
+ {
+ base.Draw(spriteBatch);
+ }
}
-
public void Death(string monsterName)
{
if(monsterName == "Zombie")
@@ -46,15 +87,65 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
isAlive = false;
}
- public override void Update(GameTime gameTime)
- {
-
- base.Update(gameTime);
- }
public void Jump()
{
velocity.Y = -300;
//сюда анимацию и доделать
+ if (Keyboard.GetState().IsKeyDown(Keys.Escape))
+ {
+ velocity.Y = -300;
+ }
+ // здесь будет анимация
}
+ public void Shoot()
+ {
+
+ }
+
+ public override void Update(GameTime gameTime)
+ {
+ GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
+ velocity.X = 0.5f;
+ if (!isVisible)
+ {
+
+ }
+ Move(gameTime);
+ base.Update(gameTime);
+ }
+
+ public void Move(GameTime gameTime)
+ {
+ float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
+ if (isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")
+ {
+ GraphicsComponent.StartAnimation("playerMoveRight");
+ }
+ _pos = playerVelocity * delta;
+ }
+ else if (!isGoRight)
+ {
+ if (GraphicsComponent.GetCurrentAnimation != "playerMoveLeft")
+ {
+ GraphicsComponent.StartAnimation("playerMoveLeft");
+ }
+ _pos= -playerVelocity * delta;
+ }
+ if (_pos.X >= rightBorder)
+ {
+ isGoRight = false;
+ }
+ if (_pos.X >= leftBorder)
+ {
+ isGoRight = true;
+ }
+ }
+ public void MoveDown()
+ {
+
+ }
+
}
}
diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs
index 5c18831..5620568 100644
--- a/DangerousD/GameCore/GameObjects/LivingEntity.cs
+++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs
@@ -11,16 +11,20 @@ public abstract class LivingEntity : Entity
{
acceleration = new Vector2(0, 30);
}
- public void SetPosition(Vector2 position) { targetPosition = position; _pos = position; } //TODO befrend targetpos and physics engine
+ public override void SetPosition(Vector2 position)
+ {
+ targetPosition = position; _pos = position;
+
+ } //TODO befrend targetpos and physics engine
public override void Update(GameTime gameTime)
{
- if (Vector2.Distance(Pos, targetPosition) > 0.5f)
- {
- Vector2 dir = targetPosition - Pos;
- dir.Normalize();
- _pos += dir * velocity;
- }
+ //if (Vector2.DistanceSquared(Pos, targetPosition) > 0.25f)
+ //{
+ // Vector2 dir = targetPosition - Pos;
+ // dir.Normalize();
+ // _pos += dir * velocity;
+ //}
base.Update(gameTime);
}
diff --git a/DangerousD/GameCore/GameObjects/MapObject.cs b/DangerousD/GameCore/GameObjects/MapObject.cs
index d4180d0..02576ef 100644
--- a/DangerousD/GameCore/GameObjects/MapObject.cs
+++ b/DangerousD/GameCore/GameObjects/MapObject.cs
@@ -1,13 +1,31 @@
-using Microsoft.Xna.Framework;
+using System.Collections.Generic;
+using Microsoft.Xna.Framework;
using System.Security.Cryptography.X509Certificates;
-
+using DangerousD.GameCore.Graphics;
+using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects;
public abstract class MapObject : GameObject
{
- public bool IsColliderOn;
- public MapObject(Vector2 position) : base(position)
+ public virtual bool IsColliderOn { get; protected set; } = true;
+ private Rectangle _sourceRectangle;
+ protected override GraphicsComponent GraphicsComponent { get; } = new("tiles");
+ public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position)
+ {
+ _sourceRectangle = sourceRectangle;
+ Width = (int)size.X;
+ Height = (int)size.Y;
+ }
+
+ public override void Initialize()
{
}
+
+ public virtual void Draw(SpriteBatch spriteBatch)
+ {
+ GraphicsComponent.DrawAnimation(Rectangle, spriteBatch, _sourceRectangle);
+ //spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.White);
+
+ }
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/GrassBlock.cs b/DangerousD/GameCore/GameObjects/MapObjects/GrassBlock.cs
deleted file mode 100644
index 3ada6f5..0000000
--- a/DangerousD/GameCore/GameObjects/MapObjects/GrassBlock.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using DangerousD.GameCore.Graphics;
-
-namespace DangerousD.GameCore.GameObjects.MapObjects
-{
- internal class GrassBlock : MapObject
- {
- protected override GraphicsComponent GraphicsComponent { get; } = new("wall");
-
- public GrassBlock(Vector2 position) : base(position)
- {
- Width = 32;
- Height = 32;
- }
- }
-}
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs b/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs
new file mode 100644
index 0000000..f69d7c9
--- /dev/null
+++ b/DangerousD/GameCore/GameObjects/MapObjects/Platform.cs
@@ -0,0 +1,21 @@
+using DangerousD.GameCore.Graphics;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace DangerousD.GameCore.GameObjects.MapObjects;
+
+public class Platform : MapObject
+{
+ public override bool IsColliderOn { get; protected set; } = true;
+ public Platform(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
+ {
+ }
+ public override void Draw(SpriteBatch spriteBatch)
+ {
+ base.Draw(spriteBatch);
+ //debug
+ //spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.Blue);
+
+ }
+
+}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs b/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs
new file mode 100644
index 0000000..b4fb7a5
--- /dev/null
+++ b/DangerousD/GameCore/GameObjects/MapObjects/StopTile.cs
@@ -0,0 +1,20 @@
+using DangerousD.GameCore.Graphics;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace DangerousD.GameCore.GameObjects.MapObjects;
+
+public class StopTile : MapObject
+{
+ public override bool IsColliderOn { get; protected set; } = true;
+ public StopTile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
+ {
+ }
+ public override void Draw(SpriteBatch spriteBatch)
+ {
+ base.Draw(spriteBatch);
+ //debug
+ // spriteBatch.Draw(debugTexture, new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height), Color.White);
+
+ }
+}
\ No newline at end of file
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/TestAnimationDeath.cs b/DangerousD/GameCore/GameObjects/MapObjects/TestAnimationDeath.cs
deleted file mode 100644
index 8e9be4d..0000000
--- a/DangerousD/GameCore/GameObjects/MapObjects/TestAnimationDeath.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using DangerousD.GameCore.Graphics;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DangerousD.GameCore.GameObjects.MapObjects
-{
- internal class TestAnimationDeath : Entity
- {
- protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "death1", "deathbear" },"death1");
-
- public TestAnimationDeath(Vector2 position) : base(position)
- {
- Width =512;
- Height = 512;
-
- GraphicsComponent.StartAnimation("deathbear");
-
- }
- }
-}
diff --git a/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs b/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs
new file mode 100644
index 0000000..5f36075
--- /dev/null
+++ b/DangerousD/GameCore/GameObjects/MapObjects/Tile.cs
@@ -0,0 +1,12 @@
+using DangerousD.GameCore.Graphics;
+using Microsoft.Xna.Framework;
+
+namespace DangerousD.GameCore.GameObjects.MapObjects;
+
+public class Tile : MapObject
+{
+ public override bool IsColliderOn { get; protected set; } = false;
+ public Tile(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
+ {
+ }
+}
\ No newline at end of file
diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs
index beb6928..32851e2 100644
--- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs
+++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs
@@ -164,8 +164,9 @@ namespace DangerousD.GameCore.Graphics
scale = destinationRectangle.Width / sourceRectangle.Width;
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
}
-
-
+
+ destinationRectangle.X -= CameraPosition.X;
+ destinationRectangle.Y -= CameraPosition.Y;
_spriteBatch.Draw(texture,
destinationRectangle, sourceRectangle, Color.White);
}
@@ -187,6 +188,8 @@ namespace DangerousD.GameCore.Graphics
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
}
+ destinationRectangle.X -= CameraPosition.X;
+ destinationRectangle.Y -= CameraPosition.Y;
_spriteBatch.Draw(texture,
destinationRectangle, sourceRectangle, Color.White);
@@ -215,5 +218,6 @@ namespace DangerousD.GameCore.Graphics
interval = lastInterval;
}
}
+ public static Point CameraPosition = new Point(0, 0);
}
}
diff --git a/DangerousD/GameCore/Levels/ILevel.cs b/DangerousD/GameCore/Levels/ILevel.cs
deleted file mode 100644
index 7fbec35..0000000
--- a/DangerousD/GameCore/Levels/ILevel.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace DangerousD.GameCore.Levels
-{
- interface ILevel
- {
- void InitLevel();
- }
-}
diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs
deleted file mode 100644
index b8f5c14..0000000
--- a/DangerousD/GameCore/Levels/Level1.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using DangerousD.GameCore.GameObjects.LivingEntities;
-using DangerousD.GameCore.GameObjects.MapObjects;
-using Microsoft.Xna.Framework;
-using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
-using System.Collections.Generic;
-
-namespace DangerousD.GameCore.Levels
-{
- public class Level1 : ILevel
- {
- public void InitLevel()
- {
-
- new Player(new Vector2(350,0));
- var Zombie = new Zombie(new Vector2(100, 128));
-
- //var Frank = new Frank(new Vector2(384, 128));
- //var Spider = new Spider(new Vector2(112, 0));
- //var FlameSkull = new FlameSkull(new Vector2(512, 0));
- //var Werewolf = new Werewolf(new Vector2(640, 0));
- //var Ghost = new Ghost(new Vector2(730, 0));
- //var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
- //var SilasHand = new SilasHands(new Vector2(200,64));
- //var SilasMaster = new SilasMaster(new Vector2(400, 64));
-
- var HunchMan = new Hunchman(new Vector2(300, 100));
-
- new GrassBlock(new Vector2(0, 224));
- for (int i = 0; i < 50; i++)
- {
- new GrassBlock(new Vector2(i*32, 256));
- }
- new GrassBlock(new Vector2(500, 224));
- }
- }
-}
diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs
index 1261b82..3379b3c 100644
--- a/DangerousD/GameCore/Managers/AppManager.cs
+++ b/DangerousD/GameCore/Managers/AppManager.cs
@@ -31,7 +31,7 @@ namespace DangerousD.GameCore
public Point inGameResolution = new Point(800, 480);
private RenderTarget2D renderTarget;
- public GameManager GameManager { get; private set; } = new GameManager();
+ public GameManager GameManager { get; private set; } = new();
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
public NetworkManager NetworkManager { get; private set; } = new NetworkManager();
public InputManager InputManager { get; private set; } = new InputManager();
@@ -39,9 +39,9 @@ namespace DangerousD.GameCore
public SettingsManager SettingsManager { get; private set; } = new SettingsManager();
public AppManager()
{
+ Content.RootDirectory = "Content";
Instance = this;
_graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
IsMouseVisible = true;
TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / 30);
@@ -65,9 +65,9 @@ namespace DangerousD.GameCore
protected override void Initialize()
{
AnimationBuilder.LoadAnimations();
- MenuGUI.Initialize(GraphicsDevice);
- LoginGUI.Initialize(GraphicsDevice);
- LobbyGUI.Initialize(GraphicsDevice);
+ MenuGUI.Initialize();
+ LoginGUI.Initialize();
+ LobbyGUI.Initialize();
base.Initialize();
}
@@ -165,7 +165,7 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
- GameManager.mapManager.LoadLevel("");
+ GameManager.mapManager.LoadLevel("lvl");
break;
case GameState.GameOver:
break;
@@ -174,30 +174,32 @@ namespace DangerousD.GameCore
}
}
- public void NetworkSync(NetworkTask networkTask)
+ public void NetworkSync(List networkTasks)
{
- //TODO
- return;
- switch (networkTask.operation)
+ foreach (NetworkTask networkTask in networkTasks)
{
- case NetworkTaskOperationEnum.TakeDamage:
- break;
- case NetworkTaskOperationEnum.SendSound:
- SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos);
- break;
- case NetworkTaskOperationEnum.CreateEntity:
- break;
- case NetworkTaskOperationEnum.SendPosition:
- break;
- case NetworkTaskOperationEnum.ChangeState:
- break;
- case NetworkTaskOperationEnum.ConnectToHost:
- break;
- case NetworkTaskOperationEnum.GetClientPlayerId:
- break;
- default:
- break;
+ switch (networkTask.operation)
+ {
+ case NetworkTaskOperationEnum.TakeDamage:
+ break;
+ case NetworkTaskOperationEnum.SendSound:
+ SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos);
+ break;
+ case NetworkTaskOperationEnum.CreateEntity:
+ break;
+ case NetworkTaskOperationEnum.SendPosition:
+ break;
+ case NetworkTaskOperationEnum.ChangeState:
+ break;
+ case NetworkTaskOperationEnum.ConnectToHost:
+ break;
+ case NetworkTaskOperationEnum.GetClientPlayerId:
+ break;
+ default:
+ break;
+ }
}
+
}
public void SetMultiplayerState(MultiPlayerStatus multiPlayerStatus)
{
diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs
index a177e86..342813b 100644
--- a/DangerousD/GameCore/Managers/GameManager.cs
+++ b/DangerousD/GameCore/Managers/GameManager.cs
@@ -7,51 +7,64 @@ using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
+using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
namespace DangerousD.GameCore
{
public class GameManager
{
public List GetAllGameObjects { get; private set; }
+
public List livingEntities;
public List entities;
public List mapObjects;
+ public List BackgroundObjects;
+ public List others;
public MapManager mapManager;
public PhysicsManager physicsManager;
public List players;
public List otherObjects = new();
+
public Player GetPlayer1 { get; private set; }
public GameManager()
{
+ others = new List();
GetAllGameObjects = new List();
livingEntities = new List();
mapObjects = new List();
+ BackgroundObjects = new List();
entities = new List();
players = new List();
- mapManager = new MapManager();
+ mapManager = new MapManager(1);
physicsManager = new PhysicsManager();
- mapManager.Init();
+
}
+
+
internal void Register(GameObject gameObject)
{
- if (gameObject is Player)
+ GetAllGameObjects.Add(gameObject);
+ if (gameObject is Player objPl)
{
livingEntities.Add(gameObject as LivingEntity);
- players.Add(gameObject as Player);
+ players.Add(objPl);
GetPlayer1 = players[0];
}
- else if (gameObject is LivingEntity)
+ else if (gameObject is LivingEntity objLE)
{
- livingEntities.Add(gameObject as LivingEntity);
+ livingEntities.Add(objLE);
}
- else if (gameObject is Entity)
+ else if (gameObject is Entity objE)
{
- entities.Add(gameObject as Entity);
+ entities.Add(objE);
}
- else if (gameObject is MapObject)
+ else if (gameObject is MapObject obj)
{
- mapObjects.Add(gameObject as MapObject);
+ if (obj.IsColliderOn)
+ mapObjects.Add(obj);
+ else
+ BackgroundObjects.Add(obj);
}
else
{
@@ -61,6 +74,8 @@ namespace DangerousD.GameCore
public void Draw(SpriteBatch _spriteBatch)
{
+ foreach (var item in BackgroundObjects)
+ item.Draw(_spriteBatch);
foreach (var item in mapObjects)
item.Draw(_spriteBatch);
foreach (var item in entities)
@@ -73,12 +88,15 @@ namespace DangerousD.GameCore
public void Update(GameTime gameTime)
{
+ foreach (var item in BackgroundObjects)
+ item.Update(gameTime);
foreach (var item in mapObjects)
item.Update(gameTime);
foreach (var item in entities)
item.Update(gameTime);
- foreach (var item in livingEntities)
- item.Update(gameTime);
+
+ for (int i = 0; i < livingEntities.Count; i++)
+ livingEntities[i].Update(gameTime);
foreach (var item in otherObjects)
item.Update(gameTime);
@@ -87,4 +105,4 @@ namespace DangerousD.GameCore
}
}
-}
\ No newline at end of file
+}
diff --git a/DangerousD/GameCore/Managers/MapManager.cs b/DangerousD/GameCore/Managers/MapManager.cs
index f5c9d28..5d7d6fc 100644
--- a/DangerousD/GameCore/Managers/MapManager.cs
+++ b/DangerousD/GameCore/Managers/MapManager.cs
@@ -1,26 +1,116 @@
-using DangerousD.GameCore.GameObjects;
-using DangerousD.GameCore.Graphics;
-using DangerousD.GameCore.Levels;
-using System;
+using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
-using System.Net.Security;
-using System.Text;
-using System.Threading.Tasks;
+using System.Xml;
+using DangerousD.GameCore.GameObjects.MapObjects;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using System.Xml.Serialization;
+using DangerousD.GameCore.GameObjects;
+using System.Globalization;
namespace DangerousD.GameCore.Managers
{
public class MapManager
{
- ILevel Level;
- public void Init()
+ private int _columns;
+ private int _scale;
+
+ public MapManager(int scale)
{
- Level = new Level1();
+ _scale = scale;
}
+
//Level
public void LoadLevel(string level)
{
- Level.InitLevel();
+ LoadTilesData();
+
+ XmlDocument xml = new();
+ xml.Load($"../../../Content/{level}.tmx");
+ Vector2 tileSize = new(int.Parse(xml.DocumentElement.Attributes["tilewidth"].Value),
+ int.Parse(xml.DocumentElement.Attributes["tileheight"].Value));
+ //tileSize *= _scale;
+
+ foreach (XmlNode layer in xml.DocumentElement.SelectNodes("layer"))
+ {
+ InstantiateTiles(layer, tileSize);
+ }
+
+ foreach (XmlNode layer in xml.DocumentElement.SelectNodes("objectgroup"))
+ {
+ InstantiateEntities(layer);
+ }
+ }
+
+ private void InstantiateTiles(XmlNode layer, Vector2 tileSize)
+ {
+ string tileType = layer.Attributes["class"].Value;
+ float offsetX = layer.Attributes["offsetx"] is not null ? float.Parse(layer.Attributes["offsetx"].Value, CultureInfo.InvariantCulture) : 0;
+ float offsetY = layer.Attributes["offsety"] is not null ? float.Parse(layer.Attributes["offsety"].Value, CultureInfo.InvariantCulture) : 0;
+
+
+ Debug.Write(layer.SelectNodes("data/chunk").Count);
+ foreach (XmlNode chunk in layer.SelectNodes("data/chunk"))
+ {
+ int chunkW = int.Parse(chunk.Attributes["width"].Value);
+ int chunkX = int.Parse(chunk.Attributes["x"].Value);
+ int chunkY = int.Parse(chunk.Attributes["y"].Value);
+
+
+ List tiles = chunk.InnerText.Split(',').Select(int.Parse).ToList();
+ for (int i = 0; i < tiles.Count; i++)
+ {
+ if (tiles[i] != 0)
+ {
+ Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale,
+ ((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());
+ Type type = Type.GetType($"DangerousD.GameCore.GameObjects.MapObjects.{tileType}");
+ Activator.CreateInstance(type, pos, tileSize * _scale, sourceRect);
+
+ /*switch (tileType)
+ {
+ case "collidable":
+ new StopTile(pos, tileSize * _scale, sourceRect);
+ break;
+ case "platform":
+ new Platform(pos, tileSize * _scale, sourceRect);
+ break;
+ case "non_collidable":
+ new Tile(pos, tileSize * _scale, sourceRect);
+ break;
+ }*/
+ }
+
+ }
+ }
+ }
+
+ private void LoadTilesData()
+ {
+ XmlDocument xml = new();
+ xml.Load($"../../../Content/map.tsx");
+ XmlNode root = xml.DocumentElement;
+
+ _columns = int.Parse(root.Attributes["columns"].Value);
+ }
+
+ private void InstantiateEntities(XmlNode group)
+ {
+ string entityType = group.Attributes["class"].Value;
+ float offsetX = group.Attributes["offsetx"] is not null ? float.Parse(group.Attributes["offsetx"].Value) : 0;
+ float offsetY = group.Attributes["offsety"] is not null ? float.Parse(group.Attributes["offsety"].Value) : 0;
+ foreach (XmlNode entity in group.ChildNodes)
+ {
+ Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityType}");
+ Entity inst = (Entity)Activator.CreateInstance(type, new Vector2(float.Parse(entity.Attributes["x"].Value, CultureInfo.InvariantCulture) + offsetX, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale);
+ inst.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height));
+ inst.Height *= _scale;
+ inst.Width *= _scale;
+ }
}
}
}
diff --git a/DangerousD/GameCore/Managers/PhysicsManager.cs b/DangerousD/GameCore/Managers/PhysicsManager.cs
index 28ecf14..980d7b3 100644
--- a/DangerousD/GameCore/Managers/PhysicsManager.cs
+++ b/DangerousD/GameCore/Managers/PhysicsManager.cs
@@ -36,33 +36,24 @@ namespace DangerousD.GameCore.Managers
public void CheckCollisions(List livingEntities,
List mapObjects)
{
+ LivingEntity currentEntity;
+ Rectangle oldRect;
for (int i = 0; i < livingEntities.Count; i++)
{
- var currentEntity = livingEntities[i];
- Rectangle oldRect = currentEntity.Rectangle;
+ currentEntity = livingEntities[i];
+ oldRect = currentEntity.Rectangle;
bool isXNormalise = true;
- bool isYNormalise = true;
+ bool isYNormalise = true;
- oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
+ oldRect.Offset((int)currentEntity.velocity.X, 0);
for (int j = 0; j < mapObjects.Count; j++)
{
- if (oldRect.Intersects(mapObjects[j].Rectangle))
- {
- isXNormalise = false;
- oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
- break;
- }
-
- }
- if (isXNormalise)
- {
- oldRect.Offset((int)currentEntity.velocity.X / 2, 0);
- for (int j = 0; j < mapObjects.Count; j++)
+ if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 550)
{
if (oldRect.Intersects(mapObjects[j].Rectangle))
{
isXNormalise = false;
- oldRect.Offset(-(int)currentEntity.velocity.X / 2, 0);
+ oldRect.Offset(-(int)currentEntity.velocity.X, 0);
break;
}
}
@@ -71,29 +62,17 @@ namespace DangerousD.GameCore.Managers
currentEntity.velocity.X = 0;
- oldRect.Offset(0, (int)currentEntity.velocity.Y/2);
+ oldRect.Offset(0, (int)currentEntity.velocity.Y);
for (int j = 0; j < mapObjects.Count; j++)
{
+
if (oldRect.Intersects(mapObjects[j].Rectangle))
{
isYNormalise = false;
- oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
+ oldRect.Offset(0, -(int)currentEntity.velocity.Y);
break;
}
}
- if (isYNormalise)
- {
- oldRect.Offset(0, (int)currentEntity.velocity.Y / 2);
- for (int j = 0; j < mapObjects.Count; j++)
- {
- if (oldRect.Intersects(mapObjects[j].Rectangle))
- {
- isYNormalise = false;
- oldRect.Offset(0, -(int)currentEntity.velocity.Y / 2);
- break;
- }
- }
- }
if (!isYNormalise)
currentEntity.velocity.Y = 0;
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
@@ -177,6 +156,7 @@ namespace DangerousD.GameCore.Managers
}
return gameObject;
}
+
public GameObject RayCast(LivingEntity entity1, Vector2 targetCast)
{
Rectangle rectangle;
@@ -217,7 +197,6 @@ namespace DangerousD.GameCore.Managers
}
return gameObject;
}
-
public List CheckRectangle(Rectangle rectangle, Type type)
{
var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects;
@@ -234,5 +213,20 @@ namespace DangerousD.GameCore.Managers
}
return intersected;
}
+ public List CheckRectangle(Rectangle rectangle)
+ {
+ var gameObjects = AppManager.Instance.GameManager.mapObjects;
+ List intersected = new List();
+ for (int i = 0; i < gameObjects.Count; i++)
+ {
+
+ if (gameObjects[i].Rectangle.Intersects(rectangle) && gameObjects[i].IsColliderOn)
+ {
+ intersected.Add(gameObjects[i]);
+ }
+
+ }
+ return intersected;
+ }
}
}
\ No newline at end of file
diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs
index ffa61d2..3a1e03f 100644
--- a/DangerousD/GameCore/Managers/SoundManager.cs
+++ b/DangerousD/GameCore/Managers/SoundManager.cs
@@ -19,12 +19,23 @@ namespace DangerousD.GameCore
public void LoadSounds() // метод для загрузки звуков из папки
{
- string[] soundFiles = Directory.GetFiles("../../../Content").Where(x=>x.EndsWith("mp3")).Select(x=>x.Split("\\").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
- foreach (var soundFile in soundFiles)
+ var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
+
+ if (k.Count() > 0)
{
- Sounds.Add(soundFile, AppManager.Instance.Content.Load(soundFile).CreateInstance());
+
+ string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
+ foreach (var soundFile in soundFiles)
+ {
+ Sounds.Add(soundFile, AppManager.Instance.Content.Load(soundFile).CreateInstance());
+ }
+
}
+ if (k.Count()>0)
+ {
+
+ }
}
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
diff --git a/DangerousD/GameCore/Network/NetworkManager.cs b/DangerousD/GameCore/Network/NetworkManager.cs
index bac781f..caf16a1 100644
--- a/DangerousD/GameCore/Network/NetworkManager.cs
+++ b/DangerousD/GameCore/Network/NetworkManager.cs
@@ -10,7 +10,7 @@ namespace DangerousD.GameCore.Network
{
public class NetworkManager
{
- public delegate void ReceivingHandler(NetworkTask networkTask);
+ public delegate void ReceivingHandler(List networkTask);
public event ReceivingHandler GetReceivingMessages;
@@ -89,8 +89,6 @@ namespace DangerousD.GameCore.Network
}
public void SendMsg(NetworkTask networkTask)
{
- //TODO
- return;
byte[] Data = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(networkTask));
int count = Data.Length;
if (state == "Host")
@@ -146,7 +144,7 @@ namespace DangerousD.GameCore.Network
}
else
{
- GetReceivingMessages(JsonConvert.DeserializeObject(so.sb.ToString()));
+ GetReceivingMessages(JsonConvert.DeserializeObject>(so.sb.ToString()));
}
}
catch { }
diff --git a/NuGet.config b/NuGet.config
new file mode 100644
index 0000000..90dab50
--- /dev/null
+++ b/NuGet.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file