示例#1
0
    public void ForgotPassAction(GameObject GO, Action callback)
    {
        var mainTransform = GO.transform;
        var email         = mainTransform.Find("EmailField").GetComponent <InputField> ();

        var emailString = email.text;

        if (string.IsNullOrEmpty(emailString))
        {
            ShowInfoDialogWithText(LocaliseText.Get("Account.EmailEmptyError"), "CLOSE");
            return;
        }
        if (!IsMailValid(emailString))
        {
            ShowInfoDialogWithText(LocaliseText.Get("Account.EmailNotValidError"), "CLOSE");
            return;
        }

        if (!Reachability.Instance.IsReachable())
        {
            ShowInfoDialogWithText(LocaliseText.Get("Account.NoConnection"), "CLOSE");
            return;
        }

        if (!GS.Available)
        {
            GS.Reconnect();
        }

        GSRequestData d = new GSRequestData();

        d.Add("email", emailString);
        d.Add("action", "passwordRecoveryRequest");

        Loading.Instance.Show();

        new AuthenticationRequest()
        .SetUserName("")
        .SetPassword("")
        .SetScriptData(d)
        .Send(((response) => {
            Loading.Instance.Hide();

            if (response.HasErrors)
            {
                ShowInfoDialogWithText(LocaliseText.Get("Account.ForgotPassEmailSuccess"), "CLOSE");

                if (callback != null)
                {
                    callback();
                }
            }
        }));
    }
示例#2
0
    public static void CreateMatchByName(string[] playersIDs)
    {
        GSRequestData data = new GSRequestData();

        data.Add("PlayersIDs", playersIDs);

        new LogEventRequest()
        .SetEventKey("CREATE_MATCH")
        .SetEventAttribute("Players", data)
        .Send((response) =>
        {
            if (response.HasErrors)
            {
                Debug.LogError("Error to create match: " + response.Errors);
            }
        });
    }
示例#3
0
    public void FindPlayers()
    {
        if (!GS.Authenticated)
        {
            print("Not logged in!");
            return;
        }
        Debug.Log("GSM| Attempting Matchmaking...");
        ObliusGameManager.instance.matchFailed = false;
        GSRequestData data = new GSRequestData();

        data.Add("server", PhotonNetwork.CloudRegion.ToString());
        new GameSparks.Api.Requests.MatchmakingRequest()
        .SetMatchShortCode("normal")
        .SetSkill(0)
        .Send((response) =>
        {
            if (response.HasErrors)
            {
                Debug.LogError("GSM| MatchMaking Error \n" + response.Errors.JSON);
            }
        });
    }
示例#4
0
    bool ItemPurchasedHandler(BaseMessage message)
    {
        ItemPurchasedMessage msg = message as ItemPurchasedMessage;

        PaymentProductCoins[] coins = CustomPaymentManager.Coins;
        for (int i = 0; i < coins.Length; i++)
        {
            if (coins[i].Product.Name.Equals(msg.ProductID))
            {
                if (coins [i].Coins > 0)
                {
                    GameObject animatedCoins = GameObject.Find("AddCoinsAnimated");

                    if (animatedCoins != null)
                    {
                        GameObject       addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent);
                        AddCoinsAnimated addCoins      = addCoinsClone.GetComponent <AddCoinsAnimated>();

                        addCoins.AnimateCoinsAdding(coins [i].Coins);
                    }
                    else
                    {
                        GameManager.Instance.Player.AddCoins(coins [i].Coins);
                        GameManager.Instance.Player.UpdatePlayerPrefs();
                    }
                }

                if (coins[i].NoAds == 1)
                {
                    PreferencesFactory.SetInt(Constants.KeyNoAds, 1);
                }

                PreferencesFactory.Save();

                if (!Debug.isDebugBuild)
                {
                    Flurry.Flurry.Instance.LogEvent(coins [i].EventCode);
                    Fabric.Answers.Answers.LogPurchase(coins [i].Price,
                                                       coins [i].Currency,
                                                       true,
                                                       coins [i].Description,
                                                       coins [i].NoAds == 1 ? "Ads" : "Coins",
                                                       msg.ProductID
                                                       );
                    Branch.userCompletedAction("InApp");
                }

                if (GameSparksManager.IsUserLoggedIn())
                {
                    GSRequestData json = new GSRequestData();
                    json.Add("package", msg.ProductID);
                    json.Add("price", string.Format("{0} {1}", coins[i].Price, coins[i].Currency));
                    json.Add("date", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));

                    new LogEventRequest()
                    .SetEventKey("IAPPurchase")
                    .SetEventAttribute("data", json)
                    .Send(((response) => {
                    }));
                }

                if (coins[i].NoAds == 1)
                {
                    DialogManager.Instance.Show(prefabName: "GeneralMessageOkButton",
                                                title: LocaliseText.Get("Text.Success"),
                                                text: LocaliseText.Get("Payment.PurchaseSuccess"),
                                                dialogButtons: DialogInstance.DialogButtonsType.Ok);
                }

                break;
            }
        }

        return(true);
    }
示例#5
0
    private void RegisterUser()
    {
        if (isSoundPlaying)
        {
            buttonAudioSource.Play();
        }
        StartMenu.playAsGuest = false;
        string _name        = NAME.text;
        string _email       = EMAIL.text;
        string _username    = USERNAME.text;
        string _password    = PASSWORD.text;
        string _countryName = countryName.text;

        if (_name == "")
        {
            ShowToast.MyShowToastMethod("Enter you Name!");
            return;
        }
        if (_email == "")
        {
            ShowToast.MyShowToastMethod("Enter you Email!");
            return;
        }
        if (_username == "")
        {
            ShowToast.MyShowToastMethod("Enter you Username!");
            return;
        }
        if (_password == "")
        {
            ShowToast.MyShowToastMethod("Enter you Password!");
            return;
        }

        Debug.Log("Registering User...");
        register_btn.interactable = false;
        GSRequestData gSRequestData = new GSRequestData();

        gSRequestData.Add("email", _email);
        new RegistrationRequest().SetDisplayName(_name).SetUserName(_username).SetPassword(_password).SetScriptData(gSRequestData).Send((response) =>
        {
            if (!response.HasErrors)
            {
                Debug.Log("Player Registered");

                ShowToast.MyShowToastMethod("Player registered successfully!");

                userId = response.UserId;
                Database.setPlayerDataInGameSpark(_name, _countryName, "null");
                Database.setPlayerDataInLocalDatabase(_name, _countryName, 5000, userId);
                Database.setAllWinsAndLosesToZero(userId);
                //change scene
                SceneManager.LoadScene(GameConstants.STARTMENU_SCENE);
                register_btn.interactable = true;
                Database.SetLoginStatus(GameConstants.LOGGED_IN_WITH_GAMESPARK);
                Database.SetUserName(_username);
                Database.SetPassword(_password);
                Database.SetDisplayName(_name);
            }
            else if (response.Errors.GetString("ERROR") == "Email in use!")
            {
                ShowToast.MyShowToastMethod("Email already in use!");
                Debug.Log("Email already in use!");
                register_btn.interactable = true;
            }
            else
            {
                Debug.Log("Error Registering Player");
                ShowToast.MyShowToastMethod("Error Registering Player!");
                register_btn.interactable = true;
                Debug.Log(response.Errors.GetString("ERROR"));
            }
        });
    }