public void ResetPlayerVC_Success(string json, object cbObject) { m_currencies.Clear(); BrainCloudWrapper.GetBC().PlayerStateService.ReadPlayerState(ReadPlayerState_Success, Failure_Callback); m_mainScene.AddLogNoLn("[ReadPlayerState]... "); }
void EnterMatch(MatchInfo match) { m_state = eState.LOADING; // Query more detail state about the match BrainCloudWrapper.GetBC().AsyncMatchService.ReadMatch(match.ownerId, match.matchId, OnReadMatch, OnReadMatchFailed, match); }
void RetrieveGlobalStats() { m_stats.Clear(); BrainCloudWrapper.GetBC().GlobalStatisticsService.ReadAllGlobalStats( ReadGlobalStatsSuccess, ReadGlobalStatsFailure); }
public override void Activate() { BrainCloudWrapper.GetBC().EntityFactory.RegisterEntityClass <Player>(Player.ENTITY_TYPE); BrainCloudWrapper.GetBC().PlayerStateService.ReadPlayerState(ReadPlayerStateSuccess, Failure_Callback); m_mainScene.AddLogNoLn("[ReadPlayerState]... "); }
void RetrievePlayerStats() { m_stats.Clear(); BrainCloudWrapper.GetBC().PlayerStatisticsService.ReadAllPlayerStats( ReadPlayerStatsSuccess, ReadPlayerStatsFailure); }
void OnFacebookLogin(FBResult result) { if (FB.IsLoggedIn) { // It worked Debug.Log("Facebook auth success"); // Now we login using Braincloud BrainCloudWrapper.GetBC().AuthenticationService.AuthenticateFacebook( FB.UserId, FB.AccessToken, true, OnBraincloudAuthenticateFacebookSuccess, OnBraincloudAuthenticateFacebookFailed); // Meanwhile, we will fetch info about our player, to get the profile pic and name FB.API("/me?fields=name,picture", Facebook.HttpMethod.GET, OnFacebookMe); } else { // It failed Debug.LogError("Facebook auth failed"); m_isConnecting = false; spinner.gameObject.SetActive(false); // Hide spinner } }
public void OnSuccess_Authenticate(string responseData, object cbObject) { AppendLog("Authenticate successful!"); JsonData response = JsonMapper.ToObject(responseData); string username = ""; if (response["data"]["playerName"].ToString() == "") { for (int i = 0; i < m_username.Length; i++) { if (m_username[i] != '@') { username += m_username[i].ToString(); } else { break; } } BrainCloudWrapper.GetBC().PlayerStateService.UpdatePlayerName(username); } else { username = response["data"]["playerName"].ToString(); } GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().ReadStatistics(); GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().ReadGlobalProperties(); GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().m_playerName = username; GameObject.Find("Version Text").transform.SetParent(null); GameObject.Find("FullScreen").transform.SetParent(null); NetworkManager.singleton.StartMatchMaker(); Application.LoadLevel("Matchmaking"); }
void OnGUI() { if (!BrainCloudWrapper.GetBC().IsAuthenticated()) { int width = Screen.width / 2 - 125; if (width < 500) { width = 500; } if (width > Screen.width) { width = Screen.width; } int height = Screen.height / 2 - 200; if (height < 400) { height = 400; } if (height > Screen.height) { height = Screen.height; } GUILayout.Window(0, new Rect(Screen.width / 2 - (width / 2), Screen.height / 2 - (height / 2), width, height), OnWindow, "brainCloud Login"); } }
public void FinishEditName() { GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().m_playerName = GameObject.Find("PlayerName").GetComponent <InputField>().text; BrainCloudWrapper.GetBC().PlayerStateService.UpdatePlayerName(GameObject.Find("PlayerName").GetComponent <InputField>().text); GameObject.Find("PlayerName").GetComponent <InputField>().interactable = false; GameObject.Find("PlayerName").GetComponent <Image>().enabled = false; }
public void OnSuccess_Authenticate(string responseData, object cbObject) { AppendLog("Authenticate successful!"); JsonData response = JsonMapper.ToObject(responseData); string username = ""; if (response["data"]["playerName"].ToString() == "") { for (int i = 0; i < m_username.Length; i++) { if (m_username[i] != '@') { username += m_username[i].ToString(); } else { break; } } BrainCloudWrapper.GetBC().PlayerStateService.UpdatePlayerName(username); PhotonNetwork.player.name = username; } else { PhotonNetwork.player.name = response["data"]["playerName"].ToString(); } GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().ReadStatistics(); GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().ReadGlobalProperties(); PhotonNetwork.sendRate = 20; Application.LoadLevel("Matchmaking"); }
private void SaveStatisticsToBrainCloud() { // Build the statistics name/inc value dictionary Dictionary <string, object> stats = new Dictionary <string, object> { { "BirdsShot", m_BirdsShot }, { "MiniUFOsShot", m_MiniUFOsShot }, { "CarsDestroyed", m_CarsDestroyed }, { "BossesKilled", m_BossesKilled }, { "TrucksDestroyed", m_TrucksDestroyed } }; // Send to the cloud BrainCloudWrapper.GetBC().PlayerStatisticsService.IncrementPlayerStats( stats, StatsSuccess_Callback, StatsFailure_Callback, null); m_BirdsShot = 0; m_CarsDestroyed = 0; m_MiniUFOsShot = 0; m_TrucksDestroyed = 0; m_BossesKilled = 0; if (m_IsQuitting) { Application.Quit(); } }
public Player() : base(BrainCloudWrapper.GetBC().EntityService) { // set up some defaults m_entityType = "player"; Name = ""; Age = 0; Hobbies = new List <Hobby>(); }
void RetrieveLeaderboard(string leaderboardId) { m_lb.Clear(); BrainCloudWrapper.GetBC().SocialLeaderboardService.GetGlobalLeaderboardPage( leaderboardId, BrainCloud.BrainCloudSocialLeaderboard.SortOrder.HIGH_TO_LOW, 0, 100, false, ReadLeaderboardSuccess, ReadLeaderboardFailure); }
void RetrieveLeaderboard(string leaderboardId) { m_lb.Clear(); BrainCloudWrapper.GetBC().SocialLeaderboardService.GetGlobalLeaderboard( leaderboardId, BrainCloud.BrainCloudSocialLeaderboard.FetchType.HIGHEST_RANKED, 100, ReadLeaderboardSuccess, ReadLeaderboardFailure); }
//////////////////////////////////////////// // BrainCloud integration code //////////////////////////////////////////// private void ReadStatistics() { // Ask brainCloud for statistics BrainCloudWrapper.GetBC().PlayerStatisticsService.ReadAllPlayerStats(StatsSuccess_Callback, StatsFailure_Callback, null); brainCloudStatusText.text = "Reading statistics from brainCloud..."; brainCloudStatusText.gameObject.SetActive(true); }
public void ReadStatistics() { // Ask brainCloud for statistics BrainCloudWrapper.GetBC().PlayerStatisticsService.ReadAllPlayerStats(StatsSuccess_Callback, StatsFailure_Callback, null); BrainCloudWrapper.GetBC().PlayerStateService.ReadPlayerState(StateSuccess_Callback, StateFailure_Callback, null); BrainCloudWrapper.GetBC().GamificationService.ReadXpLevelsMetaData(LevelsSuccess_Callback, LevelsFailure_Callback, null); BrainCloudWrapper.GetBC().GamificationService.ReadAchievements(true, AchievementSuccess_Callback, AchievementFailure_Callback, null); }
void OnGUIBottom() { GUILayout.BeginHorizontal(); GUILayout.Box("Game Id: " + BrainCloudWrapper.GetBC().GameId); GUILayout.Box("Game Version: " + BrainCloudWrapper.GetBC().GameVersion); GUILayout.Box("Profile Id: " + BrainCloudWrapper.GetBC().AuthenticationService.ProfileId); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
void OnPostScoreSuccess(string postResponseData, object cbPostObject) { // Now we fetch the leaderboards to see were we stand BrainCloudWrapper.GetBC().SocialLeaderboardService.GetLeaderboard( "spacegame_highscores", // Leaderboard Id true, // If true, your name will be replaced with "You" OnGetLeaderboardsSuccess, // Success callback OnGetLeaderboardsFailed); // Failed callback }
public void SaveStatisticsToBrainCloud() { Dictionary <string, object> stats = new Dictionary <string, object> { { "timeToCompleteLevel1", m_Level1.BestTimeToCompleteLevel }, { "totalNumberDeaths", m_TotalDeaths }, { "numberDeathsLevel1", m_Level1.NumberDeaths } }; BrainCloudWrapper.GetBC().PlayerStatisticsService.IncrementPlayerStats(stats, StatsSuccess_Callback, StatsFailure_Callback, null); }
public void ForgotPassword() { m_username = GameObject.Find("UsernameBox").GetComponent <InputField>().text; if (m_username == "" || !m_username.Contains("@")) { GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayDialog("You need to enter an email first!"); return; } BrainCloudWrapper.GetBC().AuthenticationService.ResetEmailPassword(m_username, OnSuccess_Reset, OnError_Reset); }
void OnSuccess_AuthenticateTwitter(bool success, Twitter.AccessTokenResponse response) { if (success) { BrainCloudWrapper.GetBC().IdentityService.MergeTwitterIdentity(response.UserId, response.Token, response.TokenSecret, Attach_Success, Attach_Fail); //BrainCloudWrapper.GetBC().IdentityService.AttachTwitterIdentity(response.UserId, response.Token, response.TokenSecret, Attach_Success, Attach_Fail); } else { Debug.Log("OnAccessTokenCallback - failed."); } }
void Start() { if (!BrainCloudWrapper.GetBC().IsAuthenticated()) { Application.LoadLevel("BrainCloudConnect"); } else { UpdateScoreText(); ReadStatistics(); } }
public void Get5KillsAchievement() { for (int i = 0; i < m_achievements.Count; i++) { if (m_achievements[i].m_id == "0") { if (!m_achievements[i].m_achieved) { m_achievements[i].m_achieved = true; BrainCloudWrapper.GetBC().GamificationService.AwardAchievements(m_achievements[i].m_id, null, null, null); GameObject.Find("DialogDisplay").GetComponent <DialogDisplay>().DisplayAchievement(int.Parse(m_achievements[i].m_id), m_achievements[i].m_name, m_achievements[i].m_description); } break; } } }
public void OnHUDDraw() { m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); foreach (string key in m_attributes.Keys) { GUILayout.Label(key); } GUILayout.EndVertical(); GUILayout.BeginVertical(); foreach (string value in m_attributes.Values) { GUILayout.Box(value); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); //spacer GUILayout.BeginVertical(); GUILayout.Space(5); GUILayout.EndVertical(); GUILayout.TextArea("Reseting your player will delete all player data but will keep identities intact."); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset Player")) { BrainCloudWrapper.GetBC().PlayerStateService.ResetPlayer(ResetPlayerSuccess, Failure); } GUILayout.EndHorizontal(); GUILayout.TextArea("Deleting your player will delete the player entirely. Player will need to reauthenticate and create new account"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Delete Player")) { BrainCloudWrapper.GetBC().PlayerStateService.DeletePlayer(DeletePlayerSuccess, Failure); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.EndVertical(); }
void OnTurnSubmitted(string responseData, object cbPostObject) { if (m_winner == 0) { // Go back to game select scene Application.LoadLevel("GamePicker"); return; } // Otherwise, the game was done. Send a complete turn BrainCloudWrapper.GetBC().AsyncMatchService.CompleteMatch( ownerId, matchId, OnMatchCompleted, null, null); }
private void ReadPlayerStateSuccess(string json, object cb) { m_mainScene.AddLog("SUCCESS"); m_mainScene.AddLogJson(json); m_mainScene.AddLog(""); // look for the player entity IList <BCUserEntity> entities = BrainCloudWrapper.GetBC().EntityFactory.NewUserEntitiesFromReadPlayerState(json); foreach (BCUserEntity entity in entities) { if (entity.EntityType == ENTITY_TYPE_PLAYER) { m_player = entity; } } }
private void SaveStatisticsToBrainCloud() { // Build the statistics name/inc value dictionary Dictionary <string, object> stats = new Dictionary <string, object> { { "enemiesKilled", m_enemiesKilledThisRound }, { "asteroidsDestroyed", m_asteroidsDestroyedThisRound }, { "shotsFired", m_shotsFiredThisRound }, { "gamesPlayed", 1 } }; // Send to the cloud BrainCloudWrapper.GetBC().PlayerStatisticsService.IncrementPlayerStats( stats, StatsSuccess_Callback, StatsFailure_Callback, null); brainCloudStatusText.text = "Incrementing statistics on brainCloud..."; brainCloudStatusText.gameObject.SetActive(true); }
void OnGUI() { // Display History HUD OnHistoryGUI(); if (!m_turnPlayed) { return; } string btnText = "Submit Turn"; if (m_winner != 0) { btnText = "Complete Game"; } if (m_isHistoryMatch) { if (GUI.Button(new Rect(Screen.width / 2 - 70, 60, 140, 30), "Leave")) { // Go back to game select scene Application.LoadLevel("GamePicker"); } } else if (GUI.Button(new Rect(Screen.width / 2 - 70, 60, 140, 30), btnText)) { // Ask the user to submit his turn JsonData boardStateJson = new JsonData(); boardStateJson["board"] = boardState; BrainCloudWrapper.GetBC().AsyncMatchService.SubmitTurn( ownerId, matchId, matchVersion, boardStateJson.ToJson(), "A turn has been played", null, null, null, OnTurnSubmitted, null, null); } }
private void ReadPlayerState_Success(string json, object cb) { m_mainScene.AddLog("SUCCESS"); m_mainScene.AddLogJson(json); m_mainScene.AddLog(""); JsonData jObj = JsonMapper.ToObject(json); m_playerLevel = (int)jObj["data"]["experienceLevel"]; m_playerXp = (int)jObj["data"]["experiencePoints"]; // now grab our currencies foreach (string curType in m_currencyTypes) { BrainCloudWrapper.GetBC().ProductService.GetCurrency(curType, GetPlayerVC_Success, Failure_Callback); m_mainScene.AddLogNoLn("[GetPlayerVC (" + curType + ")]... "); } }
void OnFindMatchesSuccess(string responseData, object cbPostObject) { m_matches.Clear(); // Construct our game list using response data JsonData jsonMatches = JsonMapper.ToObject(responseData)["data"]["results"]; for (int i = 0; i < jsonMatches.Count; ++i) { JsonData jsonMatch = jsonMatches[i]; MatchInfo match = new MatchInfo(jsonMatch); m_matches.Add(match); } // Now, find completed matches so the user can go see the history BrainCloudWrapper.GetBC().GetAsyncMatchService().FindCompleteMatches(OnFindCompletedMatches, null, null); }