public override IEnumerator ExecuteRequest() { // Create the move request var request = new ExecuteFunctionRequest { FunctionName = Constants.PLAYER_MOVE_FUNCTION_NAME, FunctionParameter = new MakePlayerMoveRequest { PlayFabId = Player.PlayFabId, Move = MoveToExecute }, AuthenticationContext = new PlayFabAuthenticationContext { EntityToken = Player.EntityToken } }; // Execute the move request PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; MoveResult = PlayFabSimpleJson.DeserializeObject <MakePlayerMoveResult>(result.FunctionResult.ToString()); }, (error) => { throw new Exception($"MakePlayerMove request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); }); yield return(WaitForExecution()); }
public IEnumerator Get(string sharedGroupId) { ExecutionCompleted = false; SharedGroupData = null; var request = GetExecuteFunctionRequest( Constants.GET_SHARED_GROUP, new GetSharedGroupRequest { SharedGroupId = sharedGroupId }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { SharedGroupData = result?.FunctionResult != null ? JsonUtility.FromJson <TicTacToeSharedGroupData>(result.FunctionResult.ToString()) : null; ExecutionCompleted = true; }, (error) => { SharedGroupData = null; ExecutionCompleted = true; Debug.Log($"Shared Group get request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator Delete(string sharedGroupId) { ExecutionCompleted = false; Debug.Log($"DeleteShcaredGroupHandler request '{sharedGroupId}'"); var request = GetExecuteFunctionRequest( Constants.DELETE_SHARED_GROUP_FUNCTION_NAME, new DeleteSharedGroupRequest { SharedGroupId = sharedGroupId }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { Debug.Log("Deleted"); ExecutionCompleted = true; }, (error) => { Debug.Log($"DeleteSharedGroupHandler request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public override IEnumerator ExecuteRequest() { var request = new ExecuteFunctionRequest { FunctionName = Constants.WIN_CHECK_FUNCTION_NAME, FunctionParameter = new PlayFabIdRequest { PlayFabId = Player.PlayFabId }, AuthenticationContext = new PlayFabAuthenticationContext { EntityToken = Player.EntityToken } }; PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; WinCheckResult = PlayFabSimpleJson.DeserializeObject <WinCheckResult>(result.FunctionResult.ToString()); }, (error) => { throw new Exception($"WinCheck request failed. Message: ${error.ErrorMessage}, Code: ${error.HttpCode}"); }); yield return(WaitForExecution()); }
public IEnumerator JoinMatch() { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.JOIN_MATCH_FUNCTION_NAME, new StartMatchRequest { SharedGroupId = sharedGroupId }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; TicTacToeSharedGroupData = JsonUtility.FromJson <TicTacToeSharedGroupData>(result.FunctionResult.ToString()); }, (error) => { TicTacToeSharedGroupData = null; ExecutionCompleted = true; Debug.Log($"StartMatch request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator GetMatchLobbyList(string filter = "") { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.SEARCH_MATCH_LOBBIES_FUNCTION_NAME, new SearchMatchLobbiesRequest { SearchTerm = filter }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { var resultList = JsonHelper.FromJson <MatchLobby>(result.FunctionResult.ToString()); MatchLobbyList = resultList.ToList(); ExecutionCompleted = true; }, (error) => { MatchLobbyList = null; ExecutionCompleted = true; Debug.Log($"GetMatchLobbyList request failed. Message: ${error.ErrorMessage}, Code: ${error.HttpCode}"); } ); yield return(WaitForExecution()); }
public override IEnumerator ExecuteRequest() { // Create the reset request var request = new ExecuteFunctionRequest { FunctionName = Constants.RESET_GAME_STATE_FUNCTION_NAME, FunctionParameter = new PlayFabIdRequest { PlayFabId = Player.PlayFabId }, AuthenticationContext = new PlayFabAuthenticationContext { EntityToken = Player.EntityToken } }; // Execute the reset request PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; }, (error) => { throw new Exception($"ResetGameState request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); }); yield return(WaitForExecution()); }
public IEnumerator DeleteMatchLobby(string matchLobbyId) { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.DELETE_MATCH_LOBBY_FUNCTION_NAME, new DeleteMatchLobbyInfoRequest { Id = matchLobbyId, MatchLobbyId = matchLobbyId }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; }, (error) => { ExecutionCompleted = true; Debug.Log($"DeleteMatchLobby request failed. Message: ${error.ErrorMessage}, Code: ${error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator CreateMatchLobby(string groupName) { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.CREATE_MATCH_LOBBY, new CreateMatchLobbyRequest { SharedGroupId = groupName }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { TicTacToeSharedGroupData = result?.FunctionResult != null ? JsonUtility.FromJson <TicTacToeSharedGroupData>(result.FunctionResult.ToString()) : null; ExecutionCompleted = true; }, (error) => { TicTacToeSharedGroupData = null; ExecutionCompleted = true; Debug.Log($"MatchLobby creation request failed. Message: ${error.ErrorMessage}, Code: ${error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator JoinMatchLobby(string id, string invitationCode = null) { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.JOIN_MATCH_LOBBY, new JoinMatchLobbyRequest { MatchLobbyId = id, InvitationCode = invitationCode }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { JoinMatchLobbyResponse = result?.FunctionResult != null ? JsonUtility.FromJson <ResponseWrapper <JoinMatchLobbyResponse> >(result.FunctionResult.ToString()) : null; ExecutionCompleted = true; }, (error) => { JoinMatchLobbyResponse = null; ExecutionCompleted = true; Debug.Log($"MatchLobby join request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator CreateMatchLobby(string matchLobbyId, string networkId, bool locked) { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.CREATE_MATCH_LOBBY, new CreateMatchLobbyRequest { MatchLobbyId = matchLobbyId, NetworkId = networkId, Locked = locked }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { MatchLobby = result?.FunctionResult != null ? JsonUtility.FromJson <MatchLobby>(result.FunctionResult.ToString()) : null; ExecutionCompleted = true; }, (error) => { MatchLobby = null; ExecutionCompleted = true; Debug.Log($"MatchLobby creation request failed. Message: ${error.ErrorMessage}, Code: ${error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator SetMatchLobbyLockState(string matchLobbyId, bool lockState) { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.SET_MATCH_LOBBY_LOCK_STATE, new SetMatchLobbyLockStateRequest { MatchLobbyId = matchLobbyId, Locked = lockState } ); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { SetMatchLobbyLockStateResponse = result?.FunctionResult != null ? JsonUtility.FromJson <ResponseWrapper <SetMatchLobbyLockStateResponse> >(result.FunctionResult.ToString()) : null; ExecutionCompleted = true; }, (error) => { SetMatchLobbyLockStateResponse = null; ExecutionCompleted = true; Debug.Log($"MatchLobby Lobby locked state setting has failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator LeaveMatchLobby(string matchLobbyId) { ExecutionCompleted = false; var request = GetExecuteFunctionRequest( Constants.LEAVE_MATCH_LOBBY, new LeaveMatchLobbyRequest { MatchLobbyId = matchLobbyId }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { MatchLobby = result?.FunctionResult != null ? JsonUtility.FromJson <MatchLobby>(result.FunctionResult.ToString()) : null; ExecutionCompleted = true; }, (error) => { MatchLobby = null; ExecutionCompleted = true; Debug.Log($"MatchLobby Leave request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator SetWinner(string playerId) { var request = GetExecuteFunctionRequest( Constants.SET_WINNER_GAME_FUNCTION_NAME, new SetGameWinnerRequest() { SharedGroupId = sharedGroupId, PlayerId = playerId }); PlayFabCloudScriptAPI.ExecuteFunction( request, (result) => { ExecutionCompleted = true; GameState = JsonUtility.FromJson <GameState>(result.FunctionResult.ToString()); }, (error) => { Debug.Log($"Set Game Winner request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator MakeMove(TicTacToeMove move) { var request = GetExecuteFunctionRequest( Constants.MULTIPLAYER_MOVE_FUNCTION_NAME, new MakeMultiplayerMoverRequest() { SharedGroupId = sharedGroupId, PlayerId = Player.PlayFabId, PlayerMove = move }); PlayFabCloudScriptAPI.ExecuteFunction( request, (result) => { ExecutionCompleted = true; MultiplayerMoveResponse = JsonUtility.FromJson <MakeMultiplayerMoveResponse>(result.FunctionResult.ToString()); }, (error) => { Debug.Log($"Make multiplayer move request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }
public IEnumerator Get() { var request = GetExecuteFunctionRequest( Constants.GET_GAME_STATUS_FUNCTION_NAME, new GetGameStatusRequest { SharedGroupId = sharedGroupId }); PlayFabCloudScriptAPI.ExecuteFunction(request, (result) => { ExecutionCompleted = true; GameState = JsonUtility.FromJson <GameState>(result.FunctionResult.ToString()); }, (error) => { Debug.Log($"GetGameStatus request failed. Message: {error.ErrorMessage}, Code: {error.HttpCode}"); } ); yield return(WaitForExecution()); }