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
/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
/importer:TextureImporter
/processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -15,7 +15,7 @@
{
"Item1": 1,
"Item2": 20
}
}
],
"textureFrameInterval": 1,
"framesCount": 2,

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"/>
</tileset>
<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">
<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,
@ -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,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,
0,0,0,0,0,0,0,0,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
</chunk>
<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,76,76,76,76,76,76,76,76,76,76,
@ -317,7 +317,7 @@
</chunk>
</data>
</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">
<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,
@ -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,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
</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 x="32" y="0" width="16" height="16">
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,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
</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 x="-16" y="16" width="16" height="16">
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
</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 x="32" y="16" width="16" height="16">
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,
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,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,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,
@ -498,7 +570,7 @@
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,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,
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
@ -522,14 +594,14 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="16" y="0" width="16" height="16">
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,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,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,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,
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,
@ -552,7 +624,7 @@
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,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,
0,0,0,0,0,0,0,0,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();
AppManager.Instance.GameManager.Register(this);
GraphicsComponent.parentId = id;
}
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
{
private bool isGoRight = true;
private bool isDown = true;
int leftBorder;
int rightBorder;
bool isAttaking = false;
@ -30,6 +32,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
rightBorder = 400;
//acceleration = Vector2.Zero;
delay = 30;
}
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));
velocity.X = 0;
@ -56,17 +59,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0)
{
velocity = new Vector2(5, -3);
velocity = new Vector2(5, -4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftBottom")
{
GraphicsComponent.StartAnimation("SlimeJumpLeftBottom");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
if (getCols.Count > 0)
if (getCols.Count > 0 )
{
isJumping = false;
isDown = false;
isAttaking = false;
}
}
@ -81,7 +86,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0)
{
velocity = new Vector2(-5, -3);
velocity = new Vector2(-5, -4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightBottom")
{
@ -92,6 +97,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
isJumping = false;
isDown = false;
isAttaking = false;
}
}
}
@ -106,19 +112,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
if (delay <= 0)
{
velocity = new Vector2(5, 3);
velocity = new Vector2(5, 4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
{
GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X+1, (int)Pos.Y + Height, 46, 5));
if (getCols.Count > 0)
if (getCols.Count > 0 )
{
isJumping = false;
isDown = true;
isAttaking = false;
acceleration.Y = 10;
Move(gameTime);
}
}
@ -132,24 +141,28 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
delay--;
if (delay <= 0)
{
velocity = new Vector2(-5, 3);
velocity = new Vector2(-5, 4);
acceleration.Y = 0;
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
{
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
}
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X+1, (int)Pos.Y + Height, 46, 5));
if (getCols.Count > 0)
if (getCols.Count > 0 )
{
isJumping = false;
isDown = true;
isAttaking = false;
acceleration.Y = 10;
Move(gameTime);
}
}
}
}
public override void Draw(SpriteBatch spriteBatch)
@ -246,25 +259,27 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
acceleration.Y = -acceleration.Y;
}
}
Attack();
if (!isJumping)
AppManager.Instance.DebugHUD.Set(name, isAttaking.ToString());
if(!isJumping)
{
if (isDown)
{
Jump();
Jump(gameTime);
}
else if(IsInAim())
{
Jump();
Jump(gameTime);
isAttaking = true;
}
else
else if(!isAttaking)
{
Move(gameTime);
}
else { Jump(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);
if (getCols.Count > 0)
{
return true;
}
}
@ -291,10 +307,29 @@ 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);
if (getCols.Count > 0)
{
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;
}

View file

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

View file

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

View file

@ -9,9 +9,9 @@ using Microsoft.Xna.Framework;
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;
Width = 48;

View file

@ -16,11 +16,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public class Player : LivingEntity
{
bool isAlive = true;
bool isRight;
bool isRight = true;
string stayAnimation;
bool isJump = false;
public int health;
public bool isGoRight = false;
public Vector2 playerVelocity;
public int rightBorder;
public int leftBorder;
@ -31,14 +30,18 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
private int bullets;
public bool FallingThroughPlatform = false;
public bool isUping = false;
public bool isNetworkPlayer;
private int shootLength = 160;
public int Bullets { get { return bullets; } }
public Player(Vector2 position, bool isNetworkPlayer = false) : base(position)
{
this.isNetworkPlayer = isNetworkPlayer;
Width = 16;
Height = 32;
@ -47,30 +50,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
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;
bullets = 5;
this.GraphicsComponent.actionOfAnimationEnd += (a) =>
{
if (a == "playerShootLeft" || a == "playerShootRight")
{
isShooting = false;
}
if (a == "playerReload")
{
bullets++;
}
};
}
velocity = new Vector2(0, 0);
rightBorder = (int)position.X + 100;
leftBorder = (int)position.X - 100;
bullets = 5;
this.GraphicsComponent.actionOfAnimationEnd += (a) =>
{
if (a == "playerShootLeft" || a == "playerShootRight")
{
isShooting = false;
}
if (a == "playerReload")
{
bullets++;
}
};
}
public bool IsAlive { get { return isAlive; } }
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()
{
@ -100,7 +103,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isAttacked = true;
if(monsterName == "Zombie")
{
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{
if (a == "DeathFrom" + monsterName)
@ -111,7 +114,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
else if(monsterName == "Spider")
{
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
AnimationRectangle deathRectangle = new AnimationRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{
if (a == "DeathFrom" + monsterName)
@ -134,41 +137,36 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{
if (bullets > 0)
{
if (!isShooting)
if (!isAttacked)
{
AppManager.Instance.SoundManager.StartSound("shotgun_shot", Pos, Pos);
isShooting = true;
bullets--;
if (isRight)
if (!isShooting)
{
if (GraphicsComponent.GetCurrentAnimation != "playerShootRight")
isShooting = true;
bullets--;
if (isRight)
{
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)
{
foreach (var target in targets)
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)
{
Zombie targetZombie = (Zombie)target;
Zombie targetZombie = (Zombie)targets.First();
targetZombie.TakeDamage();
}
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
}
}
else
{
if (GraphicsComponent.GetCurrentAnimation != "playerShootRight")
else
{
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)
{
foreach (var target in targets)
StartCicycleAnimation("playerShootLeft");
var targets = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - shootLength, (int)(Pos.Y - 10f), shootLength, 10), typeof(Zombie));
if (targets != null)
{
Zombie targetZombie = (Zombie)target;
targetZombie.TakeDamage();
foreach (var target in targets)
{
Zombie targetZombie = (Zombie)target;
targetZombie.TakeDamage();
}
}
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
}
}
}
@ -176,7 +174,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
public override void Update(GameTime gameTime)
{
if (AppManager.Instance.InputManager.ScopeState==ScopeState.Up)
if (AppManager.Instance.InputManager.ScopeState == ScopeState.Up)
{
isUping = true;
}
@ -189,14 +187,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
FallingThroughPlatform = false;
}
GraphicsComponent.SetCameraPosition(Pos);
if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat)
if (!isAttacked || AppManager.Instance.InputManager.InvincibilityCheat)
{
Move(gameTime);
if (!isShooting)
{
Move(gameTime);
}
else
{
velocity.X = 0;
}
}
else
{
velocity.X = 0;
}
base.Update(gameTime);
}
@ -252,6 +258,5 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
FallingThroughPlatform = true;
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.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@ -18,6 +19,7 @@ namespace DangerousD.GameCore.Graphics
private List<string> texturesNames;
private AnimationContainer currentAnimation;
static private int scaling = 4;
public int parentId;
public AnimationContainer CurrentAnimation
{
get
@ -105,6 +107,14 @@ namespace DangerousD.GameCore.Graphics
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;
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))
Exit();
if (GameManager.GetPlayer1 != null)
DebugHUD.Set("Objid: ", GameManager.GetPlayer1.id.ToString());
if (GameManager.GetPlayer1 != null)
DebugHUD.Set("id: ", GameManager.GetPlayer1.id.ToString());
InputManager.Update();
SoundManager.Update();
@ -200,9 +199,13 @@ namespace DangerousD.GameCore
break;
case GameState.Lobby:
break;
case GameState.Game:
GameManager.mapManager.LoadLevel("lvl");
GameManager.FindBorders();
case GameState.Game:
GameManager.mapManager.LoadLevel("map");
GameManager.FindBorders();
break;
case GameState.Death:
break;
@ -225,10 +228,11 @@ namespace DangerousD.GameCore
case NetworkTaskOperationEnum.CreateEntity:
break;
case NetworkTaskOperationEnum.SendPosition:
if (networkTask.objId != GameManager.GetPlayer1.id)
if (networkTask.objId != GameManager.GetPlayer1.id )
{
LivingEntity entity = GameManager.livingEntities.Find(x => x.id == networkTask.objId);
entity.SetPosition(networkTask.position);
if (entity != null)
entity.SetPosition(networkTask.position);
if (multiPlayerStatus == MultiPlayerStatus.Host)
{
NetworkTasks.Add(networkTask);
@ -236,6 +240,20 @@ namespace DangerousD.GameCore
}
break;
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;
case NetworkTaskOperationEnum.ConnectToHost:
Player connectedPlayer = new Player(Vector2.Zero, true);
@ -253,15 +271,17 @@ namespace DangerousD.GameCore
if (!GameManager.GetPlayer1.isIdFromHost)
{
GameManager.GetPlayer1.id = networkTask.objId;
GraphicsComponent gcsd = GameManager.GetPlayer1.GetGraphicsComponent();
gcsd.parentId = networkTask.objId;
GameManager.GetPlayer1.isIdFromHost = true;
}
break;
case NetworkTaskOperationEnum.AddConnectedPlayer:
Player remoteConnectedPlayer = new Player(networkTask.position, true);
remoteConnectedPlayer.id = networkTask.objId;
remoteConnectedPlayer.GetGraphicsComponent().parentId = networkTask.objId;
break;
default:
default:
break;
}
}

View file

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