public void Reload(List <Tournament> tournaments) { this.ListView.SuspendLayout(); this.ListView.Items.Clear(); Items = tournaments; for (int i = 0; i < Items.Count(); i++) { var t = Items [i]; string fee = string.Empty; string prize = string.Empty; string players = t.memberIds.Length + "/" + t.size; if (t.typeCurrency == 0) { fee = TacoManager.FormatCash(t.entryFee); prize = TacoManager.FormatCash(t.prize); } else { fee = TacoManager.FormatGTokens(t.entryFee); prize = TacoManager.FormatGTokens(t.prize); } AddListViewItem(t.name, fee, prize, t.prize_structure.ToString(), players, t, i % 2 == 0); } if (tournaments.Count == 0) { AddListViewItem(TacoConfig.NoResults, string.Empty, string.Empty, string.Empty); } this.ListView.ResumeLayout(); // fix columns panel does not show vertical handle transform.Find("ColumnsPanel").GetComponent <RectTransform> ().offsetMax = new Vector2(-20, 0); }
public void SetDefaultMoneytext() { for (int i = 0; i < CreateTournamentTacoTexts.Count; i++) { CreateTournamentTacoTexts [i].text = TacoManager.FormatGTokens(0); } for (int i = 0; i < CreateTournamentCashTexts.Count; i++) { CreateTournamentCashTexts [i].text = TacoManager.FormatCash(0); } for (int i = 0; i < CreateTournamentRPTexts.Count; i++) { CreateTournamentRPTexts [i].text = TacoManager.FormatRP(0); } }
private void UpdateCreateTournamentTotalPrize(Text totalPrize, string[] currencyStrValues) { double prize = (creatingTournament.size * creatingTournament.entryFee * (1 - 0.1f * (1 - creatingTournament.typeCurrency)) / creatingTournament.prize_structure); string prizeStr = string.Empty; if (creatingTournament.typeCurrency == 0) { prizeStr = TacoManager.FormatCash(prize); } else { prizeStr = TacoManager.FormatGTokens2(Mathf.Ceil((float)prize)); } totalPrize.text = prizeStr; }
private void UpdateCreateTournamentFeeText(Text feeText, string prefix = "") { string entryFeeStr = string.Empty; if (creatingTournament.typeCurrency == 0) { entryFeeStr = TacoManager.FormatCash(creatingTournament.entryFee); } else { entryFeeStr = TacoManager.FormatGTokens2(creatingTournament.entryFee); } feeText.text = prefix + entryFeeStr; }
public void Reload(List <Tournament> tournaments) { this.ListView.SuspendLayout(); this.ListView.Items.Clear(); Items = tournaments; for (int i = 0; i < Items.Count(); i++) { var t = Items[i]; string fee = string.Empty; string prize = string.Empty; string players = t.memberIds.Length + "/" + t.size; if (t.typeCurrency == 0) { fee = TacoManager.FormatCash(t.entryFee); prize = TacoManager.FormatCash(t.prize); } else { fee = TacoManager.FormatGTokens(t.entryFee); prize = TacoManager.FormatGTokens(t.prize); } AddListViewItem(fee, prize, t.prize_structure.ToString(), players, t, i % 2 == 0); } // if there are any results - make a row to tell that if (tournaments.Count == 0) { SetNotice(TacoConfig.NoResults); } else { SetNotice(); } // used to set selected to first row /*if( this.ListView.Items.Count > 0 ){ * * this.ListView.SelectedIndices.Add (0); * } */ this.ListView.ResumeLayout(); }
public void SetMoneytext() { for (int i = 0; i < CreateTournamentTacoTexts.Count; i++) { CreateTournamentTacoTexts [i].text = TacoManager.FormatGTokens(double.Parse(TacoManager.User.gToken)); } for (int i = 0; i < CreateTournamentCashTexts.Count; i++) { CreateTournamentCashTexts [i].text = TacoManager.FormatCash(TacoManager.User.TotalCash); } for (int i = 0; i < CreateTournamentRPTexts.Count; i++) { CreateTournamentRPTexts [i].text = TacoManager.FormatRP(TacoManager.User.ticket); } TacoSetup.Instance.SetMoneyValueForButtons(); }
private void SendWithdrawRequest() { TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00); Action <string> onSuccess = (string data) => { GeneralResult r = JsonUtility.FromJson <GeneralResult>(data); if (r.success) { TacoManager.CloseMessage(); TacoManager.OpenModalGeneralResultPanel(r.success, TacoConfig.SuccessHeader, "You will receive a confirmation email within\n1 Business day once the withdraw amount has been approved."); TacoManager.UpdateFundsOnly(r.cash); if (wdSaveProfile.isOn) { TacoManager.User.contactProfile.UpdateData(wdAddress1Input.text, wdAddress2Input.text, wdCityInput.text, wdStateInput.text, wdZipcodeInput.text); } ResetWithdrawInputField(); moneyValue.text = TacoManager.FormatCash(TacoManager.User.TotalCash); availableFund.text = TacoManager.FormatCash(TacoManager.User.funds); TournamentManager.Instance.SetMoneytext(); defaultAddress.text = TacoManager.User.contactProfile.FullAddress(); if (switchAddressBtn.transform.GetChild(0).GetComponent <Text>().text == TacoConfig.NoDefaultAddress) { withdrawBtn.onClick.Invoke(); } } else { TacoManager.CloseMessage(); TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, r.msg); } TacoManager.CloseMessage(); }; Action <string, string> onFail = (string data, string error) => { TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.ErrorHeader, error); TacoManager.CloseMessage(); }; if (newAddress.activeSelf) { StartCoroutine(ApiManager.Instance.Withdraw(withdrawAmoutInput.text, wdAddress1Input.text, wdAddress2Input.text, wdCityInput.text, wdStateInput.text, wdZipcodeInput.text, wdSaveProfile.isOn, onSuccess, onFail)); } else { ContactProfile addr = TacoManager.User.contactProfile; StartCoroutine(ApiManager.Instance.Withdraw(withdrawAmoutInput.text, addr.address, addr.address2, addr.city, addr.state, addr.zipcode, false, onSuccess, onFail)); } }
private void UpdateEntryFeeText(Text feeLabel) { cashWarningIcon.SetActive(false); tokenWarningIcon.SetActive(false); if ((creatingTournament.typeCurrency == 1 && creatingTournament.entryFee <= double.Parse(TacoManager.User.gToken)) || (creatingTournament.typeCurrency == 0 && creatingTournament.entryFee <= TacoManager.User.TotalCash)) { if (creatingTournament.typeCurrency == 0) { feeLabel.text = TacoManager.FormatCash(creatingTournament.entryFee); } else { feeLabel.text = TacoManager.FormatGTokens2(creatingTournament.entryFee); } feeLabel.text += " <color=#9E9E9EFF>(available)</color>"; entryFeeStatusIcon.sprite = TacoConfig.IconCheck; if (!createNewTournamentButton.IsInteractable()) { createNewTournamentButton.interactable = true; } } else { if (creatingTournament.typeCurrency == 0) { cashWarningIcon.SetActive(true); feeLabel.text = TacoManager.FormatCash(creatingTournament.entryFee); } else { tokenWarningIcon.SetActive(true); feeLabel.text = TacoManager.FormatGTokens2(creatingTournament.entryFee); } feeLabel.text += " <color=#9E9E9EFF>(unavailable)</color>"; entryFeeStatusIcon.sprite = TacoConfig.IconWarning; if (createNewTournamentButton.IsInteractable()) { createNewTournamentButton.interactable = false; } } }
public void Reload(List <Tournament> tournaments) { this.ListView.SuspendLayout(); this.ListView.Items.Clear(); Items = tournaments; for (int i = 0; i < Items.Count(); i++) { var t = Items [i]; string fee = string.Empty; string prize = string.Empty; t.played = true; if (t.typeCurrency == 0) { fee = TacoManager.FormatCash(t.entryFee); prize = TacoManager.FormatCash(t.prize); } else { fee = TacoManager.FormatGTokens(t.entryFee); prize = TacoManager.FormatGTokens(t.prize); } AddListViewItem(fee, prize, t.prize_structure.ToString(), t, i % 2 == 0); } if (tournaments.Count == 0) { SetNotice(TacoConfig.NoResults); } else { SetNotice(); } this.ListView.ResumeLayout(); }
public void TappedJoinFromList(Tournament t) { TacoManager.SetTarget(t); double entryFee = t.entryFee; int typeCurrency = t.typeCurrency; string replacedString = string.Empty; if (t.IsWarningTime()) { TacoManager.OpenModalWarningTimePanel(t); } else { string formatFee = string.Empty; replacedString = "To enter this <b>'" + TacoSetup.Instance.gameName + " &tournamentType'</b> the &tournamentFee will be debited from your account."; if (typeCurrency == 0) { replacedString = replacedString.Replace("&tournamentFee", "Cash Entry Fee"); formatFee = TacoManager.FormatCash(entryFee); } else { replacedString = replacedString.Replace("&tournamentFee", "Taco Token Entry Fee"); formatFee = TacoManager.FormatGTokens(entryFee); } if (CurrentSubPanel == PanelNames.MyPublicPanel) { replacedString = replacedString.Replace("&tournamentType", "Public Tournament"); } else { replacedString = replacedString.Replace("&tournamentType", "Private Tournament"); } TacoManager.OpenModalEnterTournamentPanel(replacedString, formatFee, typeCurrency); } }
private void UpdateUIValue(LeaderboardResult r) { Tournament t = r.tournament; string tournamentType = t.Type; double prizePool = t.PrizePool; double entryFee = double.Parse(t.entryFee.ToString()); LeaderboardRow currentUserRank = r.leaderboard.First(x => x.userId == TacoManager.User.userId); string infos = string.Empty; string details; double moneyValue = 0; int winnerNb = r.winner.Length; prizeIcon.sprite = TacoConfig.currencySprites [t.typeCurrency]; tournamentTypeText.text = TacoConfig.LeaderboardTournamentType.Replace("&type", tournamentType).Replace("&gameName", TacoSetup.Instance.gameName); details = TacoConfig.LeaderboardResultDetails.Replace("&player", t.size.ToString()).Replace("&winner", TacoConfig.Pluralize(t.prize_structure, "Winner")); if (!string.IsNullOrEmpty(t.endDate)) { FinishedButtons.SetActive(true); endedLeaderboardFooter.SetActive(true); rankIcon.transform.parent.gameObject.SetActive(true); int userRank = int.Parse(currentUserRank.rank); if (userRank < 4) { rankIcon.gameObject.SetActive(true); rankIcon.sprite = imageList.Images [currentUserRank.rank]; } else { rankText.transform.parent.gameObject.SetActive(true); rankText.text = TacoConfig.ToShortOrdinal(userRank); } string formatedDay = t.endDate.Substring(5, 2) + "-" + t.endDate.Substring(8, 2) + "-" + t.endDate.Substring(0, 4); infos += TacoConfig.LeaderboardResultEndOn.Replace("&day", formatedDay); if (userRank <= t.prize_structure) { resultStatus.text = "You Won!"; prizeAmount.text = "+ "; moneyValue = t.PrizePool / winnerNb; int rpModifier = 0; if (t.typeCurrency == 0) { rpModifier = 50; } else { rpModifier = 5; } redeemAmount.text = "+ " + TacoManager.FormatRP(Mathf.RoundToInt((float)(moneyValue * rpModifier))); } else { resultStatus.text = "You Lost!"; prizeAmount.text = "+ "; moneyValue = 0; redeemAmount.text = "+ " + TacoManager.FormatRP(0); } } else { resultStatus.text = "Beautiful Job!"; playingLeaderboardFooter.SetActive(true); /*if (currentUserRank.playable) * { * FinishedButtons.SetActive(true); * } * else * { * UnfinishedButtons.SetActive(true); * }*/ rankIcon.transform.parent.gameObject.SetActive(false); countdownTime = Mathf.Max((float)t.RemainingTimeSpan.TotalSeconds, -1); if (countdownTime < 0) { remainingTime.text = "00:00:00"; } } if (t.typeCurrency == 0) { prizePoolText.text = TacoManager.FormatCash(prizePool); entryFeeText.text = TacoManager.FormatCash(entryFee); prizeAmount.text += TacoManager.FormatCash(moneyValue); } else { prizePoolText.text = TacoManager.FormatGTokens(prizePool); entryFeeText.text = TacoManager.FormatGTokens(entryFee); prizeAmount.text += TacoManager.FormatGTokens(moneyValue); } for (int i = 0; i < LeaderBoardMoneyTypeImages.Count; i++) { LeaderBoardMoneyTypeImages [i].sprite = TacoConfig.currencySprites [t.typeCurrency]; } infos += TacoConfig.LeaderboardResultTournamentID.Replace("&id", t.id.ToString()); resultScore.text = "Score: " + currentUserRank.score.ToString(); tournamentDetailsText0.text = infos; tournamentDetailsText1.text = details; /*playAgain.onClick.RemoveAllListeners(); * playAgain.onClick.AddListener (() => { * TacoManager.OpenModalReEnterPanel ( * TacoConfig.ReEnterNotice.Replace ("&type", tournamentType).Replace("&gameName", t.accessType == "public" ? "Public" : "Private"), * entryFeeText.text); * });*/ Reload(r.leaderboard, !string.IsNullOrEmpty(t.endDate)); }
protected void AddListViewItem(string fee, string prize, string prize_structure, Tournament tag, bool isEven) { string winLoss; string prizeResult = TacoConfig.HidedNumber; string placement = string.Empty; string prizePool = string.Empty; string winLossKey; string placementKey = string.Empty; if (TacoSetup.Instance.TournamentCategory == TournamentCate.Cash) { prizePool = TacoManager.FormatCash(tag.PrizePool); } else { prizePool = TacoManager.FormatGTokens(tag.PrizePool); } if (string.IsNullOrEmpty(tag.endDate)) { winLoss = "Ends in\n" + tag.RemainingTimeString(false); winLossKey = "Remaining"; placement = "N/A"; } else { if (tag.rank <= tag.prize_structure) { winLoss = "<color=#ccff66>WIN</color>"; winLossKey = "win"; if (TacoSetup.Instance.TournamentCategory == TournamentCate.Cash) { prizeResult = TacoManager.FormatCash(tag.prize); } else { prizeResult = TacoManager.FormatGTokens(tag.prize); } } else { winLoss = "<color=#ff6666>LOSS</color>"; winLossKey = "loss"; } if (tag.rank < 4) { placement = string.Empty; placementKey = tag.rank.ToString(); } else { placement = tag.rank.ToString(); } } string[] subItemTexts = new string[] { tag.PlayedDayFormat, winLoss, placement, prizePool, prizeResult, string.Empty }; ListViewItem listViewItem = new ListViewItem(subItemTexts); listViewItem.Tag = tag; listViewItem.UseItemStyleForSubItems = false; listViewItem.SubItems [ColumnNames.IndexOf("WIN/LOSS")].ImageKey = winLossKey; listViewItem.SubItems [ColumnNames.IndexOf("PLACEMENT")].ImageKey = placementKey; var backgroundColor = TacoConfig.ListViewOddRow; if (isEven) { backgroundColor = TacoConfig.ListViewEvenRow; } for (int i = 0; i < listViewItem.SubItems.Count; i++) { listViewItem.SubItems [i].BackColor = backgroundColor; } this.ListView.Items.Add(listViewItem); }
private void UpdateUIValue(ManageTournamentResult data) { tournament = data.tournament; List <string> joinedPlayers = new List <string>() { TacoManager.User.email }; List <string> notJoinedPlayers = new List <string>(); invitedEmails = new List <string>() { TacoManager.User.email }; for (int i = 0; i < tournament.friendEmails.Length; i++) { if (tournament.friendStatuses[i] == "invited") { if (!notJoinedPlayers.Contains(tournament.friendEmails[i])) { notJoinedPlayers.Add(tournament.friendEmails[i]); } if (!invitedEmails.Contains(tournament.friendEmails[i])) { invitedEmails.Add(tournament.friendEmails[i]); } } else if (tournament.friendStatuses[i] == "accepted") { if (!joinedPlayers.Contains(tournament.friendEmails[i])) { joinedPlayers.Add(tournament.friendEmails[i]); } if (!invitedEmails.Contains(tournament.friendEmails[i])) { invitedEmails.Add(tournament.friendEmails[i]); } } } string infos = string.Empty; for (int i = 0; i < MoneyTypeImages.Count; i++) { MoneyTypeImages[i].sprite = TacoConfig.currencySprites[tournament.typeCurrency]; } string createdTime = TacoManager.FormatDate(tournament.createdAt); infos += TacoConfig.ManageTournamentCreatedOn.Replace("&day", createdTime); infos += TacoConfig.LeaderboardResultTournamentID.Replace("&id", tournament.id.ToString()); if (tournament.typeCurrency == 0) { prizePoolText.text = TacoManager.FormatCash(tournament.prize); entryFeeText.text = TacoManager.FormatCash(tournament.entryFee); } else { prizePoolText.text = TacoManager.FormatGTokens(tournament.prize); entryFeeText.text = TacoManager.FormatGTokens(tournament.entryFee); } winnerText.text = TacoConfig.Pluralize(tournament.prize_structure, "Winner"); playeredJoinedText.text = tournament.memberIds.Length + "/" + tournament.size + " Players Joined"; tournamentDetailsText.text = infos; countdownTime = (double)Mathf.Max((float)tournament.RemainingTimeSpan.TotalSeconds, -1); if (countdownTime < 0) { remainingTime.text = "00:00:00"; } seeResultButton.interactable = tournament.entryIds.Contains(TacoManager.User.userId); //destroy old email fields float contentWidth = contentPanel.rect.width; for (int i = 1; i < emailsPanel.childCount; i++) { Destroy(emailsPanel.GetChild(i).gameObject); } //generate new email fields float spacing = 35; float width = (contentPanel.rect.width - spacing); float height = 150; inviteEmailTexts = new List <TournamentInvite>(); for (int i = 0; i < notJoinedPlayers.Count; i++) { GameObject ob = Instantiate(TacoConfig.NotJoinedPlayerPrefab, Vector3.zero, Quaternion.identity, emailsPanel) as GameObject; Text inviteeEmailText = ob.transform.Find("EmailInput/NameInput").GetComponent <Text>(); inviteeEmailText.text = notJoinedPlayers[i]; RectTransform r = ob.GetComponent <RectTransform>(); r.localPosition = new Vector3(0, height * (-0.5f - i) - spacing); r.sizeDelta = new Vector2(width - spacing * 5, height - spacing); ob.transform.Find("EmailInput/Send").GetComponent <Button>().onClick.AddListener(() => { ob.transform.Find("EmailInput/Send").gameObject.SetActive(false); Debug.Log("send reminder"); TournamentManager.Instance.InviteFriend(inviteeEmailText.text); if (!invitedEmails.Contains(inviteeEmailText.text)) { invitedEmails.Add(inviteeEmailText.text); } }); AddRemoveEmailEvent(ob, r, inviteeEmailText.text); } float offset = height * (-notJoinedPlayers.Count); int newEmailCount = tournament.size - joinedPlayers.Count - notJoinedPlayers.Count; for (int i = 0; i < newEmailCount; i++) { GameObject ob = Instantiate(TacoConfig.InviteInputPrefab, Vector3.zero, Quaternion.identity, emailsPanel) as GameObject; RectTransform r = ob.GetComponent <RectTransform>(); r.localPosition = new Vector3(0, height * (-0.5f - i) - spacing + offset); r.sizeDelta = new Vector2(width - spacing * 5, height - spacing); TournamentInvite invite = ob.GetComponent <TournamentInvite>(); invite.reservedEmails = invitedEmails; invite.isInManage = true; if (i > 0) { inviteEmailTexts[i - 1].next = invite; invite.prev = inviteEmailTexts[i - 1]; invite.SetInteractable(false); } if (i == 0) { invite.SetFocus(); } inviteEmailTexts.Add(invite); } //fix if invite more people than tournament size offset = height * (-0.5f - Mathf.Max((notJoinedPlayers.Count + newEmailCount), notJoinedPlayers.Count)); Vector3 linePos = new Vector3(0, offset); //joined players for (int i = 0; i < joinedPlayers.Count; i++) { GameObject ob = Instantiate(joinedPlayerPrefab, Vector3.zero, Quaternion.identity, emailsPanel) as GameObject; ob.transform.Find("EmailInput/NameInput").GetComponent <Text>().text = joinedPlayers[i]; RectTransform r = ob.GetComponent <RectTransform>(); r.localPosition = new Vector3(0, height * (-1.5f - i) - spacing + offset); r.sizeDelta = new Vector2(width - spacing * 5, height - spacing); } contentPanel.sizeDelta = new Vector2(contentPanel.sizeDelta.x, Mathf.Max(5 * height, (int)(Mathf.Max(tournament.size, notJoinedPlayers.Count + joinedPlayers.Count) + 4.5f) * height + spacing)); contentPanel.localPosition = new Vector3(contentPanel.localPosition.x, 0); line.localPosition = linePos; }
private void SetupButton() { purchaseByCash.onClick.AddListener(() => { if (string.IsNullOrEmpty(cashInput.text)) { return; } ShowPurchaseTokenPanel(0); }); purchaseByRP.onClick.AddListener(() => { if (string.IsNullOrEmpty(pointInput.text)) { return; } ShowPurchaseTokenPanel(2); }); confirmPurchaseBtn.onClick.AddListener(SubmitPurchaseToken); Container.transform.Find("Header/CloseButton").GetComponent <Button>().onClick.AddListener(ClosePanel); claimBtn.onClick.AddListener(SendClaimToken); claimPopupBtn.onClick.AddListener(SendClaimToken); prizeDetailPanel.Find("Main/Buttons/Claim").GetComponent <Button>().onClick.AddListener(delegate { prizeDetailPanel.gameObject.SetActive(false); if (int.Parse(TacoManager.User.ticket) < purchasingPrize.ticket) { TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.TacoRewardHeaderError, TacoConfig.TacoRewardErrorMsg); } else { redeemPrizePanel.gameObject.SetActive(true); } }); withdrawBtn.onClick.AddListener(() => { FundPanel.SetActive(false); availableFund.text = TacoManager.FormatCash(TacoManager.User.funds); defaultAddress.text = TacoManager.User.contactProfile.FullAddress(); submitWithdrawBtn.interactable = false; if (string.IsNullOrEmpty(defaultAddress.text)) { switchAddressBtn.interactable = false; newAddress.SetActive(true); defaultAddress.transform.parent.gameObject.SetActive(false); UpdateSwitchBtnText(TacoConfig.NoDefaultAddress); } else { switchAddressBtn.interactable = true; newAddress.SetActive(false); defaultAddress.transform.parent.gameObject.SetActive(true); UpdateSwitchBtnText("Use new contact information"); } ResetWithdrawInputField(); WithdrawPanel.SetActive(true); }); depositeBtn.onClick.AddListener(() => { TacoSetup.Instance.LogEvent("open_deposit_page"); Application.OpenURL(Constants.BaseUrl + "deposit/" + TacoManager.User.webToken); //FundPanel.SetActive(false); //DepositPanel.SetActive(true); }); cancelWithdrawBtn.onClick.AddListener(() => { FundPanel.SetActive(true); WithdrawPanel.SetActive(false); }); submitWithdrawBtn.onClick.AddListener(SendWithdrawRequest); cancelDepositeBtn.onClick.AddListener(() => { FundPanel.SetActive(true); WithdrawPanel.SetActive(false); }); submitDepositeBtn.onClick.AddListener(() => { }); switchAddressBtn.onClick.AddListener(() => { bool isShowNewAddr = newAddress.activeSelf; newAddress.SetActive(!isShowNewAddr); defaultAddress.transform.parent.gameObject.SetActive(isShowNewAddr); UpdateSwitchBtnText(isShowNewAddr ? "Use new contact information" : "Use saved contact information"); ToggleWithdrawBtn(); }); }