/// <summary> /// Validates whether the playerNumber if allowed for the operation requested or not /// </summary> /// <returns>True if valid. False, otherwise</returns> private bool ValidatePlayerNumber(int playerNumber, string operationName, XboxLiveOperationType operationType) { if (playerNumber <= 0) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogError(operationName + " Failed: Player Number needs to be greater than zero."); } return(false); } if (playerNumber > GetMaximumNumberOfPlayers()) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogError(operationName + " Failed: Player Number exceeds the maximum number of users allowed on this platform."); } return(false); } if (operationType == XboxLiveOperationType.SignIn) { if (CurrentPlayers[playerNumber].XboxLiveUser != null) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogError(operationName + " Failed: Player " + playerNumber + " is already signed in."); } NotifyAllCallbacks( playerNumber, null, XboxLiveAuthStatus.Invalid, operationName + " Failed: Player " + playerNumber + " is already signed in.", true); return(false); } } if (operationType == XboxLiveOperationType.SignOut || operationType == XboxLiveOperationType.GetUser) { if (!CurrentPlayers.ContainsKey(playerNumber) || CurrentPlayers[playerNumber].XboxLiveUser == null) { if (XboxLiveServicesSettings.Instance.DebugLogsOn) { Debug.LogWarning(operationName + " Failed: Player " + playerNumber + " is not signed in."); } if (operationType == XboxLiveOperationType.SignOut) { NotifyAllCallbacks( playerNumber, null, XboxLiveAuthStatus.Invalid, operationName + " Failed: Player " + playerNumber + " is not signed in.", false); } return(false); } } return(true); }
/// <summary> /// Validates whether the playerNumber if allowed for the operation requested or not /// </summary> /// <returns>True if valid. False, otherwise</returns> private bool ValidatePlayerNumber(int playerNumber, string operationName, XboxLiveOperationType operationType) { if (playerNumber <= 0) { var errorMessage = operationName + " Failed: Player Number needs to be greater than zero."; ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.NoPlayersAreSignedIn, new Exception(errorMessage)); return(false); } if (playerNumber > GetMaximumNumberOfPlayers()) { var errorMessage = operationName + " Failed: Player Number exceeds the maximum number of users allowed on this platform."; ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.MaximumPlayerNumberReached, new Exception(errorMessage)); return(false); } if (operationType == XboxLiveOperationType.SignIn) { if (CurrentPlayers[playerNumber].XboxLiveUser != null) { var errorMessage = operationName + " Failed: Player " + playerNumber + " is already signed in."; ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.PlayerIsAlreadySignedIn, new Exception(errorMessage)); NotifyAllCallbacks( playerNumber, null, XboxLiveAuthStatus.Invalid, errorMessage, true); return(false); } } if (operationType == XboxLiveOperationType.SignOut || operationType == XboxLiveOperationType.GetUser) { if (!CurrentPlayers.ContainsKey(playerNumber) || CurrentPlayers[playerNumber].XboxLiveUser == null) { var errorMessage = operationName + " Failed: Player " + playerNumber + " is not signed in."; ExceptionManager.Instance.ThrowException( ExceptionSource.SignInManager, ExceptionType.PlayerRequestedIsNotSignedIn, new Exception(errorMessage)); if (operationType == XboxLiveOperationType.SignOut) { NotifyAllCallbacks( playerNumber, null, XboxLiveAuthStatus.Invalid, errorMessage, false); } return(false); } } return(true); }