예제 #1
0
        public static void CheckIfAnyInvalidRef(GameKitConfig config)
        {
            foreach (var item in config.LifeTimeItems)
            {
                for (int i = 0; i < item.PurchaseInfo.Count; i++)
                {
                    CheckPurchase("Life-time item", item.ID, item.PurchaseInfo[i], i);
                }
                for (int i = 0; i < item.Upgrades.Count; i++)
                {
                    UpgradeItem upgrade = item.Upgrades[i];
                    for (int j = 0; j < upgrade.PurchaseInfo.Count; j++)
                    {
                        CheckPurchase(item.ID + " upgrade", upgrade.ID, upgrade.PurchaseInfo[j], j);
                    }
                }
            }
            foreach (var item in config.SingleUseItems)
            {
                for (int i = 0; i < item.PurchaseInfo.Count; i++)
                {
                    CheckPurchase("Single use item", item.ID, item.PurchaseInfo[i], i);
                }
                for (int i = 0; i < item.Upgrades.Count; i++)
                {
                    UpgradeItem upgrade = item.Upgrades[i];
                    for (int j = 0; j < upgrade.PurchaseInfo.Count; j++)
                    {
                        CheckPurchase(item.ID + " upgrade", upgrade.ID, upgrade.PurchaseInfo[j], j);
                    }
                }
            }
            foreach (var pack in config.ItemPacks)
            {
                for (int i = 0; i < pack.PackElements.Count; i++)
                {
                    PackElement element = pack.PackElements[i];

                    if (element.Item == null)
                    {
                        Debug.LogError("Pack [" + pack.ID + "]'s [" + (i + 1) + "] element item is null.");
                    }
                }
                for (int i = 0; i < pack.PurchaseInfo.Count; i++)
                {
                    CheckPurchase("Pack", pack.ID, pack.PurchaseInfo[i], i);
                }
            }
            foreach (var category in config.Categories)
            {
                List <VirtualItem> items = category.GetItems(true);
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i] == null)
                    {
                        Debug.LogError("Category [" + category.ID + "]'s [" + (i + 1) + "] item is null.");
                    }
                }
            }
        }
예제 #2
0
        private void OnInsertUpgradeItem(object sender, ItemInsertedEventArgs args)
        {
            int    upgradeIndex = args.itemIndex + 1;
            string suffix       = upgradeIndex < 10 ? "00" + upgradeIndex :
                                  upgradeIndex < 100 ? "0" + upgradeIndex : upgradeIndex.ToString();
            GenericClassListAdaptor <UpgradeItem> listAdaptor = args.adaptor as GenericClassListAdaptor <UpgradeItem>;
            UpgradeItem upgradeItem = listAdaptor[args.itemIndex];

            upgradeItem.ID            = string.Format("{0}-upgrade{1}", _currentDisplayItem.ID, suffix);
            upgradeItem.RelatedItemID = _currentDisplayItem.ID;
            GameKit.Config.Upgrades.Add(upgradeItem);
            GameKit.Config.UpdateMapsAndTree();
            (_treeExplorer as VirtualItemsTreeExplorer).OnVirtualItemUpgradesChange(_currentDisplayItem as VirtualItem);
        }
예제 #3
0
        private void OnItemInsert <T>(object sender, ItemInsertedEventArgs args) where T : SerializableItem
        {
            GenericClassListAdaptor <T> listAdaptor = args.adaptor as GenericClassListAdaptor <T>;

            if (listAdaptor != null)
            {
                if (listAdaptor[args.itemIndex] is UpgradeItem)
                {
                    int    upgradeIndex = args.itemIndex + 1;
                    string suffix       = upgradeIndex < 10 ? "00" + upgradeIndex :
                                          upgradeIndex < 100 ? "0" + upgradeIndex : upgradeIndex.ToString();
                    UpgradeItem upgradeItem = (listAdaptor[args.itemIndex] as UpgradeItem);
                    upgradeItem.RelatedItemID = (listAdaptor[0] as UpgradeItem).RelatedItemID;
                    upgradeItem.ID            = string.Format("{0}-upgrade{1}", upgradeItem.RelatedItemID, suffix);
                    GameKit.Config.Upgrades.Add(upgradeItem);
                }
                SelectItem(listAdaptor[args.itemIndex]);
                GameKitEditorWindow.GetInstance().Repaint();
            }
        }
예제 #4
0
        private void OnRemoveUpgradeItem(object sender, ItemRemovingEventArgs args)
        {
            GenericClassListAdaptor <UpgradeItem> listAdaptor = args.adaptor as GenericClassListAdaptor <UpgradeItem>;
            UpgradeItem upgradeItem = listAdaptor[args.itemIndex];

            if (listAdaptor != null)
            {
                if (EditorUtility.DisplayDialog("Confirm to delete",
                                                "Confirm to delete upgrade [" + upgradeItem.ID + "]?", "OK", "Cancel"))
                {
                    args.Cancel = false;
                    GameKit.Config.Upgrades.Remove(upgradeItem);
                    GameKit.Config.UpdateMapsAndTree();
                    (_treeExplorer as VirtualItemsTreeExplorer).OnVirtualItemUpgradesChange(_currentDisplayItem as VirtualItem);
                }
                else
                {
                    args.Cancel = true;
                }
            }
        }
예제 #5
0
 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;
                     }
                 }
             }
         }
     }
 }