Ejemplo n.º 1
0
        private async Task <Outfit> Parse(JObject obj, bool fillAssets = true)
        {
            _ID   = obj.Value <int>("id");
            _Name = obj.Value <string>("name");

            _Assets = new List <Asset>();
            foreach (JToken tok in obj.Value <JArray>("assets"))
            {
                if (fillAssets)
                {
                    _Assets.Add(await Asset.FromID(tok.Value <int>("id")));
                }
                else
                {
                    _Assets.Add(new Asset(tok.Value <int>("id")));
                }
            }

            JObject bodyColors = obj.Value <JObject>("bodyColors");

            _HeadColor     = bodyColors.Value <int>("headColorId");
            _TorsoColor    = bodyColors.Value <int>("torsoColorId");
            _RightArmColor = bodyColors.Value <int>("rightArmColorId");
            _LeftArmColor  = bodyColors.Value <int>("leftArmColorId");
            _RightLegColor = bodyColors.Value <int>("rightLegColorId");
            _LeftLegColor  = bodyColors.Value <int>("leftLegColorId");

            return(this);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the place (as an asset) the <see cref="VisitorId"/> is in currently.
 /// </summary>
 /// <returns>Place asset that <see cref="VisitorId"/> is in.</returns>
 public async Task <Asset> GetPlaceAsAsset()
 {
     if (PlaceId <= 0) // Make sure the asset id is somewhat valid. (Asset IDs cannot be below 0)
     {
         return(null);
     }
     return(await Asset.FromID(PlaceId));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Searches using keywords and category. Will take a long time to search and then convert Search Results into Asset objects.
        /// </summary>
        /// <param name="keywords">Keywords for search</param>
        /// <param name="category">What category.</param>
        /// <returns>The results of the search as a async task.</returns>
        public static async Task <Asset[]> SearchAssets(string keywords, ESearchCategory category)
        {
            string url = string.Format("https://search.roblox.com/catalog/json?Category={0}&Keywords={1}", (int)category, System.Uri.EscapeDataString(keywords));

            string data = await HttpHelper.GetStringFromURL(url);

            List <SearchResult> results = JsonConvert.DeserializeObject <List <SearchResult> >(data);

            Asset[] assets = new Asset[results.Count];

            for (int i = 0; i < results.Count; i++)
            {
                assets[i] = await Asset.FromID(results[i].AssetId);
            }

            return(assets);
        }
Ejemplo n.º 4
0
        public async Task <Clan> GetClan()
        {
            string data = await HttpHelper.GetStringFromURL(string.Format("https://api.roblox.com/clans/get-by-user?userId={0}", ID));

            JObject obj = JObject.Parse(data);

            if (obj.Value <int>("Id") == 0) // User is not in a clan.
            {
                return(null);
            }

            Clan clan = new Clan();

            clan.ID = obj.Value <int>("Id");

            clan.Name = obj.Value <string>("Name");

            clan.EmblemAsset = await Asset.FromID(obj.Value <int>("EmblemAssetId"));

            return(clan);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a Clan object from a group/clan ID.
        /// </summary>
        /// <param name="clanId">The clan ID to get.</param>
        /// <returns>The clan object.</returns>
        public static async Task <Clan> FromID(int clanId)
        {
            try
            {
                string data = await HttpHelper.GetStringFromURL(string.Format("https://api.roblox.com/clans/get-by-id?clanId={0}", clanId));

                JObject obj  = JObject.Parse(data);
                Clan    clan = new Clan();
                clan.ID = clanId;

                clan.Name = obj.Value <string>("Name");

                clan.EmblemAsset = await Asset.FromID(obj.Value <int>("EmblemAssetId"));

                return(clan);
            }
            catch (WebException ex)
            {
                HttpWebResponse resp = (HttpWebResponse)ex.Response;
                return(null);
            }
        }