spider changes

This commit is contained in:
N4K 2023-08-18 00:25:34 +03:00
parent cbcffe8d48
commit 3962ce4eac
13 changed files with 142 additions and 53 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="left-up" width="200" height="200" tilewidth="16" tileheight="16" infinite="1" nextlayerid="5" nextobjectid="5">
<tileset firstgid="1" source="../Desktop/DangerousD map/map.tsx"/>
<layer id="1" name="Слой тайлов 1" class="StopTile" width="200" height="200">
<data encoding="csv">
<chunk x="-16" y="0" width="16" height="16">
294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,294
</chunk>
<chunk x="0" y="0" width="16" height="16">
294,294,294,294,294,321,321,321,321,321,321,321,321,321,321,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,321,321,321,321,321,321,321,321,321,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
294,294,294,294,321,321,321,321,321,321,321,321,321,321,321,321
</chunk>
</data>
</layer>
<objectgroup id="755" name="Zombies" class="LivingEntities.Player" locked="1">
<object id="26" x="-50" y="300">
<point/>
</object>
</objectgroup>
<objectgroup id="2" name="Слой объектов 1" class="LivingEntities.Monsters.FlameSkull">
<object id="1" x="1" y="300">
<point/>
</object>
</objectgroup>
<objectgroup id="3" name="Слой объектов 2" class="LivingEntities.Monsters.FrankBalls">
<object id="2" x="1" y="300">
<point/>
</object>
</objectgroup>
<objectgroup id="4" name="Слой объектов 3" class="LivingEntities.Monsters.Frank">
<object id="3" x="-56" y="420">
<point/>
</object>
</objectgroup>
<objectgroup id="5" name="Zombies" class="LivingEntities.Monsters.Spider">
<object id="4" x="1" y="300">
<point/>
</object>
</objectgroup>
</map>

View file

@ -20,7 +20,6 @@ public abstract class AbstractGui : IDrawableObject
public virtual void Initialize()
{
Manager.Initialize(AppManager.Instance.GraphicsDevice);
this.graphicsDevice = graphicsDevice;
CreateUI();
}

View file

@ -15,7 +15,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public Frank(Vector2 position) : base(position)
{
isGoRight = false;
Width = 112;
Height = 160;
leftBoarder = 50;

View file

@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
private Rectangle collision;
private Vector2 position;
private int healthBall;
private bool isFlyRight = true;
private bool isAttacking = false;

View file

@ -16,7 +16,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private int attackTime = 60;
private int moveTime = 360;
private int currentTime = 0;
private bool isGoRight = true;
int leftBorder;
int rightBorder;
List<SilasHands> hands = new List<SilasHands>();

View file

@ -12,7 +12,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Slime : CoreEnemy
{
private bool isGoRight = true;
private bool isDown = false;
int leftBorder;
int rightBorder;

View file

@ -1,4 +1,5 @@
using DangerousD.GameCore.Graphics;
using DangerousD.GameCore.Managers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@ -17,19 +18,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
protected int webLength;
protected bool isDown;
protected bool isDownUp;
protected PhysicsManager physicsManager;
protected Player player;
public Spider(Vector2 position) : base(position)
{
player = AppManager.Instance.GameManager.players[0];
isDownUp = true;
isDown = true;
physicsManager = AppManager.Instance.GameManager.physicsManager;
web = new SpiderWeb(Pos);
name = "Spider";
Width = 112;
Height = 24;
delay = 0;
webLength = 0;
monster_speed = 2;
acceleration = Vector2.Zero;
monster_speed = 3;
acceleration = new Vector2(0, -50);
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SpiderMoveRight", "SpiderMoveLeft", "SpiderOnWeb" }, "SpiderMoveRight");
@ -44,6 +49,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
Attack(gameTime);
}
Target();
base.Update(gameTime);
}
@ -59,45 +65,43 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
/// <param name="gameTime"></param>
public override void Attack(GameTime gameTime)
{ //48 72
if (isDownUp)
velocity.X = 0;
Width = 48;
Height = 72;
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (delay > 0.5 && webLength <= 4 && isDown)
{
Width = 48;
Height = 72;
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (delay > 0.5 && webLength <= 4 && isDown)
StartCicycleAnimation("SpiderOnWeb");
acceleration = Vector2.Zero;
webLength++;
_pos.Y += 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 4)
{
StartCicycleAnimation("SpiderOnWeb");
webLength++;
_pos.Y += 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 4)
{
isDown = false;
}
}
else if (delay > 0.5 && webLength != 0 && !isDown)
{
StartCicycleAnimation("SpiderOnWeb");
webLength--;
_pos.Y -= 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 0)
{
isDown = true;
}
}
else
{
Width = 112;
Height = 24;
isDown = false;
}
}
else if (delay > 0.5 && webLength != 0 && !isDown)
{
StartCicycleAnimation("SpiderOnWeb");
webLength--;
_pos.Y -= 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2 + 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 0)
{
isDown = true;
}
}
if (webLength == 0)
{
isAttack = false;
}
}
//сделать условие с Артемом
public override void Draw(SpriteBatch spriteBatch)
{
if (GraphicsComponent.GetCurrentAnimation == "SpiderOnWeb")
@ -118,6 +122,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
Width = 112;
Height = 24;
int wallCheck = physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 10, (int)Pos.Y, 150, 10)).Count;
if (wallCheck > 0)
{
isGoRight = !isGoRight;
}
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight")
@ -146,7 +158,20 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Target()
{
throw new NotImplementedException();
if (physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 300, 600), typeof(Player)) != null)
{
if (player.Pos.X - Pos.X <= 30)
{
isAttack = true;
}
}
if (physicsManager.CheckRectangle(new Rectangle((int)Pos.X-300, (int)Pos.Y, 300, 600), typeof(Player)) != null)
{
if (player.Pos.X - Pos.X <= 30)
{
isAttack = true;
}
}
}
}
}

View file

@ -111,29 +111,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
base.OnCollision(gameObject);
}
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))!=null)
{
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;
leftBorder = Pos.X - 10;
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;
rightBorder = Pos.X + 10;
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
}
}
}
public override void Attack(GameTime gameTime)
{
throw new NotImplementedException();
}
}
}

View file

@ -49,7 +49,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public override void Update(GameTime gameTime)
{
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
velocity.X = 0.5f;
velocity.X = 1;
base.Update(gameTime);
}
}

View file

@ -5,8 +5,6 @@ namespace DangerousD.GameCore.GameObjects;
public abstract class LivingEntity : Entity
{
private Vector2 targetPosition;
public Vector2 velocity;
public Vector2 acceleration;
public LivingEntity(Vector2 position) : base(position)
{
acceleration = new Vector2(0, 30);

View file

@ -165,7 +165,7 @@ namespace DangerousD.GameCore
case GameState.Lobby:
break;
case GameState.Game:
GameManager.mapManager.LoadLevel("lvl");
GameManager.mapManager.LoadLevel("map");
break;
case GameState.GameOver:
break;

View file

@ -64,7 +64,7 @@ namespace DangerousD.GameCore.Managers
{
if (tiles[i] != 0)
{
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale,
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale + 370,
((chunkY + i / chunkW) * tileSize.Y + offsetY) * _scale);
//pos *= _scale;
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)
{
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, float.Parse(entity.Attributes["y"].Value, CultureInfo.InvariantCulture) + offsetY) * _scale);
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);
inst.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height));
inst.Height *= _scale;
inst.Width *= _scale;