Merge branch 'main' into FrankBalls

This commit is contained in:
Kaktus200020 2023-08-18 18:17:10 +03:00
commit 7c526a8e11
38 changed files with 593 additions and 120 deletions

View file

@ -140,7 +140,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
@ -150,7 +150,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
@ -255,7 +255,7 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/shotgun_shot.mp3 /build:sounds/shotgun_shot.mp3
#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
@ -265,7 +265,7 @@
/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 textboxbackground1-1.png #begin textboxbackground1-1.png
/importer:TextureImporter /importer:TextureImporter

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="Door" tilewidth="32" tileheight="48" tilecount="2" columns="2"> <tileset version="1.10" tiledversion="1.10.2" name="Door" tilewidth="32" tileheight="48" tilecount="2" columns="2">
<image source="door.png" width="64" height="48"/> <image source="doors.png" width="64" height="48"/>
</tileset> </tileset>

View file

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="left-up" width="30" height="20" tilewidth="16" tileheight="16" infinite="1" nextlayerid="7" nextobjectid="5">
<tileset firstgid="1" source="map.tsx"/>
<layer id="2" name="Platform" class="StopTile" width="30" height="20">
<data encoding="csv">
<chunk x="-32" y="0" width="16" height="16">
410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
410,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="-16" y="0" width="16" height="16">
410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,410,0,0
</chunk>
<chunk x="-32" y="16" width="16" height="16">
410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="-16" y="16" width="16" height="16">
410,410,410,410,410,410,410,410,410,410,410,410,410,410,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
</data>
</layer>
<layer id="3" name="BackGround" class="Tile" width="30" height="20">
<data encoding="csv">
<chunk x="-32" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,376,375,369,370,388,389,726,390,369,370,376,389,376,388,726,
0,376,389,369,370,390,726,388,388,369,370,390,726,388,389,389,
0,388,726,369,370,390,377,375,377,369,370,431,389,389,431,431,
0,389,431,369,370,377,377,389,388,369,370,431,389,375,375,431,
0,377,377,369,370,390,376,389,431,369,370,375,375,726,388,390,
0,388,431,369,370,388,390,376,726,369,370,375,377,376,388,377,
0,388,375,369,370,376,375,377,388,369,370,376,375,389,388,431,
0,390,726,369,370,377,431,431,388,369,370,389,390,390,376,377,
0,377,376,369,370,389,377,431,376,369,370,389,431,726,431,388,
0,377,431,369,370,375,390,390,377,369,370,375,377,389,388,376,
0,390,390,369,370,431,376,389,390,369,370,390,431,376,389,390,
0,431,377,369,370,376,390,388,388,369,370,377,375,390,389,377,
0,390,726,369,370,375,377,726,390,369,370,389,376,388,388,375,
0,390,389,382,383,388,377,388,390,382,383,431,726,390,388,431,
0,389,377,395,396,389,431,377,431,395,396,375,388,726,376,389
</chunk>
<chunk x="-16" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
389,388,375,369,370,388,377,389,389,369,370,390,375,0,0,0,
390,388,726,369,370,375,726,376,726,369,370,388,375,0,0,0,
388,389,431,369,370,726,377,726,431,369,370,377,375,0,0,0,
388,376,431,369,370,377,375,726,726,369,370,431,376,0,0,0,
376,389,388,369,370,377,390,431,389,369,370,376,431,0,0,0,
389,388,389,369,370,376,726,390,377,369,370,389,377,0,0,0,
431,377,389,369,370,431,726,726,389,369,370,431,390,0,0,0,
390,389,377,369,370,390,390,376,431,369,370,390,376,0,0,0,
388,388,377,369,370,388,431,390,388,369,370,389,377,0,0,0,
388,389,390,369,370,726,377,377,388,369,370,390,390,0,0,0,
388,376,390,369,370,377,377,389,726,369,370,375,726,0,0,0,
431,726,390,369,370,375,431,377,726,369,370,389,389,0,0,0,
390,388,726,369,370,389,375,390,388,369,370,377,726,0,0,0,
375,375,375,382,383,376,390,726,388,382,383,431,726,0,0,0,
389,389,390,395,396,390,390,726,390,395,396,431,390,0,0,0
</chunk>
</data>
</layer>
<objectgroup id="5" name="SilasMaster" class="LivingEntities.Monsters.SilasMaster">
<object id="1" x="-279.333" y="121.333">
<point/>
</object>
</objectgroup>
<objectgroup id="6" name="player" class="LivingEntities.Player">
<object id="3" x="-329.333" y="111.333">
<point/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1 @@
{"id":"DeathFromGhost","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":246,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"DeathFromHunchman","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"DeathFromSilasHand","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":295,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"DeathFromSilasMaster","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":295,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"DeathFromSlime","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":50,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"DeathFromSpider","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":148,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"DeathFromWerewolf","textureName":"deathAnimation","startSpriteRectangle":{"X":1,"Y":197,"Width":48,"Height":48},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":5,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"playerShootBoomUpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":267,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":2,"isCycle":false,"offset":"0, 0"}

View file

@ -0,0 +1,24 @@
{
"id": "playerShootBoomUpRight",
"textureName": "playerAnimation",
"startSpriteRectangle": {
"X": 267,
"Y": 1,
"Width": 24,
"Height": 32
},
"frameSecond": [
{
"Item1": 0,
"Item2": 3
},
{
"Item1": 1,
"Item2": 20
}
],
"textureFrameInterval": 1,
"framesCount": 2,
"isCycle": false,
"offset": "0, 0"
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="left-up" width="30" height="20" tilewidth="16" tileheight="16" infinite="1" nextlayerid="15" nextobjectid="80"> <map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="left-up" width="30" height="20" tilewidth="16" tileheight="16" infinite="1" nextlayerid="18" nextobjectid="105">
<tileset firstgid="1" name="map" tilewidth="16" tileheight="16" tilecount="871" columns="13"> <tileset firstgid="1" name="map" tilewidth="16" tileheight="16" tilecount="871" columns="13">
<image source="tiles.BMP" width="208" height="1072"/> <image source="tiles.BMP" width="208" height="1072"/>
</tileset> </tileset>
@ -683,7 +683,7 @@
<object id="36" x="70" y="181"> <object id="36" x="70" y="181">
<point/> <point/>
</object> </object>
<object id="37" x="20" y="87"> <object id="37" x="39.3333" y="87.6667">
<point/> <point/>
</object> </object>
<object id="38" x="99.5" y="84.5"> <object id="38" x="99.5" y="84.5">
@ -698,13 +698,47 @@
<object id="41" x="582" y="83"> <object id="41" x="582" y="83">
<point/> <point/>
</object> </object>
<object id="80" x="-139.333" y="84">
<point/>
</object>
<object id="81" x="620.667" y="180">
<point/>
</object>
<object id="103" x="-96.6667" y="270">
<point/>
</object>
<object id="104" x="693.333" y="477.333">
<point/>
</object>
</objectgroup>
<objectgroup id="15" name="Monster" class="LivingEntities.Monsters">
<object id="82" type="FlameSkull" x="68.6667" y="279.333">
<point/>
</object>
<object id="97" type="Werewolf" x="536" y="88.6667">
<point/>
</object>
</objectgroup>
<objectgroup id="17" name="Hunchman" class="LivingEntities.Monsters.Hunchman">
<object id="98" x="-92" y="144">
<point/>
</object>
<object id="99" x="115.333" y="182">
<point/>
</object>
<object id="100" x="191.333" y="277.333">
<point/>
</object>
<object id="101" x="249.333" y="88.6667">
<point/>
</object>
</objectgroup> </objectgroup>
<objectgroup id="10" name="Player" class="LivingEntities.Player"> <objectgroup id="10" name="Player" class="LivingEntities.Player">
<object id="47" x="-500" y="461.333"> <object id="47" x="-500" y="461.333">
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>
<objectgroup id="12" name="Doors" class="Entities.Door"> <objectgroup id="12" name="Doors" class="Entities.Door" visible="0">
<object id="69" gid="873" x="640" y="64" width="32" height="48"/> <object id="69" gid="873" x="640" y="64" width="32" height="48"/>
<object id="70" gid="872" x="672" y="192" width="32" height="48"/> <object id="70" gid="872" x="672" y="192" width="32" height="48"/>
<object id="71" gid="872" x="672" y="288" width="32" height="48"/> <object id="71" gid="872" x="672" y="288" width="32" height="48"/>

View file

Before

Width:  |  Height:  |  Size: 464 KiB

After

Width:  |  Height:  |  Size: 464 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -13,7 +13,7 @@ internal class DeathGUI : AbstractGui
{ {
int wigth = AppManager.Instance.inGameResolution.X; int wigth = AppManager.Instance.inGameResolution.X;
int height = AppManager.Instance.inGameResolution.Y; int height = AppManager.Instance.inGameResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" }; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" };
Elements.Add(menuBackground); Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);
@ -23,7 +23,7 @@ internal class DeathGUI : AbstractGui
Elements.Add(butMenu); Elements.Add(butMenu);
butMenu.LeftButtonPressed += () => butMenu.LeftButtonPressed += () =>
{ {
AppManager.Instance.ChangeGameState(GameState.Menu); AppManager.Instance.Restart("lvl");
}; };
foreach (var item in Elements) foreach (var item in Elements)
{ {

View file

@ -16,22 +16,26 @@ namespace DangerousD.GameCore.GUI
{ {
int wigth = AppManager.Instance.inGameResolution.X; int wigth = AppManager.Instance.inGameResolution.X;
int height = AppManager.Instance.inGameResolution.Y; int height = AppManager.Instance.inGameResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
Texture2D texture; Texture2D texture;
SpriteFont spriteFont; SpriteFont spriteFont;
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
{ {
spriteBatch.Begin(); spriteBatch.Begin();
spriteBatch.Draw(texture, new Rectangle(wigth / 35 - 2, height / 35 - 2, 120 + 2, 70 + 2), Color.DarkRed); spriteBatch.Draw(texture, new Rectangle(
spriteBatch.DrawString(spriteFont, "AMMO", new Vector2(wigth / 34 + 4, height / 30 - 6), Color.Gray, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0); (int)((wigth / 35 - 2) * scaler),
spriteBatch.DrawString(spriteFont, "AMMO", new Vector2(wigth / 34 + 1, height / 30 - 6), Color.White, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0); (int)((height / 35 - 2) * scaler),
(int)((120 + 2) * scaler),
(int)((70 + 2) * scaler)), Color.DarkRed);
spriteBatch.DrawString(spriteFont, "AMMO", new Vector2((wigth / 34 + 4)* scaler, height / 30 - 6), Color.Gray, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0);
spriteBatch.DrawString(spriteFont, "AMMO", new Vector2((wigth / 34 + 1 )* scaler, height / 30 - 6), Color.White, 0, Vector2.Zero, 1.8f, SpriteEffects.None, 0);
for (int i = 1; i < 6; i++) for (int i = 1; i < 6; i++)
{ {
if (i <= AppManager.Instance.GameManager.players[0].Bullets) if (i <= AppManager.Instance.GameManager.players[0].Bullets)
{ {
spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13 + 2, height / 17 + 4, 5, 20), new Color(0.8f, 0.8f, 0, 1f)); spriteBatch.Draw(texture, new Rectangle((int)((wigth / 30 + i * 13 + 2) * scaler), (int)((height / 17 + 4) * scaler), (int)((5) * scaler), (int)((20) * scaler)), new Color(0.8f, 0.8f, 0, 1f));
spriteBatch.Draw(texture, new Rectangle(wigth / 30 + i * 13, height / 17 + 4, 5, 20), Color.Yellow); spriteBatch.Draw(texture, new Rectangle((int)((wigth / 30 + i * 13) * scaler), (int)((height / 17 + 4) * scaler), (int)((5) * scaler), (int)((20) * scaler)), Color.Yellow);
} }
else else
{ {

View file

@ -25,7 +25,7 @@ namespace DangerousD.GameCore.GUI
{ {
int screenWidth = AppManager.Instance.inGameResolution.X; int screenWidth = AppManager.Instance.inGameResolution.X;
int screenHeight = AppManager.Instance.inGameResolution.Y; int screenHeight = AppManager.Instance.inGameResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
var lobbyBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon3" }; var lobbyBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon3" };
Elements.Add(lobbyBackground); Elements.Add(lobbyBackground);

View file

@ -26,7 +26,7 @@ namespace DangerousD.GameCore.GUI
{ {
int screenWidth = AppManager.Instance.inGameResolution.X; int screenWidth = AppManager.Instance.inGameResolution.X;
int screenHeight = AppManager.Instance.inGameResolution.Y; int screenHeight = AppManager.Instance.inGameResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
var loginBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon2" }; var loginBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon2" };
Elements.Add(loginBackground); Elements.Add(loginBackground);

View file

@ -24,7 +24,7 @@ internal class MenuGUI : AbstractGui
{ {
int wigth = AppManager.Instance.inGameHUDHelperResolution.X; int wigth = AppManager.Instance.inGameHUDHelperResolution.X;
int height = AppManager.Instance.inGameHUDHelperResolution.Y; int height = AppManager.Instance.inGameHUDHelperResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" }; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" };
Elements.Add(menuBackground); Elements.Add(menuBackground);

View file

@ -15,7 +15,7 @@ namespace DangerousD.GameCore.GUI
{ {
int wigth = AppManager.Instance.inGameHUDHelperResolution.X; int wigth = AppManager.Instance.inGameHUDHelperResolution.X;
int height = AppManager.Instance.inGameHUDHelperResolution.Y; int height = AppManager.Instance.inGameHUDHelperResolution.Y;
float scaler = AppManager.Instance.resolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y; float scaler = AppManager.Instance.inGameResolution.Y / (float)AppManager.Instance.inGameHUDHelperResolution.Y;
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" }; var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" };
//Elements.Add(menuBackground); //Elements.Add(menuBackground);
menuBackground.LoadTexture(AppManager.Instance.Content); menuBackground.LoadTexture(AppManager.Instance.Content);

View file

@ -37,6 +37,8 @@ namespace DangerousD.GameCore.GameObjects.Entities
public override void OnCollision(GameObject gameObject) public override void OnCollision(GameObject gameObject)
{ {
base.OnCollision(gameObject); base.OnCollision(gameObject);
if (this is not TeleportingDoor)
{
if (gameObject is Player) if (gameObject is Player)
{ {
Player player = (Player)gameObject; Player player = (Player)gameObject;
@ -47,5 +49,7 @@ namespace DangerousD.GameCore.GameObjects.Entities
} }
} }
} }
}
} }
} }

View file

@ -1,4 +1,5 @@
using DangerousD.GameCore.Graphics; using DangerousD.GameCore.GameObjects.LivingEntities;
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
@ -14,11 +15,14 @@ namespace DangerousD.GameCore.GameObjects.Entities
{ {
private Vector2 v; private Vector2 v;
public string name;
public SilasBall(Vector2 position) : base(position) public SilasBall(Vector2 position) : base(position)
{ {
Height = 24; Height = 24;
Width = 24; Width = 24;
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
name = "SilasHand";
} }
public SilasBall(Vector2 position, Vector2 velosity) : base(position) public SilasBall(Vector2 position, Vector2 velosity) : base(position)
@ -28,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.Entities
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
velocity = velosity; velocity = velosity;
v = velosity; v = velosity;
name = "SilasHand";
} }
@ -48,5 +53,21 @@ namespace DangerousD.GameCore.GameObjects.Entities
} }
public void Attack()
{
AppManager.Instance.GameManager.GetPlayer1.Death(name);
}
public override void OnCollision(GameObject gameObject)
{
base.OnCollision(gameObject);
if (gameObject is Player)
{
if (AppManager.Instance.GameManager.players[0].IsAlive)
{
Attack();
}
}
}
} }
} }

View file

@ -0,0 +1,54 @@
using DangerousD.GameCore.GameObjects.LivingEntities;
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
{
internal class TeleportingDoor : Door
{
public Vector2 Target;
public bool IsVisible = true;
public Action action;
public TeleportingDoor(Vector2 position, Vector2 size, Rectangle sourceRectangle, Vector2 target, Action action) : base(position, size, sourceRectangle)
{
Target = target;
this.action = action;
}
public override void OnCollision(GameObject gameObject)
{
if (IsVisible)
{
if (gameObject is Player)
{
Player player = (Player)gameObject;
if (player.isUping)
{
IsVisible = false;
}
}
}
else
{
if (gameObject is Player)
{
Player player = (Player)gameObject;
if (player.isUping)
{
player.SetPosition(Target);
if (action!=null)
{
action();
}
}
}
}
}
}
}

View file

@ -15,6 +15,7 @@ namespace DangerousD.GameCore
protected Vector2 _pos; protected Vector2 _pos;
public Vector2 Pos => _pos; public Vector2 Pos => _pos;
public int id; public int id;
public bool isChildEntity = false;
public bool isIdFromHost = false; public bool isIdFromHost = false;
public int Width { get; set; } public int Width { get; set; }
public int Height { get; set; } public int Height { get; set; }
@ -63,9 +64,7 @@ namespace DangerousD.GameCore
if (AppManager.Instance.InputManager.CollisionsCheat) if (AppManager.Instance.InputManager.CollisionsCheat)
{ {
spriteBatch.Draw(debugTexture, spriteBatch.Draw(debugTexture,
new Rectangle(Rectangle.X - GraphicsComponent.CameraPosition.X, new Rectangle((Rectangle.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling, (Rectangle.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling, Rectangle.Width * GraphicsComponent.scaling, Rectangle.Height * GraphicsComponent.scaling),Color.White);
Rectangle.Y - GraphicsComponent.CameraPosition.Y, Rectangle.Width, Rectangle.Height),
Color.White);
} }
} }

View file

@ -36,9 +36,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract void Move(GameTime gameTime); public abstract void Move(GameTime gameTime);
public void TakeDamage(int damage) public virtual void TakeDamage()
{ {
monster_health -= damage; monster_health--;
if (monster_health <= 0) if (monster_health <= 0)
{ {
Death(); Death();

View file

@ -19,7 +19,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Width = 16; Width = 16;
Height = 16; Height = 16;
monster_health = 2; monster_health = 2;
monster_speed = 2; monster_speed = 1;
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
} }
@ -28,7 +28,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack() public override void Attack()
{ {
AppManager.Instance.GameManager.GetPlayer1.Death(name);
} }
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
@ -38,7 +38,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death() public override void Death()
{ {
throw new NotImplementedException(); for (int i = 0; i < 3; i++)
{
Particle particle = new Particle(Pos);
}
AppManager.Instance.GameManager.Remove(this);
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
@ -71,12 +77,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
base.Update(gameTime); base.Update(gameTime);
Move(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))
{
AppManager.Instance.GameManager.GetPlayer1.Death(name);
}
GraphicsComponent.Update(); GraphicsComponent.Update();
} }
public void TakeDamage()
{
monster_health--;
GraphicsComponent.StartAnimation("SilasHandMove");
Particle particle = new Particle(Pos);
if (monster_health <= 0)
{
Death();
}
}
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
if (AppManager.Instance.GameManager.players[0].IsAlive)
{
Attack();
}
}
base.OnCollision(gameObject);
}
} }
} }

View file

@ -16,6 +16,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private int attackTime = 60; private int attackTime = 60;
private int moveTime = 360; private int moveTime = 360;
private int currentTime = 0; private int currentTime = 0;
private int interval = 0;
int leftBorder; int leftBorder;
int rightBorder; int rightBorder;
List<SilasHands> hands = new List<SilasHands>(); List<SilasHands> hands = new List<SilasHands>();
@ -119,9 +120,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
base.Update(gameTime); base.Update(gameTime);
for (int i = 0; i < hands.Count; i++)
{
if (!AppManager.Instance.GameManager.GetAllGameObjects.Contains(hands[i]))
{
hands.RemoveAt(i);
}
}
if (hands.Count<2) if (hands.Count<2)
{ {
hands.Add(new SilasHands(new Vector2(Pos.X + 60, Pos.Y + 120))); hands.Add(new SilasHands(new Vector2(Pos.X + 30, Pos.Y + 30)));
} }
if (GraphicsComponent.CurrentAnimation.Id == "SilasMove") if (GraphicsComponent.CurrentAnimation.Id == "SilasMove")
{ {

View file

@ -8,13 +8,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DangerousD.GameCore.Managers; using DangerousD.GameCore.Managers;
using DangerousD.GameCore.GameObjects; using DangerousD.GameCore.Network;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters 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;
@ -32,6 +31,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = (int)position.X + 100; rightBorder = (int)position.X + 100;
physicsManager = new PhysicsManager(); physicsManager = new PhysicsManager();
Random random = new Random(); Random random = new Random();
monster_health = 2;
if(random.Next(0, 2) == 0) if(random.Next(0, 2) == 0)
{ {
isGoRight = true; isGoRight = true;
@ -58,21 +58,25 @@ 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()
{ {
velocity.X = 0;
isAttaking = true; isAttaking = true;
PlayAttackAnimation();
AppManager.Instance.GameManager.GetClosestPlayer(Pos).Death(name);
}
public void PlayAttackAnimation()
{
velocity.X = 0;
if (isGoRight) if (isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack") if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
{ {
GraphicsComponent.StartAnimation("ZombieRightAttack"); GraphicsComponent.StartAnimation("ZombieRightAttack");
} }
AppManager.Instance.GameManager.players[0].Death(name);
} }
else if (!isGoRight) else if (!isGoRight)
{ {
@ -80,7 +84,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
GraphicsComponent.StartAnimation("ZombieLeftAttack"); GraphicsComponent.StartAnimation("ZombieLeftAttack");
} }
AppManager.Instance.GameManager.players[0].Death(name);
} }
} }
@ -121,12 +124,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public override void OnCollision(GameObject gameObject) public override void OnCollision(GameObject gameObject)
{ {
if(gameObject is Player) if (gameObject.id == AppManager.Instance.GameManager.GetClosestPlayer(Pos).id && AppManager.Instance.GameManager.GetClosestPlayer(Pos).IsAlive)
{ {
if (AppManager.Instance.GameManager.players[0].IsAlive) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client)
{ {
Attack(); Attack();
}
}
else if (gameObject is Player)
{
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
{
NetworkTask task = new NetworkTask();
AppManager.Instance.NetworkTasks.Add(task.KillPlayer(gameObject.id, name));
} }
} }
base.OnCollision(gameObject); base.OnCollision(gameObject);
@ -174,10 +184,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{} {}
public void TakeDamage() public override void TakeDamage()
{ {
monster_health--; monster_health--;
GraphicsComponent.StartAnimation("ZombieRightAttack");
Particle particle = new Particle(Pos); Particle particle = new Particle(Pos);
if (monster_health <= 0) if (monster_health <= 0)
{ {

View file

@ -18,17 +18,22 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath
PlayDeath(DeathType); PlayDeath(DeathType);
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> {"DeathFromZombie"}, protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> {"DeathFromZombie", "DeathFromSilasHand" },
"DeathFromZombie"); "DeathFromZombie");
public GraphicsComponent Gr => GraphicsComponent; public GraphicsComponent Gr => GraphicsComponent;
private void PlayDeath(string deathName) private void PlayDeath(string deathName)
{ {
if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie") //if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie")
{ //{
GraphicsComponent.StartAnimation("DeathFromZombie"); // GraphicsComponent.StartAnimation("DeathFromZombie");
} //}
//if (GraphicsComponent.GetCurrentAnimation != "DeathFromSilasHand")
//{
// GraphicsComponent.StartAnimation("DeathFromSilasHand");
//}
GraphicsComponent.StartAnimation(deathName);
} }
} }

View file

@ -10,6 +10,7 @@ using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using DangerousD.GameCore.GameObjects.LivingEntities.Monsters; using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
using DangerousD.GameCore.Network; using DangerousD.GameCore.Network;
using DangerousD.GameCore.GameObjects.MapObjects;
namespace DangerousD.GameCore.GameObjects.LivingEntities namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
@ -65,6 +66,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
bullets++; bullets++;
} }
if(a == "playerShootBoomUpRight" || a == "playerShootBoomUpLeft")
{
isShooting = false;
}
}; };
} }
@ -73,7 +78,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public bool IsAlive { get { return isAlive; } } public bool IsAlive { get { return isAlive; } }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
"playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft"}, "playerReload"); "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot", "playerShootUpRight", "playerShootUpLeft", "playerShootBoomUpRight",
"playerShootBoomUpLeft"}, "playerReload");
public void Attack() public void Attack()
{ {
@ -87,12 +93,29 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
base.OnCollision(gameObject); base.OnCollision(gameObject);
} }
public Rectangle GetShootRectangle(bool isRight)
{
if (isRight)
return new Rectangle((int)Pos.X, (int)(Pos.Y) + 10, shootLength + Width, Height / 2);
else
return new Rectangle((int)Pos.X-shootLength, (int)(Pos.Y) + 10, shootLength, Height / 2);
}
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
{ {
if (isVisible) if (isVisible)
{ {
base.Draw(spriteBatch); base.Draw(spriteBatch);
} }
if (AppManager.Instance.InputManager.CollisionsCheat)
{
Rectangle attackRect = GetShootRectangle(isRight);
spriteBatch.Draw(debugTexture,
new Rectangle((attackRect.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling,
(attackRect.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling,
attackRect.Width * GraphicsComponent.scaling,
attackRect.Height * GraphicsComponent.scaling), Color.White);
}
} }
public void Death(string monsterName) public void Death(string monsterName)
{ {
@ -123,6 +146,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
}; };
} }
else if (monsterName == "SilasHand")
{
AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{
if (a == "DeathFrom" + monsterName)
{
AppManager.Instance.ChangeGameState(GameState.Death);
}
};
}
else if (monsterName == "SilasBall")
{
AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{
if (a == "DeathFrom" + monsterName)
{
AppManager.Instance.ChangeGameState(GameState.Death);
}
};
}
isAlive = false; isAlive = false;
} }
public void Jump() public void Jump()
@ -144,6 +189,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isShooting = true; isShooting = true;
bullets--; bullets--;
if (isRight) if (isRight)
{
if (!isUping)
{ {
StartCicycleAnimation("playerShootRight"); StartCicycleAnimation("playerShootRight");
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared()); var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
@ -155,19 +202,34 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
} }
else else
{
StartCicycleAnimation("playerShootBoomUpRight");
Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y));
bullet.ShootUpRight();
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8));
}
}
else if(!isRight)
{
if (!isUping)
{ {
StartCicycleAnimation("playerShootLeft"); StartCicycleAnimation("playerShootLeft");
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie)); var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
if (targets != null) if (targets.Count() > 0)
{ {
foreach (var target in targets) Zombie targetZombie = (Zombie)targets.First();
{
Zombie targetZombie = (Zombie)target;
targetZombie.TakeDamage(); targetZombie.TakeDamage();
} }
}
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
} }
else
{
StartCicycleAnimation("playerShootBoomUpLeft");
Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y));
bullet.ShootUpLeft();
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7));
}
}
} }
} }
} }
@ -230,14 +292,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит else if (AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
{ {
if (bullets < 5) if (isRight)
{
if (GraphicsComponent.GetCurrentAnimation != "playerReload")
{
GraphicsComponent.StartAnimation("playerReload");
}
}
else if (isRight)
{ {
if (isUping) if (isUping)
{ {
@ -246,6 +301,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
GraphicsComponent.StartAnimation("playerShootUpRight"); GraphicsComponent.StartAnimation("playerShootUpRight");
} }
} }
else if (bullets < 5)
{
if (GraphicsComponent.GetCurrentAnimation != "playerReload")
{
GraphicsComponent.StartAnimation("playerReload");
}
}
else else
{ {
GraphicsComponent.StartAnimation("playerRightStay"); GraphicsComponent.StartAnimation("playerRightStay");
@ -260,6 +322,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
GraphicsComponent.StartAnimation("playerShootUpLeft"); GraphicsComponent.StartAnimation("playerShootUpLeft");
} }
} }
else if (bullets < 5)
{
if (GraphicsComponent.GetCurrentAnimation != "playerReload")
{
GraphicsComponent.StartAnimation("playerReload");
}
}
else else
{ {
GraphicsComponent.StartAnimation("playerStayLeft"); GraphicsComponent.StartAnimation("playerStayLeft");
@ -279,13 +348,51 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isOnGround = false; isOnGround = false;
} }
public class Bullet : GameObjects.LivingEntity public class Bullet : LivingEntity
{ {
public Bullet(Vector2 position) : base(position) public Bullet(Vector2 position) : base(position)
{ {
Height = 5;
Width = 5;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft"}, "playerMoveLeft");
Vector2 direction;
Vector2 maindirection;
public void ShootUpRight()
{
direction = new Vector2(1, -1);
acceleration = Vector2.Zero;
velocity = new Vector2(10, 10) * direction;
maindirection = velocity;
}
public void ShootUpLeft()
{
direction = new Vector2(-1, -1);
acceleration = Vector2.Zero;
velocity = new Vector2(10, 10) * direction;
maindirection = velocity;
}
public override void OnCollision(GameObject gameObject)
{
if (gameObject is not Player)
{
if (gameObject is CoreEnemy)
{
CoreEnemy enemy = (CoreEnemy)gameObject;
enemy.TakeDamage();
AppManager.Instance.GameManager.Remove(this);
}
base.OnCollision(gameObject);
}
}
public override void Update(GameTime gameTime)
{
if (maindirection!=velocity)
{
AppManager.Instance.GameManager.Remove(this);
}
base.Update(gameTime);
} }
protected override GraphicsComponent GraphicsComponent { get; } = new("ZombieMoveLeft");
} }
} }
} }

View file

@ -10,6 +10,8 @@ public abstract class LivingEntity : Entity
public Vector2 velocity; public Vector2 velocity;
public Vector2 acceleration; public Vector2 acceleration;
public Vector2 Acceleration { get; private set; }
public LivingEntity(Vector2 position) : base(position) public LivingEntity(Vector2 position) : base(position)
{ {
acceleration = new Vector2(0, 30); acceleration = new Vector2(0, 30);

View file

@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
namespace DangerousD.GameCore.Graphics namespace DangerousD.GameCore.Graphics
@ -20,7 +21,7 @@ namespace DangerousD.GameCore.Graphics
private List<Texture2D> textures; private List<Texture2D> textures;
private List<string> texturesNames; private List<string> texturesNames;
private AnimationContainer currentAnimation; private AnimationContainer currentAnimation;
static private int scaling = 4; static public int scaling = 4;
public int parentId; public int parentId;
public AnimationContainer CurrentAnimation public AnimationContainer CurrentAnimation
{ {

View file

@ -17,7 +17,7 @@ using System.Threading.Tasks;
namespace DangerousD.GameCore namespace DangerousD.GameCore
{ {
public enum MultiPlayerStatus { SinglePlayer, Host, Client } public enum MultiPlayerStatus { SinglePlayer, Host, Client }
public enum GameState { Menu, Options, Lobby, Game, Login, Death, public enum GameState { Menu, Options, Lobby, Game, Login, Death, HUD,
GameOver GameOver
} }
public class AppManager : Game public class AppManager : Game
@ -36,11 +36,10 @@ namespace DangerousD.GameCore
IDrawableObject LoginGUI; IDrawableObject LoginGUI;
IDrawableObject LobbyGUI; IDrawableObject LobbyGUI;
IDrawableObject DeathGUI; IDrawableObject DeathGUI;
//IDrawableObject HUD; IDrawableObject HUD;
public DebugHUD DebugHUD; public DebugHUD DebugHUD;
public HUD HUD;
public List<NetworkTask> NetworkTasks = new List<NetworkTask>(); public List<NetworkTask> NetworkTasks = new List<NetworkTask>();
public string currentMap;
public GameManager GameManager { get; private set; } = new(); public GameManager GameManager { get; private set; } = new();
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder(); public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
public NetworkManager NetworkManager { get; private set; } = new NetworkManager(); public NetworkManager NetworkManager { get; private set; } = new NetworkManager();
@ -63,7 +62,11 @@ namespace DangerousD.GameCore
NetworkManager.GetReceivingMessages += NetworkSync; NetworkManager.GetReceivingMessages += NetworkSync;
resolution = SettingsManager.Resolution; resolution = SettingsManager.Resolution;
SetIsFullScreen(!SettingsManager.IsFullScreen);
SetIsFullScreen(SettingsManager.IsFullScreen);
_graphics.PreferredBackBufferWidth = resolution.X;
_graphics.PreferredBackBufferHeight = resolution.Y;
_graphics.IsFullScreen = false;
gameState = GameState.Menu; gameState = GameState.Menu;
MenuGUI = new MenuGUI(); MenuGUI = new MenuGUI();
LoginGUI = new LoginGUI(); LoginGUI = new LoginGUI();
@ -72,8 +75,9 @@ namespace DangerousD.GameCore
DeathGUI = new DeathGUI(); DeathGUI = new DeathGUI();
HUD = new HUD(); HUD = new HUD();
DebugHUD = new DebugHUD(); DebugHUD = new DebugHUD();
UIManager.resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight); UIManager.resolution = resolution;
UIManager.resolutionInGame = resolution; UIManager.resolutionInGame = inGameResolution;
currentMap = "lvl";
} }
protected override void Initialize() protected override void Initialize()
@ -104,7 +108,7 @@ namespace DangerousD.GameCore
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) }); GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
SoundManager.LoadSounds(); SoundManager.LoadSounds();
SoundManager.StartAmbientSound("DoomTestSong"); SoundManager.StartAmbientSound("DoomTestSong");
renderTarget = new RenderTarget2D(GraphicsDevice, resolution.X, resolution.Y); renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y);
} }
protected override void Update(GameTime gameTime) protected override void Update(GameTime gameTime)
@ -136,6 +140,7 @@ namespace DangerousD.GameCore
case GameState.Game: case GameState.Game:
HUD.Update(gameTime); HUD.Update(gameTime);
GameManager.Update(gameTime); GameManager.Update(gameTime);
break; break;
default: default:
break; break;
@ -167,6 +172,9 @@ namespace DangerousD.GameCore
case GameState.Death: case GameState.Death:
DeathGUI.Draw(_spriteBatch); DeathGUI.Draw(_spriteBatch);
break; break;
case GameState.HUD:
HUD.Draw(_spriteBatch);
break;
case GameState.Game: case GameState.Game:
_spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp); _spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);
GameManager.Draw(_spriteBatch); GameManager.Draw(_spriteBatch);
@ -200,12 +208,15 @@ namespace DangerousD.GameCore
case GameState.Lobby: case GameState.Lobby:
break; break;
case GameState.Game: case GameState.Game:
<<<<<<< HEAD
GameManager.mapManager.LoadLevel("map"); GameManager.mapManager.LoadLevel("map");
=======
GameManager.mapManager.LoadLevel(currentMap);
>>>>>>> main
GameManager.FindBorders(); GameManager.FindBorders();
break; break;
case GameState.Death: case GameState.Death:
break; break;
@ -220,7 +231,12 @@ namespace DangerousD.GameCore
{ {
switch (networkTask.operation) switch (networkTask.operation)
{ {
case NetworkTaskOperationEnum.TakeDamage: case NetworkTaskOperationEnum.DeleteObject:
GameObject gameObject = GameManager.GetAllGameObjects.Find(x => x.id == networkTask.objId);
if (gameObject != null)
{
GameManager.Remove(gameObject);
}
break; break;
case NetworkTaskOperationEnum.SendSound: case NetworkTaskOperationEnum.SendSound:
SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos); SoundManager.StartSound(networkTask.name, networkTask.position, GameManager.GetPlayer1.Pos);
@ -242,6 +258,11 @@ namespace DangerousD.GameCore
case NetworkTaskOperationEnum.ChangeState: case NetworkTaskOperationEnum.ChangeState:
if (networkTask.objId != GameManager.GetPlayer1.id) if (networkTask.objId != GameManager.GetPlayer1.id)
{ {
List<GraphicsComponent> gcs = new List<GraphicsComponent>();
foreach (var player in GameManager.players)
{
gcs.Add(player.GetGraphicsComponent());
}
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId); LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
if (entity != null) if (entity != null)
{ {
@ -276,6 +297,12 @@ namespace DangerousD.GameCore
remoteConnectedPlayer.id = networkTask.objId; remoteConnectedPlayer.id = networkTask.objId;
remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId; remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId;
break; break;
case NetworkTaskOperationEnum.KillPlayer:
Player player1 = GameManager.players.Find(x => x.id==networkTask.objId);
player1.Death(networkTask.name);
NetworkTask task1 = new NetworkTask();
NetworkTasks.Add(task1.DeleteObject(player1.id));
break;
default: default:
break; break;
} }
@ -304,5 +331,11 @@ namespace DangerousD.GameCore
_graphics.IsFullScreen = fullscrin; _graphics.IsFullScreen = fullscrin;
_graphics.ApplyChanges(); _graphics.ApplyChanges();
} }
public void Restart(string map)
{
GameManager = new();
ChangeGameState(GameState.Menu);
currentMap = map;
}
} }
} }

View file

@ -192,5 +192,10 @@ namespace DangerousD.GameCore
} }
} }
} }
public Player GetClosestPlayer(Vector2 position)
{
return players.OrderBy(x => (x.Pos - position).Length()).First();
}
} }
} }

View file

@ -87,6 +87,6 @@ namespace DangerousD.GameCore.Managers
[JsonProperty("SoundEffectsVolume")] [JsonProperty("SoundEffectsVolume")]
public float SoundEffectsVolume { get; set; } = 1; public float SoundEffectsVolume { get; set; } = 1;
[JsonProperty("Resolution")] [JsonProperty("Resolution")]
public Point Resolution { get; set; } = new Point(1920,1080); public Point Resolution { get; set; } = new Point(1366,768);
} }
} }

View file

@ -20,18 +20,6 @@ namespace DangerousD.GameCore.Network
public Type type { get; set; } public Type type { get; set; }
public NetworkTask() { } public NetworkTask() { }
/// <summary>
/// Нанести урон сущности
/// </summary>
/// <param name="LivingEntityId"></param>
/// <param name="Damage"></param>
public NetworkTask(int LivingEntityId, int Damage)
{
operation = NetworkTaskOperationEnum.TakeDamage;
objId = LivingEntityId;
value = Damage;
}
/// <summary> /// <summary>
/// Проиграть звук на позиции /// Проиграть звук на позиции
/// </summary> /// </summary>
@ -49,14 +37,12 @@ namespace DangerousD.GameCore.Network
/// </summary> /// </summary>
/// <param name="EntityType"></param> /// <param name="EntityType"></param>
/// <param name="EntityPosition"></param> /// <param name="EntityPosition"></param>
/// <param name="EntityVelocity"></param>
/// <param name="ParentId"></param> /// <param name="ParentId"></param>
public NetworkTask(Type EntityType, Vector2 EntityPosition, Vector2 EntityVelocity, int ParentId) public NetworkTask(Type EntityType, Vector2 EntityPosition, int ParentId)
{ {
operation = NetworkTaskOperationEnum.CreateEntity; operation = NetworkTaskOperationEnum.CreateEntity;
type = EntityType; type = EntityType;
position = EntityPosition; position = EntityPosition;
velocity = EntityVelocity;
objId = ParentId; objId = ParentId;
} }
@ -134,5 +120,18 @@ namespace DangerousD.GameCore.Network
position = playerPosition; position = playerPosition;
return this; return this;
} }
public NetworkTask DeleteObject(int objectId)
{
operation = NetworkTaskOperationEnum.DeleteObject;
objId = objectId;
return this;
}
public NetworkTask KillPlayer(int playerId, string mosterName)
{
operation = NetworkTaskOperationEnum.KillPlayer;
name = mosterName;
objId = playerId;
return this;
}
} }
} }

View file

@ -9,6 +9,6 @@ namespace DangerousD.GameCore.Network
[Serializable] [Serializable]
public enum NetworkTaskOperationEnum public enum NetworkTaskOperationEnum
{ {
TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer DeleteObject, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer, KillPlayer
} }
} }