Exemplo n.º 1
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();
    }
Exemplo n.º 2
0
    // 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;
    }