示例#1
0
 private void UpdateResource(ResourceResponse response)
 {
     if (response.ActorId == SUGARManager.CurrentUser?.Id)
     {
         if (response.GameId == Platform.GlobalGameId)
         {
             if (GlobalUserResources.ContainsKey(response.Key))
             {
                 GlobalUserResources[response.Key] = response.Quantity;
             }
             else
             {
                 GlobalUserResources.Add(response.Key, response.Quantity);
             }
         }
         else
         {
             if (UserGameResources.ContainsKey(response.Key))
             {
                 UserGameResources[response.Key] = response.Quantity;
             }
             else
             {
                 UserGameResources.Add(response.Key, response.Quantity);
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// Get the current resource amount for the current user from the local cache. Cache is updated at the rate set in the Inspector.
 /// </summary>
 /// <param name="key">Resource key value is being gathered for</param>
 /// <param name="globalResource">**Optional** Get value for a global resource rather than one for this game. (default: false)</param>
 /// <remarks>
 /// - If globalResource is true, resource will be global rather than for the game.
 /// </remarks>
 public long GetFromCache(string key, bool globalResource = false)
 {
     if (globalResource)
     {
         GlobalUserResources.TryGetValue(key, out var value);
         return(value);
     }
     else
     {
         UserGameResources.TryGetValue(key, out var value);
         return(value);
     }
 }
示例#3
0
 internal void ResetClient()
 {
     UserGameResources.Clear();
     GlobalUserResources.Clear();
 }