Merge pull request #31 from progtime-net/UpdateEntity
add register game objects
This commit is contained in:
commit
af5253146a
9 changed files with 35 additions and 21 deletions
|
@ -66,7 +66,7 @@ namespace ZoFo.GameCore
|
|||
}
|
||||
}
|
||||
|
||||
internal void GotData(IUpdateData update)
|
||||
internal void GotData(UpdateData update)
|
||||
{
|
||||
if (update is UpdateTileCreated)
|
||||
{
|
||||
|
|
|
@ -41,12 +41,9 @@ public class SelectModeMenu : AbstractGUI
|
|||
// single
|
||||
Server server = new Server();
|
||||
Client client = new Client();
|
||||
<<<<<<< HEAD
|
||||
server.CreateRoom(1);
|
||||
client.JoinYourself();
|
||||
|
||||
=======
|
||||
>>>>>>> e9698a8669e52b8738987a7a6ccb79c6726f91ac
|
||||
AppManager.Instance.SetServer(server);
|
||||
AppManager.Instance.SetClient(client);
|
||||
AppManager.Instance.ChangeState(GameState.HostPlaying);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
@ -21,7 +22,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
private IPEndPoint endPoint;
|
||||
private Socket socket;
|
||||
private List<Socket> clients;
|
||||
public List<IUpdateData> updates;
|
||||
public List<UpdateData> updates;
|
||||
public delegate void OnDataSend(string data);
|
||||
public event OnDataSend GetDataSend; // event
|
||||
Dictionary<Socket, Thread> managerThread;
|
||||
|
|
|
@ -16,8 +16,10 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
|||
protected Entity(Vector2 position) : base(position)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.RegisterGameObject(this);
|
||||
|
||||
graphicsComponent.LoadContent();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ZoFo.GameCore
|
|||
//TODO Comment pls
|
||||
public void OnDataSend(string data)
|
||||
{
|
||||
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
|
||||
List<UpdateData> updateDatas = JsonSerializer.Deserialize<List<UpdateData>>(data);
|
||||
for (int i = 0; i < updateDatas.Count; i++)
|
||||
{
|
||||
ProcessIUpdateData(updateDatas[i]);
|
||||
|
@ -39,7 +39,7 @@ namespace ZoFo.GameCore
|
|||
/// Обработка апдейтсов, которые нам прислал клиент
|
||||
/// </summary>
|
||||
/// <param name="updateData"></param>
|
||||
public void ProcessIUpdateData(IUpdateData updateData)
|
||||
public void ProcessIUpdateData(UpdateData updateData)
|
||||
{
|
||||
|
||||
//ТУТ Switch case будет честное слово
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -125,4 +124,5 @@ namespace ZoFo.GameCore
|
|||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue