diff --git a/DangerousD/Content/animations/SilasBallMove b/DangerousD/Content/animations/SilasBallMove new file mode 100644 index 0000000..9a0b5f4 --- /dev/null +++ b/DangerousD/Content/animations/SilasBallMove @@ -0,0 +1 @@ +{"id":"SilasBallMove","textureName":"MonstersAnimations","startSpriteRectangle":{"X":147,"Y":618,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":8}],"textureFrameInterval":1,"framesCount":2,"isCycle":true,"offset":"0, 0"} diff --git a/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs b/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs new file mode 100644 index 0000000..b14d8af --- /dev/null +++ b/DangerousD/GameCore/GameObjects/Entities/SilasBall.cs @@ -0,0 +1,36 @@ +using DangerousD.GameCore.Graphics; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DangerousD.GameCore.GameObjects.Entities +{ + public class SilasBall : LivingEntity + { + public SilasBall(Vector2 position) : base(position) + { + Height = 60; + Width = 60; + acceleration = Vector2.Zero; + + } + public SilasBall(Vector2 position, Vector2 velosity) : base(position) + { + Height = 60; + Width = 60; + acceleration = Vector2.Zero; + velocity = velosity; + + } + + protected override GraphicsComponent GraphicsComponent { get; } = new(new List { "SilasBallMove" }, "SilasBallMove"); + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + + } + } +} diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs index cf33f30..d16936a 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasHands.cs @@ -39,12 +39,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters { if (Pos.Y> AppManager.Instance.GameManager.GetPlayer1.Pos.Y) { - velocity.Y = monster_speed; + velocity.Y = -monster_speed; } else { - velocity.Y = 0; + velocity.Y = monster_speed; } if (Pos.X> AppManager.Instance.GameManager.GetPlayer1.Pos.X) { @@ -58,6 +58,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters public override void Update(GameTime gameTime) { base.Update(gameTime); + Move(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)) { diff --git a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs index 09a3928..d4fb5d2 100644 --- a/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs +++ b/DangerousD/GameCore/GameObjects/LivingEntities/Monsters/SilasMaster.cs @@ -1,4 +1,5 @@ -using DangerousD.GameCore.Graphics; +using DangerousD.GameCore.GameObjects.Entities; +using DangerousD.GameCore.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; @@ -15,6 +16,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters private int attackTime = 60; private int moveTime = 360; private int currentTime = 0; + private bool isGoRight = true; + int leftBorder; + int rightBorder; + List hands = new List(); + List balls = new List(); public SilasMaster(Vector2 position) : base(position) { name = "SilasMaster"; @@ -23,22 +29,47 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters monster_health = 15; monster_speed = 4; acceleration = Vector2.Zero; + leftBorder = (int)position.X - 60; + rightBorder = (int)position.X + 120; + acceleration = Vector2.Zero; + hands.Add(new SilasHands(new Vector2(Pos.X+60,Pos.Y+120))); + hands.Add(new SilasHands(new Vector2(Pos.X + 90, Pos.Y + 120))); + for (int i = 0; i < 4; i++) + { + SilasBall silasball = new SilasBall(new Vector2(Pos.X + i * 40, Pos.Y + 120), new Vector2((i - 2) * 4, 6)); + balls.Add(silasball); + } } protected override GraphicsComponent GraphicsComponent { get; } = new GraphicsComponent(new List() { "SilasMove", "SilasAttack" }, "SilasMove"); public override void Attack() { - if (currentTime==0) + + if (currentTime == 0) { GraphicsComponent.StartAnimation("SilasAttack"); + + } + else if (currentTime == attackTime / 2) + { + SpawnAttackBall(); } else if (currentTime >= attackTime) { + GraphicsComponent.StartAnimation("SilasMove"); currentTime = 0; } currentTime++; } - + private void SpawnAttackBall() + { + for (int i = 0; i < balls.Count; i++) + { + balls[i].SetPosition(new Vector2(Pos.X + i * 40, Pos.Y + 120)); + } + + + } public override void Death() { throw new NotImplementedException(); @@ -56,16 +87,38 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters currentTime = 0; } currentTime++; + if (isGoRight) + { + velocity.X = monster_speed; + } + else if (!isGoRight) + { + velocity.X = -monster_speed; + } + + if (Pos.X >= rightBorder) + { + isGoRight = false; + } + else if (Pos.X <= leftBorder) + { + isGoRight = true; + } } public override void Update(GameTime gameTime) { base.Update(gameTime); - if (GraphicsComponent.CurrentAnimation.Id=="SilasMove") + if (hands.Count<2) + { + hands.Add(new SilasHands(new Vector2(Pos.X + 60, Pos.Y + 120))); + } + if (GraphicsComponent.CurrentAnimation.Id == "SilasMove") { Move(gameTime); } else { + velocity = Vector2.Zero; Attack(); } } diff --git a/DangerousD/GameCore/Levels/Level1.cs b/DangerousD/GameCore/Levels/Level1.cs index 1596f63..654312d 100644 --- a/DangerousD/GameCore/Levels/Level1.cs +++ b/DangerousD/GameCore/Levels/Level1.cs @@ -3,6 +3,7 @@ using DangerousD.GameCore.GameObjects.MapObjects; using Microsoft.Xna.Framework; using DangerousD.GameCore.GameObjects.LivingEntities.Monsters; using System.Collections.Generic; +using DangerousD.GameCore.GameObjects.Entities; namespace DangerousD.GameCore.Levels { @@ -19,9 +20,9 @@ namespace DangerousD.GameCore.Levels 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 SilasBall = new SilasBall(new Vector2(550, 64)); var SilasHand = new SilasHands(new Vector2(200,64)); - var SilasMaster = new SilasMaster(new Vector2(400, 64)); + var SilasMaster = new SilasMaster(new Vector2(400, 300)); new GrassBlock(new Vector2(0, 224)); for (int i = 0; i < 50; i++) { diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index 55d83c2..70d377b 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -76,8 +76,11 @@ namespace DangerousD.GameCore item.Update(gameTime); foreach (var item in entities) item.Update(gameTime); - foreach (var item in livingEntities) - item.Update(gameTime); + + for (int i = 0; i < livingEntities.Count; i++) + { + livingEntities[i].Update(gameTime); + } foreach (var item in otherObjects) item.Update(gameTime);