void SetControllerTournamentTitle(GenericChallenge item, OnGoingTournamentListItemController controller) { if (item.gain_type == TournamentManager.GAIN_TYPE_CASH) { if (float.Parse(item.gain) == TournamentManager.WIN_BRACKET_CASH_AMATEUR) { controller.titre.text = HomeTranslationController.WIN + " " + TournamentManager.WIN_BRACKET_CASH_AMATEUR + CurrencyManager.CURRENT_CURRENCY; } else if (float.Parse(item.gain) == TournamentManager.WIN_BRACKET_CASH_NOVICE) { controller.titre.text = HomeTranslationController.WIN + " " + TournamentManager.WIN_BRACKET_CASH_NOVICE + CurrencyManager.CURRENT_CURRENCY; } else if (float.Parse(item.gain) == TournamentManager.WIN_BRACKET_CASH_CONFIRMED) { controller.titre.text = HomeTranslationController.WIN + " " + TournamentManager.WIN_BRACKET_CASH_CONFIRMED + CurrencyManager.CURRENT_CURRENCY; } } else { if (float.Parse(item.gain) == TournamentManager.WIN_BRACKET_BUBBLE_AMATEUR) { controller.titre.text = HomeTranslationController.WIN + " " + TournamentManager.WIN_BRACKET_BUBBLE_AMATEUR + " " + HomeTranslationController.BUBBLES; } else if (float.Parse(item.gain) == TournamentManager.WIN_BRACKET_BUBBLE_NOVICE) { controller.titre.text = HomeTranslationController.WIN + " " + TournamentManager.WIN_BRACKET_BUBBLE_NOVICE + " " + HomeTranslationController.BUBBLES; } else if (float.Parse(item.gain) == TournamentManager.WIN_BRACKET_BUBBLE_CONFIRMED) { controller.titre.text = HomeTranslationController.WIN + " " + TournamentManager.WIN_BRACKET_BUBBLE_CONFIRMED + " " + HomeTranslationController.BUBBLES; } } }
void SetControllerTitle(GenericChallenge item, OnGoingGameListItemController controller) { if (item.gain_type == ChallengeManager.CHALLENGE_WIN_TYPE_CASH) { if (item.gain == ChallengeManager.WIN_1V1_CASH_CONFIDENT.ToString()) { controller.titre.text = HomeTranslationController.WIN + " " + ChallengeManager.WIN_1V1_CASH_CONFIDENT + CurrencyManager.CURRENT_CURRENCY; } else if (item.gain == ChallengeManager.WIN_1V1_CASH_CHAMPION.ToString()) { controller.titre.text = HomeTranslationController.WIN + " " + ChallengeManager.WIN_1V1_CASH_CHAMPION + CurrencyManager.CURRENT_CURRENCY; } else if (item.gain == ChallengeManager.WIN_1V1_CASH_LEGEND.ToString()) { controller.titre.text = HomeTranslationController.WIN + " " + ChallengeManager.WIN_1V1_CASH_LEGEND + CurrencyManager.CURRENT_CURRENCY; } } else { if (item.gain == ChallengeManager.WIN_1V1_BUBBLES_CONFIDENT.ToString()) { controller.titre.text = HomeTranslationController.WIN + " " + ChallengeManager.WIN_1V1_BUBBLES_CONFIDENT + " " + HomeTranslationController.BUBBLES; } else if (item.gain == ChallengeManager.WIN_1V1_BUBBLES_CHAMPION.ToString()) { controller.titre.text = HomeTranslationController.WIN + " " + ChallengeManager.WIN_1V1_BUBBLES_CHAMPION + " " + HomeTranslationController.BUBBLES; } else if (item.gain == ChallengeManager.WIN_1V1_BUBBLES_LEGEND.ToString()) { controller.titre.text = HomeTranslationController.WIN + " " + ChallengeManager.WIN_1V1_BUBBLES_LEGEND + " " + HomeTranslationController.BUBBLES; } } }
private void InitOnGoingTournament(GenericChallenge challenge) { GameObject newItem = Instantiate(tournamentPrefab) as GameObject; OnGoingTournamentListItemController controller = newItem.GetComponent <OnGoingTournamentListItemController>(); string date = challenge.createdAt.Substring(0, challenge.createdAt.IndexOf("T")); string hour = challenge.createdAt.Substring(challenge.createdAt.IndexOf("T") + 1, 5).Replace(":", "H") + "MIN"; controller.Date.text = date + " " + HomeTranslationController.AT + " " + hour; TranslationManager.scene = "Home"; controller.status.text = TranslationManager.Get("pending"); controller.tournamentId.text = challenge.tournament_id; controller.gainType = challenge.tournament.gain_type; controller.CreatedAt = challenge.tournament.createdAt; controller.gain = challenge.tournament.gain; SetControllerTournamentTitle(challenge, controller); controller.GoToBracket.onClick.AddListener(() => { TournamentController.setCurrentTournamentID(challenge.tournament_id); ViewsEvents.Get.GoToMenu(ViewsEvents.Get.Brackets.gameObject); }); newItem.transform.SetParent(ContentPanel.transform); RectTransform myLayoutElement = newItem.GetComponent <RectTransform>(); myLayoutElement.transform.localScale = Vector3.one; }
void SetChallengeDetails(LastResultListController controller, GenericChallenge challenge) { string date = challenge.createdAt.ToString().Substring(0, challenge.createdAt.ToString().IndexOf("T")).Replace("/", "-"); string hour = challenge.createdAt.ToString().Substring(challenge.createdAt.ToString().IndexOf("T") + 1, 5).Replace(":", "H") + "MIN"; controller.GameDate.text = date + " AT " + hour; controller.matchId.text = challenge._id; if (challenge.user_1_score == challenge.user_2_score) { controller.equality.text = HomeTranslationController.EQUALITY; controller.equality.transform.localScale = Vector3.one; controller.result.text = HomeTranslationController.SCORE_DRAW; } else if (UserId.Equals(challenge.winner_user)) { controller.victory.text = HomeTranslationController.VICTORY; controller.victory.transform.localScale = Vector3.one; controller.result.text = HomeTranslationController.YOU_WON + controller.result.text; } else { controller.defeat.text = HomeTranslationController.DEFEAT; controller.defeat.transform.localScale = Vector3.one; controller.result.text = HomeTranslationController.YOU_LOST; } }
private void InitOnGoingChallenge(GenericChallenge challenge) { GameObject newItem = Instantiate(ListItemPrefab) as GameObject; OnGoingGameListItemController controller = newItem.GetComponent <OnGoingGameListItemController>(); controller.challengeResultId.text = challenge._id; controller.challengeId.text = challenge._id; SetControllerTitle(challenge, controller); if (challenge.status.Equals("results pending") || challenge.status.Equals("pending") || challenge.status.Equals("on going")) { TranslationManager.scene = "Home"; controller.pending_text.text = TranslationManager.Get("pending"); controller.SeeResult.transform.localScale = Vector3.zero; controller.Result.gameObject.SetActive(true); controller.Result.onClick.AddListener(async() => { LoaderManager.Get.LoaderController.ShowLoader(null); ChallengeManager.CurrentChallengeId = challenge._id; Debug.LogWarning(ChallengeManager.CurrentChallengeId); Challenge mCurrentChallenge = await ChallengeManager.Get.getChallenge(ChallengeManager.CurrentChallengeId); ChallengeManager.CurrentChallenge = mCurrentChallenge; ChallengeManager.Get.ShowResult(); LoaderManager.Get.LoaderController.HideLoader(); }); controller.SeeResult.gameObject.SetActive(false); } else if (challenge.status.Equals("see results for user 1")) { controller.pending_text.text = HomeTranslationController.GAME_FINISHED; controller.SeeResult.transform.localScale = Vector3.one; controller.SeeResult.gameObject.SetActive(true); controller.SeeResult.onClick.AddListener(async() => { ChallengeManager.CurrentChallengeId = challenge._id; LoaderManager.Get.LoaderController.ShowLoader(null); Challenge mUpdatedChallenge = await ChallengeManager.Get.UpdateChallengeStatusToFinishedAsync(token, ChallengeManager.CurrentChallengeId); Challenge Selectedchallenge = await ChallengeManager.Get.getChallenge(ChallengeManager.CurrentChallengeId); ChallengeManager.CurrentChallenge = Selectedchallenge; ChallengeManager.Get.ShowResult(); LoaderManager.Get.LoaderController.HideLoader(); }); controller.Result.gameObject.SetActive(false); } string date = challenge.createdAt.ToString().Substring(0, challenge.createdAt.ToString().IndexOf("T")); string hour = challenge.createdAt.ToString().Substring(challenge.createdAt.ToString().IndexOf("T") + 1, 5).Replace(":", "H") + "MIN"; controller.status.text = date + " " + HomeTranslationController.AT + " " + hour; newItem.transform.SetParent(ContentPanel.transform); RectTransform myLayoutElement = newItem.GetComponent <RectTransform>(); myLayoutElement.transform.localScale = Vector3.one; }
private void InitTournamentLastResult(GenericChallenge challenge) { GameObject newItem = Instantiate(ListTournamentItemPrefab) as GameObject; LastResultTournamentListController controller = newItem.GetComponent <LastResultTournamentListController>(); if (challenge.gain_type == TournamentManager.GAIN_TYPE_BUBBLE) { controller.title.text = HomeTranslationController.WIN + " " + challenge.gain + " " + HomeTranslationController.BUBBLES; } else { controller.title.text = HomeTranslationController.WIN + " " + challenge.gain + CurrencyManager.CURRENT_CURRENCY; } string date = challenge.createdAt.Substring(0, challenge.createdAt.IndexOf("T")); string hour = challenge.createdAt.Substring(challenge.createdAt.IndexOf("T") + 1, 5).Replace(":", "H") + "MIN"; controller.date.text = date + " " + HomeTranslationController.AT + " " + hour; var lose = false; foreach (string loser in challenge.tournament.losers) { if (loser == UserId) { lose = true; break; } } if (lose) { controller.defeat.text = HomeTranslationController.DEFEAT; controller.defeat.transform.localScale = Vector3.one; } else if (lose == false && challenge.tournament.status == "finished") { controller.victory.text = HomeTranslationController.VICTORY; controller.victory.transform.localScale = Vector3.one; } controller.showResult.onClick.AddListener(() => { TournamentController.setCurrentTournamentID(challenge.tournament_id); ViewsEvents.Get.GoToMenu(ViewsEvents.Get.Brackets.gameObject); }); newItem.transform.SetParent(ContentPanel.transform); RectTransform myLayoutElement = newItem.GetComponent <RectTransform>(); myLayoutElement.transform.localScale = Vector3.one; Debug.LogWarning("InitTournamentLastResult"); }
private async System.Threading.Tasks.Task InitChallengeLastResultAsync(GenericChallenge challenge) { User mOpponent; GameObject newItem = Instantiate(ListItemPrefab); LastResultListController controller = newItem.GetComponent <LastResultListController>(); if (challenge.matched_user_1.Equals(UserManager.Get.CurrentUser._id)) { mOpponent = await UserManager.Get.GetUserById(challenge.matched_user_2); await SetOpponentDetailsAsync(controller, mOpponent); } else { mOpponent = await UserManager.Get.GetUserById(challenge.matched_user_1); await SetOpponentDetailsAsync(controller, mOpponent); } SetChallengeDetails(controller, challenge); controller.avatar.GetComponentInChildren <Button>().onClick.AddListener(() => { ViewsEvents.Get.Profile.InitProfile(mOpponent); ViewsEvents.Get.ShowOverayMenu(ViewsEvents.Get.Profile.gameObject); }); controller.showResult.onClick.AddListener(async() => { ChallengeManager.CurrentChallengeId = challenge._id; LoaderManager.Get.LoaderController.ShowLoader(null); Challenge mCurrentChallenge = await ChallengeManager.Get.getChallenge(ChallengeManager.CurrentChallengeId); ChallengeManager.CurrentChallenge = mCurrentChallenge; EventsController.Get.AudioListener.enabled = true; ViewsEvents.Get.GoToMenu(ViewsEvents.Get.ResultPresenter.gameObject); LoaderManager.Get.LoaderController.HideLoader(); }); newItem.transform.SetParent(ContentPanel.transform); RectTransform myLayoutElement = newItem.GetComponent <RectTransform>(); myLayoutElement.transform.localScale = Vector3.one; }