示例#1
0
        public override bool CanPurchaseNow()
        {
            VirtualItem associatedItem  = RelatedItem;
            VirtualItem nextUpgradeItem = associatedItem.NextUpgradeItem;

            return(nextUpgradeItem != null && nextUpgradeItem == this);
        }
 private void RemoveUpgradeListForItem(VirtualItem item)
 {
     if (_upgradesListAdaptors.ContainsKey(item))
     {
         _upgradesListAdaptors.Remove(item);
         _upgradesListControls.Remove(item);
     }
 }
示例#3
0
 private void TryAddToIdItemMap(string id, VirtualItem item)
 {
     if (!string.IsNullOrEmpty(id))
     {
         if (!_idToVirtualItem.ContainsKey(id))
         {
             _idToVirtualItem.Add(id, item);
         }
         else
         {
             Debug.LogWarning("Found duplicated id " + id + " for item.");;
         }
     }
 }
        private void AddUpgradeListForItem(VirtualItem item)
        {
            if (item.HasUpgrades)
            {
                ReorderableListControl listControl = new ReorderableListControl(ReorderableListFlags.DisableDuplicateCommand);
                listControl.ItemInserted += OnItemInsert <UpgradeItem>;
                listControl.ItemRemoving += OnItemRemoving <UpgradeItem>;
                UpgradeItemListAdaptor listAdaptor = new UpgradeItemListAdaptor(item.Upgrades, 20,
                                                                                () => { return(new UpgradeItem()); },
                                                                                DrawItem <UpgradeItem>);

                _upgradesListAdaptors.Add(item, listAdaptor);
                _upgradesListControls.Add(item, listControl);
            }
        }
 public void OnVirtualItemUpgradesChange(VirtualItem item)
 {
     if (item.HasUpgrades)
     {
         if (!_upgradesListAdaptors.ContainsKey(item))
         {
             AddUpgradeListForItem(item);
         }
     }
     else
     {
         if (_upgradesListAdaptors.ContainsKey(item))
         {
             RemoveUpgradeListForItem(item);
         }
     }
 }
示例#6
0
        protected override float DoDrawItem(Rect position, IItem item)
        {
            VirtualItem virtualItem = item as VirtualItem;

            if (virtualItem != null)
            {
                return(DrawVirtualItem(position, virtualItem));
            }
            else
            {
                VirtualCategory category = item as VirtualCategory;
                if (category != null)
                {
                    GUILayout.BeginArea(new Rect(position.x, position.y + 5, position.width, position.height - 10));
                    _categoryPropertyView.Draw(position, category);
                    GUILayout.EndArea();
                    return(position.height);
                }
            }
            return(0);
        }
示例#7
0
 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);
 }
示例#8
0
        private float DrawVirtualItem(Rect position, VirtualItem item)
        {
            float yOffset = 0;
            float width   = position.width;

            _isVirtualItemPropertiesExpanded = EditorGUI.Foldout(new Rect(0, 0, width, 20),
                                                                 _isVirtualItemPropertiesExpanded, "Item");
            yOffset += 20;
            if (_isVirtualItemPropertiesExpanded)
            {
                //EditorGUI.LabelField(new Rect(0, yOffset, width, 20), "Internal ID", item.InternalID);
                //yOffset += 20;
                DrawIDField(new Rect(0, yOffset, width, 20), item, !(item is UpgradeItem), true);
                yOffset         += 20;
                item.Name        = EditorGUI.TextField(new Rect(0, yOffset, width, 20), "Name", item.Name);
                yOffset         += 20;
                item.Description = EditorGUI.TextField(new Rect(0, yOffset, width, 20), "Desription", item.Description);
                yOffset         += 20;
                if (!(item is UpgradeItem))
                {
                    EditorGUI.LabelField(new Rect(0, yOffset, width, 20), "Category", item.Category == null ? "None" : item.Category.ID);
                    yOffset += 20;
                }
                item.Icon   = EditorGUI.ObjectField(new Rect(0, yOffset, width, 50), "Icon", item.Icon, typeof(Texture2D), false) as Texture2D;
                yOffset    += 55;
                item.Extend = EditorGUI.ObjectField(new Rect(0, yOffset, width, 20), "Extend",
                                                    item.Extend, typeof(ScriptableObject), false) as ScriptableObject;
                yOffset += 20;
            }

            if (item is LifeTimeItem)
            {
                yOffset += 20;
                LifeTimeItem lifetimeItem = item as LifeTimeItem;
                lifetimeItem.IsEquippable = EditorGUI.Toggle(new Rect(0, yOffset, width, 20), "Is Equippable", lifetimeItem.IsEquippable);
                yOffset += 20;
            }
            else if (item is VirtualItemPack)
            {
                yOffset            += 20;
                _isPackInfoExpanded = EditorGUI.Foldout(new Rect(0, yOffset, width, 20), _isPackInfoExpanded, "Pack Info");
                yOffset            += 20;
                if (_isPackInfoExpanded)
                {
                    _packListView.Draw(new Rect(0, yOffset, width, 100));
                    yOffset += 100;
                }
            }
            if (item is PurchasableItem)
            {
                yOffset += 20;
                _isPurchaseInfoExpanded = EditorGUI.Foldout(new Rect(0, yOffset, width, 20), _isPurchaseInfoExpanded, "Purchase Info");
                yOffset += 20;
                if (_isPurchaseInfoExpanded)
                {
                    _purchaseListView.Draw(new Rect(0, yOffset, width, 100));
                    yOffset += 100;
                }
            }
            if (item is SingleUseItem || item is LifeTimeItem)
            {
                yOffset += 20;
                _isUpgradeInfoExpanded = EditorGUI.Foldout(new Rect(0, yOffset, width, 20),
                                                           _isUpgradeInfoExpanded, "Upgrade Info (" + item.Upgrades.Count + " levels)");
                yOffset += 20;
                if (_isUpgradeInfoExpanded)
                {
                    float height = _upgradeListControl.CalculateListHeight(_upgradeListAdaptor);
                    _upgradeListControl.Draw(new Rect(0, yOffset, width, height), _upgradeListAdaptor);
                    yOffset += height;
                }
            }
            if (item is UpgradeItem)
            {
                yOffset += 20;
                VirtualItem relatedItem = (item as UpgradeItem).RelatedItem;
                EditorGUI.LabelField(new Rect(0, yOffset, 250, 20), "Related Item",
                                     relatedItem == null ? "NULL" : relatedItem.ID);
                if (GUI.Button(new Rect(255, yOffset, 50, 20), "Edit"))
                {
                    _treeExplorer.SelectItem(relatedItem);
                }
                yOffset += 20;
            }
            return(yOffset);
        }
示例#9
0
 public bool TryGetVirtualItemByID(string id, out VirtualItem item)
 {
     return(IdToVirtualItem.TryGetValue(id, out item));
 }