Exemple #1
0
 public void checkUserLoginToShowPopup()
 {
     if (!TacoManager.UserLoggedIn())
     {
         SendMessage("ShowModalRemindSignup");
     }
 }
Exemple #2
0
        public void PostScore(int score, Tournament target)
        {
            if (target != null && TacoManager.UserLoggedIn())
            {
                Action <string> success = (string data) => {
                    ScoreResult r         = JsonUtility.FromJson <ScoreResult>(data);
                    string      modalBody = TacoConfig.TacoPlayEndedModalBody;
                    string      modal     = TacoConfig.TacoPlayEndedWinnerModalBody;
                    modalBody = modalBody.Replace("&gameEndScore", r.score.ToString());
                    if (r.tournament.typeCurrency == 0)
                    {
                        modal = modal.Replace("&prize", " $ " + Math.Round((Decimal)r.tournament.prize, 2, MidpointRounding.AwayFromZero));
                        modal = modal.Replace("&point", "P " + (int)Math.Round(r.tournament.prize * 50, 0, MidpointRounding.AwayFromZero) + " and ");
                    }
                    else
                    {
                        modal = modal.Replace("&point", string.Empty);
                        modal = modal.Replace("&prize", " T " + r.tournament.prize);
                    }

                    if (r.winner)
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.SetToMainMenu();
                        TacoManager.ShowPanel(PanelNames.MyLeaderboardPanelFromEndGame);
                    }
                    else
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.SetToMainMenu();
                        TacoManager.ShowPanel(PanelNames.MyLeaderboardPanelFromEndGame);
                    }
                    TacoManager.GameToken = null;
                    if (r.updated)
                    {
                        TacoManager.UpdateFundsWithToken(r.funds, r.gTokens.ToString(), r.ticket.ToString());
                    }
                };

                Action <string, string> fail = (string data, string error) => {
                    if (Application.internetReachability == NetworkReachability.NotReachable)
                    {
                        TacoManager.CloseMessage();
                        TacoManager.OpenModalConnectionErrorPanel(TacoConfig.ErrorStatusNoInternet);
                    }
                    else
                    {
                        var r = JsonUtility.FromJson <StartGameResult>(data);
                        TacoManager.CloseAllModals();
                        TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.TacoPlayError, r.message);
                    }
                    TacoManager.GameToken = null;
                };

                StartCoroutine(ApiManager.Instance.EndGame(score, target.id, target.gameId, TacoManager.GameToken, TacoManager.User.token, success, fail));
            }
        }
Exemple #3
0
 public void ChangeHighScoreToLocal()
 {
     if (TacoManager.UserLoggedIn())
     {
         PlayerPrefs.SetInt(TacoConfig.TacoHighScoresType, 0);
         Highscore.Instance.highscore = PlayerPrefs.GetFloat("highscoreArcade");
         Highscore.Instance.UpdateManually();
     }
 }
        public void PostScore(int score, Tournament target)
        {
            TacoConfig.print(" Game Ended with score : " + score);

            PlayerPrefs.SetInt(TacoConfig.TacoHighScoresType, 0);
            PlayerPrefs.SetFloat(TacoConfig.TacoHighScoresPerhapsText, 0);
            Highscore.Instance.highscore = PlayerPrefs.GetFloat("highscoreArcade");
            Highscore.Instance.UpdateManually();

            if (target != null && TacoManager.UserLoggedIn())
            {
                //StartCoroutine(endGame(score));

                Action <string> success = (string data) => {
                    ScoreResult r = JsonUtility.FromJson <ScoreResult>(data);
                    TacoConfig.print("Result complete = " + r.success + " - " + r.score + " - " + r.message);
                    string modalBody = string.Empty;
                    //If user play again so token can't verify
                    if (r.success)
                    {
                        modalBody = TacoConfig.TacoPlayEndedModalBody;

                        modalBody = modalBody.Replace("&gameEndScore", r.score.ToString());
                    }
                    else
                    {
                        modalBody = TacoConfig.TacoPlayEndedAgainModalBody;
                    }

                    TacoManager.CloseAllModals();
                    TacoManager.OpenModal(TacoConfig.TacoPlayEndedModalHeader, modalBody, null, ModalFunctions.TournamentGamePosted);

                    // set the status text
                    TacoManager.StatusText.text = "";

                    // game is over : release token
                    TacoManager.GameToken = null;
                    if (r.updated)
                    {
                        TacoManager.UpdateFundsWithToken(r.funds, r.gTokens.ToString());
                    }
                };

                Action <string, string> fail = (string data, string error) => {
                    var msg = data + ((string.IsNullOrEmpty(error)) ? "" : " : " + error);
                    TacoConfig.print("Error starting game - " + msg);

                    var r = JsonUtility.FromJson <StartGameResult>(data);

                    TacoManager.CloseAllModals();
                    TacoManager.OpenModal(TacoConfig.TacoPlayError, r.message);
                };

                StartCoroutine(ApiManager.Instance.EndGame(score, target.id, target.gameId, TacoManager.GameToken, TacoManager.User.token, success, fail));
            }
        }
Exemple #5
0
        public void CheckWillGetFreeTokens(object[] contentModal)
        {
            var currentScore = int.Parse(contentModal[0].ToString());

            if (TacoManager.UserLoggedIn() && currentScore > TacoManager.User.highScoreUser)
            {
                //Update HighScoreToServer
                GameManager.Instance.UpdateHighScoreAndGtokens(currentScore);
            }
            else
            {
                CallMessage("CallGameOverSence");
            }
        }
Exemple #6
0
 /// <summary>
 /// Check If user is logged in or not
 /// </summary>
 public bool IsLoggedIn()
 {
     return(TacoManager.UserLoggedIn());
 }