Example #1
0
        public static void Get(int id, Action <Objects.Trophy> callback)
        {
            if (cachedTrophies != null)
            {
                if (callback != null)
                {
                    callback(cachedTrophies.Values.Where(t => t.ID == id).FirstOrDefault());
                }
            }
            else
            {
                var parameters = new Dictionary <string, string>();
                parameters.Add("trophy_id", id.ToString());

                Core.Request.Get(Constants.API_TROPHIES_FETCH, parameters, (Core.Response response) => {
                    Objects.Trophy trophy;
                    if (response.success)
                    {
                        trophy = new Objects.Trophy(response.json["trophies"][0].AsObject);
                    }
                    else
                    {
                        trophy = null;
                    }

                    if (callback != null)
                    {
                        callback(trophy);
                    }
                });
            }
        }
Example #2
0
        static void Get(Dictionary <string, string> parameters, Action <Objects.Trophy[]> callback)
        {
            Core.Request.Get(Constants.API_TROPHIES_FETCH, parameters, (Core.Response response) => {
                Objects.Trophy[] trophies;
                if (response.success)
                {
                    int count = response.json["trophies"].AsArray.Count;
                    trophies  = new Objects.Trophy[count];

                    for (int i = 0; i < count; ++i)
                    {
                        trophies[i] = new Objects.Trophy(response.json["trophies"][i].AsObject);
                    }
                }
                else
                {
                    trophies = null;
                }

                if (callback != null)
                {
                    callback(trophies);
                }
            });
        }
Example #3
0
 static void ShowNotification(Objects.Trophy trophy)
 {
     if (trophy.Unlocked)
     {
         GameJolt.UI.Manager.Instance.QueueNotification(
             string.Format("Unlocked <b>#{0}</b>", trophy.Title),
             trophy.Image);
     }
 }
Example #4
0
 public static void Unlock(Objects.Trophy trophy, Action <bool> callback = null)
 {
     Unlock(trophy.ID, callback);
 }
Example #5
0
		public static void Get(int id, Action<Objects.Trophy> callback)
		{
			if (cachedTrophies != null)
			{
				if (callback != null)
				{
					callback(cachedTrophies.Values.Where(t => t.ID == id).FirstOrDefault());
				}
			}
			else
			{
				var parameters = new Dictionary<string, string>();
				parameters.Add("trophy_id", id.ToString());

				Core.Request.Get(Constants.API_TROPHIES_FETCH, parameters, (Core.Response response) => {
					Objects.Trophy trophy;
					if (response.success)
					{
						trophy = new Objects.Trophy(response.json["trophies"][0].AsObject);
					}
					else
					{
						trophy = null;
					}

					if (callback != null)
					{
						callback(trophy);
					}
				});
			}
		}
Example #6
0
		static void Get(Dictionary<string, string> parameters, Action<Objects.Trophy[]> callback)
		{
			Core.Request.Get(Constants.API_TROPHIES_FETCH, parameters, (Core.Response response) => {
				Objects.Trophy[] trophies;
				if (response.success)
				{
					int count = response.json["trophies"].AsArray.Count;
					trophies = new Objects.Trophy[count];
					
					for(int i = 0; i < count; ++i)
					{
						trophies[i] = new Objects.Trophy(response.json["trophies"][i].AsObject);
					}
				}
				else
				{
					trophies = null;
				}
				
				if (callback != null)
				{
					callback(trophies);
				}
			});
		}