You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Diagnostics;
- using CIGEnums;
- using SUISS.Core;
- using SUISSEngine;
- using UnityEngine;
-
- namespace CIG
- {
- public class IAPShopProductConsumer : IProductConsumer
- {
- //[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- public event IAPShopProductConsumer.ProductConsumedEventHandler ProductConsumedEvent;
-
- public bool ConsumeProduct(CIG3StoreProduct product)
- {
- switch (product.Category)
- {
- case StoreProductCategory.Shop:
- case StoreProductCategory.ShopSale:
- {
- Currencies currencies = product.Currencies;
- CIGGameState instance = SingletonMonobehaviour<CIGGameState>.Instance;
- if (!(instance != null))
- {
- return false;
- }
- instance.GiveCurrencies(currencies);
- instance.CountBoughtGoldPackageIfApplicable(currencies);
- break;
- }
- case StoreProductCategory.Packs:
- {
- IAPPack iappack = IAPPackManager.Instance.CreatePack(product.GameProductName);
- if (iappack == null)
- {
- return false;
- }
- iappack.ApplyEffects();
- break;
- }
- case StoreProductCategory.Cranes:
- {
- CIGBuilderManager instanceIfAvailable = SingletonMonobehaviour<CIGBuilderManager>.InstanceIfAvailable;
- if (!(instanceIfAvailable != null))
- {
- return false;
- }
- instanceIfAvailable.AddCrane(true);
- break;
- }
- default:
- UnityEngine.Debug.LogErrorFormat("Missing product consumer for product category '{0}'", new object[]
- {
- product.Category
- });
- return false;
- }
- return true;
- }
-
- public void FireProductConsumedEvent(CIG3StoreProduct product)
- {
- if (this.ProductConsumedEvent != null)
- {
- this.ProductConsumedEvent(product);
- }
- }
-
- public delegate void ProductConsumedEventHandler(CIG3StoreProduct product);
- }
- }
|