GameObject Fixes
This commit is contained in:
parent
54aded7c1d
commit
12a464bea6
12 changed files with 69 additions and 35 deletions
|
@ -13,25 +13,11 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
||||||
protected override GraphicsComponent graphicsComponent => null;
|
protected override GraphicsComponent graphicsComponent => null;
|
||||||
public CollisionComponent collisionComponent { get; protected set; }
|
public CollisionComponent collisionComponent { get; protected set; }
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public void CollisionComponent()
|
protected Entity(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AnimationComponent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateLogic()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//вектор
|
|
||||||
//вилосити
|
|
||||||
//поситион
|
|
||||||
//текстура
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
||||||
public class Collectable : Entity
|
public class Collectable : Entity
|
||||||
{
|
{
|
||||||
|
public Collectable(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,13 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
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
|
||||||
{
|
{
|
||||||
|
public Enemy(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,9 @@ public class LivingEntity : Entity
|
||||||
{
|
{
|
||||||
public Vector2 velocity;
|
public Vector2 velocity;
|
||||||
|
|
||||||
|
public LivingEntity(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void TextureLoad(SpriteBatch spriteBatch)
|
public void TextureLoad(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,10 @@ public class Player : LivingEntity
|
||||||
private int health;
|
private int health;
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
|
|
||||||
|
public Player(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
// server.AddData();
|
// server.AddData();
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
|
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
|
||||||
public class Bullet : Projectile
|
public class Bullet : Projectile
|
||||||
{
|
{
|
||||||
|
public Bullet(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
|
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
|
||||||
public class Projectile : LivingEntity
|
public class Projectile : LivingEntity
|
||||||
{
|
{
|
||||||
|
public Projectile(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
|
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Projectiles;
|
||||||
public class Rock : Projectile
|
public class Rock : Projectile
|
||||||
{
|
{
|
||||||
|
public Rock(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,18 @@ public abstract class GameObject
|
||||||
{
|
{
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
public virtual void UpdateLogic(GameTime gameTime)
|
||||||
|
{
|
||||||
|
PlayAnimation_OnServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Это вызывается в логике игры, которая на сервере, здесь будет вызываться уведомление об анимации
|
/// Это вызывается в логике игры, которая на сервере, здесь будет вызываться уведомление об анимации
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PlayAnimation_OnServer()
|
public void PlayAnimation_OnServer()
|
||||||
{
|
{
|
||||||
//TODO
|
graphicsComponent.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -34,22 +38,35 @@ public abstract class GameObject
|
||||||
#region Client Side
|
#region Client Side
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Для клиента
|
||||||
/// Это вызывается в клиентской части игры
|
/// Это вызывается в клиентской части игры
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PlayAnimation_OnClient()
|
public void PlayAnimation_OnClient()
|
||||||
{
|
{
|
||||||
graphicsComponent.Update();
|
graphicsComponent.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Для клиента
|
||||||
|
/// Загрузка графического компонента
|
||||||
|
/// </summary>
|
||||||
public void LoadContent()
|
public void LoadContent()
|
||||||
{
|
{
|
||||||
graphicsComponent.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)
|
public virtual void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch);
|
graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch);
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
|
||||||
_sourceRectangle = sourceRectangle;
|
_sourceRectangle = sourceRectangle;
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y);
|
||||||
}
|
}
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch, _sourceRectangle);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class StopObject : MapObject
|
||||||
{
|
{
|
||||||
CollisionComponent collisionComponent;
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,7 @@ namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
public class Server
|
public class Server
|
||||||
{
|
{
|
||||||
private List<GameObject> gameObjects;
|
|
||||||
private ServerNetworkManager networkManager;
|
private ServerNetworkManager networkManager;
|
||||||
private List<Entity> entity; //entity
|
|
||||||
public Server()
|
public Server()
|
||||||
{
|
{
|
||||||
networkManager = new ServerNetworkManager();
|
networkManager = new ServerNetworkManager();
|
||||||
|
@ -57,9 +55,16 @@ namespace ZoFo.GameCore
|
||||||
UpdateGameEnded gameEnded = new UpdateGameEnded();
|
UpdateGameEnded gameEnded = new UpdateGameEnded();
|
||||||
networkManager.AddData(gameEnded);
|
networkManager.AddData(gameEnded);
|
||||||
networkManager.CloseConnection();
|
networkManager.CloseConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<GameObject> gameObjects;
|
||||||
|
private List<Entity> entities; //entity
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
foreach (var go in gameObjects)
|
||||||
|
{
|
||||||
|
go.UpdateLogic(gameTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Reference in a new issue