/// <summary>
 /// Buys a given item
 /// </summary>
 /// <param name="item"></param>
 public void BuyItem(StoreItem item)
 {
     if (CanPurchaseItem(item))
     {
         buyerWallet.Substract(item);
         OnPurchaseSuccess?.Invoke();
     }
     else
     {
         OnPurchaseFailed.Invoke();
         return;
     }
 }
 public override void Buy()
 {
     if (currency.SpendCurrency(currencyPrice))
     {
         if (OnPurchaseSucceeded != null)
         {
             OnPurchaseSucceeded.Invoke();
         }
     }
     else
     {
         if (OnPurchaseFailed != null)
         {
             OnPurchaseFailed.Invoke();
         }
     }
 }
 public void CompletePurchase()
 {
     if (currency.SpendCurrency(currencyPrice))
     {
         if (OnPurchaseSucceeded != null)
         {
             OnPurchaseSucceeded.Invoke();
         }
     }
     else
     {
         if (OnPurchaseFailed != null)
         {
             OnPurchaseFailed.Invoke();
         }
     }
 }
        /// <summary>
        /// Buys an Item based on ID
        /// </summary>
        /// <param name="ID"></param>
        public void BuyItem(int ID)
        {
            StoreItem item = items.First(x => x.Value.ItemID == ID).Value;

            if (item != null)
            {
                if (CanPurchaseItem(item))
                {
                    buyerWallet.Substract(item);
                    OnPurchaseSuccess?.Invoke();
                }
                else
                {
                    OnPurchaseFailed.Invoke();
                    return;
                }
            }
            else
            {
                return;
            }
        }
Beispiel #5
0
 public void FailPurchase(Product product, PurchaseFailureReason failureReason)
 {
     OnPurchaseFailed?.Invoke(product, failureReason);
 }