Пример #1
0
        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");
        }
Пример #2
0
        public async void OnEnable()
        {
            userId         = UserManager.Get.getCurrentUserId();
            token          = UserManager.Get.getCurrentSessionToken();
            tournamentJson = await TournamentManager.Get.getTournament(TournamentController.getCurrentTournamentID(), token);

            setTournamentData();
            initUI(challenges, participants);
            if (!isAvailable() || !isNextChallengeAvailable())
            {
                Play.interactable = false;
            }
            else
            {
                Play.interactable = true;
            }
        }
Пример #3
0
        public async Task <string> JoinOrCreateTournament(int nb_player, float gain, string gain_type, string userId, string token)
        {
            string url = Endpoint.classesURL + "/tournaments";

            ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;
            WWWForm form = new WWWForm();

            form.AddField("nb_player", nb_player);
            form.AddField("gain", gain.ToString());
            form.AddField("gain_type", gain_type);
            form.AddField("game_id", GamesManager.GAME_ID);
            form.AddField("user_id", userId);
            var response = await SeembaWebRequest.Get.HttpsPost(url, form);

            var tournementdata = JSON.Parse(response);

            UserManager.Get.UpdateUserCredit((tournementdata["user"]["money_credit"].AsFloat).ToString(), tournementdata["user"]["bubble_credit"].Value);
            TournamentController.setCurrentTournamentID(tournementdata["tournament"]["_id"].Value);
            return(tournementdata["tournament"]["_id"].Value);
        }
Пример #4
0
        public async void setResult(float score)
        {
            if (EventsController.ChallengeType == ChallengeManager.CHALLENGE_TYPE_1V1)
            {
                SeembaAnalyticsManager.Get.SendUserDuelEvent("Duel Finished", ChallengeManager.CurrentChallengeId, score);
                LoaderManager.Get.LoaderController.ShowLoader(null);
                var resAddScore = await ChallengeManager.Get.addScore(ChallengeManager.CurrentChallengeId, score);

                ChallengeManager.Get.ShowResult();
                LoaderManager.Get.LoaderController.HideLoader();
            }
            else if (EventsController.ChallengeType == ChallengeManager.CHALLENGE_TYPE_BRACKET)
            {
                SeembaAnalyticsManager.Get.SendTournamentEvent("Tournament Challenge done", TournamentController.getCurrentTournamentID(), score);
                LoaderManager.Get.LoaderController.ShowLoader(null);
                await TournamentManager.Get.addScore(TournamentController.getCurrentTournamentID(), score);

                ViewsEvents.Get.GoToMenu(ViewsEvents.Get.Brackets.gameObject);
                SeembaAnalyticsManager.Get.SendTournamentEvent("Return to tournament", TournamentController.getCurrentTournamentID(), score);
                ViewsEvents.Get.Brackets.OnEnable();
            }
            SceneManager.UnloadSceneAsync(GamesManager.GAME_SCENE_NAME);
            LoaderManager.Get.LoaderController.HideLoader();
        }
 private void Start()
 {
     sInstance = this;
 }