spider changes

This commit is contained in:
N4K 2023-08-18 05:12:32 +03:00
parent 5118ab6305
commit 0bb77fe09d
14 changed files with 72 additions and 58 deletions

View file

@ -0,0 +1 @@
{"id":"GibsMoveLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":70,"Y":724,"Width":14,"Height":11},"frameSecond":[{"Item1":0,"Item2":6}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"GibsMoveLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":2,"Y":721,"Width":14,"Height":12},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"GibsMoveRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":106,"Y":722,"Width":13,"Height":12},"frameSecond":[{"Item1":0,"Item2":6}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"GibsMoveRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":37,"Y":721,"Width":14,"Height":13},"frameSecond":[{"Item1":0,"Item2":6}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"GibsNotMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":137,"Y":731,"Width":16,"Height":5},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}

View file

@ -1 +1 @@
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":124,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":112,"Y":124,"Width":27,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"4, 0"}

View file

@ -1 +1 @@
{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
{"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":102,"Y":99,"Width":31,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"8, 0"}

View file

@ -1,3 +1 @@
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":100,"Width":24,"Height":23},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}

View file

@ -62,7 +62,7 @@
</object>
</objectgroup>
<objectgroup id="5" name="Zombies" class="LivingEntities.Monsters.Spider">
<object id="4" x="1" y="100">
<object id="4" x="-80" y="100">
<point/>
</object>
</objectgroup>

View file

@ -19,7 +19,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
protected bool isAttack = false;
protected bool isGoRight;
protected int leftBoarder = 0;
protected int rightBoarder = 700;
protected int rightBoarder = 800;
public CoreEnemy(Vector2 position) : base(position)
{

View file

@ -1,4 +1,5 @@
using DangerousD.GameCore.Graphics;
using DangerousD.GameCore.GameObjects.MapObjects;
using DangerousD.GameCore.Graphics;
using DangerousD.GameCore.Managers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
@ -35,6 +36,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
webLength = 0;
monster_speed = 3;
acceleration = new Vector2(0, -50);
isGoRight = true;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SpiderMoveRight", "SpiderMoveLeft", "SpiderOnWeb" }, "SpiderMoveRight");
@ -66,34 +68,50 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack(GameTime gameTime)
{ //48 72
velocity.X = 0;
Width = 48;
Height = 72;
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (delay > 0.5 && webLength <= 4 && isDown)
if (isAttack)
{
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)
if (delay > 0.5 && webLength <= 4 && isDown)
{
isDown = false;
Width = 48;
Height = 72;
StartCicycleAnimation("SpiderOnWeb");
acceleration = Vector2.Zero;
webLength++;
_pos.Y += 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 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)
else if (delay > 0.5 && webLength != 0 && !isDown)
{
isDown = true;
Width = 48;
Height = 72;
StartCicycleAnimation("SpiderOnWeb");
webLength--;
_pos.Y -= 25;
web.Height = webLength * 25;
web.SetPosition(new Vector2(_pos.X + Width / 2 - web.Width / 2, Pos.Y - 25 * webLength));
delay = 0;
if (webLength == 0)
{
isDown = true;
}
}
var entitiesInter = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 200, 600));
if (entitiesInter.Count > 0)
{
foreach (var entity in entitiesInter)
{
if (entity.GetType() == typeof(Player))
{
player.Death(name);
}
}
}
}
if (webLength == 0)
@ -101,7 +119,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
isAttack = false;
}
}
//сделать условие с Артемом
public override void Draw(SpriteBatch spriteBatch)
{
if (GraphicsComponent.GetCurrentAnimation == "SpiderOnWeb")
@ -124,11 +142,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
Width = 112;
Height = 24;
int wallCheck = physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 10, (int)Pos.Y, 150, 10)).Count;
if (wallCheck > 0)
foreach (var entity in physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 7, (int)Pos.Y, 126, 10)))
{
isGoRight = !isGoRight;
if (entity.GetType() == typeof(StopTile))
{
isGoRight = !isGoRight;
}
}
if (isGoRight)
{
@ -146,31 +165,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
velocity.X = -monster_speed;
}
if (Pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (Pos.X <= leftBoarder)
{
isGoRight = true;
}
}
public override void Target()
{
if (physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 300, 600), typeof(Player)) != null)
if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width)
{
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;
}
isAttack = true;
}
}
}

View file

@ -80,6 +80,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
}
};
}
else if(monsterName == "Spider")
{
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
{
if (a == "DeathFrom" + monsterName)
{
AppManager.Instance.ChangeGameState(GameState.Death);
}
};
}
isAlive = false;
}
public void Jump()

View file

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

View file

@ -40,7 +40,6 @@ namespace DangerousD.GameCore
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
{
return;
var sound = new Sound(Sounds[soundName]);
sound.SoundEffect.IsLooped = false;
sound.SoundEffect.Play();