public static void OnJoinRequest(int hostId, int connectionId, JoinRequestMessage message) { Debug.Log("JoinRequest received"); if (!GameController.gameStarted) { return; } //ask others if a player can join to that lane ConsentMessage consentMessage = new ConsentMessage(); consentMessage.consentAction = ConsentAction.JoinGame; Lane freeLane = p2PController.GetGameController().GetFirstUnoccupiedLane(); consentMessage.result = 10; if (freeLane != null) { consentMessage.result = freeLane.id; } consentMessage.parameters.Add(hostId); consentMessage.parameters.Add(connectionId); p2PController.AskForConsent(consentMessage); }
static Lane GetFirstUnoccupiedAndUnrequestedLaneAndRequest() { foreach (Lane lane in p2PController.GetGameController().lanes) { if (!lane.IsRequested() && !lane.IsOccupied()) { lane.Request(); return(lane); } } return(null); }