main merge
|
@ -14,7 +14,14 @@
|
||||||
|
|
||||||
#---------------------------------- Content ---------------------------------#
|
#---------------------------------- Content ---------------------------------#
|
||||||
|
|
||||||
#begin MonstersAnimations.png
|
#begin ButtonFont.spritefont
|
||||||
|
/importer:FontDescriptionImporter
|
||||||
|
/processor:FontDescriptionProcessor
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:TextureFormat=Compressed
|
||||||
|
/build:ButtonFont.spritefont
|
||||||
|
|
||||||
|
#begin checkboxs_off-on.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
/processorParam:ColorKeyColor=255,0,255,255
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
@ -24,7 +31,31 @@
|
||||||
/processorParam:ResizeToPowerOfTwo=False
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
/processorParam:MakeSquare=False
|
/processorParam:MakeSquare=False
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:MonstersAnimations.png
|
/build:checkboxs_off-on.png
|
||||||
|
|
||||||
|
#begin checkboxs_off.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.png
|
||||||
|
|
||||||
|
#begin checkboxs_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_on.png
|
||||||
|
|
||||||
#begin deathAnimation.png
|
#begin deathAnimation.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
|
@ -38,12 +69,17 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:deathAnimation.png
|
/build:deathAnimation.png
|
||||||
|
|
||||||
#begin ButtonFont.spritefont
|
#begin deathBackground.jpg
|
||||||
/importer:FontDescriptionImporter
|
/importer:TextureImporter
|
||||||
/processor:FontDescriptionProcessor
|
/processor:TextureProcessor
|
||||||
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
/processorParam:ColorKeyEnabled=True
|
||||||
|
/processorParam:GenerateMipmaps=False
|
||||||
/processorParam:PremultiplyAlpha=True
|
/processorParam:PremultiplyAlpha=True
|
||||||
/processorParam:TextureFormat=Compressed
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
/build:ButtonFont.spritefont
|
/processorParam:MakeSquare=False
|
||||||
|
/processorParam:TextureFormat=Color
|
||||||
|
/build:deathBackground.jpg
|
||||||
|
|
||||||
#begin DoomTestSong.mp3
|
#begin DoomTestSong.mp3
|
||||||
/importer:Mp3Importer
|
/importer:Mp3Importer
|
||||||
|
@ -51,6 +87,13 @@
|
||||||
/processorParam:Quality=Best
|
/processorParam:Quality=Best
|
||||||
/build:DoomTestSong.mp3
|
/build:DoomTestSong.mp3
|
||||||
|
|
||||||
|
#begin Font_12.spritefont
|
||||||
|
/importer:FontDescriptionImporter
|
||||||
|
/processor:FontDescriptionProcessor
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:TextureFormat=Compressed
|
||||||
|
/build:Font_12.spritefont
|
||||||
|
|
||||||
#begin Font_25.spritefont
|
#begin Font_25.spritefont
|
||||||
/importer:FontDescriptionImporter
|
/importer:FontDescriptionImporter
|
||||||
/processor:FontDescriptionProcessor
|
/processor:FontDescriptionProcessor
|
||||||
|
@ -84,19 +127,6 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:menuFon.jpg
|
/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
|
#begin MenuFon2.jpg
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
@ -121,7 +151,127 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:menuFon3.jpg
|
/build:menuFon3.jpg
|
||||||
|
|
||||||
#begin tiles.png
|
#begin MonstersAnimations.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:MonstersAnimations.png
|
||||||
|
|
||||||
|
#begin optionsBackground.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:optionsBackground.jpg
|
||||||
|
|
||||||
|
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.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:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||||
|
|
||||||
|
#begin slider.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:slider.png
|
||||||
|
|
||||||
|
#begin sliderBackground.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:sliderBackground.png
|
||||||
|
|
||||||
|
#begin textboxbackground1-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: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
|
||||||
|
/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,5-1.png
|
||||||
|
|
||||||
|
#begin textboxbackground6-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:textboxbackground6-1.png
|
||||||
|
|
||||||
|
#begin MonstersAnimations.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:MonstersAnimations.png
|
||||||
|
|
||||||
|
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
/processorParam:ColorKeyColor=255,0,255,255
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
@ -133,6 +283,18 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:tiles.png
|
/build:tiles.png
|
||||||
|
|
||||||
|
#begin playerAnimation.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:playerAnimation.png
|
||||||
|
|
||||||
#begin wall.jpg
|
#begin wall.jpg
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
|
64
DangerousD/Content/Font_12.spritefont
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
This file contains an xml description of a font, and will be read by the XNA
|
||||||
|
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||||
|
of the font in your game, and to change the characters which are available to draw
|
||||||
|
with.
|
||||||
|
-->
|
||||||
|
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||||
|
<Asset Type="Graphics:FontDescription">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Modify this string to change the font that will be imported.
|
||||||
|
-->
|
||||||
|
<FontName>Arial</FontName>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Size is a float value, measured in points. Modify this value to change
|
||||||
|
the size of the font.
|
||||||
|
-->
|
||||||
|
<Size>12</Size>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Spacing is a float value, measured in pixels. Modify this value to change
|
||||||
|
the amount of spacing in between characters.
|
||||||
|
-->
|
||||||
|
<Spacing>0</Spacing>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||||
|
will be used when placing characters.
|
||||||
|
-->
|
||||||
|
<UseKerning>true</UseKerning>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||||
|
and "Bold, Italic", and are case sensitive.
|
||||||
|
-->
|
||||||
|
<Style>Regular</Style>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you uncomment this line, the default character will be substituted if you draw
|
||||||
|
or measure text that contains characters which were not included in the font.
|
||||||
|
-->
|
||||||
|
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
CharacterRegions control what letters are available in the font. Every
|
||||||
|
character from Start to End will be built and made available for drawing. The
|
||||||
|
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||||
|
character set. The characters are ordered according to the Unicode standard.
|
||||||
|
See the documentation for more information.
|
||||||
|
-->
|
||||||
|
<CharacterRegions>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start> </Start>
|
||||||
|
<End>~</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
<CharacterRegion>
|
||||||
|
<Start>а</Start>
|
||||||
|
<End>я</End>
|
||||||
|
</CharacterRegion>
|
||||||
|
</CharacterRegions>
|
||||||
|
</Asset>
|
||||||
|
</XnaContent>
|
1
DangerousD/Content/animations/HunchmanAttackLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":124,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/HunchmanAttackRight
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/HunchmanMoveLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"HunchmanMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":124,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
3
DangerousD/Content/animations/HunchmanMoveRight
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
||||||
|
|
1
DangerousD/Content/animations/playerJumpLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerJumpLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":101,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
1
DangerousD/Content/animations/playerJumpRight
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerJumpRight","textureName":"playerAnimation","startSpriteRectangle":{"X":126,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false,"offset":"0, 0"}
|
20
DangerousD/Content/animations/playerMoveLeft
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"id": "playerMoveLeft",
|
||||||
|
"textureName": "playerAnimation",
|
||||||
|
"startSpriteRectangle": {
|
||||||
|
"X": 26,
|
||||||
|
"Y": 34,
|
||||||
|
"Width": 24,
|
||||||
|
"Height": 32
|
||||||
|
},
|
||||||
|
"frameSecond": [
|
||||||
|
{
|
||||||
|
"Item1": 0,
|
||||||
|
"Item2": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textureFrameInterval": 1,
|
||||||
|
"framesCount": 4,
|
||||||
|
"isCycle": true,
|
||||||
|
"offset": "0, 0"
|
||||||
|
}
|
20
DangerousD/Content/animations/playerMoveRight
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"id": "playerMoveRight",
|
||||||
|
"textureName": "playerAnimation",
|
||||||
|
"startSpriteRectangle": {
|
||||||
|
"X": 26,
|
||||||
|
"Y": 1,
|
||||||
|
"Width": 24,
|
||||||
|
"Height": 32
|
||||||
|
},
|
||||||
|
"frameSecond": [
|
||||||
|
{
|
||||||
|
"Item1": 0,
|
||||||
|
"Item2": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textureFrameInterval": 1,
|
||||||
|
"framesCount": 4,
|
||||||
|
"isCycle": true,
|
||||||
|
"offset": "0, 0"
|
||||||
|
}
|
1
DangerousD/Content/animations/playerRightStay
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerRightStay","textureName":"playerAnimation","startSpriteRectangle":{"X":1,"Y":1,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/playerStayLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"playerStayLeft","textureName":"playerAnimation","startSpriteRectangle":{"X":1,"Y":34,"Width":24,"Height":32},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
BIN
DangerousD/Content/checkboxs_off-on.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
DangerousD/Content/checkboxs_off.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
DangerousD/Content/checkboxs_on.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
DangerousD/Content/deathBackground.jpg
Normal file
After Width: | Height: | Size: 396 KiB |
|
@ -752,7 +752,7 @@
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup id="10" name="Player" class="LivingEntities.Player">
|
<objectgroup id="10" name="Player" class="LivingEntities.Player">
|
||||||
<object id="47" x="-260" y="461.333">
|
<object id="47" x="-525" y="461.333">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
|
|
@ -42,27 +42,27 @@
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup id="755" name="Zombies" class="LivingEntities.Player" locked="1">
|
<objectgroup id="755" name="Zombies" class="LivingEntities.Player" locked="1">
|
||||||
<object id="26" x="-50" y="300">
|
<object id="26" x="-50" y="100">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup id="2" name="Слой объектов 1" class="LivingEntities.Monsters.FlameSkull">
|
<objectgroup id="2" name="Слой объектов 1" class="LivingEntities.Monsters.FlameSkull">
|
||||||
<object id="1" x="1" y="300">
|
<object id="1" x="1" y="100">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup id="3" name="Слой объектов 2" class="LivingEntities.Monsters.FrankBalls">
|
<objectgroup id="3" name="Слой объектов 2" class="LivingEntities.Monsters.FrankBalls">
|
||||||
<object id="2" x="1" y="300">
|
<object id="2" x="1" y="100">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup id="4" name="Слой объектов 3" class="LivingEntities.Monsters.Frank">
|
<objectgroup id="4" name="Слой объектов 3" class="LivingEntities.Monsters.Frank">
|
||||||
<object id="3" x="-56" y="420">
|
<object id="3" x="-56" y="100">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup id="5" name="Zombies" class="LivingEntities.Monsters.Spider">
|
<objectgroup id="5" name="Zombies" class="LivingEntities.Monsters.Spider">
|
||||||
<object id="4" x="1" y="300">
|
<object id="4" x="1" y="100">
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
|
Before Width: | Height: | Size: 197 KiB After Width: | Height: | Size: 7.5 MiB |
BIN
DangerousD/Content/optionsBackground.jpg
Normal file
After Width: | Height: | Size: 252 KiB |
BIN
DangerousD/Content/playerAnimation.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
DangerousD/Content/slider.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
DangerousD/Content/sliderBackground.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
DangerousD/Content/textboxbackground1-1.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
DangerousD/Content/textboxbackground2,5-1.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
DangerousD/Content/textboxbackground2-1.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
DangerousD/Content/textboxbackground6-1.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
33
DangerousD/GameCore/GUI/DeathGUI.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using DangerousD.GameCore.Managers;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using MonogameLibrary.UI.Base;
|
||||||
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GUI;
|
||||||
|
|
||||||
|
internal class DeathGUI : AbstractGui
|
||||||
|
{
|
||||||
|
protected override void CreateUI()
|
||||||
|
{
|
||||||
|
int wigth = AppManager.Instance.inGameResolution.X;
|
||||||
|
int height = AppManager.Instance.inGameResolution.Y;
|
||||||
|
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" };
|
||||||
|
Elements.Add(menuBackground);
|
||||||
|
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
|
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2 - 80, 50, 50), text = "You death", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
|
||||||
|
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, (height - 50) / 2, 50, 50), text = $"Score = {0}", mainColor = Color.Transparent, scale = 0.7f, fontName = "ButtonFont", fontColor = Color.White });
|
||||||
|
var butMenu = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, (height - 50) / 2 + 80, 300, 50), text = "Back to menu", scale = 0.7f, fontName = "ButtonFont" };
|
||||||
|
Elements.Add(butMenu);
|
||||||
|
butMenu.LeftButtonPressed += () =>
|
||||||
|
{
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
|
}
|
50
DangerousD/GameCore/GUI/DebugHUD.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using static System.String;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GUI
|
||||||
|
{
|
||||||
|
public class DebugHUD : IDrawableObject
|
||||||
|
{
|
||||||
|
private SpriteFont _spriteFont;
|
||||||
|
private Dictionary<string, string> _text = new();
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadContent()
|
||||||
|
{
|
||||||
|
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Font_12");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
spriteBatch.Begin();
|
||||||
|
spriteBatch.DrawString(
|
||||||
|
_spriteFont,
|
||||||
|
Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList()),
|
||||||
|
new Vector2(10, 10),
|
||||||
|
Color.Cyan,
|
||||||
|
0,
|
||||||
|
Vector2.Zero,
|
||||||
|
1,
|
||||||
|
SpriteEffects.None,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
spriteBatch.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(string key, string value)
|
||||||
|
{
|
||||||
|
_text[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
DangerousD/GameCore/GUI/HUD.cs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using MonogameLibrary.UI.Base;
|
||||||
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using DangerousD.GameCore.Managers;
|
||||||
|
using DangerousD.GameCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GUI
|
||||||
|
{
|
||||||
|
public class HUD : AbstractGui
|
||||||
|
{
|
||||||
|
int ammout = 0;
|
||||||
|
List<Rect> rects = new List<Rect> { };
|
||||||
|
int wigth = AppManager.Instance.inGameResolution.X;
|
||||||
|
int height = AppManager.Instance.inGameResolution.Y;
|
||||||
|
protected override void CreateUI()
|
||||||
|
{
|
||||||
|
DrawableUIElement background = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), mainColor = Color.Transparent };
|
||||||
|
Elements.Add(background);
|
||||||
|
Rect rect = new Rect(Manager) { rectangle = new Rectangle(wigth / 35, height / 35, 120, 70), mainColor = Color.DarkRed };
|
||||||
|
Elements.Add(rect);
|
||||||
|
Label label = new Label(Manager) { rectangle = new Rectangle(wigth / 34, height / 30, 120, 20), text = "ammout", fontName = "font2", scale = 0.2f, mainColor = Color.Transparent, fontColor = Color.Black };
|
||||||
|
Elements.Add(label);
|
||||||
|
|
||||||
|
}
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
rects.Clear();
|
||||||
|
for (int i = 0; i < ammout; i++)
|
||||||
|
{
|
||||||
|
rects.Add(new Rect(Manager) { rectangle = new Rectangle(wigth / 29 + i * 13, height / 17, 5, 20), mainColor = Color.Yellow });
|
||||||
|
rects[i].LoadTexture(AppManager.Instance.Content);
|
||||||
|
}
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ using DangerousD.GameCore.Managers;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using DangerousD.GameCore.Network;
|
using DangerousD.GameCore.Network;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GUI
|
namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
|
@ -30,8 +31,11 @@ namespace DangerousD.GameCore.GUI
|
||||||
lobbyBackground.LoadTexture(AppManager.Instance.Content);
|
lobbyBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
// CheckBoxs
|
// CheckBoxs
|
||||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
var lobby = new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
||||||
screenWidth / 30 * 26, screenHeight / 15 * 10) });
|
screenWidth / 30 * 26, screenHeight / 15 * 10), textureName = "textboxbackground2,5-1" };
|
||||||
|
Elements.Add(lobby);
|
||||||
|
lobby.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
|
|
||||||
// Buttons and ip textbox
|
// Buttons and ip textbox
|
||||||
{
|
{
|
||||||
|
@ -41,9 +45,10 @@ namespace DangerousD.GameCore.GUI
|
||||||
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
||||||
text = "ip",
|
text = "ip",
|
||||||
scale = 0.16f,
|
scale = 0.16f,
|
||||||
fontColor = Color.Gray,
|
fontColor = Color.Black,
|
||||||
fontName = "font2",
|
fontName = "font2",
|
||||||
textAligment = TextAligment.Left
|
textAligment = TextAligment.Left,
|
||||||
|
textureName = "textboxbackground6-1"
|
||||||
|
|
||||||
};
|
};
|
||||||
searchBarTextBox.TextChanged += input => {
|
searchBarTextBox.TextChanged += input => {
|
||||||
|
@ -59,62 +64,68 @@ namespace DangerousD.GameCore.GUI
|
||||||
searchBarTextBox.text = "ip";
|
searchBarTextBox.text = "ip";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Button backButton = new ButtonText(Manager)
|
Button backButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, 60, 50),
|
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, (int)(40 * 2.4), (int)(40 * 2.4)),
|
||||||
text = "<-",
|
text = "<-",
|
||||||
scale = 0.3f,
|
scale = 0.72f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.Black,
|
||||||
fontName = "font2"
|
fontName = "font2",
|
||||||
|
textureName = "textboxbackground1-1"
|
||||||
};
|
};
|
||||||
backButton.LeftButtonPressed += () => {
|
backButton.LeftButtonPressed += () => {
|
||||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||||
};
|
};
|
||||||
|
|
||||||
Button hostButton = new ButtonText(Manager)
|
Button hostButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, 120, 50),
|
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||||
text = "Host",
|
text = "Host",
|
||||||
scale = 0.2f,
|
scale = 0.48f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.DarkBlue,
|
||||||
fontName = "font2"
|
fontName = "buttonFont",
|
||||||
|
textureName = "textboxbackground2-1"
|
||||||
};
|
};
|
||||||
hostButton.LeftButtonPressed += () => {
|
hostButton.LeftButtonPressed += () => {
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||||
AppManager.Instance.NetworkManager.HostInit(AppManager.Instance.IpAddress);
|
AppManager.Instance.NetworkManager.HostInit(AppManager.Instance.IpAddress);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Button refreshButton = new ButtonText(Manager)
|
Button refreshButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, 120, 50),
|
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||||
text = "Refresh",
|
text = "Refresh",
|
||||||
scale = 0.2f,
|
scale = 0.48f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.DarkBlue,
|
||||||
fontName = "font2"
|
fontName = "buttonFont",
|
||||||
|
textureName = "textboxbackground2-1"
|
||||||
};
|
};
|
||||||
refreshButton.LeftButtonPressed += () => {
|
refreshButton.LeftButtonPressed += () => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Button joinSelectedButton = new ButtonText(Manager)
|
Button joinSelectedButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, 120, 50),
|
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||||
text = "Join",
|
text = "Join",
|
||||||
scale = 0.2f,
|
scale = 0.48f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.DarkBlue,
|
||||||
fontName = "font2"
|
fontName = "buttonFont",
|
||||||
|
textureName = "textboxbackground2-1"
|
||||||
};
|
};
|
||||||
joinSelectedButton.LeftButtonPressed += () => {
|
joinSelectedButton.LeftButtonPressed += () => {
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||||
AppManager.Instance.NetworkManager.ClientInit(AppManager.Instance.IpAddress);
|
AppManager.Instance.NetworkManager.ClientInit(AppManager.Instance.IpAddress);
|
||||||
};
|
};
|
||||||
Button joinByIpButton = new ButtonText(Manager)
|
Button joinByIpButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, 120, 50),
|
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, (int)(120 * 2.4), (int)(50 * 2.4)),
|
||||||
text = "JoinByIp",
|
text = "JoinByIp",
|
||||||
scale = 0.2f,
|
scale = 0.48f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.DarkBlue,
|
||||||
fontName = "font2"
|
fontName = "buttonFont",
|
||||||
|
textureName = "textboxbackground2-1"
|
||||||
};
|
};
|
||||||
joinByIpButton.LeftButtonPressed += () => {
|
joinByIpButton.LeftButtonPressed += () => {
|
||||||
AppManager.Instance.NetworkManager.ClientInit(searchBarTextBox.text);
|
AppManager.Instance.NetworkManager.ClientInit(searchBarTextBox.text);
|
||||||
|
|
|
@ -32,9 +32,9 @@ namespace DangerousD.GameCore.GUI
|
||||||
loginBackground.LoadTexture(AppManager.Instance.Content);
|
loginBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
Elements.Add(new Label(Manager) {
|
Elements.Add(new Label(Manager) {
|
||||||
rectangle = new Rectangle(screenWidth / 2 - 250, screenHeight / 6 - 50, 500, 100),
|
rectangle = new Rectangle(screenWidth / 2 - (int)(250 * 2.4), screenHeight / 6 - 100, (int)(500 * 2.4), (int)(100 * 2.4)),
|
||||||
text = "Login",
|
text = "Login",
|
||||||
scale = 0.8f,
|
scale = 1.7f,
|
||||||
fontColor = Color.White,
|
fontColor = Color.White,
|
||||||
mainColor = Color.Transparent,
|
mainColor = Color.Transparent,
|
||||||
fontName = "ButtonFont"
|
fontName = "ButtonFont"
|
||||||
|
@ -44,13 +44,16 @@ namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
TextBox loginTextBox = new TextBox(Manager)
|
TextBox loginTextBox = new TextBox(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 2 - 125, screenHeight / 6 * 2 - 20, 250, 40),
|
rectangle = new Rectangle(screenWidth / 2 - (int)(125 * 2.4), screenHeight / 6 * 2 - 20, (int)(250 * 2.4), (int)(40 * 2.4)),
|
||||||
text = "NickName",
|
text = "NickName",
|
||||||
scale = 0.16f,
|
scale = 0.33f,
|
||||||
fontColor = Color.Gray,
|
fontColor = Color.Gray,
|
||||||
fontName = "Font2",
|
fontName = "Font2",
|
||||||
textAligment = TextAligment.Left
|
textAligment = TextAligment.Left,
|
||||||
|
textureName = "textboxbackground6-1"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
loginTextBox.LoadTexture(AppManager.Instance.Content);
|
||||||
loginTextBox.TextChanged += input => {
|
loginTextBox.TextChanged += input => {
|
||||||
if (loginTextBox.fontColor == Color.Gray)
|
if (loginTextBox.fontColor == Color.Gray)
|
||||||
{
|
{
|
||||||
|
@ -67,13 +70,15 @@ namespace DangerousD.GameCore.GUI
|
||||||
|
|
||||||
TextBox passwordTextBox = new TextBox(Manager)
|
TextBox passwordTextBox = new TextBox(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 2 - 125, screenHeight / 6 * 3 - 40, 250, 40),
|
rectangle = new Rectangle(screenWidth / 2 - (int)(125 * 2.4), screenHeight / 6 * 3 - 40, (int)(250 * 2.4), (int)(40 * 2.4)),
|
||||||
text = "Password",
|
text = "Password",
|
||||||
scale = 0.16f,
|
scale = 0.33f,
|
||||||
fontColor = Color.Gray,
|
fontColor = Color.Gray,
|
||||||
fontName = "font2",
|
fontName = "font2",
|
||||||
textAligment = TextAligment.Left
|
textAligment = TextAligment.Left,
|
||||||
|
textureName = "textboxbackground6-1"
|
||||||
};
|
};
|
||||||
|
passwordTextBox.LoadTexture(AppManager.Instance.Content);
|
||||||
passwordTextBox.TextChanged += input => {
|
passwordTextBox.TextChanged += input => {
|
||||||
if (passwordTextBox.fontColor == Color.Gray)
|
if (passwordTextBox.fontColor == Color.Gray)
|
||||||
{
|
{
|
||||||
|
@ -91,12 +96,13 @@ namespace DangerousD.GameCore.GUI
|
||||||
|
|
||||||
// Кнопки
|
// Кнопки
|
||||||
{
|
{
|
||||||
Button logButton = new ButtonText(Manager) {
|
Button logButton = new Button(Manager) {
|
||||||
rectangle = new Rectangle(screenWidth / 4 + 50, screenHeight / 6 * 4, 100, 50),
|
rectangle = new Rectangle(screenWidth / 4 + (int)(50 * 2.4), screenHeight / 6 * 3 + 100, (int)(100 * 2.4), (int)(50 * 2.4)),
|
||||||
text = "LogIn",
|
text = "LogIn",
|
||||||
scale = 0.2f,
|
scale = 0.6f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.White,
|
||||||
fontName = "font2"
|
fontName = "ButtonFont",
|
||||||
|
textureName = "textboxbackground2-1"
|
||||||
};
|
};
|
||||||
logButton.LeftButtonPressed += () => {
|
logButton.LeftButtonPressed += () => {
|
||||||
if (CheckUser())
|
if (CheckUser())
|
||||||
|
@ -105,23 +111,25 @@ namespace DangerousD.GameCore.GUI
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Button regButton = new ButtonText(Manager)
|
Button regButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 4 * 2 + 50, screenHeight / 6 * 4, 100, 50),
|
rectangle = new Rectangle(screenWidth / 4 * 2 + (int)(50 * 2.4), screenHeight / 6 * 3 + 100, (int)(100 * 2.4), (int)(50 * 2.4)),
|
||||||
text = "Reg",
|
text = "Reg",
|
||||||
scale = 0.2f,
|
scale = 0.6f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.White,
|
||||||
fontName = "font2"
|
fontName = "ButtonFont",
|
||||||
|
textureName = "textboxbackground2-1"
|
||||||
};
|
};
|
||||||
regButton.LeftButtonPressed += GoToRegWebServer;
|
regButton.LeftButtonPressed += GoToRegWebServer;
|
||||||
|
|
||||||
Button backButton = new ButtonText(Manager)
|
Button backButton = new Button(Manager)
|
||||||
{
|
{
|
||||||
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, 50, 50),
|
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)),
|
||||||
text = "<-",
|
text = "<-",
|
||||||
scale = 0.3f,
|
scale = 0.72f,
|
||||||
fontColor = Color.Black,
|
fontColor = Color.Black,
|
||||||
fontName = "font2"
|
fontName = "font2",
|
||||||
|
textureName = "textboxbackground1-1"
|
||||||
};
|
};
|
||||||
backButton.LeftButtonPressed += () => {
|
backButton.LeftButtonPressed += () => {
|
||||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
using MonogameLibrary.UI.Elements;
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
@ -9,47 +10,50 @@ namespace DangerousD.GameCore.GUI;
|
||||||
|
|
||||||
internal class MenuGUI : AbstractGui
|
internal class MenuGUI : AbstractGui
|
||||||
{
|
{
|
||||||
|
int selected = 0;
|
||||||
protected override void CreateUI()
|
protected override void CreateUI()
|
||||||
{
|
{
|
||||||
|
int wigth = AppManager.Instance.inGameResolution.X;
|
||||||
|
int height = AppManager.Instance.inGameResolution.Y;
|
||||||
|
|
||||||
|
|
||||||
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
|
||||||
int height = AppManager.Instance.Window.ClientBounds.Height;
|
|
||||||
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);
|
||||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
int TopMenu = 0;
|
|
||||||
Color[] colors = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
Color[] colors = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||||
for (int i = 0; i < colors.Length; i++)
|
for (int i = 0; i < colors.Length; i++)
|
||||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 60, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1-0.05f*i*i/10, fontName = "Font2", fontColor = colors[i] });
|
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 200, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 1.35f - 0.05f * i * i / 10, fontName = "Font2", fontColor = colors[i] });
|
||||||
|
|
||||||
int dx = 100;
|
int dx = 50;
|
||||||
Color[] colors2 = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
Color[] colors2 = new Color[] { new Color(64, 53, 51), new Color(84, 58, 52),
|
||||||
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
new Color(170, 101, 63), new Color(254, 208, 116), new Color(252, 231, 124) };
|
||||||
for (int i = 0; i < colors2.Length; i++)
|
for (int i = 0; i < colors2.Length; i++)
|
||||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 250 + dx-i*i, 90 - i * i/5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 1.3f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors2[i] });
|
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 480 + dx - i * i, 260 - i * i / 5, 50, 50), text = "D", mainColor = Color.Transparent, scale = 2.15f - 0.05f * i * i / 5, fontName = "Font2", fontColor = colors2[i] });
|
||||||
|
|
||||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 130, 300, 50), text = "Singleplayer", fontName = "ButtonFont" };
|
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 350, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Singleplayer", scale = 1.2f, fontName = "ButtonFont" };
|
||||||
Elements.Add(butSingle);
|
Elements.Add(butSingle);
|
||||||
butSingle.LeftButtonPressed += () =>
|
butSingle.LeftButtonPressed += () =>
|
||||||
{
|
{
|
||||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||||
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
|
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.SinglePlayer);
|
||||||
};
|
};
|
||||||
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 190, 300, 50), text = "Multiplayer", fontName = "ButtonFont" };
|
|
||||||
|
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - (int)(300 * 2.4)) / 2, 470, (int)(300 * 2.4), (int)(50 * 2.4)), text = "Multiplayer", scale = 1.2f, fontName = "ButtonFont" };
|
||||||
|
|
||||||
Elements.Add(butMulti);
|
Elements.Add(butMulti);
|
||||||
butMulti.LeftButtonPressed += () =>
|
butMulti.LeftButtonPressed += () =>
|
||||||
{
|
{
|
||||||
AppManager.Instance.ChangeGameState(GameState.Login);
|
AppManager.Instance.ChangeGameState(GameState.Login);
|
||||||
};
|
};
|
||||||
var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 250, 300, 50), text = "Option", 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" };
|
||||||
Elements.Add(butOption);
|
Elements.Add(butOption);
|
||||||
butOption.LeftButtonPressed += () =>
|
butOption.LeftButtonPressed += () =>
|
||||||
{
|
{
|
||||||
// открытие настроек
|
// открытие настроек
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Options);
|
||||||
};
|
};
|
||||||
var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 310, 300, 50), text = "Exit", 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 += () =>
|
||||||
{
|
{
|
||||||
|
|
76
DangerousD/GameCore/GUI/OptionsGUI.cs
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using MonogameLibrary.UI.Base;
|
||||||
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using DangerousD.GameCore.Managers;
|
||||||
|
using DangerousD.GameCore;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GUI
|
||||||
|
{
|
||||||
|
public class OptionsGUI : AbstractGui
|
||||||
|
{
|
||||||
|
int selectedGUI = 0;
|
||||||
|
protected override void CreateUI()
|
||||||
|
{
|
||||||
|
int wigth = AppManager.Instance.inGameResolution.X;
|
||||||
|
int height = AppManager.Instance.inGameResolution.Y;
|
||||||
|
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "optionsBackground" };
|
||||||
|
Elements.Add(menuBackground);
|
||||||
|
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
|
var slider = new Slider(Manager)
|
||||||
|
{
|
||||||
|
MinValue = 0,
|
||||||
|
MaxValue = 1,
|
||||||
|
rectangle = new Rectangle(wigth / 2 + 220, 275, (int)(100 * 2.4), 40),
|
||||||
|
indentation = 5,
|
||||||
|
textureName = "sliderBackground"
|
||||||
|
};
|
||||||
|
|
||||||
|
var cB = new CheckBox(Manager);
|
||||||
|
cB.rectangle = new Rectangle(wigth / 2 + 440, 405, (int)(40 * 2.4), (int)(40 * 2.4));
|
||||||
|
cB.Checked += (newCheckState) =>
|
||||||
|
{
|
||||||
|
SettingsManager sM = new SettingsManager();
|
||||||
|
};
|
||||||
|
cB.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
|
var checkBox = new CheckBox(Manager);
|
||||||
|
checkBox.rectangle = new Rectangle(wigth / 2 + 360, 540, (int)(40 * 2.4), (int)(40 * 2.4));
|
||||||
|
checkBox.Checked += (newCheckState) =>
|
||||||
|
{
|
||||||
|
SettingsManager sM = new SettingsManager();
|
||||||
|
};
|
||||||
|
checkBox.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
|
Label lblOptions = new Label(Manager)
|
||||||
|
{ fontName = "buttonFont", scale = 1.2f, text = "Options", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 40, 50, 50), mainColor = Color.Transparent };
|
||||||
|
Elements.Add(lblOptions);
|
||||||
|
|
||||||
|
Label lblValue = new Label(Manager)
|
||||||
|
{ fontName = "buttonFont", scale = 1f, text = "Volume", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 250, 50, 50), mainColor = Color.Transparent };
|
||||||
|
Elements.Add(lblValue);
|
||||||
|
|
||||||
|
Label lblIsFullScreen = new Label(Manager)
|
||||||
|
{ fontName = "buttonFont", scale = 1f, text = "Full Screen", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 580, 50, 50), mainColor = Color.Transparent };
|
||||||
|
Elements.Add(lblOptions);
|
||||||
|
|
||||||
|
Label lblSwitchMode = new Label(Manager)
|
||||||
|
{ fontName = "buttonFont", scale = 1f, text = "Left/Right Mode", fontColor = Color.White, rectangle = new Rectangle((wigth - 50) / 2, 415, 50, 50), mainColor = Color.Transparent };
|
||||||
|
Elements.Add(lblSwitchMode);
|
||||||
|
|
||||||
|
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" };
|
||||||
|
Elements.Add(bTExit);
|
||||||
|
bTExit.LeftButtonPressed += () =>
|
||||||
|
{
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
base.Update(gameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,11 +14,10 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
protected Vector2 _pos;
|
protected Vector2 _pos;
|
||||||
public Vector2 Pos => _pos;
|
public Vector2 Pos => _pos;
|
||||||
|
public int id;
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
|
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
|
||||||
public Vector2 velocity;
|
|
||||||
public Vector2 acceleration;
|
|
||||||
protected abstract GraphicsComponent GraphicsComponent { get; }
|
protected abstract GraphicsComponent GraphicsComponent { get; }
|
||||||
public GameObject(Vector2 pos)
|
public GameObject(Vector2 pos)
|
||||||
{
|
{
|
||||||
|
@ -40,10 +39,14 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadContent()
|
public void PlayAnimation()
|
||||||
{
|
{
|
||||||
GraphicsComponent.LoadContent();
|
GraphicsComponent.LoadContent();
|
||||||
}
|
}
|
||||||
|
public void LoadContent()
|
||||||
|
{
|
||||||
|
PlayAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Update(GameTime gameTime)
|
public virtual void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GUI
|
namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
interface IDrawableObject
|
public interface IDrawableObject
|
||||||
{
|
{
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void LoadContent();
|
void LoadContent();
|
||||||
|
|
|
@ -4,7 +4,9 @@ using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Authentication.ExtendedProtection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -12,15 +14,71 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Hunchman : CoreEnemy
|
public class Hunchman : CoreEnemy
|
||||||
{
|
{
|
||||||
|
GameManager gameManager;
|
||||||
|
bool isAttacking;
|
||||||
public Hunchman(Vector2 position) : base(position)
|
public Hunchman(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
Width = 48;
|
||||||
|
Height = 48;
|
||||||
|
monster_speed = -2;
|
||||||
|
monster_health = 1;
|
||||||
|
name = "HunchMan";
|
||||||
|
velocity = new Vector2(monster_speed, 0);
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
isAttacking = false;
|
||||||
|
isAlive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
|
||||||
|
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft");
|
||||||
|
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
// P.S. Всё в классе можешь смело удалять и переписывать с нуля.
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
|
||||||
|
if (!isAttacking)
|
||||||
|
{
|
||||||
|
Attack();
|
||||||
|
Move(gameTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = 0;
|
||||||
|
}
|
||||||
|
Death();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
{
|
{
|
||||||
|
GameObject gameObject;
|
||||||
|
foreach (var player in gameManager.players)
|
||||||
|
{
|
||||||
|
if (player.Pos.Y + player.Height >= Pos.Y && player.Pos.Y <= Pos.Y + Height)
|
||||||
|
{
|
||||||
|
gameObject = gameManager.physicsManager.RayCast(this, player);
|
||||||
|
if (gameObject is null)
|
||||||
|
{
|
||||||
|
isAttacking = true;
|
||||||
|
GraphicsComponent.StopAnimation();
|
||||||
|
if (velocity.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackRight")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanAttackRight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (velocity.X < 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanAttackLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Attack(GameTime gameTime)
|
public override void Attack(GameTime gameTime)
|
||||||
|
@ -30,12 +88,45 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
if (monster_health <= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
if (gameManager.physicsManager.RayCast(this, new Vector2(Pos.X + Width + 10, Pos.Y + Height)) is not null)
|
||||||
|
{
|
||||||
|
monster_speed *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
velocity.X = monster_speed;
|
||||||
|
|
||||||
|
if (velocity.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveRight");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (velocity.X < 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnCollision(GameObject gameObject)
|
||||||
|
{
|
||||||
|
monster_speed *= -1;
|
||||||
|
_pos.X += 5 * monster_speed;
|
||||||
|
Debug.WriteLine("Collision");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Target()
|
public override void Target()
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Zombie : CoreEnemy
|
public class Zombie : CoreEnemy
|
||||||
{
|
{
|
||||||
private bool isGoRight = true;
|
|
||||||
float leftBorder;
|
float leftBorder;
|
||||||
float rightBorder;
|
float rightBorder;
|
||||||
bool isAttaking = false;
|
bool isAttaking = false;
|
||||||
|
@ -25,9 +24,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
Height = 40;
|
Height = 40;
|
||||||
monster_speed = 3;
|
monster_speed = 3;
|
||||||
name = "Zombie";
|
name = "Zombie";
|
||||||
leftBorder = (int)position.X - 100;
|
leftBorder = (int)position.X - 50;
|
||||||
rightBorder = (int)position.X + 100;
|
rightBorder = (int)position.X + 50;
|
||||||
physicsManager = new PhysicsManager();
|
physicsManager = new PhysicsManager();
|
||||||
|
Random random = new Random();
|
||||||
|
if(random.Next(0, 2) == 0)
|
||||||
|
{
|
||||||
|
isGoRight = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isGoRight = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack" }, "ZombieMoveLeft");
|
||||||
|
|
||||||
|
@ -38,7 +46,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
Target();
|
Target();
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
}
|
}
|
||||||
|
fixBorder();
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +58,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
|
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
|
||||||
{
|
{
|
||||||
GraphicsComponent.StartAnimation("ZombieAttackRight");
|
GraphicsComponent.StartAnimation("ZombieRightAttack");
|
||||||
}
|
}
|
||||||
AppManager.Instance.GameManager.players[0].Death(name);
|
AppManager.Instance.GameManager.players[0].Death(name);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +79,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
|
||||||
if (isGoRight)
|
if (isGoRight)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||||
|
@ -114,7 +121,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Target()
|
public override void Target()
|
||||||
{
|
{
|
||||||
if(AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-50, (int)Pos.Y, Width+100, Height), typeof(Player))!=null)
|
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0)
|
||||||
{
|
{
|
||||||
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
|
||||||
{
|
{
|
||||||
|
@ -131,10 +138,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void fixBorder()
|
||||||
public override void Attack(GameTime gameTime)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if(leftBorder <= 0)
|
||||||
|
{
|
||||||
|
leftBorder = 0;
|
||||||
|
}
|
||||||
|
if(rightBorder >= 800)
|
||||||
|
{
|
||||||
|
rightBorder = 760;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Attack(GameTime gameTime) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath
|
||||||
{
|
{
|
||||||
public DeathRectangle(Vector2 pos, string DeathType) : base(pos)
|
public DeathRectangle(Vector2 pos, string DeathType) : base(pos)
|
||||||
{
|
{
|
||||||
Height = 128;
|
Height = 48;
|
||||||
Width = 128;
|
Width = 48;
|
||||||
PlayDeath(DeathType);
|
PlayDeath(DeathType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,29 +6,69 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DangerousD.GameCore.GameObjects.PlayerDeath;
|
using DangerousD.GameCore.GameObjects.PlayerDeath;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using DangerousD.GameCore.Network;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GameObjects.LivingEntities
|
namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
{
|
{
|
||||||
public class Player : LivingEntity
|
public class Player : LivingEntity
|
||||||
{
|
{
|
||||||
bool isAlive = true;
|
bool isAlive = true;
|
||||||
|
bool isRight;
|
||||||
|
string stayAnimation;
|
||||||
|
bool isJump = false;
|
||||||
|
public int health;
|
||||||
|
public bool isGoRight = false;
|
||||||
|
public Vector2 playerVelocity;
|
||||||
|
public int rightBorder;
|
||||||
|
public int leftBorder;
|
||||||
|
public bool isVisible = true;
|
||||||
|
private bool isAttacked = false;
|
||||||
|
public GameObject objectAttack;
|
||||||
|
|
||||||
public Player(Vector2 position) : base(position)
|
public Player(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
Width = 32;
|
Width = 16;
|
||||||
Height = 64;
|
Height = 32;
|
||||||
AppManager.Instance.InputManager.MovEventJump += AnimationJump;
|
|
||||||
|
AppManager.Instance.InputManager.ShootEvent += Shoot;
|
||||||
|
|
||||||
|
AppManager.Instance.InputManager.MovEventJump += Jump;
|
||||||
|
AppManager.Instance.InputManager.MovEventDown += MoveDown;
|
||||||
|
|
||||||
|
velocity = new Vector2(0, 0);
|
||||||
|
rightBorder = (int)position.X + 100;
|
||||||
|
leftBorder = (int)position.X - 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAlive { get { return isAlive; } }
|
public bool IsAlive { get { return isAlive; } }
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack", "ZombieLeftAttack", "DeathFromZombie" }, "ZombieMoveLeft");//TODO: Change to player
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "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)
|
||||||
|
{
|
||||||
|
base.OnCollision(gameObject);
|
||||||
|
}
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
if (isVisible)
|
||||||
|
{
|
||||||
|
base.Draw(spriteBatch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Death(string monsterName)
|
public void Death(string monsterName)
|
||||||
{
|
{
|
||||||
|
isAttacked = true;
|
||||||
if(monsterName == "Zombie")
|
if(monsterName == "Zombie")
|
||||||
{
|
{
|
||||||
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
||||||
|
@ -36,21 +76,75 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
{
|
{
|
||||||
if (a == "DeathFrom" + monsterName)
|
if (a == "DeathFrom" + monsterName)
|
||||||
{
|
{
|
||||||
AppManager.Instance.ChangeGameState(GameState.GameOver);
|
AppManager.Instance.ChangeGameState(GameState.Death);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
}
|
}
|
||||||
public void AnimationJump()
|
public void Jump()
|
||||||
{
|
{
|
||||||
velocity.Y = -300;
|
if (isOnGround)
|
||||||
|
{
|
||||||
|
velocity.Y = -11;
|
||||||
|
}
|
||||||
|
// здесь будет анимация
|
||||||
}
|
}
|
||||||
|
public void Shoot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
||||||
velocity.X = 1;
|
if (!isAttacked)
|
||||||
|
{
|
||||||
|
Move(gameTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = 0;
|
||||||
|
}
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Move(GameTime gameTime)
|
||||||
|
{
|
||||||
|
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
|
velocity.X = 5 * AppManager.Instance.InputManager.VectorMovementDirection.X;
|
||||||
|
if (AppManager.Instance.InputManager.VectorMovementDirection.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "playerMoveRight")//идёт направо
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("playerMoveRight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (AppManager.Instance.InputManager.VectorMovementDirection.X < 0)//идёт налево
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "playerMoveLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("playerMoveLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(AppManager.Instance.InputManager.VectorMovementDirection.X == 0)//стоит
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("ZombieMoveLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer)
|
||||||
|
{
|
||||||
|
NetworkTask task = new NetworkTask(id, Pos);
|
||||||
|
AppManager.Instance.NetworkTasks.Add(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void MoveDown()
|
||||||
|
{
|
||||||
|
// ПОЧЕМУ
|
||||||
|
velocity.Y = -11;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,17 @@ namespace DangerousD.GameCore.GameObjects;
|
||||||
|
|
||||||
public abstract class LivingEntity : Entity
|
public abstract class LivingEntity : Entity
|
||||||
{
|
{
|
||||||
private Vector2 targetPosition;
|
public bool isOnGround = true;
|
||||||
|
public Vector2 velocity;
|
||||||
|
public Vector2 acceleration;
|
||||||
|
|
||||||
public LivingEntity(Vector2 position) : base(position)
|
public LivingEntity(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
acceleration = new Vector2(0, 30);
|
acceleration = new Vector2(0, 30);
|
||||||
}
|
}
|
||||||
public override void SetPosition(Vector2 position)
|
public override void SetPosition(Vector2 position)
|
||||||
{
|
{
|
||||||
targetPosition = position; _pos = position;
|
_pos = position;
|
||||||
|
|
||||||
} //TODO befrend targetpos and physics engine
|
} //TODO befrend targetpos and physics engine
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,10 @@ namespace DangerousD.GameCore.Graphics
|
||||||
private void buildSourceRectangle()
|
private void buildSourceRectangle()
|
||||||
{
|
{
|
||||||
sourceRectangle = new Rectangle();
|
sourceRectangle = new Rectangle();
|
||||||
|
if (currentAnimation == null)
|
||||||
|
{
|
||||||
|
currentAnimation = neitralAnimation;
|
||||||
|
}
|
||||||
sourceRectangle.X = currentAnimation.StartSpriteRectangle.X + currentFrame *
|
sourceRectangle.X = currentAnimation.StartSpriteRectangle.X + currentFrame *
|
||||||
(currentAnimation.StartSpriteRectangle.Width + currentAnimation.TextureFrameInterval);
|
(currentAnimation.StartSpriteRectangle.Width + currentAnimation.TextureFrameInterval);
|
||||||
sourceRectangle.Y = currentAnimation.StartSpriteRectangle.Y;
|
sourceRectangle.Y = currentAnimation.StartSpriteRectangle.Y;
|
||||||
|
|
|
@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum ScopeState { Up, Middle, Down }
|
public enum ScopeState { Up, Middle, Down }
|
||||||
|
public enum ControlsState { Gamepad, Keyboard, Mouse }
|
||||||
public class InputManager
|
public class InputManager
|
||||||
{
|
{
|
||||||
public delegate void Delegat();
|
public delegate void Delegat();
|
||||||
|
@ -19,26 +20,32 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
Vector2 vectorMovementDirection;
|
Vector2 vectorMovementDirection;
|
||||||
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
||||||
|
ControlsState controlsState;
|
||||||
|
|
||||||
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
||||||
private bool isShoot;
|
private bool isShoot;
|
||||||
|
|
||||||
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
||||||
public ScopeState ScopeState { get => scopeState; }
|
public ScopeState ScopeState { get => scopeState; }
|
||||||
|
public string currentControlsState = "";
|
||||||
|
|
||||||
public InputManager()
|
public InputManager()
|
||||||
{
|
{
|
||||||
this.isJumpDown = false;
|
this.isJumpDown = false;
|
||||||
this.isShoot = false;
|
this.isShoot = false;
|
||||||
scopeState = ScopeState.Middle;
|
scopeState = ScopeState.Middle;
|
||||||
|
controlsState= ControlsState.Mouse;
|
||||||
vectorMovementDirection = new Vector2(0, 0);
|
vectorMovementDirection = new Vector2(0, 0);
|
||||||
}
|
}
|
||||||
|
public void SetState(ControlsState controlsStates)
|
||||||
|
{
|
||||||
|
currentControlsState = controlsStates.ToString();
|
||||||
|
}
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
// Работа с GamePad
|
// Работа с GamePad
|
||||||
if (GamePad.GetState(0).IsConnected)
|
if (GamePad.GetState(0).IsConnected)
|
||||||
{
|
{
|
||||||
// Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
|
// Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
|
||||||
GamePadState gamePadState = GamePad.GetState(0);
|
GamePadState gamePadState = GamePad.GetState(0);
|
||||||
vectorMovementDirection = gamePadState.ThumbSticks.Left;
|
vectorMovementDirection = gamePadState.ThumbSticks.Left;
|
||||||
|
@ -86,6 +93,7 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
isShoot = false;
|
isShoot = false;
|
||||||
}
|
}
|
||||||
|
SetState(ControlsState.Gamepad);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Работа с KeyBoard
|
// Работа с KeyBoard
|
||||||
|
|
|
@ -10,11 +10,15 @@ using DangerousD.GameCore.Graphics;
|
||||||
using DangerousD.GameCore.Network;
|
using DangerousD.GameCore.Network;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
using DangerousD.GameCore.Managers;
|
using DangerousD.GameCore.Managers;
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||||
|
using DangerousD.GameCore.GameObjects;
|
||||||
|
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum GameState { Menu, Options, Lobby, Game, Login, GameOver }
|
|
||||||
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
||||||
|
public enum GameState { Menu, Options, Lobby, Game, Login, Death, HUD,
|
||||||
|
GameOver
|
||||||
|
}
|
||||||
public class AppManager : Game
|
public class AppManager : Game
|
||||||
{
|
{
|
||||||
public static AppManager Instance { get; private set; }
|
public static AppManager Instance { get; private set; }
|
||||||
|
@ -23,13 +27,16 @@ namespace DangerousD.GameCore
|
||||||
private SpriteBatch _spriteBatch;
|
private SpriteBatch _spriteBatch;
|
||||||
public GameState gameState { get; private set; }
|
public GameState gameState { get; private set; }
|
||||||
public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer;
|
public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer;
|
||||||
|
public Point resolution = new Point(1920, 1080);
|
||||||
|
public Point inGameResolution = new Point(1366, 768);
|
||||||
IDrawableObject MenuGUI;
|
IDrawableObject MenuGUI;
|
||||||
IDrawableObject OptionsGUI;
|
IDrawableObject OptionsGUI;
|
||||||
IDrawableObject LoginGUI;
|
IDrawableObject LoginGUI;
|
||||||
IDrawableObject LobbyGUI;
|
IDrawableObject LobbyGUI;
|
||||||
public Point resolution = new Point(1920, 1080);
|
IDrawableObject DeathGUI;
|
||||||
public Point inGameResolution = new Point(800, 480);
|
IDrawableObject HUD;
|
||||||
private RenderTarget2D renderTarget;
|
public DebugHUD DebugHUD;
|
||||||
|
public List<NetworkTask> NetworkTasks = new List<NetworkTask>();
|
||||||
|
|
||||||
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();
|
||||||
|
@ -37,6 +44,8 @@ namespace DangerousD.GameCore
|
||||||
public InputManager InputManager { get; private set; } = new InputManager();
|
public InputManager InputManager { get; private set; } = new InputManager();
|
||||||
public SoundManager SoundManager { get; private set; } = new SoundManager();
|
public SoundManager SoundManager { get; private set; } = new SoundManager();
|
||||||
public SettingsManager SettingsManager { get; private set; } = new SettingsManager();
|
public SettingsManager SettingsManager { get; private set; } = new SettingsManager();
|
||||||
|
|
||||||
|
private RenderTarget2D renderTarget;
|
||||||
public AppManager()
|
public AppManager()
|
||||||
{
|
{
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
|
@ -53,11 +62,15 @@ namespace DangerousD.GameCore
|
||||||
resolution = SettingsManager.Resolution;
|
resolution = SettingsManager.Resolution;
|
||||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||||
// _graphics.IsFullScreen = true;
|
_graphics.IsFullScreen = false;
|
||||||
gameState = GameState.Menu;
|
gameState = GameState.Menu;
|
||||||
MenuGUI = new MenuGUI();
|
MenuGUI = new MenuGUI();
|
||||||
LoginGUI = new LoginGUI();
|
LoginGUI = new LoginGUI();
|
||||||
|
OptionsGUI = new OptionsGUI();
|
||||||
LobbyGUI = new LobbyGUI();
|
LobbyGUI = new LobbyGUI();
|
||||||
|
DeathGUI = new DeathGUI();
|
||||||
|
HUD = new HUD();
|
||||||
|
DebugHUD = new DebugHUD();
|
||||||
UIManager.resolution = resolution;
|
UIManager.resolution = resolution;
|
||||||
UIManager.resolutionInGame = inGameResolution;
|
UIManager.resolutionInGame = inGameResolution;
|
||||||
}
|
}
|
||||||
|
@ -67,16 +80,25 @@ namespace DangerousD.GameCore
|
||||||
AnimationBuilder.LoadAnimations();
|
AnimationBuilder.LoadAnimations();
|
||||||
MenuGUI.Initialize();
|
MenuGUI.Initialize();
|
||||||
LoginGUI.Initialize();
|
LoginGUI.Initialize();
|
||||||
|
|
||||||
|
DebugHUD.Initialize();
|
||||||
|
OptionsGUI.Initialize();
|
||||||
|
HUD.Initialize();
|
||||||
LobbyGUI.Initialize();
|
LobbyGUI.Initialize();
|
||||||
|
DeathGUI.Initialize();
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadContent()
|
protected override void LoadContent()
|
||||||
{
|
{
|
||||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
|
DebugHUD.LoadContent();
|
||||||
MenuGUI.LoadContent();
|
MenuGUI.LoadContent();
|
||||||
LoginGUI.LoadContent();
|
LoginGUI.LoadContent();
|
||||||
|
OptionsGUI.LoadContent();
|
||||||
LobbyGUI.LoadContent();
|
LobbyGUI.LoadContent();
|
||||||
|
DeathGUI.LoadContent();
|
||||||
|
HUD.LoadContent();
|
||||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||||
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();
|
||||||
|
@ -91,6 +113,7 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
InputManager.Update();
|
InputManager.Update();
|
||||||
SoundManager.Update();
|
SoundManager.Update();
|
||||||
|
|
||||||
switch (gameState)
|
switch (gameState)
|
||||||
{
|
{
|
||||||
case GameState.Menu:
|
case GameState.Menu:
|
||||||
|
@ -105,12 +128,19 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Lobby:
|
case GameState.Lobby:
|
||||||
LobbyGUI.Update(gameTime);
|
LobbyGUI.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
|
case GameState.Death:
|
||||||
|
DeathGUI.Update(gameTime);
|
||||||
|
break;
|
||||||
|
case GameState.HUD:
|
||||||
|
HUD.Update(gameTime);
|
||||||
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
GameManager.Update(gameTime);
|
GameManager.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
DebugHUD.Update(gameTime);
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
@ -134,6 +164,12 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Lobby:
|
case GameState.Lobby:
|
||||||
LobbyGUI.Draw(_spriteBatch);
|
LobbyGUI.Draw(_spriteBatch);
|
||||||
break;
|
break;
|
||||||
|
case GameState.Death:
|
||||||
|
DeathGUI.Draw(_spriteBatch);
|
||||||
|
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);
|
||||||
|
@ -148,6 +184,7 @@ namespace DangerousD.GameCore
|
||||||
_spriteBatch.End();
|
_spriteBatch.End();
|
||||||
|
|
||||||
|
|
||||||
|
DebugHUD.Draw(_spriteBatch);
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,9 +202,9 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Lobby:
|
case GameState.Lobby:
|
||||||
break;
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
GameManager.mapManager.LoadLevel("map");
|
GameManager.mapManager.LoadLevel("lvl");
|
||||||
break;
|
break;
|
||||||
case GameState.GameOver:
|
case GameState.Death:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
@ -188,18 +225,29 @@ namespace DangerousD.GameCore
|
||||||
case NetworkTaskOperationEnum.CreateEntity:
|
case NetworkTaskOperationEnum.CreateEntity:
|
||||||
break;
|
break;
|
||||||
case NetworkTaskOperationEnum.SendPosition:
|
case NetworkTaskOperationEnum.SendPosition:
|
||||||
|
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
|
||||||
|
entity.SetPosition(networkTask.position);
|
||||||
break;
|
break;
|
||||||
case NetworkTaskOperationEnum.ChangeState:
|
case NetworkTaskOperationEnum.ChangeState:
|
||||||
break;
|
break;
|
||||||
case NetworkTaskOperationEnum.ConnectToHost:
|
case NetworkTaskOperationEnum.ConnectToHost:
|
||||||
|
Player connectedPlayer = new Player(Vector2.Zero);
|
||||||
|
NetworkTasks.Add(new NetworkTask(connectedPlayer.id));
|
||||||
|
NetworkTask task = new NetworkTask();
|
||||||
|
NetworkTasks.Add(task.AddConnectedPlayer(GameManager.GetPlayer1.id, GameManager.GetPlayer1.Pos));
|
||||||
break;
|
break;
|
||||||
case NetworkTaskOperationEnum.GetClientPlayerId:
|
case NetworkTaskOperationEnum.GetClientPlayerId:
|
||||||
|
GameManager.GetPlayer1.id = networkTask.objId;
|
||||||
|
break;
|
||||||
|
case NetworkTaskOperationEnum.AddConnectedPlayer:
|
||||||
|
Player remoteConnectedPlayer = new Player(networkTask.position);
|
||||||
|
remoteConnectedPlayer.id = networkTask.objId;
|
||||||
|
GameManager.players.Add(remoteConnectedPlayer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void SetMultiplayerState(MultiPlayerStatus multiPlayerStatus)
|
public void SetMultiplayerState(MultiPlayerStatus multiPlayerStatus)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,14 +8,18 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
|
using DangerousD.GameCore.GameObjects.LivingEntities.Monsters;
|
||||||
|
using System.Linq;
|
||||||
|
using DangerousD.GameCore.GUI;
|
||||||
|
using DangerousD.GameCore.Network;
|
||||||
|
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public class GameManager
|
public class GameManager
|
||||||
{
|
{
|
||||||
public List<GameObject> GetAllGameObjects { get; private set; }
|
public List<GameObject> GetAllGameObjects { get; private set; }
|
||||||
|
private int currentEntityId = 0;
|
||||||
public List<LivingEntity> livingEntities;
|
public List<LivingEntity> livingEntities;
|
||||||
|
public List<LivingEntity> livingEntitiesWithoutPlayers;
|
||||||
public List<Entity> entities;
|
public List<Entity> entities;
|
||||||
public List<MapObject> mapObjects;
|
public List<MapObject> mapObjects;
|
||||||
public List<MapObject> BackgroundObjects;
|
public List<MapObject> BackgroundObjects;
|
||||||
|
@ -24,35 +28,43 @@ namespace DangerousD.GameCore
|
||||||
public PhysicsManager physicsManager;
|
public PhysicsManager physicsManager;
|
||||||
public List<Player> players;
|
public List<Player> players;
|
||||||
public List<GameObject> otherObjects = new();
|
public List<GameObject> otherObjects = new();
|
||||||
|
|
||||||
public Player GetPlayer1 { get; private set; }
|
public Player GetPlayer1 { get; private set; }
|
||||||
public GameManager()
|
public GameManager()
|
||||||
{
|
{
|
||||||
others = new List<GameObject>();
|
others = new List<GameObject>();
|
||||||
GetAllGameObjects = new List<GameObject>();
|
GetAllGameObjects = new List<GameObject>();
|
||||||
livingEntities = new List<LivingEntity>();
|
livingEntities = new List<LivingEntity>();
|
||||||
|
livingEntitiesWithoutPlayers = new List<LivingEntity>();
|
||||||
mapObjects = new List<MapObject>();
|
mapObjects = new List<MapObject>();
|
||||||
BackgroundObjects = new List<MapObject>();
|
BackgroundObjects = new List<MapObject>();
|
||||||
entities = new List<Entity>();
|
entities = new List<Entity>();
|
||||||
players = new List<Player>();
|
players = new List<Player>();
|
||||||
mapManager = new MapManager(1);
|
mapManager = new MapManager(1);
|
||||||
physicsManager = new PhysicsManager();
|
physicsManager = new PhysicsManager();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
internal void Register(GameObject gameObject)
|
internal void Register(GameObject gameObject)
|
||||||
{
|
{
|
||||||
GetAllGameObjects.Add(gameObject);
|
GetAllGameObjects.Add(gameObject);
|
||||||
|
if (gameObject is Entity)
|
||||||
|
{
|
||||||
|
gameObject.id = currentEntityId;
|
||||||
|
currentEntityId++;
|
||||||
|
}
|
||||||
if (gameObject is Player objPl)
|
if (gameObject is Player objPl)
|
||||||
{
|
{
|
||||||
livingEntities.Add(gameObject as LivingEntity);
|
livingEntities.Add(gameObject as LivingEntity);
|
||||||
players.Add(objPl);
|
players.Add(objPl);
|
||||||
GetPlayer1 = players[0];
|
if (GetPlayer1 is null)
|
||||||
|
{
|
||||||
|
GetPlayer1 = players[players.Count - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (gameObject is LivingEntity objLE)
|
else if (gameObject is LivingEntity objLE)
|
||||||
{
|
{
|
||||||
|
livingEntitiesWithoutPlayers.Add(objLE);
|
||||||
livingEntities.Add(objLE);
|
livingEntities.Add(objLE);
|
||||||
}
|
}
|
||||||
else if (gameObject is Entity objE)
|
else if (gameObject is Entity objE)
|
||||||
|
@ -71,7 +83,6 @@ namespace DangerousD.GameCore
|
||||||
otherObjects.Add(gameObject);
|
otherObjects.Add(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch _spriteBatch)
|
public void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
foreach (var item in BackgroundObjects)
|
foreach (var item in BackgroundObjects)
|
||||||
|
@ -88,21 +99,39 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
AppManager.Instance.DebugHUD.Set("playerId: ", GetPlayer1.id.ToString());
|
||||||
|
if (AppManager.Instance.NetworkTasks.Count > 0)
|
||||||
|
{
|
||||||
|
AppManager.Instance.NetworkManager.SendMsg(AppManager.Instance.NetworkTasks.ToList());
|
||||||
|
AppManager.Instance.NetworkTasks.Clear();
|
||||||
|
}
|
||||||
foreach (var item in BackgroundObjects)
|
foreach (var item in BackgroundObjects)
|
||||||
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)
|
foreach (var item in entities)
|
||||||
item.Update(gameTime);
|
item.Update(gameTime);
|
||||||
|
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Client)
|
||||||
for (int i = 0; i < livingEntities.Count; i++)
|
{
|
||||||
livingEntities[i].Update(gameTime);
|
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
|
||||||
|
{
|
||||||
|
livingEntitiesWithoutPlayers[i].Update(gameTime);
|
||||||
|
}
|
||||||
|
GetPlayer1.Update(gameTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
|
||||||
|
{
|
||||||
|
livingEntitiesWithoutPlayers[i].PlayAnimation();
|
||||||
|
}
|
||||||
|
GetPlayer1.Update(gameTime);
|
||||||
|
}
|
||||||
|
GetPlayer1.Update(gameTime);
|
||||||
foreach (var item in otherObjects)
|
foreach (var item in otherObjects)
|
||||||
item.Update(gameTime);
|
item.Update(gameTime);
|
||||||
|
|
||||||
physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, gameTime);
|
physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, gameTime);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,7 +64,7 @@ namespace DangerousD.GameCore.Managers
|
||||||
{
|
{
|
||||||
if (tiles[i] != 0)
|
if (tiles[i] != 0)
|
||||||
{
|
{
|
||||||
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale + 370,
|
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale,
|
||||||
((chunkY + i / chunkW) * tileSize.Y + offsetY) * _scale);
|
((chunkY + i / chunkW) * tileSize.Y + offsetY) * _scale);
|
||||||
//pos *= _scale;
|
//pos *= _scale;
|
||||||
Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint());
|
Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint());
|
||||||
|
@ -106,7 +106,7 @@ namespace DangerousD.GameCore.Managers
|
||||||
foreach (XmlNode entity in group.ChildNodes)
|
foreach (XmlNode entity in group.ChildNodes)
|
||||||
{
|
{
|
||||||
Type type = Type.GetType($"DangerousD.GameCore.GameObjects.{entityType}");
|
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+280, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY - 200) * _scale);
|
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.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height));
|
||||||
inst.Height *= _scale;
|
inst.Height *= _scale;
|
||||||
inst.Width *= _scale;
|
inst.Width *= _scale;
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DangerousD.GameCore.GameObjects.LivingEntities;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.Managers
|
namespace DangerousD.GameCore.Managers
|
||||||
|
@ -20,9 +21,9 @@ namespace DangerousD.GameCore.Managers
|
||||||
item.velocity = item.velocity + item.acceleration * delta;
|
item.velocity = item.velocity + item.acceleration * delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckCollisions(livingEntities, mapObjects);
|
CheckCollisionsLE_MO(livingEntities, mapObjects);
|
||||||
OnCollision(entities, livingEntities);
|
CheckCollisionsE_LE(entities, livingEntities);
|
||||||
OnCollision(livingEntities);
|
CheckCollisionsLE_LE(livingEntities);
|
||||||
|
|
||||||
//entities dont move
|
//entities dont move
|
||||||
//Living entities dont move
|
//Living entities dont move
|
||||||
|
@ -33,68 +34,88 @@ namespace DangerousD.GameCore.Managers
|
||||||
//OnCollision
|
//OnCollision
|
||||||
|
|
||||||
}
|
}
|
||||||
public void CheckCollisions(List<LivingEntity> livingEntities,
|
private void CheckCollisionsLE_MO(List<LivingEntity> livingEntities,
|
||||||
List<MapObject> mapObjects)
|
List<MapObject> mapObjects)
|
||||||
{
|
{
|
||||||
LivingEntity currentEntity;
|
foreach (var currentEntity in livingEntities)
|
||||||
Rectangle oldRect;
|
|
||||||
for (int i = 0; i < livingEntities.Count; i++)
|
|
||||||
{
|
{
|
||||||
currentEntity = livingEntities[i];
|
var currentRect = currentEntity.Rectangle;
|
||||||
oldRect = currentEntity.Rectangle;
|
var newRect = currentRect;
|
||||||
bool isXNormalise = true;
|
|
||||||
bool isYNormalise = true;
|
|
||||||
|
|
||||||
oldRect.Offset((int)currentEntity.velocity.X, 0);
|
#region x collision
|
||||||
for (int j = 0; j < mapObjects.Count; j++)
|
var collidedX = false;
|
||||||
|
var tryingRectX = currentRect;
|
||||||
|
tryingRectX.Offset((int)Math.Ceiling(currentEntity.velocity.X), 0);
|
||||||
|
foreach (var mapObject in mapObjects)
|
||||||
{
|
{
|
||||||
if (Math.Abs(mapObjects[i].Pos.X - currentEntity.Pos.X) < 550 && Math.Abs(mapObjects[i].Pos.Y - currentEntity.Pos.Y) < 550)
|
if (
|
||||||
|
Math.Abs(mapObject.Pos.X - currentEntity.Pos.X) < 550
|
||||||
|
&& Math.Abs(mapObject.Pos.Y - currentEntity.Pos.Y) < 550
|
||||||
|
&& tryingRectX.Intersects(mapObject.Rectangle)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (oldRect.Intersects(mapObjects[j].Rectangle))
|
collidedX = true;
|
||||||
{
|
|
||||||
isXNormalise = false;
|
|
||||||
oldRect.Offset(-(int)currentEntity.velocity.X, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isXNormalise)
|
|
||||||
currentEntity.velocity.X = 0;
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isYNormalise)
|
if (collidedX)
|
||||||
|
{
|
||||||
|
currentEntity.velocity.X = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newRect.X = tryingRectX.X;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region y collision
|
||||||
|
var collidedY = false;
|
||||||
|
var tryingRectY = currentRect;
|
||||||
|
tryingRectY.Offset(0, (int)Math.Ceiling(currentEntity.velocity.Y));
|
||||||
|
if (currentEntity is Player)
|
||||||
|
{
|
||||||
|
AppManager.Instance.DebugHUD.Set("velocity", currentEntity.velocity.ToString());
|
||||||
|
AppManager.Instance.DebugHUD.Set("intersects y", "");
|
||||||
|
}
|
||||||
|
foreach (var mapObject in mapObjects)
|
||||||
|
{
|
||||||
|
if (tryingRectY.Intersects(mapObject.Rectangle))
|
||||||
|
{
|
||||||
|
if (currentEntity is Player) AppManager.Instance.DebugHUD.Set("intersects y", mapObject.GetType().ToString());
|
||||||
|
collidedY = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentEntity.isOnGround = collidedY && currentEntity.velocity.Y > 0;
|
||||||
|
if (collidedY)
|
||||||
|
{
|
||||||
currentEntity.velocity.Y = 0;
|
currentEntity.velocity.Y = 0;
|
||||||
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newRect.Y = tryingRectY.Y;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
currentEntity.SetPosition(new Vector2(newRect.X, newRect.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void OnCollision(List<Entity> entities, List<LivingEntity> livingEntities)
|
private void CheckCollisionsE_LE(List<Entity> entities, List<LivingEntity> livingEntities)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < entities.Count; i++)
|
foreach (var entity in entities)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < livingEntities.Count; j++)
|
foreach (var livingEntity in livingEntities)
|
||||||
{
|
{
|
||||||
if (livingEntities[j].Rectangle.Intersects(entities[i].Rectangle))
|
if (livingEntity.Rectangle.Intersects(entity.Rectangle))
|
||||||
{
|
{
|
||||||
livingEntities[j].OnCollision(entities[i]);
|
livingEntity.OnCollision(entity);
|
||||||
entities[i].OnCollision(livingEntities[j]);
|
entity.OnCollision(livingEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void OnCollision(List<LivingEntity> livingEntities)
|
private void CheckCollisionsLE_LE(List<LivingEntity> livingEntities)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < livingEntities.Count; i++)
|
for (int i = 0; i < livingEntities.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,8 @@ namespace DangerousD.GameCore
|
||||||
public void LoadSounds() // метод для загрузки звуков из папки
|
public void LoadSounds() // метод для загрузки звуков из папки
|
||||||
{
|
{
|
||||||
var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
|
var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
|
||||||
if (k.Count()>0)
|
|
||||||
|
if (k.Count() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
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
|
||||||
|
@ -30,17 +31,23 @@ namespace DangerousD.GameCore
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (k.Count()>0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
var sound = new Sound(Sounds[soundName]);
|
var sound = new Sound(Sounds[soundName]);
|
||||||
sound.SoundEffect.IsLooped = false;
|
sound.SoundEffect.IsLooped = false;
|
||||||
sound.SoundEffect.Play();
|
sound.SoundEffect.Play();
|
||||||
PlayingSounds.Add(sound);
|
PlayingSounds.Add(sound);
|
||||||
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
||||||
{
|
{
|
||||||
AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(Vector2.Zero, soundName));
|
AppManager.Instance.NetworkTasks.Add(new Network.NetworkTask(Vector2.Zero, soundName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void StartSound(string soundName, Vector2 soundPos, Vector2 playerPos) // запустить звук у которого есть позиция
|
public void StartSound(string soundName, Vector2 soundPos, Vector2 playerPos) // запустить звук у которого есть позиция
|
||||||
|
@ -52,7 +59,7 @@ namespace DangerousD.GameCore
|
||||||
PlayingSounds.Add(sound);
|
PlayingSounds.Add(sound);
|
||||||
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host)
|
||||||
{
|
{
|
||||||
AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(soundPos, soundName));
|
AppManager.Instance.NetworkTasks.Add(new Network.NetworkTask(soundPos, soundName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void StopAllSounds() // остановка всех звуков
|
public void StopAllSounds() // остановка всех звуков
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace DangerousD.GameCore.Network
|
||||||
{
|
{
|
||||||
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
IPAddress address = IPAddress.Parse(IpAddress);
|
IPAddress address = IPAddress.Parse(IpAddress);
|
||||||
int port = 8000;
|
int port = 51873;
|
||||||
endPoint = new IPEndPoint(address, port);
|
endPoint = new IPEndPoint(address, port);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
@ -71,6 +71,7 @@ namespace DangerousD.GameCore.Network
|
||||||
Thread acceptThread = new Thread(AcceptSockets);
|
Thread acceptThread = new Thread(AcceptSockets);
|
||||||
acceptThread.Start();
|
acceptThread.Start();
|
||||||
state = "Host";
|
state = "Host";
|
||||||
|
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Host);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
@ -84,10 +85,13 @@ namespace DangerousD.GameCore.Network
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
Thread ReceivingThread = new Thread(ReceiveMsgFromHost);
|
Thread ReceivingThread = new Thread(ReceiveMsgFromHost);
|
||||||
ReceivingThread.Start();
|
ReceivingThread.Start();
|
||||||
|
NetworkTask connectionTask = new NetworkTask("Player");
|
||||||
|
AppManager.Instance.NetworkTasks.Add(connectionTask);
|
||||||
|
AppManager.Instance.SetMultiplayerState(MultiPlayerStatus.Client);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
public void SendMsg(NetworkTask networkTask)
|
public void SendMsg(List<NetworkTask> networkTask)
|
||||||
{
|
{
|
||||||
byte[] Data = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(networkTask));
|
byte[] Data = Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(networkTask));
|
||||||
int count = Data.Length;
|
int count = Data.Length;
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace DangerousD.GameCore.Network
|
||||||
public Vector2 velocity { get; set; }
|
public Vector2 velocity { get; set; }
|
||||||
public Type type { get; set; }
|
public Type type { get; set; }
|
||||||
|
|
||||||
|
public NetworkTask() { }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Нанести урон сущности
|
/// Нанести урон сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -126,5 +127,12 @@ namespace DangerousD.GameCore.Network
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
public NetworkTask AddConnectedPlayer(int connectedPlayerId, Vector2 playerPosition)
|
||||||
|
{
|
||||||
|
operation = NetworkTaskOperationEnum.AddConnectedPlayer;
|
||||||
|
objId = connectedPlayerId;
|
||||||
|
position = playerPosition;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@ namespace DangerousD.GameCore.Network
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public enum NetworkTaskOperationEnum
|
public enum NetworkTaskOperationEnum
|
||||||
{
|
{
|
||||||
TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId
|
TakeDamage, SendSound, CreateEntity, SendPosition, ChangeState, ConnectToHost, GetClientPlayerId, AddConnectedPlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MonogameLibrary.UI.Base
|
||||||
protected Texture2D texture;
|
protected Texture2D texture;
|
||||||
protected int layerIndex;
|
protected int layerIndex;
|
||||||
protected UIManager Manager;
|
protected UIManager Manager;
|
||||||
public string textureName;
|
public string textureName = "";
|
||||||
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
||||||
public Color mainColor = Color.White;
|
public Color mainColor = Color.White;
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,13 @@ using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
namespace MonogameLibrary.UI.Base
|
namespace MonogameLibrary.UI.Base
|
||||||
{
|
{
|
||||||
|
public enum InputState { GamePad, Keyboard, Mouse }
|
||||||
public class UIManager
|
public class UIManager
|
||||||
{
|
{
|
||||||
Dictionary<int, List<DrawableUIElement>> layerCollection = new();
|
Dictionary<int, List<DrawableUIElement>> layerCollection = new();
|
||||||
public GraphicsDevice GraphicsDevice { get; private set; }
|
public GraphicsDevice GraphicsDevice { get; private set; }
|
||||||
public SpriteFont BaseFont { get; private set; }
|
public SpriteFont BaseFont { get; private set; }
|
||||||
|
public InputState inputState = InputState.Mouse;
|
||||||
public void Initialize(GraphicsDevice graphicsDevice)
|
public void Initialize(GraphicsDevice graphicsDevice)
|
||||||
{
|
{
|
||||||
GraphicsDevice = graphicsDevice;
|
GraphicsDevice = graphicsDevice;
|
||||||
|
@ -29,6 +31,7 @@ namespace MonogameLibrary.UI.Base
|
||||||
static MouseState mouseState, prevmouseState;
|
static MouseState mouseState, prevmouseState;
|
||||||
static KeyboardState keyboardState;
|
static KeyboardState keyboardState;
|
||||||
public static Point resolutionInGame, resolution;
|
public static Point resolutionInGame, resolution;
|
||||||
|
|
||||||
|
|
||||||
public void LoadContent(ContentManager content, string font)
|
public void LoadContent(ContentManager content, string font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace MonogameLibrary.UI.Elements
|
||||||
|
|
||||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||||
{
|
{
|
||||||
|
//if (Manager.)
|
||||||
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||||
{
|
{
|
||||||
if (mouseState.LeftButton == ButtonState.Pressed || mouseState.RightButton == ButtonState.Pressed)
|
if (mouseState.LeftButton == ButtonState.Pressed || mouseState.RightButton == ButtonState.Pressed)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
|
@ -15,6 +16,9 @@ namespace MonogameLibrary.UI.Elements
|
||||||
public CheckBox(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
public CheckBox(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
private Texture2D texture1;
|
||||||
|
private Texture2D texture2;
|
||||||
|
private Texture2D texture3;
|
||||||
public delegate void OnCheck(bool checkState);
|
public delegate void OnCheck(bool checkState);
|
||||||
public event OnCheck? Checked;
|
public event OnCheck? Checked;
|
||||||
private bool isChecked;
|
private bool isChecked;
|
||||||
|
@ -42,25 +46,33 @@ namespace MonogameLibrary.UI.Elements
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void LoadTexture(ContentManager content)
|
||||||
|
{
|
||||||
|
texture1 = content.Load<Texture2D>("checkboxs_off");
|
||||||
|
texture2 = content.Load<Texture2D>("checkboxs_off-on");
|
||||||
|
texture3 = content.Load<Texture2D>("checkboxs_on");
|
||||||
|
base.LoadTexture(content);
|
||||||
|
}
|
||||||
public override void Draw(SpriteBatch _spriteBatch)
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
if (isChecked)
|
if (isChecked)
|
||||||
{
|
{
|
||||||
if (hoverState == HoverState.None)
|
if (hoverState == HoverState.None)
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(124, 255, 0));
|
_spriteBatch.Draw(texture3, rectangle, Color.White);
|
||||||
else if (hoverState == HoverState.Hovering)
|
else if (hoverState == HoverState.Hovering)
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(124, 215, 0));
|
_spriteBatch.Draw(texture3, rectangle, Color.White);
|
||||||
else
|
else
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(124, 175, 0));
|
_spriteBatch.Draw(texture2, rectangle, Color.White );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (hoverState == HoverState.None)
|
if (hoverState == HoverState.None)
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(255, 20, 0));
|
_spriteBatch.Draw(texture1, rectangle, Color.White);
|
||||||
else if (hoverState == HoverState.Hovering)
|
else if (hoverState == HoverState.Hovering)
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(215, 20, 0));
|
_spriteBatch.Draw(texture2, rectangle, Color.White);
|
||||||
else
|
else
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(175, 20, 0));
|
_spriteBatch.Draw(texture2, rectangle, Color.White);
|
||||||
}
|
}
|
||||||
DrawText(_spriteBatch);
|
DrawText(_spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
68
MonogameLibrary/UI/Elements/Rect.cs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using MonogameLibrary.UI.Base;
|
||||||
|
using MonogameLibrary.UI.Enums;
|
||||||
|
using MonogameLibrary.UI.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using static MonogameLibrary.UI.Elements.Button;
|
||||||
|
|
||||||
|
namespace MonogameLibrary.UI.Elements
|
||||||
|
{
|
||||||
|
public class Rect : DrawableTextedUiElement, IInteractable
|
||||||
|
{
|
||||||
|
public delegate void OnButtonPressed();
|
||||||
|
public event OnButtonPressed? RightButtonPressed;
|
||||||
|
public event OnButtonPressed? LeftButtonPressed;
|
||||||
|
protected HoverState hoverState = HoverState.None;
|
||||||
|
|
||||||
|
public Rect(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||||
|
{
|
||||||
|
//if (Manager.)
|
||||||
|
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||||
|
{
|
||||||
|
if (mouseState.LeftButton == ButtonState.Pressed || mouseState.RightButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Pressing;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Hovering;
|
||||||
|
}
|
||||||
|
if (prevmouseState.LeftButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
if (mouseState.LeftButton != prevmouseState.LeftButton)
|
||||||
|
{
|
||||||
|
hoverState = HoverState.Pressing;
|
||||||
|
LeftButtonPressed?.Invoke();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(prevmouseState.RightButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
if (mouseState.RightButton != prevmouseState.RightButton)
|
||||||
|
{
|
||||||
|
RightButtonPressed?.Invoke();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hoverState = HoverState.None;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public override void Draw(SpriteBatch _spriteBatch)
|
||||||
|
{
|
||||||
|
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||||
|
DrawText(_spriteBatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
|
@ -17,7 +18,9 @@ namespace MonogameLibrary.UI.Elements
|
||||||
}
|
}
|
||||||
public delegate void OnSliderChanges(float value);
|
public delegate void OnSliderChanges(float value);
|
||||||
public event OnSliderChanges? SliderChanged;
|
public event OnSliderChanges? SliderChanged;
|
||||||
|
public int indentation = 5;
|
||||||
|
|
||||||
|
Texture2D texture2;
|
||||||
public Rectangle sliderRect = new Rectangle(0, 0, 30, 30);
|
public Rectangle sliderRect = new Rectangle(0, 0, 30, 30);
|
||||||
private float sliderValue = 0;
|
private float sliderValue = 0;
|
||||||
private float minValue = 0, maxValue = 1;
|
private float minValue = 0, maxValue = 1;
|
||||||
|
@ -50,6 +53,13 @@ namespace MonogameLibrary.UI.Elements
|
||||||
sliderState = SliderState.None;
|
sliderState = SliderState.None;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void LoadTexture(ContentManager content)
|
||||||
|
{
|
||||||
|
texture2 = content.Load<Texture2D>("slider");
|
||||||
|
base.LoadTexture(content);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetValue(float setvalue)
|
public void SetValue(float setvalue)
|
||||||
{
|
{
|
||||||
sliderValue = setvalue;
|
sliderValue = setvalue;
|
||||||
|
@ -60,14 +70,14 @@ namespace MonogameLibrary.UI.Elements
|
||||||
{
|
{
|
||||||
base.Draw(_spriteBatch);
|
base.Draw(_spriteBatch);
|
||||||
sliderRect.Location = rectangle.Location;
|
sliderRect.Location = rectangle.Location;
|
||||||
sliderRect.X += (int)(sliderValue * (rectangle.Width - sliderRect.Width));
|
sliderRect.X += (int)(sliderValue * (rectangle.Width - sliderRect.Width - indentation * 2) + indentation);
|
||||||
sliderRect.Y -= sliderRect.Height / 2 - rectangle.Height / 2;
|
sliderRect.Y -= sliderRect.Height / 2 - rectangle.Height / 2;
|
||||||
if (sliderState == SliderState.Moving)
|
if (sliderState == SliderState.Moving)
|
||||||
_spriteBatch.Draw(texture, sliderRect, Color.DarkRed);
|
_spriteBatch.Draw(texture2, sliderRect, Color.DarkRed);
|
||||||
else if(sliderState == SliderState.HoveringOverSliderButton)
|
else if(sliderState == SliderState.HoveringOverSliderButton)
|
||||||
_spriteBatch.Draw(texture, sliderRect, new Color(200,0,0));
|
_spriteBatch.Draw(texture2, sliderRect, new Color(200,0 ,0));
|
||||||
else
|
else
|
||||||
_spriteBatch.Draw(texture, sliderRect, Color.Red);
|
_spriteBatch.Draw(texture2, sliderRect, Color.Red);
|
||||||
DrawText(_spriteBatch);
|
DrawText(_spriteBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace MonogameLibrary.UI.Elements
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
||||||
else
|
else
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144));
|
_spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144));
|
||||||
DrawText(_spriteBatch);
|
DrawText(_spriteBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|