Compare commits

...

31 commits

Author SHA1 Message Date
SergoDobro
3b63d63087 Merge branch 'черешня' into sounds 2023-08-18 20:28:51 +03:00
SergoDobro
9a044746d8 sounds 2023-08-18 20:25:42 +03:00
AnloGames
0756023c5a d 2023-08-18 20:25:22 +03:00
AnloGames
e70cae920c time 2023-08-18 20:22:28 +03:00
N4K
ec8e0a8cd5 Merge branch 'черешня' of https://github.com/progtime-net/DangerousD into черешня 2023-08-18 20:21:43 +03:00
N4K
868990579a merge? 2023-08-18 20:21:21 +03:00
gravity
665ba7353a Merge branch 'черешня' of https://github.com/progtime-net/DangerousD into черешня 2023-08-18 20:16:24 +03:00
N4K
2dad49fc95 Merge branch 'черешня' into livingEntitiesVlad 2023-08-18 20:15:59 +03:00
Ivan Filipenkov
90018ac034 fix smoke 2023-08-18 20:13:54 +03:00
N4K
3d00ba57b7 Merge branch 'черешня' into livingEntitiesVlad 2023-08-18 20:13:42 +03:00
gravity
eaefd89eb4 Merge branch 'черешня' of https://github.com/progtime-net/DangerousD into черешня 2023-08-18 20:12:09 +03:00
AnloGames
b304a0db88 pla 2023-08-18 20:11:55 +03:00
gravity
38f4e0a81f Merge branch 'черешня' of https://github.com/progtime-net/DangerousD into черешня 2023-08-18 20:09:24 +03:00
AnloGames
ce40ddab57 Merge branch 'черешня' of https://github.com/progtime-net/DangerousD into черешня 2023-08-18 20:08:22 +03:00
AnloGames
0a6e6573c5 d 2023-08-18 20:08:16 +03:00
gravity
81ac0b854f Merge branch 'ui_new1' into черешня 2023-08-18 20:06:51 +03:00
SergoDobro
9d2ff11d50 Merge branch 'черешня' into reserv
# Conflicts:
#	DangerousD/Content/Content.mgcb
2023-08-18 20:02:56 +03:00
Ivan Filipenkov
87c3a168af fix 2023-08-18 19:59:32 +03:00
SergoDobro
a4d47379d6 working game and diamonds 2023-08-18 19:59:22 +03:00
Ivan Filipenkov
69f96286ef Merge remote-tracking branch 'origin/FrankBalls' into черешня
# Conflicts:
#	DangerousD/GameCore/GameObjects/LivingEntities/Player/Player.cs
2023-08-18 19:57:50 +03:00
AnloGames
c05a6e4eef fsd 2023-08-18 19:53:19 +03:00
AnloGames
d176dfedf3 debufgdsf kspdnisa 2023-08-18 19:52:48 +03:00
gravity
75e184274a ui 2023-08-18 18:41:44 +03:00
Kaktus200020
7c526a8e11 Merge branch 'main' into FrankBalls 2023-08-18 18:17:10 +03:00
Kaktus200020
1ed1dd635f GhostAdding 2023-08-18 17:42:26 +03:00
Kaktus200020
d87770f9ec WereWolfAdding 2023-08-18 17:19:44 +03:00
bmvolf
61ea7a5644 tried to fix host error 2023-08-18 17:09:37 +03:00
Timofey06
d478d1afdc Merge branch 'main' of https://github.com/progtime-net/DangerousD 2023-08-18 17:48:44 +03:00
polten0
ba0135bf29 Merge branch 'main' of https://github.com/progtime-net/DangerousD 2023-08-18 17:40:35 +03:00
polten0
91db8f92d0 AddDeathAnimations 2023-08-18 17:37:48 +03:00
bmvolf
b43c3a457d added up shooting 2023-08-18 16:52:38 +03:00
31 changed files with 403 additions and 80 deletions

View file

@ -21,18 +21,6 @@
/processorParam:TextureFormat=Compressed /processorParam:TextureFormat=Compressed
/build:ButtonFont.spritefont /build:ButtonFont.spritefont
#begin checkboxs_off-on.png
/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:checkboxs_off-on.png
#begin checkboxs_off.png #begin checkboxs_off.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -45,6 +33,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:checkboxs_off.png /build:checkboxs_off.png
#begin checkboxs_off-on.png
/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:checkboxs_off-on.png
#begin checkboxs_on.png #begin checkboxs_on.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -81,6 +81,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:deathBackground.jpg /build:deathBackground.jpg
#begin Diamond.png
/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:Diamond.png
#begin door.png #begin door.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -121,6 +133,18 @@
/processorParam:TextureFormat=Compressed /processorParam:TextureFormat=Compressed
/build:Font2.spritefont /build:Font2.spritefont
#begin GetScore.png
/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:GetScore.png
#begin menuFon.jpg #begin menuFon.jpg
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -133,7 +157,7 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:menuFon.jpg /build:menuFon.jpg
#begin menuFon2.jpg #begin MenuFon2.jpg
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255 /processorParam:ColorKeyColor=255,0,255,255
@ -143,7 +167,7 @@
/processorParam:ResizeToPowerOfTwo=False /processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False /processorParam:MakeSquare=False
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:menuFon2.jpg /build:MenuFon2.jpg
#begin menuFon3.jpg #begin menuFon3.jpg
/importer:TextureImporter /importer:TextureImporter
@ -236,8 +260,7 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:sliderBackground.png /build:sliderBackground.png
#begin SmokeAnimation2.png
#begin smokeAnimation2.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255 /processorParam:ColorKeyColor=255,0,255,255
@ -247,7 +270,13 @@
/processorParam:ResizeToPowerOfTwo=False /processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False /processorParam:MakeSquare=False
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:smokeAnimation2.png /build:SmokeAnimation2.png
#begin sounds/collected_coins.mp3
/importer:Mp3Importer
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/collected_coins.mp3
#begin sounds/DoomTestSong.mp3 #begin sounds/DoomTestSong.mp3
/importer:Mp3Importer /importer:Mp3Importer
@ -255,12 +284,36 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/DoomTestSong.mp3 /build:sounds/DoomTestSong.mp3
#begin sounds/reloading.mp3
/importer:Mp3Importer
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/reloading.mp3
#begin sounds/shotgun_shot.mp3 #begin sounds/shotgun_shot.mp3
/importer:Mp3Importer /importer:Mp3Importer
/processor:SoundEffectProcessor /processor:SoundEffectProcessor
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/shotgun_shot.mp3 /build:sounds/shotgun_shot.mp3
#begin sounds/StartGame.mp3
/importer:Mp3Importer
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/StartGame.mp3
#begin sounds/z1.mp3
/importer:Mp3Importer
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/z1.mp3
#begin sounds/z3.mp3
/importer:Mp3Importer
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/z3.mp3
#begin textboxbackground1-1.png #begin textboxbackground1-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -273,18 +326,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:textboxbackground1-1.png /build:textboxbackground1-1.png
#begin textboxbackground2-1.png
/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:textboxbackground2-1.png
#begin textboxbackground2,5-1.png #begin textboxbackground2,5-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -297,6 +338,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:textboxbackground2,5-1.png /build:textboxbackground2,5-1.png
#begin textboxbackground2-1.png
/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:textboxbackground2-1.png
#begin textboxbackground6-1.png #begin textboxbackground6-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -0,0 +1 @@
{"id":"Diamond","textureName":"Diamond","startSpriteRectangle":{"X":0,"Y":0,"Width":128,"Height":128},"frameSecond":[{"Item1":0,"Item2":15}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}

View file

@ -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"}

View file

@ -0,0 +1,20 @@
{
"id": "score100",
"textureName": "GetScore",
"startSpriteRectangle": {
"X": 0,
"Y": 0,
"Width": 32,
"Height": 32
},
"frameSecond": [
{
"Item1": 0,
"Item2": 10
}
],
"textureFrameInterval": 1,
"framesCount": 3,
"isCycle": false,
"offset": "1, 0"
}

View file

@ -0,0 +1,20 @@
{
"id": "score600",
"textureName": "GetScore",
"startSpriteRectangle": {
"X": 0,
"Y": 33,
"Width": 32,
"Height": 32
},
"frameSecond": [
{
"Item1": 0,
"Item2": 10
}
],
"textureFrameInterval": 1,
"framesCount": 3,
"isCycle": false,
"offset": "1, 0"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 KiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View file

@ -71,5 +71,10 @@
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>
<objectgroup id="6" name="Слой объектов 1" class="LivingEntities.Monsters.Ghost">
<object id="5" x="150" y="200">
<point/>
</object>
</objectgroup>
</map> </map>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -9,6 +9,7 @@ namespace DangerousD.GameCore.GUI;
internal class DeathGUI : AbstractGui internal class DeathGUI : AbstractGui
{ {
protected override void CreateUI() protected override void CreateUI()
{ {
int wigth = AppManager.Instance.inGameResolution.X; int wigth = AppManager.Instance.inGameResolution.X;
@ -23,6 +24,7 @@ internal class DeathGUI : AbstractGui
Elements.Add(butMenu); Elements.Add(butMenu);
butMenu.LeftButtonPressed += () => butMenu.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartSound("reloading", Vector2.Zero, Vector2.Zero);
AppManager.Instance.Restart("lvl"); AppManager.Instance.Restart("lvl");
}; };
foreach (var item in Elements) foreach (var item in Elements)
@ -40,6 +42,7 @@ internal class DeathGUI : AbstractGui
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
(Elements[2] as DrawableTextedUiElement).text = $"Score: {AppManager.Instance.GameManager.GetPlayer1.score}";
base.Update(gameTime); base.Update(gameTime);
} }
} }

View file

@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GUI
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
{ {
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()); /*var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
spriteBatch.Begin(); spriteBatch.Begin();
spriteBatch.DrawString( spriteBatch.DrawString(
_spriteFont, _spriteFont,
@ -52,7 +52,7 @@ namespace DangerousD.GameCore.GUI
SpriteEffects.None, SpriteEffects.None,
0 0
); );
spriteBatch.End(); spriteBatch.End();*/
} }
public void Set(string key, string value) public void Set(string key, string value)

View file

@ -44,6 +44,7 @@ namespace DangerousD.GameCore.GUI
Button backButton = new Button(Manager) Button backButton = new Button(Manager)
{ {
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)), rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)),
text = "<-",
fontColor = Color.Black, fontColor = Color.Black,
fontName = "font2", fontName = "font2",
textureName = "textboxbackground1-1" textureName = "textboxbackground1-1"

View file

@ -49,6 +49,7 @@ internal class MenuGUI : AbstractGui
Elements.Add(butSingle); Elements.Add(butSingle);
butSingle.LeftButtonPressed += () => butSingle.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartSound("StartGame", Vector2.Zero, Vector2.Zero);
AppManager.Instance.ChangeGameState(GameState.Game); AppManager.Instance.ChangeGameState(GameState.Game);
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer); AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
@ -59,6 +60,7 @@ internal class MenuGUI : AbstractGui
Elements.Add(butMulti); Elements.Add(butMulti);
butMulti.LeftButtonPressed += () => butMulti.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartSound("reloading", Vector2.Zero, Vector2.Zero);
AppManager.Instance.ChangeGameState(GameState.Login); AppManager.Instance.ChangeGameState(GameState.Login);
}; };
var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(160 * 2.4)) / 2, 590, (int)(160 * 2.4), (int)(50 * 2.4)), text = "Option", scale = 1.2f, fontName = "ButtonFont" }; var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(160 * 2.4)) / 2, 590, (int)(160 * 2.4), (int)(50 * 2.4)), text = "Option", scale = 1.2f, fontName = "ButtonFont" };
@ -66,12 +68,14 @@ internal class MenuGUI : AbstractGui
butOption.LeftButtonPressed += () => butOption.LeftButtonPressed += () =>
{ {
// открытие настроек // открытие настроек
AppManager.Instance.SoundManager.StartSound("reloading", Vector2.Zero, Vector2.Zero);
AppManager.Instance.ChangeGameState(GameState.Options); AppManager.Instance.ChangeGameState(GameState.Options);
}; };
var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(110 * 2.4)) / 2, 710, (int)(110 * 2.4), (int)(50 * 2.4)), text = "Exit", scale = 1.2f, fontName = "ButtonFont" }; var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(110 * 2.4)) / 2, 710, (int)(110 * 2.4), (int)(50 * 2.4)), text = "Exit", scale = 1.2f, fontName = "ButtonFont" };
Elements.Add(butExit); Elements.Add(butExit);
butExit.LeftButtonPressed += () => butExit.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartSound("reloading", Vector2.Zero, Vector2.Zero);
AppManager.Instance.Exit(); AppManager.Instance.Exit();
}; };

View file

@ -66,7 +66,7 @@ namespace DangerousD.GameCore.GUI
Elements.Add(lblSwitchMode); Elements.Add(lblSwitchMode);
Button bTExit = new Button(Manager) Button bTExit = new Button(Manager)
{ fontName = "Font2", scale = 0.72f, text = "<-", rectangle = new Rectangle(wigth / 30, height / 30, (int)(40 * 2.4), (int)(40 * 2.4)), textureName = "textboxbackground1-1" }; { fontName = "Font2", text = "<-", rectangle = new Rectangle(wigth / 30, height / 30, (int)(40 * 2.4), (int)(40 * 2.4)), textureName = "textboxbackground1-1" };
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {

View file

@ -7,13 +7,14 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using DangerousD.GameCore.GameObjects.Entities.Items;
namespace DangerousD.GameCore.GameObjects.Entities namespace DangerousD.GameCore.GameObjects.Entities
{ {
public class Door : Entity public class Door : Entity
{ {
private Rectangle _sourceRectangle; private Rectangle _sourceRectangle;
Random random = new Random();
public Door(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position) public Door(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position)
{ {
_sourceRectangle = sourceRectangle; _sourceRectangle = sourceRectangle;
@ -46,6 +47,11 @@ namespace DangerousD.GameCore.GameObjects.Entities
{ {
AppManager.Instance.GameManager.Remove(this); AppManager.Instance.GameManager.Remove(this);
//тут спавн лута //тут спавн лута
for (int i = 0; i < random.Next(0,15); i++)
{
var d = new Diamond(Vector2.Zero);
d.SetPosition(Pos + new Vector2(random.Next(-30, 30), Height - d.Height));
}
} }
} }
} }

View file

@ -1,13 +1,32 @@
using DangerousD.GameCore.GameObjects.LivingEntities;
using DangerousD.GameCore.Graphics; using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using static System.Formats.Asn1.AsnWriter;
namespace DangerousD.GameCore.GameObjects.Entities.Items; namespace DangerousD.GameCore.GameObjects.Entities.Items;
public class Diamond : Entity public class Diamond : Entity
{ {
Random random = new Random();
public Diamond(Vector2 position) : base(position) public Diamond(Vector2 position) : base(position)
{ {
int scal = random.Next(3, 12);
Width = scal;
Height = scal;
GraphicsComponent.StartAnimation("Diamond");
} }
protected override GraphicsComponent GraphicsComponent { get; } protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List<string>() { "Diamond" }, "Diamond");
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
AppManager.Instance.GameManager.Remove(this);
new ScoreText(Pos, ScoreText.scores[random.Next(0, ScoreText.scores.Length)]);
AppManager.Instance.SoundManager.StartSound("collected_coins", Pos, Pos);
}
base.OnCollision(gameObject);
}
} }

View file

@ -0,0 +1,35 @@
using DangerousD.GameCore.GameObjects.LivingEntities;
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.Items
{
internal class ScoreText : Entity
{
public static int[] scores = new int[] { 100, 600};
public ScoreText(Vector2 position, int score) : base(position)
{
Width = 32;
Height = 32;
GraphicsComponent.StartAnimation("score"+ score);
AppManager.Instance.GameManager.GetPlayer1.score += score;
GraphicsComponent.actionOfAnimationEnd += (a) => { AppManager.Instance.GameManager.Remove(this); };
}
public override void Initialize()
{
}
public override void Update(GameTime gameTime)
{
_pos.Y -= 1.0f;
base.Update(gameTime);
}
protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List<string>() { "score100", "score600" }, "score100");
}
}

View file

@ -17,6 +17,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private bool isFlyRight = true; private bool isFlyRight = true;
private bool isFlyUp = true; private bool isFlyUp = true;
private bool isAttacking = false; private bool isAttacking = false;
private int hp;
public Rectangle Collision public Rectangle Collision
{ {
@ -32,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
monster_speed = 3; monster_speed = 3;
velocity = new Vector2(3,-3); velocity = new Vector2(3,-3);
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
hp = 10;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
@ -39,7 +41,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
Move(gameTime); Move(gameTime);
AppManager.Instance.DebugHUD.Set(name, velocity.ToString());
Death();
base.Update(gameTime); base.Update(gameTime);
} }
public override void Attack() public override void Attack()
@ -60,7 +64,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death() public override void Death()
{ {
if (hp <= 0)
{
AppManager.Instance.GameManager.Remove(this);
}
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
@ -75,6 +82,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isFlyRight = false; isFlyRight = false;
velocity.X = -velocity.X; velocity.X = -velocity.X;
hp--;
} }
} }
else else
@ -84,6 +92,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isFlyRight = true; isFlyRight = true;
velocity.X = -velocity.X; velocity.X = -velocity.X;
hp--;
} }
} }
if (isFlyUp) if (isFlyUp)
@ -94,6 +103,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isFlyUp = false; isFlyUp = false;
velocity.Y = -velocity.Y; velocity.Y = -velocity.Y;
hp--;
} }
} }
else else
@ -103,6 +113,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isFlyUp = true; isFlyUp = true;
velocity.Y = -velocity.Y; velocity.Y = -velocity.Y;
hp--;
} }
} }

View file

@ -17,11 +17,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isGoRight = true; isGoRight = true;
monster_speed = 3; monster_speed = 3;
name = "Ghost"; name = "Ghost";
Width = 48; Width = 24;
Height = 62; Height = 30;
GraphicsComponent.StartAnimation("GhostSpawn"); GraphicsComponent.StartAnimation("GhostSpawn");
acceleration = Vector2.Zero; acceleration = new Vector2(0,1);
monster_health = 1;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "GhostMoveRight", "GhostMoveLeft", "GhostSpawn", "GhostAttack" }, "GhostMoveRight");
@ -38,13 +38,32 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack() 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 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) public override void Move(GameTime gameTime)
{ {
@ -64,17 +83,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
velocity.X = -monster_speed; 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,10 +108,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
} }
public void TakeDamage()
{
monster_health--;
if (monster_health <= 0)
{
Death();
}
}
public override void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -174,6 +174,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death() public override void Death()
{ {
Particle particle = new Particle(Pos);
AppManager.Instance.GameManager.Remove(this);
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
@ -220,7 +224,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
velocity.X = -monster_speed; 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) if (isGoRight)
{ {
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 51, 2)); 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); base.OnCollision(gameObject);
} }
public void TakeDamage()
{
monster_health--;
Particle particle = new Particle(Pos);
if (monster_health <= 0)
{
Death();
}
}
} }
} }

View file

@ -12,25 +12,34 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public class Werewolf : CoreEnemy public class Werewolf : CoreEnemy
{ {
private bool isAttack; private bool isJump;
int delay;
public Werewolf(Vector2 position) : base(position) public Werewolf(Vector2 position) : base(position)
{ {
name = "Wolf"; name = "Wolf";
monster_speed = 4; monster_speed = 3;
Width = 39; Width = 39;
Height = 48; Height = 48;
delay = 10;
monster_health = 3;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "WolfMoveRight", "WolfMoveLeft", "WolfJumpRight", "WolfJumpLeft" }, "WolfMoveRight");
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (!isAttack) if(!isJump )
{
Jump();
}
if(isOnGround)
{ {
Move(gameTime); Move(gameTime);
} }
base.Update(gameTime); base.Update(gameTime);
} }
@ -41,11 +50,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death() 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) public override void Move(GameTime gameTime)
{ {
isJump = false;
if (isGoRight) if (isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight") if (GraphicsComponent.GetCurrentAnimation != "WolfMoveRight")
@ -62,13 +78,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
velocity.X = -monster_speed; 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;
}
} }
} }
@ -76,9 +103,65 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
} }
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 TakeDamage()
{
monster_health--;
Particle particle = new Particle(Pos);
if (monster_health <= 0)
{
Death();
}
}
public override void Target() public override void Target()
{ {
} }
} }
} }

View file

@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public class Zombie : CoreEnemy public class Zombie : CoreEnemy
{ {
private bool isAttack;
float leftBorder; float leftBorder;
float rightBorder; float rightBorder;
@ -59,18 +58,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Target(); Target();
Move(gameTime); Move(gameTime);
} }
fixBorder(); //fixBorder();
base.Update(gameTime); base.Update(gameTime);
} }
public override void Attack() public override void Attack()
{ {
AppManager.Instance.GameManager.GetPlayer1.Death(name); isAttaking = true;
PlayAttackAnimation();
AppManager.Instance.GameManager.GetClosestPlayer(Pos).Death(name);
} }
public void PlayAttackAnimation() public void PlayAttackAnimation()
{ {
velocity.X = 0; velocity.X = 0;
isAttaking = true;
if (isGoRight) if (isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack") if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
@ -124,7 +124,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void OnCollision(GameObject gameObject) public override void OnCollision(GameObject gameObject)
{ {
if (gameObject.id == AppManager.Instance.GameManager.GetPlayer1.id && AppManager.Instance.GameManager.GetPlayer1.IsAlive) if (gameObject.id == AppManager.Instance.GameManager.GetClosestPlayer(Pos).id && AppManager.Instance.GameManager.GetClosestPlayer(Pos).IsAlive)
{ {
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client)
{ {
@ -186,6 +186,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void TakeDamage() public override void TakeDamage()
{ {
if (monster_health == 3)
AppManager.Instance.SoundManager.StartSound("z3", Pos, Pos);
if (monster_health == 2)
AppManager.Instance.SoundManager.StartSound("z1", Pos, Pos);
if (monster_health == 1)
AppManager.Instance.SoundManager.StartSound("z3", Pos, Pos);
monster_health--; monster_health--;
Particle particle = new Particle(Pos); Particle particle = new Particle(Pos);
if (monster_health <= 0) if (monster_health <= 0)

View file

@ -33,6 +33,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public bool isUping = false; public bool isUping = false;
public bool isNetworkPlayer; public bool isNetworkPlayer;
private int shootLength = 160; private int shootLength = 160;
public int score = 0;
@ -186,6 +187,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
if (!isShooting) if (!isShooting)
{ {
AppManager.Instance.SoundManager.StartSound("shotgun_shot", Pos, Pos);
isShooting = true; isShooting = true;
bullets--; bullets--;
if (isRight) if (isRight)
@ -195,7 +197,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
StartCicycleAnimation("playerShootRight"); StartCicycleAnimation("playerShootRight");
Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y));
bullet.ShootRight(); bullet.ShootRight();
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
} }
else else
{ {
@ -212,7 +214,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
StartCicycleAnimation("playerShootBoomUpLeft"); StartCicycleAnimation("playerShootBoomUpLeft");
Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y));
bullet.ShootLeft(); bullet.ShootLeft();
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
} }
else else
{ {
@ -298,6 +300,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
if (GraphicsComponent.GetCurrentAnimation != "playerReload") if (GraphicsComponent.GetCurrentAnimation != "playerReload")
{ {
GraphicsComponent.StartAnimation("playerReload"); GraphicsComponent.StartAnimation("playerReload");
AppManager.Instance.SoundManager.StartSound("reloading", Pos,Pos);
} }
} }
else else
@ -342,9 +345,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
Height = 5; Height = 5;
Width = 5; Width = 5;
} }
int time = 0;
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft" }, "playerMoveLeft"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft" }, "playerMoveLeft");
Vector2 direction; Vector2 direction;
Vector2 maindirection; public Vector2 maindirection;
public void ShootUpRight() public void ShootUpRight()
{ {
direction = new Vector2(1, -1); direction = new Vector2(1, -1);
@ -412,10 +416,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (maindirection != velocity)
{
AppManager.Instance.GameManager.Remove(this);
}
base.Update(gameTime); base.Update(gameTime);
} }
} }

View file

@ -241,6 +241,7 @@ namespace DangerousD.GameCore
Player.Bullet bullet = new Player.Bullet(networkTask.position); Player.Bullet bullet = new Player.Bullet(networkTask.position);
bullet.id = networkTask.objId; bullet.id = networkTask.objId;
bullet.velocity = networkTask.velocity; bullet.velocity = networkTask.velocity;
bullet.maindirection = bullet.velocity;
} }
break; break;
case NetworkTaskOperationEnum.SendPosition: case NetworkTaskOperationEnum.SendPosition:

View file

@ -148,8 +148,10 @@ namespace DangerousD.GameCore
item.Update(gameTime); item.Update(gameTime);
foreach (var item in mapObjects) foreach (var item in mapObjects)
item.Update(gameTime); item.Update(gameTime);
foreach (var item in entities) for (int i = 0; i < entities.Count; i++)
item.Update(gameTime); {
entities[i].Update(gameTime);
}
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client)
{ {
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++) for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
@ -172,7 +174,7 @@ namespace DangerousD.GameCore
} }
} }
GetPlayer1.Update(gameTime); GetPlayer1.Update(gameTime);
for(int i = 0; i < otherObjects.Count; i++) for (int i = 0; i < otherObjects.Count; i++)
{ {
otherObjects[i].Update(gameTime); otherObjects[i].Update(gameTime);
} }
@ -183,7 +185,7 @@ namespace DangerousD.GameCore
{ {
foreach (var item in GetAllGameObjects) foreach (var item in GetAllGameObjects)
{ {
if (item.Pos.X<CameraBorder.X) if (item.Pos.X < CameraBorder.X)
{ {
CameraBorder.X = item.Pos.X; CameraBorder.X = item.Pos.X;
} }
@ -201,5 +203,10 @@ namespace DangerousD.GameCore
} }
} }
} }
public Player GetClosestPlayer(Vector2 position)
{
return players.OrderBy(x => (x.Pos - position).Length()).First();
}
} }
} }

View file

@ -13,7 +13,7 @@ namespace DangerousD.GameCore
{ {
public class SoundManager public class SoundManager
{ {
public Dictionary<string, SoundEffectInstance> Sounds = new Dictionary<string, SoundEffectInstance>(); // словарь со звуками где строка - название файла public Dictionary<string, SoundEffect> Sounds = new Dictionary<string, SoundEffect>(); // словарь со звуками где строка - название файла
public List<Sound> PlayingSounds = new List<Sound>(); // список со всеми звуками, которые проигрываются public List<Sound> PlayingSounds = new List<Sound>(); // список со всеми звуками, которые проигрываются
public float MaxSoundDistance = 1500; // максимальная дальность звука public float MaxSoundDistance = 1500; // максимальная дальность звука
@ -27,7 +27,7 @@ namespace DangerousD.GameCore
string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
foreach (var soundFile in soundFiles) foreach (var soundFile in soundFiles)
{ {
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds//" + soundFile).CreateInstance()); Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds//" + soundFile));
} }
} }
@ -40,7 +40,7 @@ namespace DangerousD.GameCore
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
{ {
var sound = new Sound(Sounds[soundName]); var sound = new Sound(Sounds[soundName].CreateInstance());
sound.SoundEffect.IsLooped = false; sound.SoundEffect.IsLooped = false;
sound.SoundEffect.Play(); sound.SoundEffect.Play();
PlayingSounds.Add(sound); PlayingSounds.Add(sound);
@ -51,7 +51,7 @@ namespace DangerousD.GameCore
} }
public void StartSound(string soundName, Vector2 soundPos, Vector2 playerPos) // запустить звук у которого есть позиция public void StartSound(string soundName, Vector2 soundPos, Vector2 playerPos) // запустить звук у которого есть позиция
{ {
var sound = new Sound(Sounds[soundName], soundPos); var sound = new Sound(Sounds[soundName].CreateInstance(), soundPos);
sound.SoundEffect.IsLooped = false; sound.SoundEffect.IsLooped = false;
sound.SoundEffect.Volume = (float)(MaxSoundDistance-sound.GetDistance(playerPos)) / MaxSoundDistance; sound.SoundEffect.Volume = (float)(MaxSoundDistance-sound.GetDistance(playerPos)) / MaxSoundDistance;
sound.SoundEffect.Play(); sound.SoundEffect.Play();
@ -71,7 +71,7 @@ namespace DangerousD.GameCore
public void Update() // апдейт, тут происходит изменение громкости public void Update() // апдейт, тут происходит изменение громкости
{ {
return;
var player = AppManager.Instance.GameManager.GetPlayer1; var player = AppManager.Instance.GameManager.GetPlayer1;
if (player != null) if (player != null)