public virtual void onStoreThirdPartyPurchaseSuccess(GameStorePurchaseRecord data) { LogUtil.Log("onStoreThirdPartyPurchaseSuccess"); if (data != null) { LogUtil.Log("onStoreThirdPartyPurchaseSuccess: data.messageTitle:" + data.messageTitle); UINotificationDisplay.QueueInfo(data.messageTitle, data.messageDescription); } GameProduct product = GameProducts.Instance.GetProductByPlaformProductCode(data.productId); if (product == null) { return; } GameStorePurchaseDataItem itemPurchasing = GetItemPurchasing(product.code); if (itemPurchasing != null) { LogUtil.Log("onStoreThirdPartyPurchaseSuccess: itemPurchasing.product:" + itemPurchasing.product.code); if (product.type == GameProductType.currency) { GameStoreController.HandleCurrencyPurchase(itemPurchasing.product, itemPurchasing.quantity); } else if (product.type == GameProductType.access) { GameStoreController.HandleAccessPurchase(itemPurchasing.product, itemPurchasing.quantity); } ResetPurchase(itemPurchasing.product.code); } }
public override void OnButtonClickEventHandler(string buttonName) { if (UIUtil.IsButtonClicked(buttonBuyRecharge, buttonName)) { GameStoreController.Purchase("rpg-recharge-full-1", 1); } else if (UIUtil.IsButtonClicked(buttonEarn, buttonName)) { GameController.QuitGame(); GameUIController.ShowGameMode(); } else if (UIUtil.IsButtonClicked(buttonResume, buttonName)) { HideAll(); GameController.ResumeGame(); } }
public virtual void purchase(GameStorePurchaseData data) { foreach (GameStorePurchaseDataItem item in data.items) { if (item.product != null) { if (IsPurchasing(item.product.code)) { return; } SetItemPurchasing(item.product.code, item); if (item.product.type == GameProductType.currency || item.product.type == GameProductType.access) { // do third party process and event GameStoreController.PurchaseThirdParty(item.product, item.quantity); } else { // do local or server process and event if (checkIfCanPurchase(item.product)) // has the money { GameStoreController.HandlePurchase(item.product, item.quantity); } else { GameStoreController.BroadcastPurchaseFailed( GameStorePurchaseRecord.Create(false, data, "", "Purchase Unsuccessful", "Not enough coins to purchase. Earn more coins by playing or training.", item.product.code, item.quantity)); } } } // TODO handle multiple events, for now only purchase one at a time... break; } }
public virtual void handlePurchase(GameProduct gameProduct, double quantity) { // HANDLE ACCOUNTING double currentCurrency = GameProfileRPGs.Current.GetCurrency(); double productCost = double.Parse(gameProduct.GetDefaultProductInfoByLocale().cost); // TODO quantity... if (currentCurrency > productCost) { // can buy GameProfileRPGs.Current.SubtractCurrency(productCost); // HANDLE INVENTORY GameStoreController.HandleInventory(gameProduct, quantity); } }
public void onProductPurchaseCancelled(ProductNetworkRecord record) { LogUtil.Log("onProductPurchaseSuccess:" + " record:" + record.ToJson()); if (record == null) { LogUtil.Log("record not found"); return; } GameProduct product = GameProducts.Instance.GetProductByPlaformProductCode(record.productId); if (product == null) { LogUtil.Log("Product not found:" + record.productId); return; } GameStorePurchaseDataItem itemPurchasing = GetItemPurchasing(product.code); if (itemPurchasing == null) { LogUtil.Log("itemPurchasing not found:" + product.code); LogUtil.Log("itemsPurchasing:" + itemsPurchasing.ToJson()); } if (itemPurchasing != null) { GameStorePurchaseRecord data = GameStorePurchaseRecord.Create( false, record.data, record.receipt, "Purchase CANCELLED:" + itemPurchasing.product.GetCurrentProductInfoByLocale().display_name, itemPurchasing.product.GetCurrentProductInfoByLocale().description, product.code, record.quantity); GameStoreController.BroadcastThirdPartyPurchaseCancelled(data); } }
public virtual void handleInventory(GameProduct gameProduct, double quantity) { //string message = "Enjoy your new purchase."; bool doPurchase = false; if (gameProduct.type == GameProductType.rpgUpgrade) { // Add upgrades double val = gameProduct.GetDefaultProductInfoByLocale().quantity; GameProfileRPGs.Current.AddUpgrades(val); doPurchase = true; //message = "Advance your character with your upgrades and get to top of the game"; } else if (gameProduct.type == GameProductType.powerup) { // Add upgrades if (gameProduct.code.Contains("rpg-recharge-full")) { GameProfileCharacters.Current.CurrentCharacterAddGamePlayerProgressEnergyAndHealth(1f, 1f); //message = "Recharging your health + energy..."; doPurchase = true; } else if (gameProduct.code.Contains("rpg-recharge-health")) { GameProfileCharacters.Current.CurrentCharacterAddGamePlayerProgressHealth(1f); //message = "Recharging your health..."; doPurchase = true; } else if (gameProduct.code.Contains("rpg-recharge-energy")) { GameProfileCharacters.Current.CurrentCharacterAddGamePlayerProgressEnergy(1f); //message = "Recharging your health..."; doPurchase = true; } } else if (gameProduct.type == GameProductType.currency) { // Add skraight cash moneh GameStoreController.HandleCurrencyPurchase(gameProduct, quantity); doPurchase = true; } else if (gameProduct.type == GameProductType.access) { // Add skraight cash moneh GameStoreController.HandleAccessPurchase(gameProduct, quantity); doPurchase = true; } else if (gameProduct.type == GameProductType.characterSkin) { // TODO lookup skin and apply /* * GameCharacterSkin skin = GameCharacterSkins.Instance.GetById(productCodeUse); * GameCharacterSkinItemRPG rpg = skin.GetGameCharacterSkinByData(productCharacterUse, weaponType); * if(rpg != null) { * GameProfileCharacters.Current.SetCurrentCharacterCostumeCode(rpg.prefab); * } */ doPurchase = true; } else { // trigger purchased and rewards from the product items handleGameProductItems(gameProduct); doPurchase = true; } if (doPurchase) { GameStoreController.BroadcastPurchaseSuccess( GameStorePurchaseRecord.Create(true, gameProduct, "", "Purchase Successful:" + gameProduct.GetCurrentProductInfoByLocale().display_name, gameProduct.GetCurrentProductInfoByLocale().description, gameProduct.code, quantity)); } }
public virtual void purchase(string productId, double quantity) { GameStoreController.Purchase( GameStorePurchaseData.PurchaseData(productId, quantity)); }