예제 #1
0
    public bool HasResource(Helpers.ResourceType resourceType, int amount)
    {
        if (resourceType == Helpers.ResourceType.NONE)
        {
            return(true);
        }

        if (PlayerProfileManager.Instance.GetResourceBalance(resourceType) >= amount)
        {
            return(true);
        }
        return(false);
    }
예제 #2
0
 public bool SpendResource(Helpers.ResourceType resourceType, int amount)
 {
     if (HasResource(resourceType, amount))
     {
         //NONE is effectively free.
         if (resourceType == Helpers.ResourceType.NONE)
         {
             return(true);
         }
         return(PlayerProfileManager.Instance.SpendResources(resourceType, amount));
     }
     else
     {
         Debug.Log("Not enough " + resourceType.ToString() + " to complete purchase.");
         return(false);
     }
 }
예제 #3
0
    public bool AddResource(Helpers.ResourceType resourceType, int amount)
    {
        if (resourceType == Helpers.ResourceType.NONE)
        {
            return(true);
        }

        if (amount < 0)
        {
            Debug.LogWarning("Attempted to add negative resource amount. This is not allowed to prevent hacking");
            return(false);
        }

        if (amount == 0)
        {
            return(true);
        }

        return(PlayerProfileManager.Instance.AddResources(resourceType, amount));
    }