public PurchaseInfoListView(PurchasableItem item) { _listControl = new ReorderableListControl(ReorderableListFlags.DisableDuplicateCommand | ReorderableListFlags.ShowIndices); _listControl.ItemInserted += OnItemInsert; _listControl.ItemRemoving += OnItemRemoving; _purchasePopupDrawers = new List <ItemPopupDrawer>(); UpdatePurchasePopupDrawers(); }
public void UpdateDisplayItem(PurchasableItem item) { _currentPurchasableItem = item; if (item != null) { _listAdaptor = new GenericClassListAdaptor <Purchase>(item.PurchaseInfo, 18, CreatePurchase, DrawOnePurchase); UpdatePurchasePopupDrawers(); } }
public PurchaseError Execute(PurchasableItem purchasable) { if (Type == PurchaseType.PurchaseWithVirtualCurrency) { return(BuyWithVirtualCurrency(purchasable)); } else { return(BuyWithMarket(purchasable)); } }
private PurchaseError BuyWithVirtualCurrency(PurchasableItem item) { int priceInVirtualCurrency = (int)Price; int balance = VirtualCurrency.Balance; if (balance < priceInVirtualCurrency) { return(PurchaseError.InsufficientVirtualCurrency); } else { VirtualCurrency.Take(priceInVirtualCurrency); item.Give(1); item.OnPurchased(); return(PurchaseError.None); } }
public static MarketProduct TryCreateMarketProductFromVirtualItem(VirtualItem item) { if (item is PurchasableItem) { PurchasableItem purchasableItem = item as PurchasableItem; foreach (Purchase purchase in purchasableItem.PurchaseInfo) { if (purchase.IsMarketPurchase) { MarketProduct product = new MarketProduct(); product.ProductIdentifier = purchase.MarketID; product.Title = item.Name; product.Price = purchase.Price.ToString(); product.Description = item.Description; product.CurrencySymbol = "¥"; product.CurrencyCode = "RMB"; product.FormattedPrice = string.Format("{0}{1}.00", product.CurrencySymbol, product.Price); return(product); } } } return(null); }
private void UpdateRelatedIDOfItems(IItem[] items, string oldID, string newID) { foreach (var item in items) { if (item is Gate) { Gate gate = item as Gate; if (gate.RelatedItemID.Equals(oldID)) { gate.RelatedItemID = newID; } } else if (item is UpgradeItem) { UpgradeItem upgrade = item as UpgradeItem; if (upgrade.RelatedItemID.Equals(oldID)) { upgrade.RelatedItemID = newID; upgrade.ID = upgrade.ID.Replace(oldID, newID); } } else if (item is Reward) { Reward reward = item as Reward; if (reward.RelatedItemID.Equals(oldID)) { reward.RelatedItemID = newID; } } else if (item is Score) { Score score = item as Score; if (score.RelatedVirtualItemID.Equals(oldID)) { score.RelatedVirtualItemID = newID; } } else if (item is VirtualCategory) { VirtualCategory category = item as VirtualCategory; for (int i = 0; i < category.ItemIDs.Count; i++) { if (category.ItemIDs[i].Equals(oldID)) { category.ItemIDs[i] = newID; } } } else if (item is VirtualItem) { if (item is PurchasableItem) { PurchasableItem purchsable = item as PurchasableItem; for (int i = 0; i < purchsable.PurchaseInfo.Count; i++) { if (!purchsable.PurchaseInfo[i].IsMarketPurchase && purchsable.PurchaseInfo[i].VirtualCurrencyID.Equals(oldID)) { purchsable.PurchaseInfo[i].VirtualCurrencyID = newID; } } } if (item is VirtualItemPack) { VirtualItemPack pack = item as VirtualItemPack; for (int i = 0; i < pack.PackElements.Count; i++) { if (pack.PackElements[i].ItemID.Equals(oldID)) { pack.PackElements[i].ItemID = newID; } } } } } }
public override IItem[] GetAffectedItems(string itemID) { List <IItem> items = new List <IItem>(); //check item id in upgradeItem foreach (var item in GameKit.Config.Upgrades) { if (item.RelatedItemID.Equals(itemID)) { items.Add(item); } } // check virtual currency id in purchase foreach (var item in GameKit.Config.VirtualItems) { if (item is PurchasableItem) { PurchasableItem purchasableItem = item as PurchasableItem; foreach (var purchase in purchasableItem.PurchaseInfo) { if (!purchase.IsMarketPurchase && purchase.VirtualCurrencyID.Equals(itemID)) { items.Add(purchasableItem); break; } } } } // check item id in pack foreach (var pack in GameKit.Config.ItemPacks) { foreach (var packElement in pack.PackElements) { if (packElement.ItemID.Equals(itemID)) { items.Add(pack); break; } } } // check item id in category foreach (var category in GameKit.Config.Categories) { foreach (var id in category.ItemIDs) { if (id.Equals(itemID)) { items.Add(category); break; } } } // check gates && scores & mission/rewards foreach (var world in GameKit.Config.Worlds) { if (world.Gate.IsGroup) { foreach (var subGateID in world.Gate.SubGatesID) { Gate subGate = GameKit.Config.GetSubGateByID(subGateID); if ((subGate.Type == GateType.VirtualItemGate || subGate.Type == GateType.PurchasableGate) && subGate.RelatedItemID.Equals(itemID)) { items.Add(subGate); } } } else if ((world.Gate.Type == GateType.VirtualItemGate || world.Gate.Type == GateType.PurchasableGate) && world.Gate.RelatedItemID.Equals(itemID)) { items.Add(world.Gate); } foreach (var score in world.Scores) { if (score.IsVirtualItemScore && score.RelatedVirtualItemID.Equals(itemID)) { items.Add(score); } } foreach (var mission in world.Missions) { foreach (var reward in mission.Rewards) { if (reward.Type == RewardType.VirtualItemReward && reward.RelatedItemID.Equals(itemID)) { items.Add(reward); } } } } return(items.ToArray()); }
private PurchaseError BuyWithMarket(PurchasableItem item) { _currentItemPurchasedWithMarket = item; return(Market.Instance.StartPurchase(MarketID, 1, OnMarketPurchaseSucceeded, OnMarketPurchaseFailed)); }