diff --git a/AnimationsFileCreator/Program.cs b/AnimationsFileCreator/Program.cs index bda2baf..9a712a0 100644 --- a/AnimationsFileCreator/Program.cs +++ b/AnimationsFileCreator/Program.cs @@ -5,6 +5,7 @@ using System; using System.Windows.Forms; using System.IO; using System.Linq; +using System.Reflection.Metadata; namespace AnimationsFileCreator { @@ -62,7 +63,7 @@ namespace AnimationsFileCreator container.TextureFrameInterval = 1; container.Id = id; string json = JsonConvert.SerializeObject(container); - StreamWriter writer = new StreamWriter("../../../../DangerousD/Content/animations/" + id); + StreamWriter writer = new StreamWriter("../../../../DangerousD/Content/animations/"+id); writer.WriteLine(json); writer.Close(); } diff --git a/DangerousD/Content/animations/SilasAttack b/DangerousD/Content/animations/SilasAttack new file mode 100644 index 0000000..4727523 --- /dev/null +++ b/DangerousD/Content/animations/SilasAttack @@ -0,0 +1,20 @@ +{ + "id": "SilasAttack", + "textureName": "MonstersAnimations", + "startSpriteRectangle": { + "X": 1, + "Y": 618, + "Width": 72, + "Height": 80 + }, + "frameSecond": [ + { + "Item1": 0, + "Item2": 5 + } + ], + "textureFrameInterval": 1, + "framesCount": 2, + "isCycle": true, + "offset": "0, 0" +} diff --git a/DangerousD/Content/animations/SilasHandMove b/DangerousD/Content/animations/SilasHandMove new file mode 100644 index 0000000..06589c3 --- /dev/null +++ b/DangerousD/Content/animations/SilasHandMove @@ -0,0 +1 @@ +{"id":"SilasHandMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":197,"Y":618,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/Content/animations/SilasMove b/DangerousD/Content/animations/SilasMove new file mode 100644 index 0000000..334d3c5 --- /dev/null +++ b/DangerousD/Content/animations/SilasMove @@ -0,0 +1,20 @@ +{ + "id": "SilasMove", + "textureName": "MonstersAnimations", + "startSpriteRectangle": { + "X": 1, + "Y": 618, + "Width": 72, + "Height": 80 + }, + "frameSecond": [ + { + "Item1": 0, + "Item2": 60 + } + ], + "textureFrameInterval": 1, + "framesCount": 2, + "isCycle": true, + "offset": "0, 0" +} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs index 6c13e1b..cf33f30 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs @@ -1,4 +1,8 @@ -using System; +using DangerousD.GameCore.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +10,60 @@ using System.Threading.Tasks; namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { - internal class SilasHands + public class SilasHands : CoreEnemy { + public SilasHands(Vector2 position) : base(position) + { + name = "SilasHand"; + Width = 48; + Height = 48; + monster_health = 2; + monster_speed = 2; + acceleration = Vector2.Zero; + + } + + protected override GraphicsComponent GraphicsComponent { get; }=new GraphicsComponent(new List() { "SilasHandMove" }, "SilasHandMove"); + + public override void Attack() + { + throw new NotImplementedException(); + } + + public override void Death() + { + throw new NotImplementedException(); + } + + public override void Move(GameTime gameTime) + { + if (Pos.Y> AppManager.Instance.GameManager.GetPlayer1.Pos.Y) + { + velocity.Y = monster_speed; + + } + else + { + velocity.Y = 0; + } + if (Pos.X> AppManager.Instance.GameManager.GetPlayer1.Pos.X) + { + velocity.X = -monster_speed; + } + else + { + velocity.X = monster_speed; + } + } + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + if ((Pos.X + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.X || Pos.X - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.X)&&(Pos.Y + 20 <= AppManager.Instance.GameManager.GetPlayer1.Pos.Y || Pos.Y - 20 >= AppManager.Instance.GameManager.GetPlayer1.Pos.Y)) + { + + AppManager.Instance.GameManager.GetPlayer1.Death(name); + } + GraphicsComponent.Update(); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs index 4a5d727..09a3928 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs @@ -1,4 +1,8 @@ -using System; +using DangerousD.GameCore.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +10,64 @@ using System.Threading.Tasks; namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { - public class SilasMaster + public class SilasMaster : CoreEnemy { + private int attackTime = 60; + private int moveTime = 360; + private int currentTime = 0; + public SilasMaster(Vector2 position) : base(position) + { + name = "SilasMaster"; + Width = 144; + Height = 160; + monster_health = 15; + monster_speed = 4; + acceleration = Vector2.Zero; + } + protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List() { "SilasMove", "SilasAttack" }, "SilasMove"); + public override void Attack() + { + if (currentTime==0) + { + GraphicsComponent.StartAnimation("SilasAttack"); + } + else if (currentTime >= attackTime) + { + GraphicsComponent.StartAnimation("SilasMove"); + currentTime = 0; + } + currentTime++; + } + + public override void Death() + { + throw new NotImplementedException(); + } + + public override void Move(GameTime gameTime) + { + if (currentTime == 0) + { + GraphicsComponent.StartAnimation("SilasMove"); + } + else if (currentTime >= moveTime) + { + GraphicsComponent.StartAnimation("SilasAttack"); + currentTime = 0; + } + currentTime++; + } + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + if (GraphicsComponent.CurrentAnimation.Id=="SilasMove") + { + Move(gameTime); + } + else + { + Attack(); + } + } } } diff --git a/DangerousD/GameCore/Graphics/GraphicsComponent.cs b/DangerousD/GameCore/Graphics/GraphicsComponent.cs index ca70881..beb6928 100644 --- a/DangerousD/GameCore/Graphics/GraphicsComponent.cs +++ b/DangerousD/GameCore/Graphics/GraphicsComponent.cs @@ -16,7 +16,14 @@ namespace DangerousD.GameCore.Graphics private List textures; private List texturesNames; private AnimationContainer currentAnimation; - + public AnimationContainer CurrentAnimation + { + get + { + return currentAnimation; + } + } + public string LastAnimation { get; set; } public string GetCurrentAnimation { get { return currentAnimation.Id; } @@ -26,6 +33,13 @@ namespace DangerousD.GameCore.Graphics //private SpriteBatch _spriteBatch; private int currentFrame; + public int CurrentFrame + { + get + { + return currentFrame; + } + } private int interval; private int lastInterval; private Rectangle sourceRectangle; diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index c3558d9..1596f63 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -10,16 +10,18 @@ namespace DangerousD.GameCore.Levels { public void InitLevel() { - new Player(new Vector2(80,0)); - var Zombie = new Zombie(new Vector2(140, 128)); - var Frank = new Frank(new Vector2(384, 128)); + new Player(new Vector2(0,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 Frank = new Frank(new Vector2(100, 64)); var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y)); - + var Zombie = new Zombie(new Vector2(300, 64)); + + var SilasHand = new SilasHands(new Vector2(200,64)); + var SilasMaster = new SilasMaster(new Vector2(400, 64)); new GrassBlock(new Vector2(0, 224)); for (int i = 0; i < 50; i++) {