spider changes
This commit is contained in:
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 |
70
DangerousD/Content/map.tmx
Normal file
70
DangerousD/Content/map.tmx
Normal 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>
|
|
@ -20,7 +20,6 @@ public abstract class AbstractGui : IDrawableObject
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
Manager.Initialize(AppManager.Instance.GraphicsDevice);
|
||||||
this.graphicsDevice = graphicsDevice;
|
|
||||||
CreateUI();
|
CreateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
public Frank(Vector2 position) : base(position)
|
public Frank(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
isGoRight = false;
|
isGoRight = false;
|
||||||
|
|
||||||
Width = 112;
|
Width = 112;
|
||||||
Height = 160;
|
Height = 160;
|
||||||
leftBoarder = 50;
|
leftBoarder = 50;
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
private Rectangle collision;
|
private Rectangle collision;
|
||||||
private Vector2 position;
|
private Vector2 position;
|
||||||
private int healthBall;
|
|
||||||
private bool isFlyRight = true;
|
private bool isFlyRight = true;
|
||||||
private bool isAttacking = false;
|
private bool isAttacking = false;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
private int attackTime = 60;
|
private int attackTime = 60;
|
||||||
private int moveTime = 360;
|
private int moveTime = 360;
|
||||||
private int currentTime = 0;
|
private int currentTime = 0;
|
||||||
private bool isGoRight = true;
|
|
||||||
int leftBorder;
|
int leftBorder;
|
||||||
int rightBorder;
|
int rightBorder;
|
||||||
List<SilasHands> hands = new List<SilasHands>();
|
List<SilasHands> hands = new List<SilasHands>();
|
||||||
|
|
|
@ -12,7 +12,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Slime : CoreEnemy
|
public class Slime : CoreEnemy
|
||||||
{
|
{
|
||||||
private bool isGoRight = true;
|
|
||||||
private bool isDown = false;
|
private bool isDown = false;
|
||||||
int leftBorder;
|
int leftBorder;
|
||||||
int rightBorder;
|
int rightBorder;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using DangerousD.GameCore.Graphics;
|
using DangerousD.GameCore.Graphics;
|
||||||
|
using DangerousD.GameCore.Managers;
|
||||||
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;
|
||||||
|
@ -17,19 +18,23 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
protected int webLength;
|
protected int webLength;
|
||||||
protected bool isDown;
|
protected bool isDown;
|
||||||
protected bool isDownUp;
|
protected bool isDownUp;
|
||||||
|
protected PhysicsManager physicsManager;
|
||||||
|
protected Player player;
|
||||||
|
|
||||||
public Spider(Vector2 position) : base(position)
|
public Spider(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
player = AppManager.Instance.GameManager.players[0];
|
||||||
isDownUp = true;
|
isDownUp = true;
|
||||||
isDown = true;
|
isDown = true;
|
||||||
|
physicsManager = AppManager.Instance.GameManager.physicsManager;
|
||||||
web = new SpiderWeb(Pos);
|
web = new SpiderWeb(Pos);
|
||||||
name = "Spider";
|
name = "Spider";
|
||||||
Width = 112;
|
Width = 112;
|
||||||
Height = 24;
|
Height = 24;
|
||||||
delay = 0;
|
delay = 0;
|
||||||
webLength = 0;
|
webLength = 0;
|
||||||
monster_speed = 2;
|
monster_speed = 3;
|
||||||
acceleration = Vector2.Zero;
|
acceleration = new Vector2(0, -50);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SpiderMoveRight", "SpiderMoveLeft", "SpiderOnWeb" }, "SpiderMoveRight");
|
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);
|
Attack(gameTime);
|
||||||
}
|
}
|
||||||
|
Target();
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
@ -59,45 +65,43 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
/// <param name="gameTime"></param>
|
/// <param name="gameTime"></param>
|
||||||
public override void Attack(GameTime gameTime)
|
public override void Attack(GameTime gameTime)
|
||||||
{ //48 72
|
{ //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;
|
StartCicycleAnimation("SpiderOnWeb");
|
||||||
Height = 72;
|
acceleration = Vector2.Zero;
|
||||||
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
|
webLength++;
|
||||||
if (delay > 0.5 && webLength <= 4 && isDown)
|
_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");
|
isDown = false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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)
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation == "SpiderOnWeb")
|
if (GraphicsComponent.GetCurrentAnimation == "SpiderOnWeb")
|
||||||
|
@ -118,6 +122,14 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
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 (isGoRight)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight")
|
if (GraphicsComponent.GetCurrentAnimation != "SpiderMoveRight")
|
||||||
|
@ -146,7 +158,20 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Target()
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,29 +111,30 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
}
|
}
|
||||||
base.OnCollision(gameObject);
|
base.OnCollision(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
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))!=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;
|
isTarget = true;
|
||||||
leftBorder = Pos.X - 10;
|
leftBorder = Pos.X - 10;
|
||||||
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 + 10;
|
||||||
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
|
leftBorder = AppManager.Instance.GameManager.players[0].Pos.X;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Attack(GameTime gameTime)
|
public override void Attack(GameTime gameTime)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
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 = 0.5f;
|
velocity.X = 1;
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ namespace DangerousD.GameCore.GameObjects;
|
||||||
public abstract class LivingEntity : Entity
|
public abstract class LivingEntity : Entity
|
||||||
{
|
{
|
||||||
private Vector2 targetPosition;
|
private Vector2 targetPosition;
|
||||||
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);
|
||||||
|
|
|
@ -165,7 +165,7 @@ 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");
|
||||||
break;
|
break;
|
||||||
case GameState.GameOver:
|
case GameState.GameOver:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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,
|
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale + 370,
|
||||||
((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, 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.SetPosition(new Vector2(inst.Pos.X, inst.Pos.Y - inst.Height));
|
||||||
inst.Height *= _scale;
|
inst.Height *= _scale;
|
||||||
inst.Width *= _scale;
|
inst.Width *= _scale;
|
||||||
|
|
Loading…
Add table
Reference in a new issue