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)); }
private void CreateActionButton(ListViewItem item, Tournament t, GameObject prefab, int nbOfActions) { ListViewItem.ListViewSubItem selectedSubItem = item.SubItems [ColumnNames.IndexOf(TacoConfig.TournamentActionColumn)]; SelectedPreFabToDestroy = Instantiate(prefab) as GameObject; selectedSubItem.CustomControl = SelectedPreFabToDestroy.transform as RectTransform; Transform background = SelectedPreFabToDestroy.transform.Find("Background"); RectTransform rectPos = background.gameObject.GetComponent <RectTransform> (); if (nbOfActions > 1) { SelectedPreFabToDestroy.transform.Find("Background/Text").gameObject.SetActive(false); rectPos.sizeDelta = new Vector2(rectPos.sizeDelta.x / 2, rectPos.sizeDelta.y); SelectedPreFabToDestroy.transform.Find("Background/BackgroundImage").gameObject.SetActive(false); SelectedPreFabToDestroy.transform.Find("Background/BackgroundImage1").gameObject.SetActive(true); } background.GetComponent <Button> ().onClick.AddListener(() => { if (prefab.name == ItemShowLeaderboardPrefab.name) { TournamentManager.Instance.SeeResult(t); } else { TacoManager.Target = t; TacoManager.ShowPanel(PanelNames.ManageTournamentPanel); } }); if (nbOfActions > 1) { SelectedPreFabToDestroy.transform.Find("Background/Text").gameObject.SetActive(false); } }
void Awake() { Instance = this; #if UNITY_IOS_ || UNITY_ANDROID_ if (!FB.IsInitialized) { // Initialize the Facebook SDK //FB.Init(InitCallback, OnHideUnity); } else { // Already initialized, signal an app activation App Event //FB.ActivateApp(); } #endif Init(); copyCode.onClick.AddListener(() => { CodeDisplayPanel.transform.Find("Main/Code").GetComponent <InputField> ().text = deviceInfo.user_code; }); goToGooglePage.onClick.AddListener(() => { TacoManager.OpenMessage(TacoConfig.Processing); CodeDisplayPanel.SetActive(false); Application.OpenURL(deviceInfo.verification_url); StartCoroutine(PollRequestToGoogle(deviceInfo)); }); submitResetBtn.interactable = false; resetAccount.onValueChanged.AddListener((string value) => { submitResetBtn.interactable = !string.IsNullOrEmpty(value); }); }
public void TappedInviteFromCreate( ) { TacoManager.OpenModalWithPreFab(TacoConfig.TacoInviteFriendsModalHeader, TournamentCreateInvitePrefab, TacoConfig.InviteSprite, ModalFunctions.InviteFriendsFromCreate, TacoConfig.CloseSprite, null); TacoModalPanel.Instance.SetModalButtonEnabled(false); TournamentCreateInvite _tournamentCreateInvite = TacoModalPanel.Instance.GetPreFab().GetComponent <TournamentCreateInvite> (); for (var i = 0; i < invitedFriends.Count; i++) { _tournamentCreateInvite.AddInvite(invitedFriends[i], i); /* * _tournamentCreateInvite.AddInvite(invitedFriends[0] , 1); * _tournamentCreateInvite.AddInvite(invitedFriends[0], 2); * _tournamentCreateInvite.AddInvite(invitedFriends[0] , 3); * _tournamentCreateInvite.AddInvite(invitedFriends[0], 4); * _tournamentCreateInvite.AddInvite(invitedFriends[0] , 5); * _tournamentCreateInvite.AddInvite(invitedFriends[0], 0); * _tournamentCreateInvite.AddInvite(invitedFriends[0] , 0); * _tournamentCreateInvite.AddInvite(invitedFriends[0], 0); * _tournamentCreateInvite.AddInvite(invitedFriends[0] , 0); * _tournamentCreateInvite.AddInvite(invitedFriends[0], 0); * _tournamentCreateInvite.AddInvite(invitedFriends[0] , 0); * _tournamentCreateInvite.AddInvite(invitedFriends[0], 0); */ } }
public void TappedGameFromList(Tournament t) { TacoManager.SetTarget(t); if (t.played) { TournamentManager.Instance.ShowTournamentPanel(PanelNames.MyLeaderboardPanel); } else { Double prize = t.prize; int typeCurrency = t.typeCurrency; string replacedString = string.Empty; if (typeCurrency == 0) { replacedString = TacoConfig.TacoSurePlayModalBody.Replace("&prize", TacoManager.FormatMoney(prize)); } else { replacedString = TacoConfig.TacoSurePlayModalBody.Replace("&prize", TacoManager.FormatGTokens(prize)); } TacoManager.OpenModal(TacoConfig.TacoSurePlayModalHeader, replacedString, TacoConfig.PlaySprite, ModalFunctions.StartPlay, TacoConfig.CloseSprite, null); } }
private void ChangeEmailState() { inputValue = true; if (string.IsNullOrEmpty(EmailInput.text)) { emailValidated = false; EmailOkay.SetActive(false); ShowErrorText(TacoConfig.TacoRegisteredErrorMessage06); } else { var textEmail = EmailInput.text; bool isEmail = TacoManager.ValidateEmail(textEmail); if (isEmail == true) { emailValidated = true; ShowErrorText(); ChangeInputState(); EmailOkay.SetActive(true); } else { emailValidated = false; ShowErrorText(TacoConfig.TacoRegisteredErrorMessage01); EmailOkay.SetActive(false); } } ToggleRegisterButton(AllInputIsValid()); }
public void InviteFriend() { TacoManager.OpenMessage(TacoConfig.TacoSending); Action <string> success = (string data) => { TacoManager.CloseMessage(); }; Action <string, string> fail = (string data, string error) => { TacoConfig.print("Error getting open tournaments : " + data); if (!string.IsNullOrEmpty(error)) { TacoConfig.print("Error : " + error); } }; string fromEmail = TacoManager.User.email; string baseUrl = "baysidegames.com"; GameObject invitePreFab = TacoModalPanel.Instance.GetPreFab(); TournamentInvite _TournamentInvite = invitePreFab.GetComponent <TournamentInvite>(); string emails = _TournamentInvite.GetEmail(); int tournamentId = TacoManager.Target.id; TacoConfig.print("emails : " + emails); StartCoroutine(ApiManager.Instance.InviteFriend(fromEmail, baseUrl, emails, tournamentId, success, fail)); }
private void GenerateTransactionTable() { for (int i = 1; i < transactionRect.childCount; i++) { Destroy(transactionRect.GetChild(i).gameObject); } float height = 140; float width = transactionRect.rect.width; float padding = 20; for (int i = 0; i < transactions.Length; i++) { RectTransform row = Instantiate(TransactionPrefab, transactionRect).GetComponent <RectTransform>(); row.localPosition = new Vector3(row.localPosition.x, -padding - height * i); row.Find("Name").GetComponent <Text>().text = transactions[i].action; RectTransform col = row.Find("Name").GetComponent <RectTransform>(); col.sizeDelta = new Vector2(width * 0.5f, height); col.localPosition = new Vector3(30, 0); row.Find("Value").GetComponent <Text>().text = transactions[i].FormatCurrency; col = row.Find("Value").GetComponent <RectTransform>(); col.sizeDelta = new Vector2(width * 0.25f, height); col.localPosition = new Vector3(width * 0.55f, 0); row.Find("Day").GetComponent <Text>().text = TacoManager.FormatDate(transactions[i].createdAt, '-'); col = row.Find("Day").GetComponent <RectTransform>(); col.sizeDelta = new Vector2(width * 0.20f, height); col.localPosition = new Vector3(width * 0.8f, 0); } transactionRect.sizeDelta = new Vector2(transactionRect.sizeDelta.x, transactions.Length * (height + padding) + height); }
public void RemoveFriend(string email, Action callback) { TacoManager.OpenMessage(TacoConfig.TacoSending); Action <string> success = (string data) => { TacoManager.CloseMessage(); TacoManager.OpenModalRemovePlayerNoticePanel(); callback(); }; Action <string, string> fail = (string data, string error) => { Debug.Log("Error getting open tournaments : " + data); if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } }; Tournament t = ManageTournament.Instance.tournament; int friendId = 0; for (int i = 0; i < t.friendEmails.Length; i++) { if (t.friendEmails [i] == email) { friendId = t.friendIds [i]; break; } } int tournamentId = t.id; StartCoroutine(ApiManager.Instance.RemoveFriend(email, friendId, tournamentId, success, fail)); }
private void AddAddressesEvent() { SubmitAddessesBtn.onClick.AddListener(() => { if (!string.IsNullOrEmpty(addressInput.text + address2Input.text + cityInput.text + stateInput.text + zipcodeInput.text)) { TacoManager.OpenMessage(TacoConfig.Processing); Action <string> success = (string data) => { TacoManager.CloseMessage(); GeneralResult r = JsonUtility.FromJson <GeneralResult>(data); string notice = string.Empty; string header = string.Empty; if (r.success) { notice = r.msg; header = TacoConfig.SuccessHeader; TacoManager.User.contactProfile.UpdateData(addressInput.text, address2Input.text, cityInput.text, stateInput.text, zipcodeInput.text); FillFullAddress(); } else { notice = r.err; header = TacoConfig.ErrorHeader; FillAddressesField(); } TacoManager.OpenModalGeneralResultPanel(r.success, header, notice); }; Action <string, string> fail = (string data, string error) => { TacoManager.CloseMessage(); GeneralResult r = JsonUtility.FromJson <GeneralResult>(data); TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, r.err); }; StartCoroutine(ApiManager.Instance.ChangeAddress(addressInput.text, address2Input.text, cityInput.text, stateInput.text, zipcodeInput.text, success, fail)); } }); }
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 LoadPrizes(Prize[] prizeList) { for (int i = 1; i < prizeListRect.childCount; i++) { Destroy(prizeListRect.GetChild(i).gameObject); } float height = 530; float width = prizeListRect.rect.width; float padding = 30; int prizePerRow = 1; for (int i = 0; i < prizeList.Length; i++) { Prize prize = prizeList[i]; RectTransform row = Instantiate(prizePrefab, prizeListRect).GetComponent <RectTransform>(); row.sizeDelta = new Vector2(width / prizePerRow - padding * 2, height - padding); row.localPosition = new Vector3(padding + (i % prizePerRow) * (width / prizePerRow), -250 - padding - height * (i / prizePerRow)); row.Find("PrizeName").GetComponent <Text>().text = prize.name; row.Find("Buttons/Token/Text").GetComponent <Text>().text = TacoManager.FormatRP(prize.ticket); Image prizeImage = row.Find("Image").GetComponent <Image>(); StartCoroutine(ApiManager.Instance.WWWPrizeImage(prize.images, prizeImage)); Button btn = row.Find("Buttons/Claim").GetComponent <Button>(); btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { prizeDetailPanel.gameObject.SetActive(true); prizeDetailPanel.Find("Main/Header").GetComponent <Text>().text = prize.name; prizeDetailPanel.Find("Main/Description").GetComponent <Text>().text = prize.description; prizeDetailPanel.Find("Main/Image").GetComponent <Image>().sprite = prizeImage.sprite; prizeDetailPanel.Find("Main/Buttons/Token/Text").GetComponent <Text>().text = TacoManager.FormatRP(prize.ticket); purchasingPrize = prize; }); } prizeListRect.sizeDelta = new Vector2(prizeListRect.sizeDelta.x, (prizeList.Length / prizePerRow) * (height + padding)); }
public void Init(int currencyType) { fromMainMenu = !TacoManager.TacoTournamentsCanvas.activeSelf; if (fromMainMenu) { TacoManager.TacoTournamentsCanvas.SetActive(true); } Container.gameObject.SetActive(true); moneyIcon.sprite = TacoConfig.currencySprites[currencyType]; if (currencyType == 0) { title.text = TacoConfig.YourFundsHeader; FundPanel.SetActive(true); moneyValue.text = TacoManager.FormatMoney(TacoManager.User.TotalCash, currencyType); } else if (currencyType == 1) { title.text = TacoConfig.YourTokensHeader; TokenPanel.SetActive(true); moneyValue.text = TacoManager.FormatGTokens(double.Parse(TacoManager.User.gToken)); ResetTacoInput(); } else if (currencyType == 2) { title.text = TacoConfig.PrizesHeader; PointPanel.SetActive(true); moneyValue.text = TacoManager.FormatRP(TacoManager.User.ticket); if (!alreadyLoadPrize) { GetPrizesList(); } } }
private void SendClaimToken() { TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00); Action <string> onSuccess = (string data) => { ClaimInfo r = JsonUtility.FromJson <ClaimInfo>(data); if (r.success) { TacoManager.OpenClaimTokenPanel(TacoConfig.ClaimSuccessHeader, tokenClaim.text, TacoConfig.ClaimSuccessNotice); TacoManager.User.gToken = r.newTacoToken.ToString(); UpdateUI(r); TournamentManager.Instance.SetMoneytext(); } else { TacoManager.OpenClaimTokenPanel(TacoConfig.ClaimFailHeader, "0", TacoConfig.NoTokenNotice); UpdateUI(r); } TacoManager.CloseMessage(); }; Action <string, string> onFail = (string data, string error) => { TacoManager.OpenClaimTokenPanel(TacoConfig.ClaimFailHeader, "0", TacoConfig.ClaimErrorNotice); TacoManager.CloseMessage(); }; StartCoroutine(ApiManager.Instance.ClaimToken(onSuccess, onFail)); }
public void ValidateUserOrEmail(string emailToCheck) { EmailOkay.SetActive(false); Action <string> success = (string data) => { GameFeaturedResult r = JsonUtility.FromJson <GameFeaturedResult> (data); if (r.success) { if (data.Contains("true")) { EmailOkay.SetActive(true); } } ; }; Action <string, string> fail = (string errorData, string error) => { Debug.Log("Error on get : " + errorData); if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } TacoManager.CloseMessage(); TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword); }; string url = "api/user/verify?u=" + emailToCheck; StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail)); }
public void InviteFriend(string email, Action callback = null) { TacoManager.OpenMessage(TacoConfig.TacoSending); Action <string> success = (string data) => { if (callback != null) { callback(); } TacoManager.CloseMessage(); }; Action <string, string> fail = (string data, string error) => { Debug.Log("Error getting open tournaments : " + data); if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } }; string fromEmail = TacoManager.User.email; string baseUrl = "baysidegames.com"; int tournamentId = TacoManager.Target.id; StartCoroutine(ApiManager.Instance.InviteFriend(fromEmail, baseUrl, email, tournamentId, success, fail)); }
public void ChangeInputState() { inputValue = true; if (string.IsNullOrEmpty(UserInput.text)) { userValidated = false; ShowErrorText(TacoConfig.TacoRegisteredErrorMessage03); UserOkay.SetActive(false); } else if (UserInput.text.Length < TacoConfig.UsernameMinLength) { userValidated = false; ShowErrorText(TacoConfig.TacoRegisteredErrorUsernameLength); UserOkay.SetActive(false); } else if (!TacoManager.ValidateUsername(UserInput.text)) { userValidated = false; ShowErrorText(TacoConfig.TacoRegisteredErrorUsernameFormat); UserOkay.SetActive(false); } else { userValidated = true; UserOkay.SetActive(true); if (StatusText.text == TacoConfig.TacoRegisteredErrorMessage03) { ShowErrorText(); } } ToggleRegisterButton(AllInputIsValid()); }
public void getCompletedTournaments(Func <Tournament, bool> filterCondition = null) { TacoManager.OpenMessage(TacoConfig.TacoRefreshing); int cate = (int)TacoSetup.Instance.TournamentCategory; Action <string> success = (string data) => { List <Tournament> publicList = new List <Tournament> (); CompletedTournamentsResult r = JsonUtility.FromJson <CompletedTournamentsResult> (data); foreach (var item in r.tournaments) { if (item.typeCurrency == cate) { publicList.Add(item); } } if (filterCondition != null) { publicList = publicList.Where(filterCondition).ToList(); } CompletedTournamentsList.Instance.Reload(publicList); TacoManager.CloseMessage(); }; Action <string, string> fail = (string data, string error) => { if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } }; StartCoroutine(ApiManager.Instance.GetWithToken("api/tournament/history/" + TacoSetup.Instance.SiteId + "/" + TacoManager.User.userId, success, fail)); }
public void TournamentSubmit() { // pop the message panel while submitting TacoManager.OpenMessage(TacoConfig.TacoTournamentSubmittingMessage); CreateTournament(); }
public void getPrivateUserTournaments(Func <Tournament, bool> filterCondition = null) { TacoManager.OpenMessage(TacoConfig.TacoRefreshing); int cate = (int)TacoSetup.Instance.TournamentCategory; Action <string> success = (string data) => { List <Tournament> publicList = new List <Tournament> (); PrivateTournamentsResult r = JsonUtility.FromJson <PrivateTournamentsResult> (data); foreach (Tournament item in r.tournaments) { if (item.typeCurrency == cate && (!item.played || item.playable) && item.status != "ended") { publicList.Add(item); } } if (filterCondition != null) { publicList = publicList.Where(filterCondition).ToList(); } publicList = publicList.OrderBy(x => PrivateTournamentsList.Instance.GetDisplayedStatus(x)).ToList(); PrivateTournamentsList.Instance.Reload(publicList); TacoManager.CloseMessage(); }; Action <string, string> fail = (string data, string error) => { Debug.Log("Error getting open tournaments : " + data); if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } }; StartCoroutine(ApiManager.Instance.GetWithToken("api/tournament/private/" + TacoSetup.Instance.SiteId, success, fail)); }
public void TappedInviteFromList(Tournament t) { // TODO : move tournament Target to this class TacoManager.SetTarget(t); TacoManager.OpenModalWithPreFab(TacoConfig.TacoInviteFriendsModalHeader, TournamentInvitePrefab, TacoConfig.InviteSprite, ModalFunctions.InviteFriends, TacoConfig.CloseSprite, null); if (t.played) { TournamentManager.Instance.ShowTournamentPanel(PanelNames.MyLeaderboardPanel); } else if (t.memberlength == t.size) { Double prize = double.Parse(t.prize.ToString()); string replacedString = TacoConfig.TacoSurePlayModalBody.Replace("&prize", TacoManager.FormatMoney(prize)); TacoManager.OpenModal(TacoConfig.TacoSurePlayModalHeader, replacedString, TacoConfig.PlaySprite, ModalFunctions.StartPlay, TacoConfig.CloseSprite, null); } else { TacoManager.OpenModalWithPreFab(TacoConfig.TacoInviteFriendsModalHeader, TournamentInvitePrefab, TacoConfig.InviteSprite, ModalFunctions.InviteFriends, TacoConfig.CloseSprite, null); TacoModalPanel.Instance.SetModalButtonEnabled(false); TournamentInvite tournamentInvite = TacoModalPanel.Instance.GetPreFab().GetComponent <TournamentInvite> (); } }
public void getActiveTournaments(Action <bool> callback) { TacoManager.OpenMessage(TacoConfig.TacoRefreshing); int cate = (int)TacoSetup.Instance.TournamentCategory; Action <string> success = (string data) => { List <Tournament> publicList = new List <Tournament> (); PrivateTournamentsResult r = JsonUtility.FromJson <PrivateTournamentsResult> (data); foreach (Tournament item in r.tournaments) { publicList.Add(item); } ActiveTournamentList.Instance.Reload(publicList); callback(publicList.Count > 0); }; Action <string, string> fail = (string data, string error) => { Debug.Log("Error getting open tournaments : " + data); if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } callback(false); }; StartCoroutine(ApiManager.Instance.GetWithToken("api/tournament/active/" + TacoSetup.Instance.SiteId, success, fail)); }
public void TappedJoinFromList(Tournament t) { // TODO : move tournament Target to this class TacoManager.SetTarget(t); TacoConfig.print("join"); TacoConfig.print(t); TacoConfig.print(t.typeCurrency); Double prize = t.prize; Double entryFee = t.entryFee; int typeCurrency = t.typeCurrency; string players = t.size.ToString() + " " + TacoConfig.Players; TacoManager.OpenModalWithPreFab(TacoConfig.TacoSureJoinModalHeader, TournamentDetailsPrefab, TacoConfig.JoinSprite, ModalFunctions.JoinTournament, TacoConfig.CloseSprite, null); TournamentDetails tournamentDetails = TacoModalPanel.Instance.GetPreFab().GetComponent <TournamentDetails> (); if (typeCurrency == 0) { string replacedString = TacoConfig.TacoSureJoinModalBody.Replace("&entryFee", TacoManager.FormatMoney(entryFee)); replacedString = replacedString.Replace("&prize", TacoManager.FormatMoney(prize)); tournamentDetails.UpdateDetails(replacedString, players, TacoManager.FormatMoney(prize)); } else { string replacedString = TacoConfig.TacoSureJoinModalBody.Replace("&entryFee", TacoManager.FormatGTokens(entryFee)); replacedString = replacedString.Replace("&prize", TacoManager.FormatGTokens(prize)); tournamentDetails.UpdateDetails(replacedString, players, TacoManager.FormatGTokens(prize)); } }
public void checkUserLoginToShowPopup() { if (!TacoManager.UserLoggedIn()) { SendMessage("ShowModalRemindSignup"); } }
public void GetOurGames() { TacoManager.OpenMessage(TacoConfig.TacoOurGamesLoadingMessage); foreach (Transform child in gamesList) { Destroy(child.gameObject); } ourGamesList = new List <OurGame> (); buttons [0].isOn = true; //set default to all toggle Action <string> success = (string data) => { GameFeaturedResult r = JsonUtility.FromJson <GameFeaturedResult> (data); if (r.success) { TacoManager.CloseMessage(); UpdateGames(r.games); } }; Action <string, string> fail = (string errorData, string error) => { Debug.Log("Error on get : " + errorData); if (!string.IsNullOrEmpty(error)) { Debug.Log("Error : " + error); } TacoManager.CloseMessage(); TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword); }; string url = "api/game/featured?userAgent=" + platform; StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail)); }
public IEnumerator GetWithToken(string url, Action <string> onSuccess, Action <string, string> onFail = null) { UnityWebRequest www = UnityWebRequest.Get(Constants.BaseUrl + url); AddValidationHeader(www); string currentToken = null; if (TacoManager.User == null) { currentToken = TacoManager.GetPreferenceString(UserPreferences.userToken); } else { currentToken = TacoManager.User.token; } www.SetRequestHeader("x-access-token", currentToken); yield return(www.SendWebRequest()); if (www.isNetworkError || www.responseCode == 500) { Debug.Log("www.isError =" + www.error); if (onFail != null) { onFail(www.downloadHandler.text, www.error); } } else { onSuccess(www.downloadHandler.text); } }
// Update is called once per frame void Update() { if (this.isActiveAndEnabled & !TacoManager.CheckModalsOpen()) { if (Input.GetKeyDown(KeyCode.Tab)) { if (EmailInput.GetComponent <InputField> ().isFocused) { PasswordInput.GetComponent <InputField> ().ActivateInputField(); } if (PasswordInput.GetComponent <InputField> ().isFocused) { EmailInput.GetComponent <InputField> ().ActivateInputField(); } else if (!EmailInput.GetComponent <InputField> ().isFocused&& !PasswordInput.GetComponent <InputField> ().isFocused) { EmailInput.GetComponent <InputField> ().ActivateInputField(); } } else if (Input.GetKeyDown(KeyCode.Return)) { Login(); } } }
public IEnumerator EndGame(int score, int tournamentId, int gameId, string gameToken, string userToken, Action <string> onSuccess, Action <string, string> onFail = null) { WWWForm form = new WWWForm(); form.AddField("token", string.IsNullOrEmpty(gameToken) ? string.Empty : gameToken); form.AddField("tournamentId", tournamentId); form.AddField("gameId", gameId); form.AddField("score", score); UnityWebRequest www = UnityWebRequest.Post(Constants.BaseUrl + "api/game/end", form); www.SetRequestHeader("x-access-token", userToken); string message = string.IsNullOrEmpty(gameToken) ? TacoConfig.TacoPlayAgainEndedMessage : TacoConfig.TacoPlayEndedMessage; TacoManager.OpenMessage(message); yield return(www.SendWebRequest()); if (www.isNetworkError) { if (onFail != null) { onFail(www.downloadHandler.text, www.error); } } else { onSuccess(www.downloadHandler.text); } }
public void LoginWithGoogle() { TacoManager.LoginPanelObject.SetActive(true);//if from register panel TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00); Debug.Log("internet: " + Application.internetReachability); if (Application.internetReachability == NetworkReachability.NotReachable) { TacoManager.CloseMessage(); TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginStatusNoInternet); return; } Action <string> onSuccess = (string data) => { TacoManager.CloseMessage(); GoogleDeviceInfo r = JsonUtility.FromJson <GoogleDeviceInfo> (data); CodeDisplayPanel.SetActive(true); CodeDisplayPanel.transform.Find("Main/Code").GetComponent <InputField> ().text = r.user_code; deviceInfo = r; //testing TextEditor te = new TextEditor(); te.text = deviceInfo.user_code; te.SelectAll(); te.Copy(); }; Action <string, string> onFail = (string data, string error) => { TacoManager.CloseMessage(); TacoManager.OpenModalLoginFailedPanel(error); }; StartCoroutine(ApiManager.Instance.RequestDeviceAdnUserCode(authorizationDeviceEndpoint, clientID, onSuccess, onFail)); }
private void AddRedeemFormValidation() { dateOfBirthInput.onEndEdit.AddListener((string value) => { ValidateRedeemAge(value); }); RedeemSubmit.onClick.AddListener(() => { if (!TacoManager.ValidateEmail(emailInput.text)) { ToggleRedeemErrorMsg(TacoConfig.RedeemErrorIncorrectEmail); } else if (string.IsNullOrEmpty(dateOfBirthInput.text) || string.IsNullOrEmpty(streetInput.text) || string.IsNullOrEmpty(buildingInput.text) || string.IsNullOrEmpty(countryInput.text) || string.IsNullOrEmpty(stateInput.text) || string.IsNullOrEmpty(postcodeInput.text) || string.IsNullOrEmpty(cityInput.text)) { ToggleRedeemErrorMsg(TacoConfig.RedeemErrorNoFill); } else if (!isValidAge) { ValidateRedeemAge(dateOfBirthInput.text); } else { ToggleRedeemErrorMsg(); SubmitRedeemForm(); } }); }