MultiplyPlayerCommit
This commit is contained in:
parent
23b32fa2f0
commit
a3ffef519a
5 changed files with 17 additions and 5 deletions
|
@ -50,7 +50,8 @@ namespace ZoFo.GameCore
|
||||||
networkManager.AddData(new UpdateInput()
|
networkManager.AddData(new UpdateInput()
|
||||||
{
|
{
|
||||||
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(),
|
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(),
|
||||||
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize()
|
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize(),
|
||||||
|
PlayerId = AppManager.Instance.client.networkManager.PlayerId
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
{
|
{
|
||||||
public class ClientNetworkManager
|
public class ClientNetworkManager
|
||||||
{
|
{
|
||||||
private int PlayerId;
|
public int PlayerId;
|
||||||
private IPEndPoint endPoint;
|
private IPEndPoint endPoint;
|
||||||
private IPEndPoint sendingEP;
|
private IPEndPoint sendingEP;
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
private IPAddress ip;
|
private IPAddress ip;
|
||||||
private bool isMultiplayer;
|
private bool isMultiplayer;
|
||||||
//Player Id to Player endPoint
|
//Player Id to Player endPoint
|
||||||
private List<IPEndPoint> clientsEP;
|
public List<IPEndPoint> clientsEP;
|
||||||
public IPEndPoint endPoint;
|
public IPEndPoint endPoint;
|
||||||
private List<UpdateData> commonUpdates;
|
private List<UpdateData> commonUpdates;
|
||||||
private List<UpdateData> importantUpdates;
|
private List<UpdateData> importantUpdates;
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer
|
||||||
// public int IdEntity { get; set; }
|
// public int IdEntity { get; set; }
|
||||||
public SerializableVector2 InputMovementDirection{get;set;}
|
public SerializableVector2 InputMovementDirection{get;set;}
|
||||||
public SerializableVector2 InputAttackDirection {get;set;}
|
public SerializableVector2 InputAttackDirection {get;set;}
|
||||||
|
|
||||||
|
public int PlayerId {get;set;}
|
||||||
public UpdateInput()
|
public UpdateInput()
|
||||||
{
|
{
|
||||||
UpdateType = "UpdateInput";
|
UpdateType = "UpdateInput";
|
||||||
|
|
|
@ -69,7 +69,11 @@ namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
case "UpdateInput":
|
case "UpdateInput":
|
||||||
if (players.Count > 0)
|
if (players.Count > 0)
|
||||||
players[0].HandleNewInput(updateData as UpdateInput);//TODO id instead of 0
|
{
|
||||||
|
UpdateInput data = updateData as UpdateInput;
|
||||||
|
players[data.PlayerId-1].HandleNewInput(data);
|
||||||
|
}
|
||||||
|
//TODO id instead of 0
|
||||||
else
|
else
|
||||||
DebugHUD.DebugLog("NO PLAYER ON MAP");
|
DebugHUD.DebugLog("NO PLAYER ON MAP");
|
||||||
break;
|
break;
|
||||||
|
@ -124,7 +128,12 @@ namespace ZoFo.GameCore
|
||||||
new MapManager().LoadMap();
|
new MapManager().LoadMap();
|
||||||
|
|
||||||
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140)));
|
for (int i = 0; i < networkManager.clientsEP.Count; i++)
|
||||||
|
{
|
||||||
|
Player player = new Player(new Vector2(760 - 30 * i, 140));
|
||||||
|
RegisterGameObject(player);
|
||||||
|
networkManager.AddData(new UpdateCreatePlayer() { PlayerId = i+1, IdEntity=player.Id});
|
||||||
|
}
|
||||||
//for (int i = 0; i < 20; i++)
|
//for (int i = 0; i < 20; i++)
|
||||||
// for (int j = 0; j < 20; j++)
|
// for (int j = 0; j < 20; j++)
|
||||||
// AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70)));
|
// AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70)));
|
||||||
|
|
Loading…
Add table
Reference in a new issue