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()); }
private void ProcessWinCheckResult(WinCheckResult result) { switch (result.winner) { case GameWinnerType.NONE: break; case GameWinnerType.DRAW: WinnerStatusText.text = "DRAW!"; break; case GameWinnerType.PLAYER: WinnerStatusText.text = "YOU WIN"; break; case GameWinnerType.AI: WinnerStatusText.text = "YOU LOSE"; break; } if (result.winner != GameWinnerType.NONE) { WinnerStatusText.GetComponent <Text>().enabled = true; RestartButton.gameObject.SetActive(true); GameOver = true; } }
private WinCheckResult GetCurrentGameResult(GameState gameState) { var checkResult = new WinCheckResult { winner = GameWinnerType.NONE }; if (gameState.boardState.Length > 0) { checkResult = WinCheckUtil.Check(gameState); } return(checkResult); }