-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PlayFab REST API Docs - https://learn.microsoft.com/en-us/rest/api/?view=Playfab Use api - LoginWithEmailAddress - ExecuteCloudScript
- Loading branch information
1 parent
9feff7d
commit 41f55a2
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using PlayFab; | ||
using PlayFab.ClientModels; | ||
using System; | ||
|
||
public enum CallbackType | ||
{ | ||
Success, | ||
Fail | ||
} | ||
|
||
public class LoginInfo | ||
{ | ||
public string email; | ||
public string password; | ||
} | ||
|
||
public class LoginCallback | ||
{ | ||
public CallbackType callbackType; | ||
public LoginResult result; | ||
public PlayFabError error; | ||
} | ||
|
||
public static class AuthBackend | ||
{ | ||
public static void OnLogin(LoginInfo info, Action<LoginCallback> callback = null) | ||
{ | ||
PlayFabClientAPI.LoginWithEmailAddress(new LoginWithEmailAddressRequest | ||
{ | ||
Email = info.email, | ||
Password = info.password, | ||
TitleId = PlayFabSettings.TitleId | ||
}, | ||
result => | ||
{ | ||
callback?.Invoke(new LoginCallback { callbackType = CallbackType.Success, result = result }); | ||
}, | ||
error => | ||
{ | ||
callback?.Invoke(new LoginCallback { callbackType = CallbackType.Fail, error = error }); | ||
}); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using PlayFab; | ||
using PlayFab.ClientModels; | ||
using System; | ||
using UnityEngine; | ||
|
||
public static class DataBackend | ||
{ | ||
// Àӽà ÄÚµå | ||
private static int _attackCount = 0; | ||
|
||
public static void PlusAttackCount() | ||
{ | ||
_attackCount++; | ||
} | ||
|
||
public static void UpdateLeaderboard(Action callback = null) | ||
{ | ||
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest | ||
{ | ||
FunctionName = "updatePlayerLeaderboard", | ||
FunctionParameter = new { | ||
LeaderboardName = "AttackCount", | ||
Value = _attackCount | ||
}, | ||
GeneratePlayStreamEvent = true | ||
}, | ||
result => | ||
{ | ||
callback?.Invoke(); | ||
Debug.Log("Leaderboard Update Success!"); | ||
}, | ||
error => | ||
{ | ||
callback?.Invoke(); | ||
Debug.LogError("Leaderboard Update Fail!"); | ||
}); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters