diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index af738dd..6c1c0a4 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -22,7 +22,8 @@ using System.Linq; using System.Web; using ZoFo.GameCore.GUI; using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; -using ZoFo.GameCore.GameObjects.MapObjects.StopObjects; +using ZoFo.GameCore.GameObjects.MapObjects.StopObjects; +using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies; namespace ZoFo.GameCore { public class Client @@ -127,15 +128,10 @@ namespace ZoFo.GameCore if ((update as UpdateGameObjectCreated).GameObjectType == "Player") gameObjects.Add(new Player((update as UpdateGameObjectCreated).position)); if ((update as UpdateGameObjectCreated).GameObjectType == "Ammo") - gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position)); -<<<<<<< Updated upstream - if ((update as UpdateGameObjectCreated).GameObjectType == "Zombie") + gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position)) if ((update as UpdateGameObjectCreated).GameObjectType == "Zombie") gameObjects.Add(new Zombie((update as UpdateGameObjectCreated).position)); -======= - ->>>>>>> Stashed changes (gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity); //var a = Assembly.GetAssembly(typeof(GameObject)); //gameObjects.Add( TODO reflection diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Enemy.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Enemy.cs index f948689..61762ae 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Enemy.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Enemy.cs @@ -8,7 +8,14 @@ using Microsoft.Xna.Framework.Content; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies; public class Enemy : LivingEntity { + protected float speed; + protected int health; public Enemy(Vector2 position) : base(position) { + } + public override void Update() + { + + } } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs new file mode 100644 index 0000000..632eceb --- /dev/null +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Enemies/Zombie.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.Graphics; + +namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies +{ + class Zombie : Enemy + { + public override GraphicsComponent graphicsComponent { get; } = new("Textures/icons/8"); + public Zombie(Vector2 position) : base(position) + { + health = 5; + speed =2; + collisionComponent.stopRectangle = new Rectangle(0, 0, 100, 100); + graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100); + } + + public override void Update() + { + Vector2 duration = Vector2.Normalize(new Vector2(600 - position.X, 500 - position.Y)); + velocity=new Vector2(duration.X * speed, duration.Y*speed); + if(position.X>595 && 605>position.X && position.Y>495 && 505>position.Y) + { + velocity = Vector2.Zero; + } + //position.X += velocity.X*t; + //position.Y += velocity.Y * t; + } + } +} diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index d0272db..95a7ecd 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -126,6 +126,7 @@ namespace ZoFo.GameCore AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(40, 40))); AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140))); + AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1000, 1000))); AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440))); AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440))); }