コード例 #1
0
    void Update()
    {
        //progress.AnimationCompleted += (dfTweenPlayableBase sender) => {
        if (!progress.IsPlaying)
        {
            Debug.Log("done");
            CategoryConstant.GameType = gameType;

            if (CategoryConstant.GameType.Equals("fun"))
            {
                HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

                new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_player_fun_points.php?prize_id=" + CategoryConstant.PrizeId + "&th_cat_id=" + CategoryConstant.MainCategoryId + "&sec_cat_id=" + CategoryConstant.SubCategoryId + "&cat_id=" + CategoryConstant.GrandCategoryId + "&game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType)
                .OnReply((reply) => {
                    pointReply = JsonConvert.DeserializeObject <PointReply>(reply.DataAsString);

                    if (pointReply.success == 1)
                    {
                        GameConstant.FunHighScore = pointReply.points;
                    }
                    else
                    {
                        GameConstant.FunHighScore = 0;
                    }
                })
                .Send();
            }

            GameConstant.CurrentScore = 0;
            SceneManager.LoadScene("TriviaStratPlay");
            //};
        }
    }
コード例 #2
0
    void Start()
    {
        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "all_categories.php?restaurant_id=5")
        .OnReply((reply) => {
            /*
             * JObject obj = JObject.Parse(reply.DataAsString);
             * JArray list = obj["data"] as JArray;
             * foreach (JToken token in list)
             * {
             *      CatagoryData data =	JsonConvert.DeserializeObject<CatagoryData>(token.ToString());
             *      Catagory instance = Instantiate(Prefab) as Catagory;
             *      instance.Data = data;
             * }
             */
            CatagoryReply catReply = JsonConvert.DeserializeObject <CatagoryReply>(reply.DataAsString);
            foreach (CatagoryData data in catReply.data)
            {
                Catagory instance = Instantiate(Prefab) as Catagory;
                instance.Data     = data;
            }
        })
        .Send();
    }
コード例 #3
0
        public async Task <ActionResult> Index()
        {
            var currentUserId = User.Identity.GetUserId();

            TriviaDashboardViewModel viewModel = new TriviaDashboardViewModel();

            viewModel.NewQuizzes = await TriviaService.GetNewQuizzesAsync();

            viewModel.DailyQuizzes = await TriviaService.GetDailyQuizzesAsync(5);

            viewModel.TrendingQuizzes = await GetTrendingQuizzesAsync();

            viewModel.PopularQuizzes = await GetPopularQuizzesAsync();

            // unauthenticated users don't have any quizzes to track
            if (User.Identity.IsAuthenticated)
            {
                viewModel.UnfinishedQuizzes = await TriviaService.GetUnfinishedQuizzesAsync(User.Identity.GetUserId());
            }

            // alters the viewmodel's list of quizzes to indicate if the quiz has already been completed by the currently logged in user
            await SetQuizzesCompletedByCurrentUser(currentUserId, viewModel);

            viewModel.RecentlyCompletedQuizzes = await TriviaService.GetUsersCompletedQuizzesAsync(currentUserId);

            viewModel.QuizCategories = await TriviaService.GetQuizCategoriesAsync();

            await SetNotificationsAsync();

            return(View(viewModel));
        }
コード例 #4
0
        private async Task <List <QuestionViewModel> > GetQuestionsForIndividualQuizAsync(string userId, int quizId, ICollection <Question> questionsEntity)
        {
            // get the already answered questions for this quiz
            var answeredQuizQuestions = await TriviaService.GetAnsweredQuizQuestionsAsync(userId, quizId);

            // get the list of all possible questions for this quiz
            //var quizQuestions = await TriviaService.GetQuizQuestionsAsync(quizId);
            var questionListViewModel = Mapper.Map <ICollection <Question>, List <QuestionViewModel> >(questionsEntity);

            // match up the already selected answers with the questions for this quiz
            foreach (var questionViewModel in questionListViewModel)
            {
                var answeredQuizQuestion = answeredQuizQuestions[questionViewModel.QuestionId];
                questionViewModel.SelectedAnswerId  = answeredQuizQuestion.AnswerId;
                questionViewModel.IsAlreadyAnswered = true;

                // mark the correct answer to show the user on the UI that it was correct
                foreach (var answer in questionViewModel.Answers)
                {
                    answer.IsCorrect = (answer.AnswerId == questionViewModel.CorrectAnswerId);
                }
            }

            return(questionListViewModel);
        }
コード例 #5
0
    public void OnClick()
    {
        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();

        if (!emailText.Text.ToString().Equals("") && !passText.Text.ToString().Equals(""))
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "login_user.php?user_name=" + emailText.Text.ToString() + "&user_pass="******"OWN";
                    GameConstant.UserEmail   = loginReply.data[0].user_email;
                    GameConstant.UserCountry = loginReply.data[0].user_country;
                    GameConstant.IsMusic     = loginReply.data[0].ismusic;
                    GameConstant.IsSound     = loginReply.data[0].issound;
                    //Debug.Log(gameConsatant.user_country);
                    SceneManager.LoadScene("TriviaGamePlay");
                }
                else
                {
                    invalidText.IsVisible = true;
                }
            })
            .Send();
        }
    }
コード例 #6
0
    void Start()
    {
        notFoundPanel.IsVisible = false;
        dfScrollPanel leaderPanel = GetComponent <dfScrollPanel> ();

        //categoryPanel.Anchor = dfAnchorStyle.All;
        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_game_leaderboard.php?prize_id=" + CategoryConstant.PrizeId)
        .OnReply((reply) => {
            LeaderBoardReply leaderReply = JsonConvert.DeserializeObject <LeaderBoardReply>(reply.DataAsString);
            if (leaderReply.success == 1)
            {
                foreach (LeaderBoardData data in leaderReply.data)
                {
                    LeaderBoard instance = leaderPanel.AddPrefab(Prefab.gameObject).GetComponent <LeaderBoard>();
                    //instance.GetComponent<dfPanel>().Anchor = dfAnchorStyle.All;

                    instance.Data = data;
                    instance.start();
                }
                loaderPanel.IsVisible = false;
            }
            else
            {
                notFoundPanel.IsVisible = true;
                loaderPanel.IsVisible   = false;
            }
        })
        .Send();
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        //topTitle.Text = categoryConstant.MainCategoryName;
        notFoundPanel.IsVisible = false;
        dfScrollPanel categoryPanel = GetComponent <dfScrollPanel> ();

        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "second_categories.php?parent_id=" + CategoryConstant.MainCategoryId)
        .OnReply((reply) => {
            SubCatagoryReply catReply = JsonConvert.DeserializeObject <SubCatagoryReply>(reply.DataAsString);
            if (catReply.success == 1)
            {
                foreach (SubCatagoryData data in catReply.data)
                {
                    SubCatagory instance = categoryPanel.AddPrefab(Prefab.gameObject).GetComponent <SubCatagory>();

                    //MainCatagory instance = Instantiate(Prefab) as MainCatagory;
                    instance.Data = data;
                    instance.start();
                }
                loaderPanel.IsVisible = false;
            }
            else
            {
                //	notFoundPanel.IsVisible = true;
                //	loaderPanel.IsVisible = false;

                CategoryConstant.SubCategoryId   = 0;
                CategoryConstant.GrandCategoryId = 0;
                SceneManager.LoadScene("TriviaGameSponsor");
            }
        })
        .Send();
    }
コード例 #8
0
        /// <summary>
        /// Sets up the view model to contain a random question to display to a user
        /// </summary>
        /// <param name="currentUserId"></param>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        private async Task SetupRandomQuestionOnDashboardAsync(string currentUserId, DashboardViewModel viewModel)
        {
            // generate a random question with its answers to view
            var randomQuestion = await TriviaService.GetRandomQuestionAsync(currentUserId, (int)QuestionTypeValues.Random);

            viewModel.RandomQuestion = Mapper.Map <Question, QuestionViewModel>(randomQuestion);
        }
コード例 #9
0
        /// <summary>
        /// Sets up the ViewBag to contain notification counts and collections such as messages, gifts received, and announcements.
        /// </summary>
        /// <returns></returns>
        protected async Task SetNotificationsAsync()
        {
            ViewBag.ShowNewTriviaText = false;
            ViewBag.ShowStoreSaleText = false;

            // notifications are only useful for logged in users
            if (User.Identity.IsAuthenticated)
            {
                string currentUserId = User.Identity.GetUserId();
                var    currentUser   = await UserManager.FindByIdAsync(currentUserId);

                ViewBag.MessageNotificationCount = await NotificationService.GetMessageNotificationCountAsync(currentUserId);

                ViewBag.PointsCount       = currentUser.CurrentPoints;
                ViewBag.NotificationCount = currentUser.NotificationCount;

                // are there any unplayed quizzes by the user
                // if so, show "New" on the trivia button
                int unfinishedQuizCount = await TriviaService.GetUnfinishedQuizCountForUserAsync(currentUserId);

                if (unfinishedQuizCount > 0)
                {
                    ViewBag.ShowNewTriviaText = true;
                }

                // are there any active sales
                // if so, show "Sale" on the store button
                bool isActiveSale = await StoreService.IsActiveSaleAsync();

                if (isActiveSale)
                {
                    ViewBag.ShowStoreSaleText = true;
                }
            }
        }
コード例 #10
0
    IEnumerator UploadImg(string user_name)
    {
        Texture2D texture       = icon.Texture as Texture2D;
        string    screenShotURL = TriviaService.GetImageUploadUrl();

        byte[] bytes = texture.EncodeToPNG();
        //Destroy( texture );
        // Create a Web Form
        string  name = user_name + "_profile.jpg";
        WWWForm form = new WWWForm();

        form.AddField("frameCount", Time.frameCount.ToString());
        //form.AddField("user_id",  gameConsatant.user_id);
        form.AddBinaryData("file", bytes, name, "image/jpg");
        // Upload to a cgi script
        UnityWebRequest www = UnityWebRequest.Post(screenShotURL, form);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log("Form upload complete!");
            alert_text.Text      = "Image successfully uploaded.";
            alert_text.IsVisible = true;
        }
    }
コード例 #11
0
    //private string url = "login_user.php";
    //?app_user_name=saqib&app_user_pass=1234";

    public void OnClick()
    {
        if (!emailText.Text.ToString().Equals("") && !passText.Text.ToString().Equals(""))
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "login_user.php?user_name=" + emailText.Text.ToString() + "&user_pass="******"OWN";

                    Tween.Play();
                    Tween.TweenCompleted += (dfTweenPlayableBase sender) => {
                        SceneManager.LoadScene("introduction");
                    };
                }
                else
                {
                }
            })
            .Send();
        }
    }
コード例 #12
0
    public void OnClick()
    {
        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();

        if (!passText.Text.ToString().Equals(""))
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "update_pass.php?user_id=" + GameConstant.UserId + "&user_pass="******"Pass not valid.";
            invalidText.IsVisible = true;
        }
    }
コード例 #13
0
        private async Task HandleConfirm(IDialogContext context, IAwaitable <bool> result)
        {
            bool selectedOption = await result;

            if (selectedOption)
            {
                currentTrivia = await TriviaService.GetTrivia();

                await context.PostAsync("Category: " + currentTrivia.category);

                await context.PostAsync("Difficulty: " + currentTrivia.difficulty);

                List <string> answers = new List <string>();

                answers.AddRange(currentTrivia.incorrect_answers);

                int randomIndex = new Random().Next(answers.Count);
                answers.Insert(randomIndex, currentTrivia.correct_answer);

                PromptDialog.Choice <string>(context, HandleAnswerChoice, answers, currentTrivia.question);
            }
            else
            {
                await context.PostAsync("OK... Maybe next time.");
            }
        }
コード例 #14
0
    void Start()
    {
        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

        notFoundPanel.IsVisible = false;
        dfScrollPanel winnerPanel = GetComponent <dfScrollPanel> ();

        //categoryPanel.Anchor = dfAnchorStyle.All;

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_game_winners.php")
        .OnReply(reply =>
        {
            WinnerReply winReply = JsonConvert.DeserializeObject <WinnerReply>(reply.DataAsString);
            if (winReply.success == 1)
            {
                foreach (WinnerData data in winReply.data)
                {
                    Winner instance = winnerPanel.AddPrefab(Prefab.gameObject).GetComponent <Winner>();
                    //instance.GetComponent<dfPanel>().Anchor = dfAnchorStyle.All;

                    instance.Data = data;
                    instance.start();
                }
                loaderPanel.IsVisible = false;
            }
            else
            {
                notFoundPanel.IsVisible = true;
                loaderPanel.IsVisible   = false;
            }
        })
        .Send();
    }
コード例 #15
0
ファイル: LoadHistory.cs プロジェクト: suxrobGM/TriviaStreak
    void Start()
    {
        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

        notFoundPanel.IsVisible = false;
        dfScrollPanel historyPanel = GetComponent <dfScrollPanel> ();

        //categoryPanel.Anchor = dfAnchorStyle.All;

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_user_game_history.php?game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType)
        .OnReply((reply) => {
            HistoryReply hReply = JsonConvert.DeserializeObject <HistoryReply>(reply.DataAsString);
            if (hReply.success == 1)
            {
                foreach (HistoryData data in hReply.data)
                {
                    History instance = historyPanel.AddPrefab(Prefab.gameObject).GetComponent <History>();

                    instance.Data = data;
                    instance.start();
                }
                loaderPanel.IsVisible = false;
            }
            else
            {
                notFoundPanel.IsVisible = true;
                loaderPanel.IsVisible   = false;
            }
        })
        .Send();
    }
コード例 #16
0
        /// <summary>
        /// Returns a view model containing a random question of a certain type with its tags and users who have already answered it correctly.
        /// </summary>
        /// <param name="questionTypeId"></param>
        /// <returns></returns>
        private async Task <QuestionViewModel> GetRandomQuestionViewModelAsync(int questionTypeId)
        {
            await SetNotificationsAsync();

            var currentUserId = User.Identity.GetUserId();

            // generate a random question with its answers to view
            var randomQuestion = await TriviaService.GetRandomQuestionAsync(currentUserId, questionTypeId);

            QuestionViewModel viewModel = Mapper.Map <Question, QuestionViewModel>(randomQuestion);

            if (viewModel != null)
            {
                viewModel.QuestionTypeId         = questionTypeId;
                viewModel.UsersAnsweredCorrectly = await GetUsersAnsweredCorrectlyAsync(randomQuestion.Id);

                viewModel.Tags = await GetTagsForQuestionAsync(randomQuestion.Id);

                foreach (var user in viewModel.UsersAnsweredCorrectly)
                {
                    user.IsFavoritedByCurrentUser = await ProfileService.IsProfileFavoritedByUserAsync(user.ProfileId, currentUserId);
                }
            }

            return(viewModel);
        }
コード例 #17
0
        public async Task <ActionResult> MinefieldQuiz(QuizViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("quiz", new { id = viewModel.QuizId, seoName = viewModel.SEOName }));
            }

            string currentUserId = User.Identity.GetUserId();

            var profile = await ProfileService.GetProfileAsync(currentUserId);

            // loop through questions and record answers
            var result = await TriviaService.RecordAnsweredMinefieldQuestionAsync(
                currentUserId,
                viewModel.MinefieldQuestion.MinefieldQuestionId,
                viewModel.MinefieldQuestion.Answers);

            if (result.Succeeded)
            {
                int count = await TriviaService.SetQuizAsCompletedAsync(currentUserId, viewModel.QuizId, result.CorrectAnswerCount);
            }

            TempData["TagsAwardedCount"]        = 0;
            TempData["DidUserJustCompleteQuiz"] = true;

            return(RedirectToAction("quiz", new { id = viewModel.QuizId, seoName = viewModel.SEOName }));
        }
コード例 #18
0
ファイル: MainCatagory.cs プロジェクト: suxrobGM/TriviaStreak
    IEnumerator DownloadImg()
    {
        string url = TriviaService.GetHttpMainCategoryMediaPath() + Data.cat_image;
        //Texture2D texture = new Texture2D(1,1);
        WWW www = new WWW(url);

        yield return(www);

        //if (www.error != null){
        menu_icon.Texture = www.texture as Texture;
    }
コード例 #19
0
    public IEnumerator DownloadImg()
    {
        string url = TriviaService.GetImageDisplayUrl() + GameConstant.UserId + "_profile.jpg";
        //Texture2D texture = new Texture2D(1,1);
        WWW www = new WWW(url);

        yield return(www);

        //if (www.error != null){
        avatar.Texture = www.texture as Texture;
    }
コード例 #20
0
ファイル: signupuser.cs プロジェクト: suxrobGM/TriviaStreak
    public void OnClick()
    {
        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();

        if (!emailText.Text.ToString().Equals("email") && !usernameText.Text.ToString().Equals("username"))
        {
            if (!emailText.Text.ToString().Equals("") && !passText.Text.ToString().Equals("") && !usernameText.Text.ToString().Equals("") && !rpassText.Text.ToString().Equals(""))
            {
                if (passText.Text.ToString().Equals(rpassText.Text.ToString()))
                {
                    HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

                    new HTTP.Request(TriviaService.GetHttpFolderPath() + "register_user.php?user_name=" + usernameText.Text.ToString() + "&user_pass="******"&user_email=" + emailText.Text.ToString() + "&user_type=OWN")
                    .OnReply(reply =>
                    {
                        RegisterReply registerReply = JsonConvert.DeserializeObject <RegisterReply>(reply.DataAsString);
                        if (registerReply.success == 1)
                        {
                            GameConstant.UserId    = usernameText.Text.ToString();
                            GameConstant.UserType  = "OWN";
                            GameConstant.UserEmail = emailText.Text.ToString();
                            StartCoroutine(UploadImg(usernameText.Text.ToString()));
                        }
                        else
                        {
                            invalidText.Text      = registerReply.message.ToString();
                            invalidText.IsVisible = true;
                        }
                    })
                    .Send();
                }
                else
                {
                    invalidText.Text      = "Password not match.";
                    invalidText.IsVisible = true;
                }
            }
            else
            {
                invalidText.Text      = "Fill all the required fields.";
                invalidText.IsVisible = true;
            }
        }
        else
        {
            invalidText.Text      = "Fill all the required fields.";
            invalidText.IsVisible = true;
        }
    }
コード例 #21
0
        /// <summary>
        /// Sets up the view model to contain a list of quizzes and whether or not the current user has completed those quizzes
        /// </summary>
        /// <param name="currentUserId"></param>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        private async Task SetupQuizzesOnDashboardAsync(string currentUserId, DashboardViewModel viewModel)
        {
            var quizzes = await TriviaService.GetQuizzesAsync();

            viewModel.Quizzes = Mapper.Map <IReadOnlyCollection <Quiz>, IReadOnlyCollection <QuizOverviewViewModel> >(quizzes);
            var completedQuizzes = await TriviaService.GetCompletedQuizzesByUserAsync(currentUserId);

            foreach (var quiz in viewModel.Quizzes)
            {
                if (completedQuizzes.Any(q => q.Key == quiz.Id))
                {
                    quiz.IsComplete = true;
                }
            }
        }
コード例 #22
0
        public async Task <ActionResult> Quiz(QuizViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("quiz", new { id = viewModel.QuizId, seoName = viewModel.SEOName }));
            }

            string currentUserId = User.Identity.GetUserId();

            // loop through questions and record answers
            int        numberOfCorrectAnswers = 0;
            int        numberOfTagsAwarded    = 0;
            List <int> milestoneIdsUnlocked   = new List <int>();

            foreach (var question in viewModel.Questions)
            {
                var result = await TriviaService.RecordAnsweredQuestionAsync(
                    currentUserId,
                    question.QuestionId,
                    question.SelectedAnswerId.Value,
                    (int)QuestionTypeValues.Quiz);

                if (result.Succeeded)
                {
                    if (question.SelectedAnswerId.Value == result.CorrectAnswerId)
                    {
                        numberOfCorrectAnswers++;
                    }

                    numberOfTagsAwarded += result.TagsAwardedCount;

                    // collect up any milestones that were unlocked by the user
                    foreach (var milestoneIds in result.AwardedAchievements)
                    {
                        milestoneIdsUnlocked.AddRange(milestoneIds.MilestoneIdsUnlocked);
                    }
                }
            }

            TempData["DidUserJustCompleteQuiz"] = true;
            TempData["TagsAwardedCount"]        = numberOfTagsAwarded;
            TempData["MilestoneIdsUnlocked"]    = milestoneIdsUnlocked;

            int count = await TriviaService.SetQuizAsCompletedAsync(currentUserId, viewModel.QuizId, numberOfCorrectAnswers);

            return(RedirectToAction("quiz", new { id = viewModel.QuizId, seoName = viewModel.SEOName }));
        }
コード例 #23
0
        public async Task <JsonResult> SubmitAnswer(int questionId, int answerId)
        {
            var currentUserId = User.Identity.GetUserId();

            var result = await TriviaService.RecordAnsweredQuestionAsync(
                currentUserId,
                questionId,
                answerId,
                (int)QuestionTypeValues.Random);

            if (result.Succeeded)
            {
                return(Json(new { success = true, correctAnswerId = result.CorrectAnswerId }));
            }

            return(Json(new { success = false, error = ErrorMessages.AnswerNotSubmitted }));
        }
コード例 #24
0
ファイル: playGame.cs プロジェクト: suxrobGM/TriviaStreak
    public void Start()
    {
        if (CategoryConstant.GameType.Equals("fun"))
        {
            if (GameConstant.CurrentScore > GameConstant.FunHighScore)
            {
                //highScoreLable.Text = gameConsatant.currentScore.ToString();
                highScoreLable.Text = CategoryConstant.PrizeTopScore.ToString();
            }
            else
            {
                //highScoreLable.Text = gameConsatant.FunHighScore.ToString();
                highScoreLable.Text = CategoryConstant.PrizeTopScore.ToString();
            }
        }
        //Debug.Log("Score = "+gameConsatant.currentScore.ToString());

        //countObj.start ();
        if (catReply == null)
        {
            HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

            new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_questions.php?category_id=" + CategoryConstant.MainCategoryId + "&parent_id=" + CategoryConstant.SubCategoryId + "&grand_parant_id=" + CategoryConstant.GrandCategoryId)
            .OnReply(reply =>
            {
                catReply = JsonConvert.DeserializeObject <QuestionReply>(reply.DataAsString);

                if (catReply.success == 1)
                {
                    totalQuestion = catReply.data.Count;
                    StartRound();
                }
            })
            .Send();
        }
        else
        {
            StartRound();
        }


        //mainPanel.IsVisible = false;
        //StartCoroutine(Wait(2.0f));
        //Invoke( "LoadNewLevel", 5 );
    }
コード例 #25
0
    public void OnClick()
    {
        CategoryConstant.GameType = "fun";
        AudioSource backgroundClip = mainpanel.GetComponent <AudioSource>();

        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();

        if (!backgroundClip.isPlaying)
        {
            backgroundClip.Play();
            progress.Resume();
        }
        else
        {
            backgroundClip.Stop();
            progress.Stop();
            //  start game play

            if (CategoryConstant.GameType.Equals("fun"))
            {
                HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

                new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_player_fun_points.php?prize_id=" + CategoryConstant.PrizeId + "&th_cat_id=" + CategoryConstant.MainCategoryId + "&sec_cat_id=" + CategoryConstant.SubCategoryId + "&cat_id=" + CategoryConstant.GrandCategoryId + "&game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType)
                .OnReply((reply) => {
                    pointReply = JsonConvert.DeserializeObject <PointReply>(reply.DataAsString);

                    if (pointReply.success == 1)
                    {
                        GameConstant.FunHighScore = pointReply.points;
                    }
                    else
                    {
                        GameConstant.FunHighScore = 0;
                    }
                }).Send();
            }

            GameConstant.CurrentScore = 0;
            SceneManager.LoadScene("TriviaStratPlay");
        }
    }
コード例 #26
0
    void Start()
    {
        //  Grab user current daily game
        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));
        new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_player_game.php?game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType)
        .OnReply((reply2) => {
            DailyGameReply dailyReply = JsonConvert.DeserializeObject <DailyGameReply>(reply2.DataAsString);
            if (dailyReply.daily_game == 0)
            {
                SceneManager.LoadScene("TriviaInAppPurchase");
            }
        }).Send();


        notFoundPanel.IsVisible = false;
        dfScrollPanel categoryPanel = GetComponent <dfScrollPanel> ();

        //categoryPanel.Anchor = dfAnchorStyle.All;

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "first_categories.php")
        .OnReply((reply) => {
            MainCatagoryReply catReply = JsonConvert.DeserializeObject <MainCatagoryReply>(reply.DataAsString);
            if (catReply.success == 1)
            {
                foreach (MainCatagoryData data in catReply.data)
                {
                    MainCatagory instance = categoryPanel.AddPrefab(Prefab.gameObject).GetComponent <MainCatagory>();
                    //instance.GetComponent<dfPanel>().Anchor = dfAnchorStyle.All;

                    instance.Data = data;
                    instance.start();
                }
                loaderPanel.IsVisible = false;
            }
            else
            {
                notFoundPanel.IsVisible = true;
                loaderPanel.IsVisible   = false;
            }
        })
        .Send();
    }
コード例 #27
0
        public async Task <ActionResult> Timed()
        {
            QuestionViewModel viewModel = new QuestionViewModel();

            viewModel = await GetRandomQuestionViewModelAsync((int)QuestionTypeValues.Timed);

            if (viewModel != null)
            {
                viewModel.QuestionViolation = await GetQuestionViolationViewModelAsync();
            }
            else
            {
                viewModel      = new QuestionViewModel();
                viewModel.Tags = new List <TagViewModel>();
                viewModel.UsersAnsweredCorrectly = new List <UserAnsweredQuestionCorrectlyViewModel>();
            }

            viewModel.QuizCategories = await TriviaService.GetQuizCategoriesAsync();

            return(View(viewModel));
        }
コード例 #28
0
        private async Task <MinefieldQuestionViewModel> GetQuestionForMinefieldQuizAsync(string currentUserId, int quizId, MinefieldQuestion minefieldQuestionEntity)
        {
            // get the already answered questions for this quiz
            var answeredQuizQuestions = await TriviaService.GetSelectedMinefieldAnswersAsync(currentUserId, quizId);

            var minefieldQuestion = Mapper.Map <MinefieldQuestion, MinefieldQuestionViewModel>(minefieldQuestionEntity);

            // mark up the answers that were selected and are correct for the user's quiz score
            foreach (var answer in minefieldQuestion.Answers)
            {
                AnsweredMinefieldQuestion answeredQuizQuestion = null;
                bool selectedByUser = answeredQuizQuestions.TryGetValue(answer.AnswerId, out answeredQuizQuestion);
                if (selectedByUser)
                {
                    answer.IsSelected = true;
                    answer.IsCorrect  = answeredQuizQuestion.Answer.IsCorrect;
                }
            }

            return(minefieldQuestion);
        }
コード例 #29
0
        public async Task <ActionResult> AddQuizQuestions(AddQuizQuestionsViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                foreach (var question in viewModel.Questions)
                {
                    var answerContents = question.Answers.Select(x => x.Content).ToList();
                    var result         = await TriviaService.AddQuestionToQuizAsync(
                        viewModel.QuizId,
                        question.Content,
                        question.Points,
                        answerContents.AsReadOnly(),
                        question.CorrectAnswer,
                        question.SelectedTags.AsReadOnly());
                }
            }

            viewModel.Tags = await GetSearchableTagsAsync();

            return(View(viewModel));
        }
コード例 #30
0
ファイル: showResult.cs プロジェクト: suxrobGM/TriviaStreak
    // Use this for initialization
    void Start()
    {
        correctanswer.Text    = "Correct Answers:       " + GameConstant.CorrectAnswerCount;
        difficultyanswer.Text = "Difficulty Bonus:       " + GameConstant.DifficultyAnswerCount;
        speedanswer.Text      = "Speed Bonus:       " + GameConstant.SpeedAnswerCount;
        pointscore.Text       = "Points Earned:       " + GameConstant.CurrentScore;

        //  insert score

        HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

        new HTTP.Request(TriviaService.GetHttpFolderPath() + "add_game_score.php?game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType + "&game_points=" + GameConstant.CurrentScore + "&cat_id=" + CategoryConstant.GrandCategoryId + "&sec_cat_id=" + CategoryConstant.SubCategoryId + "&th_cat_id=" + CategoryConstant.MainCategoryId + "&prize_id=" + CategoryConstant.PrizeId)
        .OnReply((reply) => {
            AddScoreReply scoreReply = JsonConvert.DeserializeObject <AddScoreReply>(reply.DataAsString);
            if (scoreReply.success == 1)
            {
                //  Grab user current game Rank

                new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_player_game_rank.php?game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType + "&cat_id=" + CategoryConstant.GrandCategoryId + "&sec_cat_id=" + CategoryConstant.SubCategoryId + "&th_cat_id=" + CategoryConstant.MainCategoryId + "&prize_id=" + CategoryConstant.PrizeId)
                .OnReply((reply1) => {
                    RankReply rankReply  = JsonConvert.DeserializeObject <RankReply>(reply1.DataAsString);
                    totalpointscore.Text = rankReply.points.ToString();
                    userplace.Text       = rankReply.rank.ToString() + "th Place";
                }).Send();

                //  Grab user current daily game

                new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_player_game.php?game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType)
                .OnReply((reply2) => {
                    DailyGameReply dailyReply = JsonConvert.DeserializeObject <DailyGameReply>(reply2.DataAsString);
                    dailygame.Text            = dailyReply.daily_game.ToString();
                }).Send();
            }
        }).Send();

        GameConstant.CorrectAnswerCount    = 0;
        GameConstant.DifficultyAnswerCount = 0;
        GameConstant.SpeedAnswerCount      = 0;
        GameConstant.CurrentScore          = 0;
    }