MultiplyPlayersShootInterractCommit
This commit is contained in:
parent
a0208805ed
commit
128f304780
5 changed files with 22 additions and 8 deletions
|
@ -60,11 +60,11 @@ namespace ZoFo.GameCore
|
|||
};
|
||||
AppManager.Instance.InputManager.OnInteract += () =>
|
||||
{
|
||||
networkManager.AddData(new UpdateInputInteraction() { });
|
||||
networkManager.AddData(new UpdateInputInteraction() {PlayerId = AppManager.Instance.client.networkManager.PlayerId });
|
||||
};
|
||||
AppManager.Instance.InputManager.ShootEvent += () =>
|
||||
{
|
||||
networkManager.AddData(new UpdateInputShoot() { });
|
||||
networkManager.AddData(new UpdateInputShoot() { PlayerId = AppManager.Instance.client.networkManager.PlayerId });
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -9,4 +9,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
|||
public class UpdateInputInteraction : UpdateData
|
||||
{
|
||||
public UpdateInputInteraction() { UpdateType = "UpdateInputInteraction"; }
|
||||
public int PlayerId { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
|||
public class UpdateInputShoot : UpdateData
|
||||
{
|
||||
public UpdateInputShoot() { UpdateType = "UpdateInputShoot"; }
|
||||
public int PlayerId { get; set; }
|
||||
}
|
||||
|
|
|
@ -59,7 +59,10 @@ namespace ZoFo.GameCore.GameObjects
|
|||
|
||||
public virtual void Delete()
|
||||
{
|
||||
AppManager.Instance.server.DeleteObject(this);
|
||||
if (AppManager.Instance.gamestate == GameState.HostPlaying)
|
||||
{
|
||||
AppManager.Instance.server.DeleteObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ namespace ZoFo.GameCore
|
|||
case "UpdateInput":
|
||||
if (players.Count > 0)
|
||||
{
|
||||
UpdateInput data = updateData as UpdateInput;
|
||||
players[data.PlayerId-1].HandleNewInput(data);
|
||||
UpdateInput data = updateData as UpdateInput;
|
||||
players[data.PlayerId - 1].HandleNewInput(data);
|
||||
}
|
||||
//TODO id instead of 0
|
||||
else
|
||||
|
@ -80,13 +80,21 @@ namespace ZoFo.GameCore
|
|||
case "UpdateTileCreated":
|
||||
break;
|
||||
case "UpdateInputInteraction":
|
||||
players[0].HandleInteract(updateData as UpdateInputInteraction);
|
||||
if (players.Count > 0)
|
||||
{
|
||||
UpdateInputInteraction data = updateData as UpdateInputInteraction;
|
||||
players[data.PlayerId - 1].HandleInteract(data);
|
||||
}
|
||||
break;
|
||||
case "UpdateInputShoot":
|
||||
players[0].HandleShoot(updateData as UpdateInputShoot);
|
||||
if (players.Count > 0)
|
||||
{
|
||||
UpdateInputShoot data = updateData as UpdateInputShoot;
|
||||
players[data.PlayerId - 1].HandleShoot(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//Поспать
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Reference in a new issue