Ejemplo n.º 1
0
        public void TappedRemovedEmailFromCreate(int index)
        {
            invitedFriends.RemoveAt(index);

            TacoManager.CloseAllModals();

            TappedInviteFromCreate();
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 3
0
        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));
            }
        }
Ejemplo n.º 4
0
        public void StartPlay(Tournament target)
        {
            if (target != null && target.id > 0)
            {
                TacoManager.OpenMessage(TacoConfig.TacoPlayStarting);
                //StartCoroutine(postStart());

                Action <string> success = (string data) => {
                    var r = JsonUtility.FromJson <StartGameResult>(data);
                    if (r.success)
                    {
                        TacoManager.GameToken = r.token;

                        GameManager.Instance.GetHighScore(r.highScore);

                        TacoManager.CloseMessage();

                        // delegate to your game
                        TacoSetup.Instance.StartMyGame();

                        // set the status text
                        TacoManager.StatusText.text = TacoConfig.GamePlayingMessage;

                        // close taco to play the game
                        TacoManager.CloseTaco();
                    }
                    else
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.OpenModal(TacoConfig.TacoPlayError, r.message);
                    }
                };


                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.StartGame(target.id, TacoManager.User.token, success, fail));
            }
        }
Ejemplo n.º 5
0
        public void StartPlay(Tournament target)
        {
            if (target != null && target.id > 0)
            {
                TacoManager.OpenMessage(TacoConfig.TacoPlayStarting);
                Action <string> success = (string data) => {
                    var r = JsonUtility.FromJson <StartGameResult>(data);
                    if (r.success)
                    {
                        TacoManager.GameToken = r.token;
                        TacoManager.CloseMessage();
                        // delegate to your game
                        TacoSetup.Instance.StartTournamentGame();
                        TacoManager.CloseTaco();
                    }
                    else
                    {
                        TacoManager.CloseAllModals();
                        TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.TacoPlayError, r.message);
                    }
                };


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

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

                    TacoManager.CloseAllModals();
                    TacoManager.CloseAllModals();
                    if (r.forbidden)
                    {
                        TacoManager.OpenModalTournamentCreationForbiddenPanel(r.message);
                    }
                    else
                    {
                        TacoManager.OpenModalPlayTournamentErrorPanel(r.message);
                    }
                    //TacoManager.OpenModal(TacoConfig.TacoPlayError, r.message);
                };

                StartCoroutine(ApiManager.Instance.StartGame(target.typeCurrency, target.id, TacoManager.User.token, success, fail));
            }
        }
Ejemplo n.º 6
0
        public void UpdateHighScoreAndGtokens(int newHighScore)
        {
            TacoConfig.print(newHighScore);
            TacoManager.OpenMessage("Sending High Score");
            Action <string> success = (string data) => {
                var r = JsonUtility.FromJson <UpdateHighScoreAndTokensResult>(data);
                if (r.success)
                {
                    TacoConfig.print("Update highscore for user success" + r);
                    TacoManager.UpdateTokenOnly(r.gtokens);
                    TacoSetup.Instance.CallMessage("ShowModalEarningTokens");
                }
            };

            Action <string, string> fail = (string data, string error) => {
                TacoManager.CloseAllModals();
                TacoConfig.print("Error on register : " + data);
                if (!string.IsNullOrEmpty(error))
                {
                    TacoConfig.print("Error : " + error);
                }
                TacoManager.CloseMessage();
                string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);
                if (!string.IsNullOrEmpty(data))
                {
                    ErrorResult errorResult = JsonUtility.FromJson <ErrorResult>(data);
                    if (!errorResult.success)
                    {
                        msg = errorResult.message;
                    }
                }

                TacoConfig.print(msg);
            };

            StartCoroutine(ApiManager.Instance.UpdateHighScoreAndGTokens(newHighScore, TacoManager.User.token, success, fail));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Call to open confirm panel when the user want to exit current tournament
 /// Please set current score using <code>ScoreNow</code> when the user choose to exit the tournament
 /// </summary>
 public void TacoOpenEndPlayGame(System.Action callback = null)
 {
     TacoManager.CloseAllModals();
     TacoManager.OpenModalEndPlayingPanel(TacoConfig.EndTournamentHeader, TacoConfig.EndTournamentConfirm, callback);
 }
Ejemplo n.º 8
0
 public void TacoCloseAllModal()
 {
     TacoManager.CloseAllModals();
 }
Ejemplo n.º 9
0
 public static void AskToLogoutUser()
 {
     TacoManager.CloseAllModals();
     OpenModal(TacoConfig.TacoSureLogoutModalHeader, TacoConfig.TacoSureLogoutModalBody, null, "LogoutUser", TacoConfig.CloseSprite, null);
 }