Example #1
0
        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;
        }
Example #2
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");
        }
        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);
        }