예제 #1
0
        public async Task <Post> GetPost(string id, string subreddit)
        {
            JArray json = await RedditConnector.GetJSONArrayAsync("/r/" + subreddit + "/comments/" + id + ".json");

            if (json[0]["error"] == null)
            {
                var  currentPost = json[0]["data"]["children"][0]["data"];
                Post post        = ConvertPostFromJson(currentPost);
                post.Comments = new List <Comment>();
                // Get comments
                var currentComments = json[1]["data"]["children"];
                foreach (var comment in currentComments)
                {
                    if (comment["data"]["body"] == null || comment["data"]["author"] == null)
                    {
                        continue;
                    }

                    Comment newComment = new Comment()
                    {
                        Body       = comment["data"]["body"].ToString(),
                        AuthorName = comment["data"]["author"].ToString()
                    };
                    post.Comments.Add(newComment);
                }

                return(post);
            }
            return(null);
        }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        votedPosts = new List <string>();

        textBox.text = "";

        reddit = new RedditConnector();

        postWindow.localPosition    = GetWindowPosition(postWindow, postOffX);
        commentWindow.localPosition = GetWindowPosition(commentWindow, commentOffX);
        voteWindow.localPosition    = GetWindowPosition(voteWindow, voteOffX);

        addSpot = addition.transform.localPosition;

        shownScore     = totalScore = ScoreManager.Instance.GetValidatedScore();
        scoreText.text = totalScore.ToString();

        MoveAlienLoading();

        LoadVotedPosts();

        Invoke("LoadPost", 0.25f);

        doTutorial      = !PlayerPrefs.HasKey("Tutorial");
        doComboTutorial = !PlayerPrefs.HasKey("ComboTutorial");

        //if (Application.isEditor) doTutorial = true;
        //if (Application.isEditor) doComboTutorial = true;
    }
예제 #3
0
        /// <summary>
        /// Populate post list with the top reddit posts right now
        /// </summary>
        /// <returns></returns>
        public async Task PopulatePosts(string subreddit)
        {
            JObject json = await RedditConnector.GetJSONAsync("/r/" + subreddit + ".json");

            if (json["error"] == null)
            {
                int index = 1;
                foreach (var post in json["data"]["children"])
                {
                    var  currentPost = post["data"];
                    Post newPost     = ConvertPostFromJson(currentPost);
                    redditPosts.Add(newPost);
                    index++;
                }
            }
        }