This commit is contained in:
bmvolf 2023-08-15 17:17:56 +03:00
parent f2a6cdbd8d
commit 03e6f7b75d
10 changed files with 49 additions and 11 deletions

View file

@ -13,6 +13,18 @@
#---------------------------------- Content ---------------------------------#
#begin animation1.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:animation1.png
#begin File.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -0,0 +1 @@
{"id":"ZombieMoveLeft","textureName":"animation1","startSpriteRectangle":{"X":1,"Y":50,"Width":24,"Height":40},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":4,"isCycle":true}

View file

@ -1 +1 @@
{"id":"ZombieMoveRight","textureName":"animation1","startSpriteRectangle":{"X":1,"Y":9,"Width":24,"Height":40},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":4,"isCycle":true}
{"id":"ZombieMoveRight","textureName":"animation1","startSpriteRectangle":{"X":1,"Y":9,"Width":24,"Height":40},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":4,"isCycle":true}

View file

@ -0,0 +1 @@
{"id":"ZombieRightAttack","textureName":"animation1","startSpriteRectangle":{"X":126,"Y":6,"Width":50,"Height":40},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":3,"isCycle":false}

View file

@ -16,6 +16,8 @@ namespace DangerousD.GameCore
public int Width { get; protected set; }
public int Height { get; protected set; }
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
public Vector2 velocity;
public Vector2 acceleration;
protected abstract GraphicsComponent GraphicsComponent { get; }
public GameObject(Vector2 pos)
{

View file

@ -34,6 +34,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
public abstract void Attack();
public abstract void Move();
public abstract void Move(GameTime gameTime);
}
}

View file

@ -12,19 +12,22 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Zombie : CoreEnemy
{
private bool isGoRight = true;
public Zombie(Vector2 position) : base(position)
{
Width = 24;
Height = 40;
GraphicsComponent.StartAnimation("ZombieMoveRight");
Width = 72;
Height = 120;
GraphicsComponent.StartAnimation("ZombieRightAttack");
monster_speed = 100;
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight"}, "ZombieMoveRight");
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "ZombieMoveRight", "ZombieMoveLeft", "ZombieRightAttack"}, "ZombieMoveRight");
public override void Update(GameTime gameTime)
{
Move();
//Move(gameTime);
if (monster_health <= 0)
{
isAlive = false;
Death();
}
base.Update(gameTime);
@ -32,7 +35,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Attack()
{
if (isGoRight)
{
}
}
public override void Death()
@ -40,8 +46,25 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
}
public override void Move()
public override void Move(GameTime gameTime)
{
if (isGoRight)
{
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
{
GraphicsComponent.StartAnimation("ZombieMoveRight");
velocity = new Vector2(monster_speed, 0);
}
}
else if (!isGoRight)
{
if(GraphicsComponent.GetCurrentAnimation != "ZombieMoveLeft")
{
GraphicsComponent.StartAnimation("ZombieMoveLeft");
velocity = new Vector2(-monster_speed, 0);
}
}
}
}
}

View file

@ -10,10 +10,10 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
{
public class Player : LivingEntity
{
public Player(Vector2 position): base(position)
public Player(Vector2 position) : base(position)
{
}
protected override GraphicsComponent GraphicsComponent => throw new NotImplementedException();
public void Kill()

View file

@ -10,7 +10,6 @@ namespace DangerousD.GameCore.Levels
{
public void InitLevel()
{
//new Player();
var Трава = new GrassBlock(new Vector2(0, 128));
var Death = new TestAnimationDeath(new Vector2(128, 128));
var Zombie = new Zombie(new Vector2(256, 128));