ServerChange

This commit is contained in:
rawer470 2024-08-16 15:25:08 +03:00
commit 7a444a1e3e
12 changed files with 69 additions and 36 deletions

View file

@ -13,25 +13,11 @@ namespace ZoFo.GameCore.GameObjects.Entities
protected override GraphicsComponent graphicsComponent => null;
public CollisionComponent collisionComponent { get; protected set; }
public int Id { get; set; }
public void CollisionComponent()
protected Entity(Vector2 position) : base(position)
{
}
public void AnimationComponent()
{
}
public void UpdateLogic()
{
}
}
}
//вектор
//вилосити
//поситион
//текстура

View file

@ -1,7 +1,10 @@
using System;
using Microsoft.Xna.Framework;
using System;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
public class Collectable : Entity
{
public Collectable(Vector2 position) : base(position)
{
}
}

View file

@ -2,10 +2,13 @@
using System.Collections.Generic;
using System.Net.Mime;
using System.Reflection;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
public class Enemy : LivingEntity
{
public Enemy(Vector2 position) : base(position)
{
}
}

View file

@ -9,6 +9,9 @@ public class LivingEntity : Entity
{
public Vector2 velocity;
public LivingEntity(Vector2 position) : base(position)
{
}
public void TextureLoad(SpriteBatch spriteBatch)
{

View file

@ -9,6 +9,10 @@ public class Player : LivingEntity
private int health;
Server server = new Server();
public Player(Vector2 position) : base(position)
{
}
public void Update(GameTime gameTime)
{
// server.AddData();

View file

@ -1,7 +1,10 @@
using System;
using Microsoft.Xna.Framework;
using System;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
public class Bullet : Projectile
{
public Bullet(Vector2 position) : base(position)
{
}
}

View file

@ -1,7 +1,10 @@
using System;
using Microsoft.Xna.Framework;
using System;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
public class Projectile : LivingEntity
{
public Projectile(Vector2 position) : base(position)
{
}
}

View file

@ -1,7 +1,10 @@
using System;
using Microsoft.Xna.Framework;
using System;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
public class Rock : Projectile
{
public Rock(Vector2 position) : base(position)
{
}
}

View file

@ -18,14 +18,18 @@ public abstract class GameObject
{
this.position = position;
}
public virtual void UpdateLogic(GameTime gameTime)
{
PlayAnimation_OnServer();
}
/// <summary>
/// Это вызывается в логике игры, которая на сервере, здесь будет вызываться уведомление об анимации
/// </summary>
public void PlayAnimation_OnServer()
{
//TODO
graphicsComponent.Update();
}
#endregion
@ -34,22 +38,35 @@ public abstract class GameObject
#region Client Side
/// <summary>
/// Для клиента
/// Это вызывается в клиентской части игры
/// </summary>
public void PlayAnimation_OnClient()
{
graphicsComponent.Update();
}
/// <summary>
/// Для клиента
/// Загрузка графического компонента
/// </summary>
public void LoadContent()
{
graphicsComponent.LoadContent();
}
public virtual void Update(GameTime gameTime)
/// <summary>
/// Для клиента
/// Обновление, которое вызывается у клиента, для просмотра анимаций
/// </summary>
public virtual void UpdateAnimations(GameTime gameTime)
{
//PlayAnimation();
PlayAnimation_OnClient();
}
/// <summary>
/// Для клиента
/// </summary>
public virtual void Draw(SpriteBatch spriteBatch)
{
graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch);

View file

@ -21,6 +21,10 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
_sourceRectangle = sourceRectangle;
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y);
}
public override void Draw(SpriteBatch spriteBatch)
{
graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch, _sourceRectangle);
}
}
}

View file

@ -9,7 +9,7 @@ public class StopObject : MapObject
{
CollisionComponent collisionComponent;
protected StopObject(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position, size, sourceRectangle)
protected StopObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position, size, sourceRectangle, textureName)
{
}
}

View file

@ -15,9 +15,7 @@ namespace ZoFo.GameCore
{
public class Server
{
private List<GameObject> gameObjects;
private ServerNetworkManager networkManager;
private List<Entity> entity; //entity
public Server()
{
networkManager = new ServerNetworkManager();
@ -57,10 +55,16 @@ namespace ZoFo.GameCore
UpdateGameEnded gameEnded = new UpdateGameEnded();
networkManager.AddData(gameEnded);
networkManager.CloseConnection();
}
public void Update(GameTime gameTime)
{
}
private List<GameObject> gameObjects;
private List<Entity> entities; //entity
public void Update(GameTime gameTime)
{
foreach (var go in gameObjects)
{
go.UpdateLogic(gameTime);
}
}
/// <summary>