Пример #1
0
    private void OnNearbyPlayerInfoReceived(string data)
    {
        string[] DataArray = data.Split(IOSNative.DATA_SPLITTER);

        string    playerId = DataArray[0];
        GK_Player player   = GameCenterManager.GetPlayerById(playerId);


        bool reachable = Convert.ToBoolean(DataArray[1]);

        if (reachable)
        {
            if (!_NearbyPlayers.ContainsKey(player.Id))
            {
                _NearbyPlayers.Add(player.Id, player);
            }
        }
        else
        {
            if (_NearbyPlayers.ContainsKey(player.Id))
            {
                _NearbyPlayers.Remove(player.Id);
            }
        }

        ActionNearbyPlayerStateUpdated(player, reachable);
    }
    public UM_PlayerTemplate GetPlayer(string playerId)
    {
        UM_PlayerTemplate player = null;

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GK_Player gk_player = GameCenterManager.GetPlayerById(playerId);
            if (gk_player != null)
            {
                player = new UM_PlayerTemplate(gk_player, null);
            }
            break;

        case RuntimePlatform.Android:
            GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(playerId);
            if (gp_player != null)
            {
                player = new UM_PlayerTemplate(null, gp_player);
            }
            break;
        }

        return(player);
    }
Пример #3
0
    public UM_Score(GK_Score gkScore, GPScore gpScore, GC_Score gcScore)
    {
        _GK_Score = gkScore;
        _GP_Score = gpScore;
        _GC_Score = gcScore;
        if (IsValid)
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
                {
                    GC_Player gc_player = SA_AmazonGameCircleManager.Instance.GetPlayerById(_GC_Score.PlayerId);
                    player = new UM_Player(null, null, gc_player);
                }
                else
                {
                    GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(_GP_Score.PlayerId);
                    player = new UM_Player(null, gp_player, null);
                }
                break;

            case RuntimePlatform.IPhonePlayer:
                GK_Player gk_player = GameCenterManager.GetPlayerById(_GK_Score.PlayerId);
                player = new UM_Player(gk_player, null, null);
                break;
            }
        }
    }
Пример #4
0
    private void OnMatchDataReceived(string data)
    {
        string[]  DataArray = data.Split(IOSNative.DATA_SPLITTER);
        string    playerId  = DataArray[0];
        GK_Player player    = GameCenterManager.GetPlayerById(playerId);

        byte[] decodedFromBase64 = System.Convert.FromBase64String(DataArray[1]);
        ActionDataReceived(player, decodedFromBase64);
    }
Пример #5
0
    public GK_Invite(string inviteData)
    {
        string[] DataArray = inviteData.Split(IOSNative.DATA_SPLITTER);
        _Id     = DataArray[0];
        _Sender = GameCenterManager.GetPlayerById(DataArray[1]);

        _PlayerGroup      = System.Convert.ToInt32(DataArray[2]);
        _PlayerAttributes = System.Convert.ToInt32(DataArray[3]);
    }
Пример #6
0
    // --------------------------------------
    // Native Events
    // --------------------------------------

    private void OnInviteeResponse(string data)
    {
        Debug.Log("OnInviteeResponse");
        string[] DataArray = data.Split(IOSNative.DATA_SPLITTER[0]);

        GK_Player player = GameCenterManager.GetPlayerById(DataArray[0]);
        GK_InviteRecipientResponse responce = (GK_InviteRecipientResponse)Convert.ToInt32(DataArray[1]);

        ActionInviteeResponse(player, responce);
    }
Пример #7
0
    private void OnMatchPlayerStateChanged(string data)
    {
        string[]  DataArray = data.Split(IOSNative.DATA_SPLITTER[0]);
        string    playerId  = DataArray[0];
        GK_Player player    = GameCenterManager.GetPlayerById(playerId);

        GK_PlayerConnectionState state = (GK_PlayerConnectionState)Convert.ToInt32(DataArray[1]);

        ActionPlayerStateChanged(player, state, CurrentMatch);
    }
Пример #8
0
    public GK_RTM_Match(string matchData)
    {
        string[] MatchData = matchData.Split(new string[] { IOSNative.DATA_SPLITTER2 }, StringSplitOptions.None);
        _ExpectedPlayerCount = Convert.ToInt32(MatchData[0]);

        string[] playersIds = IOSNative.ParseArray(MatchData[1]);
        foreach (string playerId in playersIds)
        {
            GK_Player player = GameCenterManager.GetPlayerById(playerId);
            _Players.Add(player);
        }
    }
Пример #9
0
    private void OnPlayerRequestedMatchWithRecipients_RTM(string data)
    {
        ISN_Logger.Log("OnPlayerRequestedMatchWithRecipients_RTM");
        string[]         playersIds = SA.Common.Data.Converter.ParseArray(data);
        List <GK_Player> players    = new List <GK_Player>();

        foreach (string playerId in playersIds)
        {
            players.Add(GameCenterManager.GetPlayerById(playerId));
        }

        ActionPlayerRequestedMatchWithRecipients(GK_MatchType.RealTime, playersIds, players.ToArray());
    }
Пример #10
0
    private void OnPlayerRequestedMatchWithRecipients_TBM(string data)
    {
        Debug.Log("OnPlayerRequestedMatchWithRecipients_TBM");
        string[]         playersIds = IOSNative.ParseArray(data);
        List <GK_Player> players    = new List <GK_Player>();

        foreach (string playerId in playersIds)
        {
            players.Add(GameCenterManager.GetPlayerById(playerId));
        }

        ActionPlayerRequestedMatchWithRecipients(GK_MatchType.RealTime, playersIds, players.ToArray());
    }
    private void OnMatchPlayerStateChanged(string data)
    {
        if (_CurrentMatch == null)
        {
            return;
        }

        string[]  DataArray = data.Split(SA.Common.Data.Converter.DATA_SPLITTER);
        string    playerId  = DataArray[0];
        GK_Player player    = GameCenterManager.GetPlayerById(playerId);



        GK_PlayerConnectionState state = (GK_PlayerConnectionState)Convert.ToInt32(DataArray[1]);

        ActionPlayerStateChanged(player, state, CurrentMatch);
    }
Пример #12
0
    public UM_Score(GK_Score gkScore, GPScore gpScore)
    {
        _GK_Score = gkScore;
        _GP_Score = gpScore;
        if (IsValid)
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(_GP_Score.PlayerId);
                player = new UM_Player(null, gp_player);
                break;

            case RuntimePlatform.IPhonePlayer:
                GK_Player gk_player = GameCenterManager.GetPlayerById(_GK_Score.PlayerId);
                player = new UM_Player(gk_player, null);
                break;
            }
        }
    }
    public UM_Player GetPlayer(string playerId)
    {
        UM_Player player = null;

        switch (Application.platform)
        {
        case RuntimePlatform.IPhonePlayer:
            GK_Player gk_player = GameCenterManager.GetPlayerById(playerId);
            if (gk_player != null)
            {
                player = new UM_Player(gk_player, null, null);
            }
            break;

        case RuntimePlatform.Android:
            if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon)
            {
                GC_Player gc_player = SA_AmazonGameCircleManager.Instance.GetPlayerById(playerId);
                if (gc_player != null)
                {
                    player = new UM_Player(null, null, gc_player);
                }
            }
            else
            {
                GooglePlayerTemplate gp_player = GooglePlayManager.Instance.GetPlayerById(playerId);
                if (gp_player != null)
                {
                    player = new UM_Player(null, gp_player, null);
                }
            }
            break;
        }

        return(player);
    }
    void OnGUI()
    {
        GUI.Label(new Rect(10, 20, 400, 40), "Friend List Load Example", headerStyle);

        if (GUI.Button(new Rect(300, 10, 150, 50), "Load Friends"))
        {
            GameCenterManager.OnFriendsListLoaded += OnFriendsListLoaded;
            GameCenterManager.RetrieveFriends();
        }


        if (GUI.Button(new Rect(500, 10, 150, 50), "Invite Friends"))
        {
            GK_FriendRequest r = new GK_FriendRequest();
            r.Send();
        }

        if (GUI.Button(new Rect(700, 10, 150, 50), "Invite with Emails"))
        {
            GK_FriendRequest r = new GK_FriendRequest();
            r.addRecipientsWithEmailAddresses("*****@*****.**", "*****@*****.**");
            r.Send();
        }



        if (!renderFriendsList)
        {
            return;
        }

        if (GUI.Button(new Rect(500, 10, 180, 50), "Leaberboard Challenge All"))
        {
            GameCenterManager.IssueLeaderboardChallenge(ChallengeLeaderboard, "Your message here", GameCenterManager.FriendsList.ToArray());
        }


        if (GUI.Button(new Rect(730, 10, 180, 50), "Achievement Challenge All"))
        {
            GameCenterManager.IssueAchievementChallenge(ChallengeAchievement, "Your message here", GameCenterManager.FriendsList.ToArray());
        }


        GUI.Label(new Rect(10, 90, 100, 40), "id", boardStyle);
        GUI.Label(new Rect(150, 90, 100, 40), "name", boardStyle);;
        GUI.Label(new Rect(300, 90, 100, 40), "avatar ", boardStyle);

        int i = 1;

        foreach (string FriendId in GameCenterManager.FriendsList)
        {
            GK_Player player = GameCenterManager.GetPlayerById(FriendId);
            if (player != null)
            {
                GUI.Label(new Rect(10, 90 + 70 * i, 100, 40), player.Id, boardStyle);
                GUI.Label(new Rect(150, 90 + 70 * i, 100, 40), player.Alias, boardStyle);
                if (player.SmallPhoto != null)
                {
                    GUI.DrawTexture(new Rect(300, 75 + 70 * i, 50, 50), player.SmallPhoto);
                }
                else
                {
                    GUI.Label(new Rect(300, 90 + 70 * i, 100, 40), "no photo ", boardStyle);
                }

                if (GUI.Button(new Rect(450, 90 + 70 * i, 150, 30), "Challenge Leaderboard"))
                {
                    GameCenterManager.IssueLeaderboardChallenge(ChallengeLeaderboard, "Your message here", FriendId);
                }

                if (GUI.Button(new Rect(650, 90 + 70 * i, 150, 30), "Challenge Achievement"))
                {
                    GameCenterManager.IssueAchievementChallenge(ChallengeAchievement, "Your message here", FriendId);
                }


                i++;
            }
        }
    }
Пример #15
0
    private void OnDiconnectedPlayerReinvited(string playerId)
    {
        GK_Player player = GameCenterManager.GetPlayerById(playerId);

        ActionDiconnectedPlayerReinvited(player);
    }
Пример #16
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 20, 400, 40), "Friend List Load Example", headerStyle);

        if (GUI.Button(new Rect(300, 10, 150, 50), "Load Friends"))
        {
            GameCenterManager.RetrieveFriends();
        }


        if (!renderFriendsList)
        {
            return;
        }

        if (GUI.Button(new Rect(500, 10, 180, 50), "Leaberboard Chalange All"))
        {
            GameCenterManager.issueLeaderboardChallenge(ChalangeLeadeboard, "Your message here", GameCenterManager.friendsList.ToArray());
        }


        if (GUI.Button(new Rect(730, 10, 180, 50), "Achievement Chalange All"))
        {
            GameCenterManager.issueAchievementChallenge(ChalangeAchivment, "Your message here", GameCenterManager.friendsList.ToArray());
        }


        GUI.Label(new Rect(10, 90, 100, 40), "id", boardStyle);
        GUI.Label(new Rect(150, 90, 100, 40), "name", boardStyle);;
        GUI.Label(new Rect(300, 90, 100, 40), "avatar ", boardStyle);

        int i = 1;

        foreach (string FriendId in GameCenterManager.friendsList)
        {
            GameCenterPlayerTemplate player = GameCenterManager.GetPlayerById(FriendId);
            if (player != null)
            {
                GUI.Label(new Rect(10, 90 + 70 * i, 100, 40), player.playerId, boardStyle);
                GUI.Label(new Rect(150, 90 + 70 * i, 100, 40), player.alias, boardStyle);
                if (player.avatar != null)
                {
                    GUI.DrawTexture(new Rect(300, 75 + 70 * i, 50, 50), player.avatar);
                }
                else
                {
                    GUI.Label(new Rect(300, 90 + 70 * i, 100, 40), "no photo ", boardStyle);
                }

                if (GUI.Button(new Rect(450, 90 + 70 * i, 150, 30), "Chalange Leaberboard"))
                {
                    GameCenterManager.issueLeaderboardChallenge(ChalangeLeadeboard, "Your message here", FriendId);
                }

                if (GUI.Button(new Rect(650, 90 + 70 * i, 150, 30), "Chalange Achievement"))
                {
                    GameCenterManager.issueAchievementChallenge(ChalangeAchivment, "Your message here", FriendId);
                }


                i++;
            }
        }
    }
Пример #17
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 20, 400, 40), "Custom Leaderboard GUI Example", headerStyle);

        if (GUI.Button(new Rect(400, 10, 150, 50), "Load Friends Scores"))
        {
            GameCenterManager.LoadScore(leaderboardId, 1, 10, GK_TimeSpan.ALL_TIME, GK_CollectionType.FRIENDS);
        }

        if (GUI.Button(new Rect(600, 10, 150, 50), "Load Global Scores"))
        {
            GameCenterManager.LoadScore(leaderboardId, 50, 150, GK_TimeSpan.ALL_TIME, GK_CollectionType.GLOBAL);
        }

        Color defaultColor = GUI.color;

        if (displayCollection == GK_CollectionType.GLOBAL)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(800, 10, 170, 50), "Displaying Global Scores"))
        {
            displayCollection = GK_CollectionType.GLOBAL;
        }
        GUI.color = defaultColor;



        if (displayCollection == GK_CollectionType.FRIENDS)
        {
            GUI.color = Color.green;
        }
        if (GUI.Button(new Rect(800, 70, 170, 50), "Displaying Friends Scores"))
        {
            displayCollection = GK_CollectionType.FRIENDS;
        }
        GUI.color = defaultColor;

        GUI.Label(new Rect(10, 90, 100, 40), "rank", boardStyle);
        GUI.Label(new Rect(100, 90, 100, 40), "score", boardStyle);
        GUI.Label(new Rect(200, 90, 100, 40), "playerId", boardStyle);
        GUI.Label(new Rect(400, 90, 100, 40), "name ", boardStyle);
        GUI.Label(new Rect(550, 90, 100, 40), "avatar ", boardStyle);

        if (loadedLeaderboard != null)
        {
            for (int i = 1; i < 10; i++)
            {
                GK_Score score = loadedLeaderboard.GetScore(i, GK_TimeSpan.ALL_TIME, displayCollection);
                if (score != null)
                {
                    GUI.Label(new Rect(10, 90 + 70 * i, 100, 40), i.ToString(), boardStyle);
                    GUI.Label(new Rect(100, 90 + 70 * i, 100, 40), score.GetLongScore().ToString(), boardStyle);
                    GUI.Label(new Rect(200, 90 + 70 * i, 100, 40), score.playerId, boardStyle);


                    GK_Player player = GameCenterManager.GetPlayerById(score.playerId);
                    if (player != null)
                    {
                        GUI.Label(new Rect(400, 90 + 70 * i, 100, 40), player.Alias, boardStyle);
                        if (player.SmallPhoto != null)
                        {
                            GUI.DrawTexture(new Rect(550, 75 + 70 * i, 50, 50), player.SmallPhoto);
                        }
                        else
                        {
                            GUI.Label(new Rect(550, 90 + 70 * i, 100, 40), "no photo ", boardStyle);
                        }
                    }

                    if (GUI.Button(new Rect(650, 90 + 70 * i, 100, 30), "Challenge"))
                    {
                        GameCenterManager.IssueLeaderboardChallenge(leaderboardId, "Your message here", score.playerId);
                    }
                }
            }
        }
    }