Merge pull request #31 from progtime-net/UpdateEntity

add register game objects
This commit is contained in:
Andrey 2024-08-16 23:38:43 +03:00 committed by GitHub
commit ea08cc83c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 14 deletions

View file

@ -11,6 +11,7 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers
{
public enum ScopeState { Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight }
public class InputManager
{
public delegate void Delegat();

View file

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Sockets;
using System.Text;
using System.Text.Json;

View file

@ -16,8 +16,10 @@ namespace ZoFo.GameCore.GameObjects.Entities
protected Entity(Vector2 position) : base(position)
{
}
public virtual void Update()
{
}
}
}

View file

@ -3,20 +3,26 @@ using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameObjects.Entities;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore.GameManagers;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities;
public class LivingEntity : Entity
{
public Vector2 velocity;
private InputManager inputManager;
public LivingEntity(Vector2 position) : base(position)
{
inputManager = new InputManager();
}
public void TextureLoad(SpriteBatch spriteBatch)
#region Server side
/*public override void Update()
{
}
}*/
#endregion
}

View file

@ -1,25 +1,27 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
public class Player : LivingEntity
{
public Vector2 InputWeaponRotation{ get; set; }
public Vector2 InputPlayerRotation{ get; set;}
public bool IsTryingToShoot{get;set;}
Texture2D texture;
private float speed;
private int health;
Server server = new Server();
public Player(Vector2 position) : base(position)
{
//InputWeaponRotation = new Vector2(0, 0);
//InputPlayerRotation = new Vector2(0, 0);
}
public void Update(GameTime gameTime)
{
// server.AddData();
}
public void TextureLoad(SpriteBatch spriteBatch)
{
}
}

View file

@ -4,12 +4,15 @@ using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore;
namespace ZoFo.GameCore.GameObjects;
public abstract class GameObject
{
public Vector2 position;
private Server server;
public Vector2 rotation; //вектор направления объекта
public abstract GraphicsComponent graphicsComponent { get; }
@ -17,6 +20,8 @@ public abstract class GameObject
public GameObject(Vector2 position)
{
this.position = position;
server = new Server();
server.RegisterEntity(this);
graphicsComponent.LoadContent();
}

View file

@ -87,8 +87,7 @@ namespace ZoFo.GameCore
networkManager.AddData(gameEnded);
networkManager.CloseConnection();
}
#endregion
private List<GameObject> gameObjects;
private List<GameObject> gameObjects = new List<GameObject>();
private List<Entity> entities; //entity
public void Update(GameTime gameTime)
{