示例#1
0
        public override void UpdateMappingID(string authenID, string gameID, GameMapID gameMapId)
        {
            CreateGameIdMap(gameID, gameMapId);

            var ids = (GameMapIDEX)gameMapId;

            //facebook
            if (!ids.authFacebook.Equals(""))
            {
                CreateAuthenticationMap(ids.authFacebook, new SocialMapIDEX {
                    GameId = gameID
                });
            }

            //game center
            if (!ids.authGameCenter.Equals(""))
            {
                CreateAuthenticationMap(ids.authGameCenter, new SocialMapIDEX {
                    GameId = gameID
                });
            }

            //google play
            if (!ids.authGooglePlay.Equals(""))
            {
                CreateAuthenticationMap(ids.authGooglePlay, new SocialMapIDEX {
                    GameId = gameID
                });
            }

            //email
            if (!ids.authEmail.Equals(""))
            {
                CreateAuthenticationMap(ids.authEmail, new SocialMapIDEX {
                    GameId = gameID
                });
            }

            //guest
            if (!ids.authGuest.Equals(""))
            {
                CreateAuthenticationMap(ids.authGuest, new SocialMapIDEX {
                    GameId = gameID
                });
            }
        }
示例#2
0
        public override void CreateGameIdMap(string gameID, GameMapID gameMap)
        {
            var data = (GameMapIDEX)gameMap;

            Debug.Log($"{DefineContain.DebugMapping} Create game ID map {gameID} - {data.ToDataString()}");
            var json = JsonUtility.ToJson(data);

            gameMapping.Child(gameID)
            .SetRawJsonValueAsync(json)
            .ContinueWithOnMainThread(task =>
            {
                if (task.IsCompleted)
                {
                    Debug.Log($"{DefineContain.DebugMapping} Create game id map is complete");
                }
                else
                {
                    Debug.Log($"{DefineContain.DebugMapping} Create game id map is faulted");
                }
            });
        }
 public virtual void UpdateMappingID(string authenID, string gameID, GameMapID gameMapId)
 {
 }
 public virtual void CreateGameIdMap(string gameID, GameMapID gameMap)
 {
 }
 public virtual void MappingData(EnumProvider providerCheck, string authenID, string localGameID, GameMapID gameMaps, Action <EnumMappingState, SocialMapID, GameMapID> callback)
 {
 }
示例#6
0
        public override void MappingData(EnumProvider providerCheck, string authenID, string localGameID, GameMapID gameMaps, Action <EnumMappingState, SocialMapID, GameMapID> callback)
        {
            Debug.Log($"{DefineContain.DebugMapping} Mapping:  authenID:{authenID} - gameID:{localGameID} - GameIDMap:{JsonUtility.ToJson(gameMaps, true)}");
            GetAuthenticationMap(authenID, (checkAuthenState, outSocialMap) =>
            {
                Debug.Log($"{DefineContain.DebugMapping} stateGetAuthen: {checkAuthenState}");
                if (checkAuthenState == EnumDataState.NoData)
                {
                    GetGameIdMap(localGameID, (checkGameState, gameIDs) =>
                    {
                        Debug.Log($"{DefineContain.DebugMapping} checkGameState: {checkGameState}");
                        if (checkGameState == EnumDataState.NoData)
                        {
                            Debug.Log($"{DefineContain.DebugMapping} no data create new user data");
                            // 0 - 0
                            callback?.Invoke(EnumMappingState.CreateNewData, new SocialMapIDEX(localGameID), gameMaps);
                        }
                        else if (checkGameState == EnumDataState.Exists)
                        {
                            // 0 - 1
                            var outGameId = (GameMapIDEX)gameIDs;
                            var success   = true;
                            var cloudId   = "";
                            switch (providerCheck)
                            {
                            case EnumProvider.Email:
                                if (string.IsNullOrEmpty(outGameId.authEmail))
                                {
                                    outGameId.authEmail = authenID;
                                }
                                else
                                {
                                    success = false;
                                }

                                break;

                            case EnumProvider.Facebook:
                                if (string.IsNullOrEmpty(outGameId.authFacebook))
                                {
                                    outGameId.authFacebook = authenID;
                                }
                                else
                                {
                                    success = false;
                                }

                                break;

                            case EnumProvider.GooglePlay:
                                if (string.IsNullOrEmpty(outGameId.authGooglePlay))
                                {
                                    outGameId.authGooglePlay = authenID;
                                }
                                else
                                {
                                    success = false;
                                }

                                break;

                            case EnumProvider.GameCenter:
                                if (string.IsNullOrEmpty(outGameId.authGameCenter))
                                {
                                    outGameId.authGameCenter = authenID;
                                }
                                else
                                {
                                    success = false;
                                }

                                break;

                            case EnumProvider.Guest:
                                if (string.IsNullOrEmpty(outGameId.authGuest))
                                {
                                    outGameId.authGuest = authenID;
                                }
                                else
                                {
                                    success = false;
                                }

                                break;
                            }

                            if (success)
                            {
                                Debug.Log($"{DefineContain.DebugMapping} not AuthenID - exits game ID");
                                callback?.Invoke(EnumMappingState.NoDataAuthen_ExitsGameId, new SocialMapIDEX(localGameID), outGameId);
                            }
                            else
                            {
                                Debug.Log($"{DefineContain.DebugMapping} not AuthenID - not match game ID");
                                callback?.Invoke(EnumMappingState.NoDataAuthen_NoMatchGameId, new SocialMapIDEX(localGameID), outGameId);
                            }
                        }
                        else if (checkGameState == EnumDataState.Error)
                        {
                            Debug.Log($"{DefineContain.DebugMapping} mapping data error");
                            callback?.Invoke(EnumMappingState.Error, new SocialMapIDEX(localGameID), gameMaps);
                        }
                    });
                }
                else if (checkAuthenState == EnumDataState.Exists)
                {
                    GetGameIdMap(localGameID, (checkGameState, gameIDs) =>
                    {
                        Debug.Log($"{DefineContain.DebugMapping} checkGameState: {checkGameState}");
                        // 1 - 0
                        if (checkGameState == EnumDataState.NoData)
                        {
                            Debug.Log($"{DefineContain.DebugMapping} exists AuthenID:{authenID} - no data GameID{outSocialMap.ToDataString()}");
                            callback?.Invoke(EnumMappingState.ExitsAuthen_NoDataGameID, new SocialMapIDEX(localGameID), gameMaps);
                        }
                        else if (checkGameState == EnumDataState.Exists)
                        {
                            var outGameId = (GameMapIDEX)gameIDs;
                            Debug.Log($"{DefineContain.DebugMapping} game mapping date: {outGameId.ToDataString()}");
                            // 1 - 1
                            var success = false;
                            var cloudID = "";
                            switch (providerCheck)
                            {
                            case EnumProvider.Facebook:
                                cloudID = outGameId.authFacebook;
                                if (authenID.Equals(outGameId.authFacebook) || string.IsNullOrEmpty(outGameId.authFacebook))
                                {
                                    success = true;
                                }

                                break;

                            case EnumProvider.GooglePlay:
                                cloudID = outGameId.authGooglePlay;
                                if (authenID.Equals(outGameId.authGooglePlay) || string.IsNullOrEmpty(outGameId.authGooglePlay))
                                {
                                    success = true;
                                }

                                break;

                            case EnumProvider.GameCenter:
                                cloudID = outGameId.authGameCenter;
                                if (authenID.Equals(outGameId.authGameCenter) || string.IsNullOrEmpty(outGameId.authGameCenter))
                                {
                                    success = true;
                                }

                                break;

                            case EnumProvider.Email:
                                cloudID = outGameId.authEmail;
                                if (authenID.Equals(outGameId.authEmail) || string.IsNullOrEmpty(outGameId.authEmail))
                                {
                                    success = true;
                                }

                                break;

                            case EnumProvider.Guest:
                                cloudID = outGameId.authGuest;
                                if (authenID.Equals(outGameId.authGuest) || string.IsNullOrEmpty(outGameId.authGuest))
                                {
                                    success = true;
                                }

                                break;
                            }

                            if (success)
                            {
                                Debug.Log($"{DefineContain.DebugMapping} mapping date success");
                                callback?.Invoke(EnumMappingState.Success, outSocialMap, gameIDs);
                            }
                            else
                            {
                                Debug.Log($"{DefineContain.DebugMapping} have 2 Authen connect 1 game id: local:{authenID} - cloud: {cloudID}");
                                callback?.Invoke(EnumMappingState.TwoAuthenOneGameID, outSocialMap, gameIDs);
                            }
                        }
                        else if (checkGameState == EnumDataState.Error)
                        {
                            Debug.Log($"{DefineContain.DebugMapping} mapping data error");
                            callback?.Invoke(EnumMappingState.Error, new SocialMapIDEX(localGameID), gameMaps);
                        }
                    });
                }
                else if (checkAuthenState == EnumDataState.Error)
                {
                    Debug.Log($"{DefineContain.DebugMapping} mapping data error");
                    callback?.Invoke(EnumMappingState.Error, new SocialMapIDEX(localGameID), gameMaps);
                }
            });
        }