Exemplo n.º 1
0
    public void ResetPlayerVC_Success(string json, object cbObject)
    {
        m_currencies.Clear();

        BrainCloudWrapper.GetBC().PlayerStateService.ReadPlayerState(ReadPlayerState_Success, Failure_Callback);
        m_mainScene.AddLogNoLn("[ReadPlayerState]... ");
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
        void RetrieveGlobalStats()
        {
            m_stats.Clear();

            BrainCloudWrapper.GetBC().GlobalStatisticsService.ReadAllGlobalStats(
                ReadGlobalStatsSuccess, ReadGlobalStatsFailure);
        }
Exemplo n.º 4
0
    public override void Activate()
    {
        BrainCloudWrapper.GetBC().EntityFactory.RegisterEntityClass <Player>(Player.ENTITY_TYPE);

        BrainCloudWrapper.GetBC().PlayerStateService.ReadPlayerState(ReadPlayerStateSuccess, Failure_Callback);
        m_mainScene.AddLogNoLn("[ReadPlayerState]... ");
    }
Exemplo n.º 5
0
        void RetrievePlayerStats()
        {
            m_stats.Clear();

            BrainCloudWrapper.GetBC().PlayerStatisticsService.ReadAllPlayerStats(
                ReadPlayerStatsSuccess, ReadPlayerStatsFailure);
        }
Exemplo n.º 6
0
    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
        }
    }
Exemplo n.º 7
0
        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");
        }
Exemplo n.º 8
0
        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");
            }
        }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
        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");
        }
Exemplo n.º 11
0
    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();
        }
    }
Exemplo n.º 12
0
 public Player() : base(BrainCloudWrapper.GetBC().EntityService)
 {
     // set up some defaults
     m_entityType = "player";
     Name         = "";
     Age          = 0;
     Hobbies      = new List <Hobby>();
 }
Exemplo n.º 13
0
        void RetrieveLeaderboard(string leaderboardId)
        {
            m_lb.Clear();

            BrainCloudWrapper.GetBC().SocialLeaderboardService.GetGlobalLeaderboardPage(
                leaderboardId, BrainCloud.BrainCloudSocialLeaderboard.SortOrder.HIGH_TO_LOW, 0, 100, false,
                ReadLeaderboardSuccess, ReadLeaderboardFailure);
        }
Exemplo n.º 14
0
        void RetrieveLeaderboard(string leaderboardId)
        {
            m_lb.Clear();

            BrainCloudWrapper.GetBC().SocialLeaderboardService.GetGlobalLeaderboard(
                leaderboardId, BrainCloud.BrainCloudSocialLeaderboard.FetchType.HIGHEST_RANKED, 100,
                ReadLeaderboardSuccess, ReadLeaderboardFailure);
        }
Exemplo n.º 15
0
    ////////////////////////////////////////////
    // 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);
    }
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 17
0
 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();
 }
Exemplo n.º 18
0
 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
 }
Exemplo n.º 19
0
    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);
    }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
 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.");
     }
 }
Exemplo n.º 22
0
 void Start()
 {
     if (!BrainCloudWrapper.GetBC().IsAuthenticated())
     {
         Application.LoadLevel("BrainCloudConnect");
     }
     else
     {
         UpdateScoreText();
         ReadStatistics();
     }
 }
Exemplo n.º 23
0
 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;
         }
     }
 }
Exemplo n.º 24
0
        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();
        }
Exemplo n.º 25
0
    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);
    }
Exemplo n.º 26
0
    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;
            }
        }
    }
Exemplo n.º 27
0
    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);
    }
Exemplo n.º 28
0
    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);
        }
    }
Exemplo n.º 29
0
    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 + ")]... ");
        }
    }
Exemplo n.º 30
0
    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);
    }