Merge branch 'main' into ui_new

This commit is contained in:
SergoDobro 2023-08-18 13:57:24 +03:00
commit 0f0c553758
16 changed files with 324 additions and 103 deletions

View file

@ -255,6 +255,18 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/shotgun_shot.mp3 /build:sounds/shotgun_shot.mp3
#begin SmokeAnimation2.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:SmokeAnimation2.png
#begin textboxbackground1-1.png #begin textboxbackground1-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

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

View file

@ -7,7 +7,7 @@
<image source="doors.png" width="64" height="48"/> <image source="doors.png" width="64" height="48"/>
</tileset> </tileset>
<tileset firstgid="874" source="../../../../../Desktop/deathAnimation.tsx"/> <tileset firstgid="874" source="../../../../../Desktop/deathAnimation.tsx"/>
<layer id="1" name="Collidable" class="StopTile" width="30" height="20" offsetx="-352.033" offsety="192.098"> <layer id="1" name="Collidable" class="StopTile" width="30" height="20" visible="0" offsetx="-352.033" offsety="192.098">
<data encoding="csv"> <data encoding="csv">
<chunk x="0" y="-16" width="16" height="16"> <chunk x="0" y="-16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -147,7 +147,7 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,272,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,272,0,0,0,272,0,0,0,0,0,0,0,0,0,
52,52,52,0,0,0,52,52,52,52,52,52,52,52,52,52, 52,52,52,0,0,0,52,52,52,52,52,52,52,52,52,52,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -208,7 +208,7 @@
0,0,0,75,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,75,0,0,0,0,0,0,0,0,0,0,0,0
</chunk> </chunk>
<chunk x="-16" y="16" width="16" height="16"> <chunk x="-16" y="16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,46,0,0,66,67,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,66,67,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,66,67,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,66,67,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,66,67,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,66,67,0,
0,0,0,0,0,0,76,76,76,76,76,76,76,76,76,76, 0,0,0,0,0,0,76,76,76,76,76,76,76,76,76,76,
@ -317,7 +317,7 @@
</chunk> </chunk>
</data> </data>
</layer> </layer>
<layer id="6" name="Ladders" class="Platform" width="30" height="20"> <layer id="6" name="Ladders" class="Platform" width="30" height="20" visible="0" offsetx="-1" offsety="0">
<data encoding="csv"> <data encoding="csv">
<chunk x="-16" y="0" width="16" height="16"> <chunk x="-16" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -336,6 +336,24 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,147,199,148,0,0,0,0,0,0,0, 0,0,0,0,0,0,147,199,148,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="0" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,696,697,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,696,697,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk> </chunk>
<chunk x="32" y="0" width="16" height="16"> <chunk x="32" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@ -354,6 +372,24 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,147,199,148,0,0,0,0,0,0,0,0,0,0, 0,0,0,147,199,148,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="-32" y="16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,46,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk> </chunk>
<chunk x="-16" y="16" width="16" height="16"> <chunk x="-16" y="16" width="16" height="16">
0,0,0,0,0,0,147,199,148,0,0,0,0,0,0,0, 0,0,0,0,0,0,147,199,148,0,0,0,0,0,0,0,
@ -372,6 +408,42 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="0" y="16" width="16" height="16">
0,0,0,0,0,0,0,696,697,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="16" y="16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,696,697,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk> </chunk>
<chunk x="32" y="16" width="16" height="16"> <chunk x="32" y="16" width="16" height="16">
0,0,0,147,199,148,0,0,0,0,0,0,0,0,0,0, 0,0,0,147,199,148,0,0,0,0,0,0,0,0,0,0,
@ -442,7 +514,7 @@
144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144, 144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157, 157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,
157,157,157,157,157,157,258,157,157,157,149,152,157,157,157,157, 157,157,157,157,157,157,258,157,157,157,149,152,157,157,157,157,
157,157,157,157,157,157,271,157,157,157,150,153,157,696,697,157, 157,157,157,157,157,157,271,157,157,157,150,153,157,0,0,157,
157,157,0,204,204,204,284,204,204,204,151,154,204,709,710,204, 157,157,0,204,204,204,284,204,204,204,151,154,204,709,710,204,
157,157,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 157,157,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
157,157,144,144,144,144,144,144,144,144,144,144,144,144,144,144, 157,157,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
@ -498,7 +570,7 @@
29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29, 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
29,29,29,19,20,21,22,0,0,29,29,29,29,29,29,29, 29,29,29,19,20,21,22,0,0,29,29,29,29,29,29,29,
29,30,31,32,33,34,35,0,0,29,29,29,29,29,29,29, 29,30,31,32,33,34,35,0,0,29,29,29,29,29,29,29,
29,43,44,45,46,47,48,0,0,29,29,29,29,29,29,29, 29,43,44,45,0,47,48,0,0,29,29,29,29,29,29,29,
64,65,18,58,59,60,18,0,0,29,29,29,29,29,29,29, 64,65,18,58,59,60,18,0,0,29,29,29,29,29,29,29,
77,78,18,71,72,73,18,0,0,68,56,56,55,56,56,69, 77,78,18,71,72,73,18,0,0,68,56,56,55,56,56,69,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
@ -522,14 +594,14 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk> </chunk>
<chunk x="16" y="0" width="16" height="16"> <chunk x="16" y="0" width="16" height="16">
157,157,157,157,267,268,157,696,697,157,157,193,157,157,235,236, 157,157,157,157,267,268,157,0,0,157,157,193,157,157,235,236,
157,0,204,204,280,281,204,709,710,204,204,204,204,204,204,204, 157,0,204,204,280,281,204,709,710,204,204,204,204,204,204,204,
157,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 157,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
157,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144, 157,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
157,157,157,178,179,157,157,157,157,157,157,157,157,157,157,157, 157,157,157,178,179,157,157,157,157,157,157,157,157,157,157,157,
157,157,157,191,192,157,248,249,157,157,157,157,157,157,157,157, 157,157,157,191,192,157,248,249,157,157,157,157,157,157,157,157,
157,157,157,157,157,157,250,251,157,217,261,262,263,264,217,157, 157,157,157,157,157,157,250,251,157,217,261,262,263,264,217,157,
272,204,204,204,204,204,239,240,204,230,274,275,276,277,230,204, 0,204,204,204,204,204,239,240,204,230,274,275,276,277,230,204,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144, 144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
157,157,157,157,157,157,157,157,243,157,157,209,210,211,212,157, 157,157,157,157,157,157,157,157,243,157,157,209,210,211,212,157,
@ -552,7 +624,7 @@
144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144, 144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
157,157,178,179,157,157,157,157,157,157,157,157,157,157,157,157, 157,157,178,179,157,157,157,157,157,157,157,157,157,157,157,157,
157,157,191,192,157,157,157,157,258,157,157,157,248,249,157,157, 157,157,191,192,157,157,157,157,258,157,157,157,248,249,157,157,
157,157,157,157,157,696,697,157,271,157,157,157,250,251,157,157, 157,157,157,157,157,0,0,157,271,157,157,157,250,251,157,157,
204,204,204,204,204,709,710,204,284,204,204,204,239,240,204,204, 204,204,204,204,204,709,710,204,284,204,204,204,239,240,204,204,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -30,6 +30,7 @@ namespace DangerousD.GameCore
LoadContent(); LoadContent();
AppManager.Instance.GameManager.Register(this); AppManager.Instance.GameManager.Register(this);
GraphicsComponent.parentId = id;
} }
public virtual void OnCollision(GameObject gameObject) public virtual void OnCollision(GameObject gameObject)
@ -68,5 +69,9 @@ namespace DangerousD.GameCore
} }
} }
public GraphicsComponent GetGraphicsComponent()
{
return this.GraphicsComponent;
}
} }
} }

View file

@ -12,8 +12,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public class Slime : CoreEnemy public class Slime : CoreEnemy
{ {
private bool isGoRight = true; private bool isGoRight = true;
private bool isDown = true; private bool isDown = true;
int leftBorder; int leftBorder;
int rightBorder; int rightBorder;
bool isAttaking = false; bool isAttaking = false;
@ -30,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 400; rightBorder = 400;
//acceleration = Vector2.Zero; //acceleration = Vector2.Zero;
delay = 30; delay = 30;
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop", protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
@ -40,7 +43,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
} }
public void Jump() public void Jump(GameTime gameTime)
{ {
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100)); var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100));
velocity.X = 0; velocity.X = 0;
@ -56,8 +59,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0) if (delay <= 0)
{ {
velocity = new Vector2(5, -3); velocity = new Vector2(5, -4);
acceleration.Y = 0; acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom") if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom")
{ {
GraphicsComponent.StartAnimation("SlimeJumpLeftBottom"); GraphicsComponent.StartAnimation("SlimeJumpLeftBottom");
@ -67,6 +71,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isJumping = false; isJumping = false;
isDown = false; isDown = false;
isAttaking = false;
} }
} }
@ -81,7 +86,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0) if (delay <= 0)
{ {
velocity = new Vector2(-5, -3); velocity = new Vector2(-5, -4);
acceleration.Y = 0; acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightBottom") if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightBottom")
{ {
@ -92,6 +97,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isJumping = false; isJumping = false;
isDown = false; isDown = false;
isAttaking = false;
} }
} }
} }
@ -106,8 +112,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0) if (delay <= 0)
{ {
velocity = new Vector2(5, 3); velocity = new Vector2(5, 4);
acceleration.Y = 0; acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop") if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
{ {
GraphicsComponent.StartAnimation("SlimeJumpLeftTop"); GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
@ -118,7 +125,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isJumping = false; isJumping = false;
isDown = true; isDown = true;
isAttaking = false;
acceleration.Y = 10; acceleration.Y = 10;
Move(gameTime);
} }
} }
@ -132,8 +141,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
delay--; delay--;
if (delay <= 0) if (delay <= 0)
{ {
velocity = new Vector2(-5, 3); velocity = new Vector2(-5, 4);
acceleration.Y = 0; acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop") if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
{ {
GraphicsComponent.StartAnimation("SlimeJumpRightTop"); GraphicsComponent.StartAnimation("SlimeJumpRightTop");
@ -143,7 +153,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isJumping = false; isJumping = false;
isDown = true; isDown = true;
isAttaking = false;
acceleration.Y = 10; acceleration.Y = 10;
Move(gameTime);
} }
} }
@ -151,6 +163,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
} }
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
{ {
@ -246,24 +259,26 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
acceleration.Y = -acceleration.Y; acceleration.Y = -acceleration.Y;
} }
} }
Attack(); AppManager.Instance.DebugHUD.Set(name, isAttaking.ToString());
if(!isJumping) if(!isJumping)
{ {
if (isDown) if (isDown)
{ {
Jump(); Jump(gameTime);
} }
else if(IsInAim()) else if(IsInAim())
{ {
Jump(); Jump(gameTime);
isAttaking = true;
} }
else else if(!isAttaking)
{ {
Move(gameTime); Move(gameTime);
}
} }
else { Jump(gameTime); }
}
base.Update(gameTime); base.Update(gameTime);
@ -283,6 +298,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X + Width, (int)Pos.Y + Height, 200, 500), false); getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X + Width, (int)Pos.Y + Height, 200, 500), false);
if (getCols.Count > 0) if (getCols.Count > 0)
{ {
return true; return true;
} }
} }
@ -291,9 +307,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y + Height, 200, 500), false); getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y + Height, 200, 500), false);
if (getCols.Count > 0) if (getCols.Count > 0)
{ {
return true; return true;
} }
} }
/*/else if (isGoRight && isDown)
{
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X +Width, (int)Pos.Y -500, 200, 500), false);
if (getCols.Count > 0)
{
isAttaking = true;
return true;
}
}
else if (!isGoRight && isDown)
{
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 200, (int)Pos.Y - 500, 200, 500), false);
if (getCols.Count > 0)
{
isAttaking = true;
return true;
}
}/*/
return false; return false;

View file

@ -30,11 +30,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isDownUp = true; isDownUp = true;
isDown = true; isDown = true;
physicsManager = AppManager.Instance.GameManager.physicsManager; physicsManager = AppManager.Instance.GameManager.physicsManager;
web = new SpiderWeb(Pos);
name = "Spider"; name = "Spider";
Width = 112; Width = 112;
Height = 24; Height = 24;
delay = 0; delay = 0;
web = new SpiderWeb(new Vector2(Pos.X-Width/2,Pos.Y));
webLength = 0; webLength = 0;
monster_speed = 3; monster_speed = 3;
acceleration = new Vector2(0, -50); acceleration = new Vector2(0, -50);

View file

@ -39,6 +39,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
isGoRight = false; isGoRight = false;
} }
this.GraphicsComponent.actionOfAnimationEnd += (a) =>
{
if (a == "ZombieRightAttack" || a == "ZombieLeftAttack")
{
isAttaking = 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");
@ -90,19 +98,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
if (isGoRight) if (isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight") StartCicycleAnimation("ZombieMoveRight");
{
GraphicsComponent.StartAnimation("ZombieMoveRight");
}
velocity.X = monster_speed; velocity.X = monster_speed;
} }
else if (!isGoRight) else if (!isGoRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft") StartCicycleAnimation("ZombieMoveLeft");
{
GraphicsComponent.StartAnimation("ZombieMoveLeft");
}
velocity.X = -monster_speed; velocity.X = -monster_speed;
} }
@ -136,14 +138,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X) if(isGoRight && this._pos.X <= AppManager.Instance.GameManager.players[0].Pos.X)
{ {
isTarget = true; isTarget = true;
leftBorder = Pos.X - 10; leftBorder = Pos.X - 100;
rightBorder = Pos.X + AppManager.Instance.GameManager.players[0].Pos.X; rightBorder = Pos.X + AppManager.Instance.GameManager.players[0].Pos.X;
} }
else if(!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X) else if(!isGoRight && this._pos.X >= AppManager.Instance.GameManager.players[0].Pos.X)
{ {
isTarget = true; isTarget = true;
rightBorder = Pos.X + 10; rightBorder = Pos.X + 100;
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X; leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
} }
} }
@ -159,6 +161,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 760; rightBorder = 760;
} }
} }
public void SwitchToRight()
{
isGoRight = true;
}
public void SwitchToLeft()
{
isGoRight = false;
}
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{} {}

View file

@ -9,9 +9,9 @@ using Microsoft.Xna.Framework;
namespace DangerousD.GameCore.GameObjects.PlayerDeath namespace DangerousD.GameCore.GameObjects.PlayerDeath
{ {
public class DeathRectangle : GameObject public class AnimationRectangle : GameObject
{ {
public DeathRectangle(Vector2 pos, string DeathType) : base(pos) public AnimationRectangle(Vector2 pos, string DeathType) : base(pos)
{ {
Height = 48; Height = 48;
Width = 48; Width = 48;

View file

@ -16,11 +16,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public class Player : LivingEntity public class Player : LivingEntity
{ {
bool isAlive = true; bool isAlive = true;
bool isRight; bool isRight = true;
string stayAnimation; string stayAnimation;
bool isJump = false; bool isJump = false;
public int health; public int health;
public bool isGoRight = false;
public Vector2 playerVelocity; public Vector2 playerVelocity;
public int rightBorder; public int rightBorder;
public int leftBorder; public int leftBorder;
@ -31,6 +30,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
private int bullets; private int bullets;
public bool FallingThroughPlatform = false; public bool FallingThroughPlatform = false;
public bool isUping = false; public bool isUping = false;
public bool isNetworkPlayer;
private int shootLength = 160;
@ -39,6 +41,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public Player(Vector2 position, bool isNetworkPlayer = false) : base(position) public Player(Vector2 position, bool isNetworkPlayer = false) : base(position)
{ {
this.isNetworkPlayer = isNetworkPlayer;
Width = 16; Width = 16;
Height = 32; Height = 32;
@ -47,8 +50,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
AppManager.Instance.InputManager.ShootEvent += Shoot; AppManager.Instance.InputManager.ShootEvent += Shoot;
AppManager.Instance.InputManager.MovEventJump += Jump; AppManager.Instance.InputManager.MovEventJump += Jump;
AppManager.Instance.InputManager.MovEventDown += MoveDown; AppManager.Instance.InputManager.MovEventDown += MoveDown;
}
velocity = new Vector2(0, 0); velocity = new Vector2(0, 0);
rightBorder = (int)position.X + 100; rightBorder = (int)position.X + 100;
leftBorder = (int)position.X - 100; leftBorder = (int)position.X - 100;
@ -67,10 +68,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}; };
} }
}
public bool IsAlive { get { return isAlive; } } public bool IsAlive { get { return isAlive; } }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft", protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft", "playerMoveRight", "DeathFromZombie", "playerRightStay", "playerStayLeft",
"playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload"}, "playerReload"); "playerJumpRight" , "playerJumpLeft", "playerShootLeft", "playerShootRight", "playerReload", "smokeAfterShoot"}, "playerReload");
public void Attack() public void Attack()
{ {
@ -100,7 +103,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isAttacked = true; isAttacked = true;
if(monsterName == "Zombie") if(monsterName == "Zombie")
{ {
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) => deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{ {
if (a == "DeathFrom" + monsterName) if (a == "DeathFrom" + monsterName)
@ -111,7 +114,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
else if(monsterName == "Spider") else if(monsterName == "Spider")
{ {
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName); AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) => deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{ {
if (a == "DeathFrom" + monsterName) if (a == "DeathFrom" + monsterName)
@ -133,35 +136,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public void Shoot() public void Shoot()
{ {
if (bullets > 0) if (bullets > 0)
{
if (!isAttacked)
{ {
if (!isShooting) if (!isShooting)
{ {
AppManager.Instance.SoundManager.StartSound("shotgun_shot", Pos, Pos);
isShooting = true; isShooting = true;
bullets--; bullets--;
if (isRight) if (isRight)
{ {
if (GraphicsComponent.GetCurrentAnimation != "playerShootRight") StartCicycleAnimation("playerShootRight");
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), shootLength + 24, 10), typeof(Zombie)).OrderBy(x => (x.Pos - Pos).LengthSquared());
if (targets.Count() > 0)
{ {
GraphicsComponent.StartAnimation("playerShootRight"); Zombie targetZombie = (Zombie)targets.First();
}
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), 100, 10), typeof(Zombie));
if (targets != null)
{
foreach (var target in targets)
{
Zombie targetZombie = (Zombie)target;
targetZombie.TakeDamage(); targetZombie.TakeDamage();
} }
} SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
} }
else else
{ {
if (GraphicsComponent.GetCurrentAnimation != "playerShootRight") StartCicycleAnimation("playerShootLeft");
{ var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie));
GraphicsComponent.StartAnimation("playerShootRight");
}
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)(Pos.Y - 10f), -100, 10), typeof(Zombie));
if (targets != null) if (targets != null)
{ {
foreach (var target in targets) foreach (var target in targets)
@ -170,6 +166,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
targetZombie.TakeDamage(); targetZombie.TakeDamage();
} }
} }
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
}
} }
} }
} }
@ -190,6 +188,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
GraphicsComponent.SetCameraPosition(Pos); GraphicsComponent.SetCameraPosition(Pos);
if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat) if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat)
{
if (!isShooting)
{ {
Move(gameTime); Move(gameTime);
} }
@ -197,6 +197,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
velocity.X = 0; velocity.X = 0;
} }
}
else
{
velocity.X = 0;
}
base.Update(gameTime); base.Update(gameTime);
} }
@ -252,6 +258,5 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
FallingThroughPlatform = true; FallingThroughPlatform = true;
isOnGround = false; isOnGround = false;
} }
} }
} }

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DangerousD.GameCore.GameObjects;
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
namespace DangerousD.GameCore.GameObjects.PlayerDeath
{
public class SmokeAfterShoot : GameObject
{
public SmokeAfterShoot(Vector2 pos) : base(pos)
{
Height = 6;
Width = 6;
PlaySmoke();
this.GraphicsComponent.actionOfAnimationEnd += (a) =>
{
if (a == "smokeAfterShoot")
{
AppManager.Instance.GameManager.Remove(this);
}
};
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "smokeAfterShoot" },
"smokeAfterShoot");
public GraphicsComponent Gr => GraphicsComponent;
private void PlaySmoke()
{
if (GraphicsComponent.GetCurrentAnimation != "smokeAfterShoot")
{
GraphicsComponent.StartAnimation("smokeAfterShoot");
}
}
}
}

View file

@ -1,4 +1,5 @@
using DangerousD.GameCore.Managers; using DangerousD.GameCore.Managers;
using DangerousD.GameCore.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@ -18,6 +19,7 @@ namespace DangerousD.GameCore.Graphics
private List<string> texturesNames; private List<string> texturesNames;
private AnimationContainer currentAnimation; private AnimationContainer currentAnimation;
static private int scaling = 4; static private int scaling = 4;
public int parentId;
public AnimationContainer CurrentAnimation public AnimationContainer CurrentAnimation
{ {
get get
@ -105,6 +107,14 @@ namespace DangerousD.GameCore.Graphics
public void StartAnimation(string startedanimationId) public void StartAnimation(string startedanimationId)
{ {
if (startedanimationId == "playerShootRight" && parentId == 17)
{
string a = "2";
}
if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.SinglePlayer && startedanimationId != GetCurrentAnimation)
{
AppManager.Instance.NetworkTasks.Add(new NetworkTask(parentId, startedanimationId, Vector2.Zero));
}
currentFrame = 0; currentFrame = 0;
currentAnimation = animations.Find(x => x.Id == startedanimationId); currentAnimation = animations.Find(x => x.Id == startedanimationId);

View file

@ -111,9 +111,8 @@ namespace DangerousD.GameCore
{ {
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit(); Exit();
if (GameManager.GetPlayer1 != null) if (GameManager.GetPlayer1 != null)
DebugHUD.Set("Objid: ", GameManager.GetPlayer1.id.ToString()); DebugHUD.Set("id: ", GameManager.GetPlayer1.id.ToString());
InputManager.Update(); InputManager.Update();
SoundManager.Update(); SoundManager.Update();
@ -201,8 +200,12 @@ namespace DangerousD.GameCore
case GameState.Lobby: case GameState.Lobby:
break; break;
case GameState.Game: case GameState.Game:
GameManager.mapManager.LoadLevel("lvl");
GameManager.mapManager.LoadLevel("map");
GameManager.FindBorders(); GameManager.FindBorders();
break; break;
case GameState.Death: case GameState.Death:
break; break;
@ -228,6 +231,7 @@ namespace DangerousD.GameCore
if (networkTask.objId != GameManager.GetPlayer1.id ) if (networkTask.objId != GameManager.GetPlayer1.id )
{ {
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId); LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
if (entity != null)
entity.SetPosition(networkTask.position); entity.SetPosition(networkTask.position);
if (multiPlayerStatus == MultiPlayerStatus.Host) if (multiPlayerStatus == MultiPlayerStatus.Host)
{ {
@ -236,6 +240,20 @@ namespace DangerousD.GameCore
} }
break; break;
case NetworkTaskOperationEnum.ChangeState: case NetworkTaskOperationEnum.ChangeState:
if (networkTask.objId != GameManager.GetPlayer1.id)
{
List<GraphicsComponent> gcs = new List<GraphicsComponent>();
foreach (var player in GameManager.players)
{
gcs.Add(player.GetGraphicsComponent());
}
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
if (entity != null)
{
GraphicsComponent gc = entity.GetGraphicsComponent();
gc.StartAnimation(networkTask.name);
}
}
break; break;
case NetworkTaskOperationEnum.ConnectToHost: case NetworkTaskOperationEnum.ConnectToHost:
Player connectedPlayer = new Player(Vector2.Zero, true); Player connectedPlayer = new Player(Vector2.Zero, true);
@ -253,13 +271,15 @@ namespace DangerousD.GameCore
if (!GameManager.GetPlayer1.isIdFromHost) if (!GameManager.GetPlayer1.isIdFromHost)
{ {
GameManager.GetPlayer1.id = networkTask.objId; GameManager.GetPlayer1.id = networkTask.objId;
GraphicsComponent gcsd = GameManager.GetPlayer1.GetGraphicsComponent();
gcsd.parentId = networkTask.objId;
GameManager.GetPlayer1.isIdFromHost = true; GameManager.GetPlayer1.isIdFromHost = true;
} }
break; break;
case NetworkTaskOperationEnum.AddConnectedPlayer: case NetworkTaskOperationEnum.AddConnectedPlayer:
Player remoteConnectedPlayer = new Player(networkTask.position, true); Player remoteConnectedPlayer = new Player(networkTask.position, true);
remoteConnectedPlayer.id = networkTask.objId; remoteConnectedPlayer.id = networkTask.objId;
remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId;
break; break;
default: default:
break; break;

View file

@ -150,16 +150,24 @@ namespace DangerousD.GameCore
} }
else else
{ {
for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++) for (int i = 0; i < livingEntitiesWithoutPlayers.Count; i++)
{ {
livingEntitiesWithoutPlayers[i].PlayAnimation(); livingEntitiesWithoutPlayers[i].PlayAnimation();
} }
} }
foreach (Player player in players)
{
if (player.id != GetPlayer1.id)
{
player.PlayAnimation();
}
}
GetPlayer1.Update(gameTime); GetPlayer1.Update(gameTime);
foreach (var item in otherObjects) for(int i = 0; i < otherObjects.Count; i++)
item.Update(gameTime); {
otherObjects[i].Update(gameTime);
}
physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, players, gameTime); physicsManager.UpdateCollisions(entities, livingEntities, mapObjects, players, gameTime);
} }