slimeReadyMaybe
This commit is contained in:
parent
f7ef5e835b
commit
9f6b6fd16a
18 changed files with 238 additions and 4 deletions
1
DangerousD/Content/animations/SlimeJumpLeftBottom
Normal file
1
DangerousD/Content/animations/SlimeJumpLeftBottom
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeJumpLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":176,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeJumpLeftTop
Normal file
1
DangerousD/Content/animations/SlimeJumpLeftTop
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeJumpLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":151,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeJumpRightBottom
Normal file
1
DangerousD/Content/animations/SlimeJumpRightBottom
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeJumpRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":176,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeJumpRightTop
Normal file
1
DangerousD/Content/animations/SlimeJumpRightTop
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeJumpRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":151,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeMoveLeftBottom
Normal file
1
DangerousD/Content/animations/SlimeMoveLeftBottom
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeMoveLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":182,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeMoveLeftTop
Normal file
1
DangerousD/Content/animations/SlimeMoveLeftTop
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeMoveLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":51,"Y":182,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeMoveRightBottom
Normal file
1
DangerousD/Content/animations/SlimeMoveRightBottom
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeMoveRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":165,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeMoveRightTop
Normal file
1
DangerousD/Content/animations/SlimeMoveRightTop
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeMoveRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":51,"Y":165,"Width":24,"Height":8},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeReadyJumpLeftBottom
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpLeftBottom
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeReadyJumpLeftBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeReadyJumpLeftTop
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpLeftTop
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeReadyJumpLeftTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":157,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeReadyJumpRightBottom
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpRightBottom
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeReadyJumpRightBottom","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
|
1
DangerousD/Content/animations/SlimeReadyJumpRightTop
Normal file
1
DangerousD/Content/animations/SlimeReadyJumpRightTop
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"SlimeReadyJumpRightTop","textureName":"MonstersAnimations","startSpriteRectangle":{"X":126,"Y":174,"Width":24,"Height":16},"frameSecond":[{"Item1":0,"Item2":30}],"textureFrameInterval":1,"framesCount":1,"isCycle":false,"offset":"0, 0"}
|
|
@ -12,19 +12,143 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
public class Slime : CoreEnemy
|
||||
{
|
||||
private bool isGoRight = true;
|
||||
private bool isDown = false;
|
||||
int leftBorder;
|
||||
int rightBorder;
|
||||
bool isAttaking = false;
|
||||
int delay;
|
||||
bool isJumping = false;
|
||||
public Slime(Vector2 position) : base(position)
|
||||
{
|
||||
Width = 48;
|
||||
Height = 16;
|
||||
name = "Slime";
|
||||
monster_speed = 3;
|
||||
monster_health = 2;
|
||||
leftBorder = 100;
|
||||
rightBorder = 400;
|
||||
//acceleration = Vector2.Zero;
|
||||
delay = 30;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "SlimeMoveLeftTop", "SlimeMoveLeftBottom", "SlimeMoveRightTop",
|
||||
"SlimeMoveRightBottom", "SlimeReadyJumpRightBottom", "SlimeReadyJumpRightTop", "SlimeReadyJumpLeftBottom", "SlimeReadyJumpLeftTop", "SlimeJumpRightBottom",
|
||||
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "");
|
||||
"SlimeJumpRightTop", "SlimeJumpLeftBottom", "SlimeJumpLeftTop" }, "SlimeMoveRightTop");
|
||||
|
||||
public override void Attack()
|
||||
{
|
||||
|
||||
}
|
||||
public void Jump()
|
||||
{
|
||||
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 100, 100));
|
||||
velocity.X = 0;
|
||||
Height = 32;
|
||||
if (isGoRight && isDown)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpLeftBottom")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeReadyJumpLeftBottom");
|
||||
|
||||
}
|
||||
delay--;
|
||||
if (delay <= 0)
|
||||
{
|
||||
isJumping = true;
|
||||
velocity = new Vector2(5, -3);
|
||||
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)
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (!isGoRight && isDown)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpRightTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeReadyJumpRightTop");
|
||||
}
|
||||
delay--;
|
||||
if (delay <= 0)
|
||||
{
|
||||
velocity = new Vector2(-5, -3);
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
|
||||
}
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5));
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isGoRight && !isDown)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpLeftTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeReadyJumpLeftTop");
|
||||
|
||||
}
|
||||
delay--;
|
||||
if (delay <= 0)
|
||||
{
|
||||
isJumping = true;
|
||||
velocity = new Vector2(5, 3);
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpLeftTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeJumpLeftTop");
|
||||
}
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5));
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (!isGoRight && !isDown)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeReadyJumpRightTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeReadyJumpRightTop");
|
||||
}
|
||||
delay--;
|
||||
if (delay <= 0)
|
||||
{
|
||||
velocity = new Vector2(-5, 3);
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeJumpRightTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeJumpRightTop");
|
||||
}
|
||||
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5));
|
||||
if (getCols.Count > 0)
|
||||
{
|
||||
isJumping = false;
|
||||
isDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Draw(debugTexture, new Rectangle((int)Pos.X, (int)Pos.Y - 5, 48, 5), Color.White);
|
||||
spriteBatch.Draw(debugTexture, new Rectangle((int)Pos.X, (int)Pos.Y + Height, 48, 5), Color.White);
|
||||
base.Draw(spriteBatch);
|
||||
}
|
||||
public override void Death()
|
||||
{
|
||||
|
||||
|
@ -32,7 +156,82 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
delay = 30;
|
||||
Height = 16;
|
||||
if (isGoRight && isDown)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveRightBottom")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeMoveRightBottom");
|
||||
}
|
||||
velocity.X = monster_speed;
|
||||
|
||||
}
|
||||
|
||||
else if (!isGoRight && isDown)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveLeftBottom")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeMoveLeftBottom");
|
||||
}
|
||||
velocity.X = -monster_speed;
|
||||
|
||||
}
|
||||
else if (!isDown && isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveRightTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeMoveRightTop");
|
||||
|
||||
}
|
||||
velocity.X = monster_speed;
|
||||
|
||||
|
||||
}
|
||||
else if (!isDown && !isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "SlimeMoveLeftTop")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("SlimeMoveLeftTop");
|
||||
}
|
||||
velocity.X = -monster_speed;
|
||||
|
||||
}
|
||||
|
||||
if (Pos.X >= rightBorder)
|
||||
{
|
||||
isGoRight = false;
|
||||
}
|
||||
|
||||
else if (Pos.X <= leftBorder)
|
||||
{
|
||||
isGoRight = true;
|
||||
}
|
||||
}
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
if (isDown)
|
||||
{
|
||||
|
||||
if (acceleration.Y < 0)
|
||||
{
|
||||
acceleration.Y = -acceleration.Y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (acceleration.Y > 0)
|
||||
{
|
||||
acceleration.Y = -acceleration.Y;
|
||||
}
|
||||
}
|
||||
//if (!isAttaking){ Move(gameTime); }
|
||||
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace DangerousD.GameCore.GameObjects.MapObjects
|
|||
{
|
||||
Width = 32;
|
||||
Height = 32;
|
||||
IsColliderOn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,17 +12,19 @@ namespace DangerousD.GameCore.Levels
|
|||
{
|
||||
new Player(new Vector2(80,0));
|
||||
var Zombie = new Zombie(new Vector2(140, 128));
|
||||
var Frank = new Frank(new Vector2(384, 128));
|
||||
var Frank = new Frank(new Vector2(384, 0));
|
||||
|
||||
var Spider = new Spider(new Vector2(112, 0));
|
||||
var FlameSkull = new FlameSkull(new Vector2(512, 0));
|
||||
var Werewolf = new Werewolf(new Vector2(640, 0));
|
||||
var Ghost = new Ghost(new Vector2(730, 0));
|
||||
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
|
||||
var Slime = new Slime(new Vector2(300, 200));
|
||||
|
||||
new GrassBlock(new Vector2(0, 224));
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
new GrassBlock(new Vector2(i * 32, 100));
|
||||
new GrassBlock(new Vector2(i*32, 256));
|
||||
}
|
||||
new GrassBlock(new Vector2(500, 224));
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
public class GameManager
|
||||
{
|
||||
public List<GameObject> GetAllGameObjects { get; private set; }
|
||||
|
||||
public List<LivingEntity> livingEntities;
|
||||
public List<Entity> entities;
|
||||
|
@ -23,6 +24,7 @@ namespace DangerousD.GameCore
|
|||
public Player GetPlayer1 { get; private set; }
|
||||
public GameManager()
|
||||
{
|
||||
GetAllGameObjects = new List<GameObject>();
|
||||
livingEntities = new List<LivingEntity>();
|
||||
mapObjects = new List<MapObject>();
|
||||
entities = new List<Entity>();
|
||||
|
@ -34,6 +36,9 @@ namespace DangerousD.GameCore
|
|||
|
||||
internal void Register(GameObject gameObject)
|
||||
{
|
||||
|
||||
|
||||
GetAllGameObjects.Add(gameObject);
|
||||
if (gameObject is Player)
|
||||
{
|
||||
livingEntities.Add(gameObject as LivingEntity);
|
||||
|
|
|
@ -206,5 +206,20 @@ namespace DangerousD.GameCore.Managers
|
|||
}
|
||||
return null;
|
||||
}
|
||||
public List<GameObject> CheckRectangle(Rectangle rectangle)
|
||||
{
|
||||
var gameObjects = AppManager.Instance.GameManager.mapObjects;
|
||||
List<GameObject> intersected = new List<GameObject>();
|
||||
for (int i = 0; i < gameObjects.Count; i++)
|
||||
{
|
||||
|
||||
if (gameObjects[i].Rectangle.Intersects(rectangle) && gameObjects[i].IsColliderOn)
|
||||
{
|
||||
intersected.Add(gameObjects[i]);
|
||||
}
|
||||
|
||||
}
|
||||
return intersected;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue