Add zombie

This commit is contained in:
Kaktus200020 2024-08-18 14:37:07 +03:00
parent 1a6f1c0fce
commit 50f1c5f4fc
4 changed files with 46 additions and 7 deletions

View file

@ -23,6 +23,7 @@ using System.Web;
using ZoFo.GameCore.GUI; using ZoFo.GameCore.GUI;
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables; 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 namespace ZoFo.GameCore
{ {
public class Client public class Client
@ -127,15 +128,10 @@ namespace ZoFo.GameCore
if ((update as UpdateGameObjectCreated).GameObjectType == "Player") if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
gameObjects.Add(new Player((update as UpdateGameObjectCreated).position)); gameObjects.Add(new Player((update as UpdateGameObjectCreated).position));
if ((update as UpdateGameObjectCreated).GameObjectType == "Ammo") if ((update as UpdateGameObjectCreated).GameObjectType == "Ammo")
gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position)); gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position)) if ((update as UpdateGameObjectCreated).GameObjectType == "Zombie")
<<<<<<< Updated upstream
if ((update as UpdateGameObjectCreated).GameObjectType == "Zombie")
gameObjects.Add(new Zombie((update as UpdateGameObjectCreated).position)); gameObjects.Add(new Zombie((update as UpdateGameObjectCreated).position));
=======
>>>>>>> Stashed changes
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity); (gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
//var a = Assembly.GetAssembly(typeof(GameObject)); //var a = Assembly.GetAssembly(typeof(GameObject));
//gameObjects.Add( TODO reflection //gameObjects.Add( TODO reflection

View file

@ -8,7 +8,14 @@ using Microsoft.Xna.Framework.Content;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
public class Enemy : LivingEntity public class Enemy : LivingEntity
{ {
protected float speed;
protected int health;
public Enemy(Vector2 position) : base(position) public Enemy(Vector2 position) : base(position)
{ {
}
public override void Update()
{
} }
} }

View file

@ -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;
}
}
}

View file

@ -126,6 +126,7 @@ namespace ZoFo.GameCore
AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(40, 40))); 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 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(140, 440)));
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440))); AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
} }