private void GetTransaction() { isLoadingTransaction = true; TacoManager.OpenMessage(TacoConfig.Processing); Action <string> success = (string data) => { Debug.Log(data); isLoadingTransaction = false; if (!isLoadingActiveTours) { TacoManager.CloseMessage(); } TransactionResult r = JsonUtility.FromJson <TransactionResult>(data); if (r.transactions.Length > 0) { UserTransaction recent = r.transactions[0]; recentTransaction.text = string.Format("{0} ({1})", recent.action, recent.FormatCurrency); } transactions = r.transactions; GenerateTransactionTable(); }; Action <string, string> fail = (string data, string error) => { isLoadingTransaction = false; if (!isLoadingActiveTours) { TacoManager.CloseMessage(); } TacoManager.OpenModalConnectionErrorPanel(error); recentTransaction.text = string.Empty; }; StartCoroutine(ApiManager.Instance.GetTransactions(3, success, fail)); }
private void SubmitPurchaseToken() { TacoManager.OpenMessage(TacoConfig.Processing); Action <string> success = (string data) => { TacoManager.CloseMessage(); GeneralResult r = JsonUtility.FromJson <GeneralResult>(data); string notice; string header; if (r.success) { TacoManager.UpdateFundsWithToken(r.cash, r.token.ToString(), r.ticket.ToString()); moneyValue.text = TacoManager.FormatGTokens(double.Parse(TacoManager.User.gToken)); TournamentManager.Instance.SetMoneytext(); header = TacoConfig.SuccessHeader; notice = r.msg; } else { header = TacoConfig.ErrorHeader; notice = r.err; } TacoManager.OpenModalGeneralResultPanel(r.success, header, notice); }; Action <string, string> fail = (string data, string error) => { TacoManager.CloseMessage(); TacoManager.OpenModalConnectionErrorPanel(error); }; string currency = exchangedCurrencyIcon.sprite == TacoConfig.currencySprites[0] ? "0" : "2"; StartCoroutine(ApiManager.Instance.BuyToken(currency, exchangedNumber, success, fail)); }
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)); } }
private void GetPrizesList() { TacoManager.OpenMessage(TacoConfig.Processing); Action <string> success = (string data) => { alreadyLoadPrize = true; TacoManager.CloseMessage(); PrizesResult r = JsonUtility.FromJson <PrizesResult>(data); LoadPrizes(r.prizes); }; Action <string, string> fail = (string data, string error) => { TacoManager.CloseMessage(); TacoManager.OpenModalConnectionErrorPanel(error); }; StartCoroutine(ApiManager.Instance.GetPrizes(success, fail)); }