Merge branch 'черешня' into sounds

This commit is contained in:
SergoDobro 2023-08-18 20:28:51 +03:00
commit 3b63d63087
22 changed files with 141 additions and 87 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 KiB

After

Width:  |  Height:  |  Size: 1.6 MiB

View file

@ -719,20 +719,6 @@
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>
<objectgroup id="17" name="Hunchman" class="LivingEntities.Monsters.Hunchman">
<object id="98" x="-92" y="144">
<point/>
</object>
<object id="99" x="115.333" y="182">
<point/>
</object>
<object id="100" x="191.333" y="277.333">
<point/>
</object>
<object id="101" x="249.333" y="88.6667">
<point/>
</object>
</objectgroup>
<objectgroup id="10" name="Player" class="LivingEntities.Player"> <objectgroup id="10" name="Player" class="LivingEntities.Player">
<object id="47" x="-500" y="461.333"> <object id="47" x="-500" y="461.333">
<point/> <point/>

View file

@ -62,7 +62,7 @@
</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="-80" y="100"> <object id="4" x="-50" y="200">
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>

View file

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

View file

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

View file

@ -13,7 +13,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract class CoreEnemy : LivingEntity public abstract class CoreEnemy : LivingEntity
{ {
protected int monster_health; protected int monster_health;
protected int monster_speed; protected float monster_speed;
protected string name; protected string name;
protected bool isAlive = true; protected bool isAlive = true;
protected int leftBoarder = 0; protected int leftBoarder = 0;
@ -45,5 +45,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
isAlive = false; isAlive = false;
} }
} }
public abstract void Target();
} }
} }

View file

@ -13,20 +13,38 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public class FlameSkull : CoreEnemy public class FlameSkull : CoreEnemy
{ {
private bool isAttack; private bool isAttack;
protected Vector2 startPosition;
public FlameSkull(Vector2 position) : base(position) /*protected Vector2[] positions = { new Vector2(0, 242), new Vector2(0, 332), new Vector2(582, 332), new Vector2(0, 332),
{ new Vector2(0, 444), new Vector2(582, 444), new Vector2(0, 444), new Vector2(0, 242), new Vector2(582, 242),
Width = 62; new Vector2(0, 242), new Vector2(0, 149), new Vector2(582, 149), new Vector2(0,149)};*/
Height = 40; protected Vector2[] positions = { new Vector2(0,246), new Vector2(0, 344), new Vector2(550,344), new Vector2(520, 246)};
monster_speed = 3; protected int i;
public FlameSkull(Vector2 position) : base(position)
{ // v3 -> v2 -> s2 -> v2 -> v1 -> s1 -> v1 -> v3 -> s3 -> v3 -> v4 -> s4 -> v4
//0 149 verv 4 [7]
//582 108 stairs 4 [6]
//0 242 verv 3 [5]
//582 220 stairs 3 [4]
//0 332 verv 2 [3]
//582 332 stairs 2 [2]
//0 444 verv 1 [1]
//582 444 stairs 1 [0]
startPosition = new Vector2(500, 242);
_pos = startPosition;
i = 0;
Width = 31;
Height = 20;
monster_speed = 2;
name = "Skull"; name = "Skull";
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
startPosition = new Vector2();
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FlameSkullMoveRight" , "FlameSkullMoveLeft"}, "FlameSkullMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FlameSkullMoveRight" , "FlameSkullMoveLeft"}, "FlameSkullMoveRight");
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
AppManager.Instance.DebugHUD.Set("number i: ", i.ToString());
if (!isAttack) if (!isAttack)
{ {
Move(gameTime); Move(gameTime);
@ -63,19 +81,52 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
velocity.X = -monster_speed; velocity.X = -monster_speed;
} }
if (Pos.X >= rightBoarder)
if (i%2 == 0)
{ {
isGoRight = false; if (Pos.X > positions[i].X)
{
isGoRight = false;
}
else if (Pos.X < positions[i].X)
{
isGoRight = true;
}
else if (Pos.X == positions[i].X)
{
i++;
velocity.X = 0;
}
} }
else if (Pos.X <= leftBoarder) else
{ {
isGoRight = true; if (Pos.Y > positions[i].Y)
{
_pos.Y -= monster_speed;
}
else if (Pos.Y < positions[i].Y)
{
_pos.Y += monster_speed;
}
else if (Pos.Y == positions[i].Y)
{
i++;
}
}
if (i == positions.Length)
{
i = 0;
} }
} }
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{ {
throw new NotImplementedException();
}
public override void Target()
{
} }
} }
} }

View file

@ -74,9 +74,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -120,14 +120,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -111,16 +111,15 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public void TakeDamage() public void TakeDamage()
{ {
monster_health--; monster_health--;
if (monster_health <= 0) if (monster_health <= 0)
{ {
Death(); Death();
} }
} }
public void Target()
public override void Target()
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -129,9 +129,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Debug.WriteLine("Collision"); Debug.WriteLine("Collision");
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -42,9 +42,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -68,9 +68,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)

View file

@ -112,9 +112,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)

View file

@ -288,7 +288,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
base.Update(gameTime); base.Update(gameTime);
} }
public void Target() public override void Target()
{ {
} }

View file

@ -19,10 +19,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
protected SpiderWeb web; protected SpiderWeb web;
protected float delay; protected float delay;
protected int webLength; protected int webLength;
protected int widthS;
protected bool isDown; protected bool isDown;
protected bool isDownUp; protected bool isDownUp;
protected PhysicsManager physicsManager; protected PhysicsManager physicsManager;
protected Player player; protected Player player;
protected Vector2 oldPosition;
public Spider(Vector2 position) : base(position) public Spider(Vector2 position) : base(position)
{ {
@ -31,8 +33,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isDown = true; isDown = true;
physicsManager = AppManager.Instance.GameManager.physicsManager; physicsManager = AppManager.Instance.GameManager.physicsManager;
name = "Spider"; name = "Spider";
Width = 112; Width = 28;
Height = 24; Height = 6;
widthS = Width;
web = new SpiderWeb(new Vector2(Pos.X+Width/2,Pos.Y));
delay = 0; delay = 0;
web = new SpiderWeb(new Vector2(Pos.X-Width/2,Pos.Y)); web = new SpiderWeb(new Vector2(Pos.X-Width/2,Pos.Y));
webLength = 0; webLength = 0;
@ -45,7 +49,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (!isAttack) if (isAttack == false)
{ {
Move(gameTime); Move(gameTime);
} }
@ -68,15 +72,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
/// </summary> /// </summary>
/// <param name="gameTime"></param> /// <param name="gameTime"></param>
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{ //48 72 {
velocity.X = 0;
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (isAttack) if (isAttack)
{ {
if (delay > 0.5 && webLength <= 4 && isDown) velocity.X = 0;
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (delay > 0.25 && webLength <= 4 && isDown)
{ {
Width = 48; Width = 12;
Height = 72; Height = 18;
StartCicycleAnimation("SpiderOnWeb"); StartCicycleAnimation("SpiderOnWeb");
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
webLength++; webLength++;
@ -91,8 +96,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
else if (delay > 0.5 && webLength != 0 && !isDown) else if (delay > 0.5 && webLength != 0 && !isDown)
{ {
Width = 48; Width = 12;
Height = 72; Height = 18;
StartCicycleAnimation("SpiderOnWeb"); StartCicycleAnimation("SpiderOnWeb");
webLength--; webLength--;
_pos.Y -= 25; _pos.Y -= 25;
@ -104,22 +109,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isDown = true; isDown = true;
} }
} }
var entitiesInter = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 200, 600)); if (webLength == 0)
if (entitiesInter.Count > 0)
{ {
foreach (var entity in entitiesInter) isAttack = false;
}
var entities = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height + 200));
foreach (var entity in entities)
{
if (webLength == 4 && entity is Player)
{ {
if (entity.GetType() == typeof(Player)) AppManager.Instance.GameManager.players[0].Death(name);
{
player.Death(name);
}
} }
} }
} }
if (webLength == 0)
{
isAttack = false;
}
} }
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
@ -142,8 +144,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
Width = 112; Width = 28;
Height = 24; Height = 6;
foreach (var entity in physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 7, (int)Pos.Y, 126, 10))) foreach (var entity in physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 7, (int)Pos.Y, 126, 10)))
{ {
if (entity.GetType() == typeof(StopTile)) if (entity.GetType() == typeof(StopTile))
@ -169,12 +171,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
} }
public void Target() public override void Target()
{ {
if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width) if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width)
{ {
isAttack = true; isAttack = true;
} }
} }
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
if (AppManager.Instance.GameManager.players[0].IsAlive)
{
Attack();
}
}
base.OnCollision(gameObject);
}
} }
} }

View file

@ -15,7 +15,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public SpiderWeb(Vector2 position) : base(position) public SpiderWeb(Vector2 position) : base(position)
{ {
name = "Web"; name = "Web";
monster_speed = 1;
Width = 16; Width = 16;
Height = 0; Height = 0;
acceleration = Vector2.Zero; acceleration = Vector2.Zero;
@ -43,9 +42,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
public void Target() public override void Target()
{ {
throw new NotImplementedException();
} }
} }
} }

View file

@ -102,6 +102,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack(GameTime gameTime) public override void Attack(GameTime gameTime)
{ {
} }
public void Jump() public void Jump()
{ {
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
@ -148,10 +149,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
} }
base.OnCollision(gameObject);/*/ base.OnCollision(gameObject);/*/
} }
public void Target()
{
throw new NotImplementedException();
}
public void TakeDamage() public void TakeDamage()
{ {
monster_health--; monster_health--;
@ -162,5 +159,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
Death(); Death();
} }
} }
public override void Target()
{
}
} }
} }

View file

@ -142,7 +142,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
base.OnCollision(gameObject); base.OnCollision(gameObject);
} }
public void Target() public override void Target()
{ {
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 200, Height), typeof(Player)).Count > 0) if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 200, Height), typeof(Player)).Count > 0)
{ {

View file

@ -197,7 +197,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
StartCicycleAnimation("playerShootRight"); StartCicycleAnimation("playerShootRight");
Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y)); Bullet bullet = new Bullet(new Vector2(Pos.X + 16, Pos.Y));
bullet.ShootRight(); bullet.ShootRight();
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 12, Pos.Y - 8)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X + 30, Pos.Y + 7));
} }
else else
{ {
@ -214,7 +214,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
StartCicycleAnimation("playerShootBoomUpLeft"); StartCicycleAnimation("playerShootBoomUpLeft");
Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y)); Bullet bullet = new Bullet(new Vector2(Pos.X, Pos.Y));
bullet.ShootLeft(); bullet.ShootLeft();
SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 6, Pos.Y - 7)); SmokeAfterShoot smokeAfterShoot = new SmokeAfterShoot(new Vector2(Pos.X - 12, Pos.Y + 7));
} }
else else
{ {
@ -345,9 +345,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
Height = 5; Height = 5;
Width = 5; Width = 5;
} }
int time = 0;
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft" }, "playerMoveLeft"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "playerMoveLeft" }, "playerMoveLeft");
Vector2 direction; Vector2 direction;
Vector2 maindirection; public Vector2 maindirection;
public void ShootUpRight() public void ShootUpRight()
{ {
direction = new Vector2(1, -1); direction = new Vector2(1, -1);
@ -415,10 +416,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (maindirection != velocity)
{
AppManager.Instance.GameManager.Remove(this);
}
base.Update(gameTime); base.Update(gameTime);
} }
} }

View file

@ -40,7 +40,10 @@ public abstract class LivingEntity : Entity
//} //}
base.Update(gameTime); base.Update(gameTime);
} }
/// <summary>
///
/// </summary>
/// <param name="animationName"></param>
public virtual void StartCicycleAnimation(string animationName) public virtual void StartCicycleAnimation(string animationName)
{ {
if (GraphicsComponent.GetCurrentAnimation != animationName) if (GraphicsComponent.GetCurrentAnimation != animationName)

View file

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