diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 18f7ea3..8c17266 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -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 diff --git a/DangerousD/Content/animation1.png b/DangerousD/Content/animation1.png new file mode 100644 index 0000000..01d185c Binary files /dev/null and b/DangerousD/Content/animation1.png differ diff --git a/DangerousD/Content/animations/ZombieMoveLeft b/DangerousD/Content/animations/ZombieMoveLeft new file mode 100644 index 0000000..2f41b50 --- /dev/null +++ b/DangerousD/Content/animations/ZombieMoveLeft @@ -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} diff --git a/DangerousD/Content/animations/ZombieMoveRight b/DangerousD/Content/animations/ZombieMoveRight index 91368de..c59cd6f 100644 --- a/DangerousD/Content/animations/ZombieMoveRight +++ b/DangerousD/Content/animations/ZombieMoveRight @@ -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} diff --git a/DangerousD/Content/animations/ZombieRightAttack b/DangerousD/Content/animations/ZombieRightAttack new file mode 100644 index 0000000..5df80a2 --- /dev/null +++ b/DangerousD/Content/animations/ZombieRightAttack @@ -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} diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index 82648d4..81ff721 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -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) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs b/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs index 52b684b..5b73955 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/CoreEnemy.cs @@ -34,6 +34,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities public abstract void Attack(); - public abstract void Move(); + public abstract void Move(GameTime gameTime); } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs index 8b38332..9605857 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/Zombie.cs @@ -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 { "ZombieMoveRight"}, "ZombieMoveRight"); + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "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); + } + } } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs index a36ee64..8caadd3 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Player.cs @@ -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() diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index bae0eee..1716044 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -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));