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;
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        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());
        }
Exemple #3
0
 public float CalculateHeight(Gate gate)
 {
     return(DrawGate(gate, 0, true));
 }
Exemple #4
0
        private float DrawGate(Gate gate, float width, bool calculateHeight)
        {
            float yOffset = 0;

            if (!calculateHeight)
            {
                if (_allowSubgates)
                {
                    GateType newType = (GateType)EditorGUI.EnumPopup(new Rect(0, yOffset, width, 20), "Type", gate.Type);
                    if (newType != gate.Type)
                    {
                        gate.Type = newType;
                        UpdateItemPopupDrawer(gate.Type);
                    }
                }
                else
                {
                    GateType newType = (GateType)EditorGUI.EnumPopup(new Rect(0, yOffset, width, 20), "Type", (SubGateType)gate.Type);
                    if (newType != gate.Type)
                    {
                        gate.Type = newType;
                        UpdateItemPopupDrawer(gate.Type);
                    }
                }
            }
            yOffset += 20;

            if (gate.Type != GateType.None)
            {
                if (!calculateHeight)
                {
                    EditorGUI.LabelField(new Rect(0, yOffset, width, 20), new GUIContent("ID"), new GUIContent(gate.ID));
                }
                yOffset += 20;
            }

            if (_itemPopupDrawer != null)
            {
                if (!calculateHeight)
                {
                    gate.RelatedItemID = _itemPopupDrawer.Draw(new Rect(0, yOffset, width, 20),
                                                               gate.RelatedItemID, new GUIContent(_itemPopupLabel));
                }
                yOffset += 20;
            }
            if (gate.Type == GateType.ScoreGate)
            {
                if (!calculateHeight)
                {
                    Score score = gate.RelatedItem as Score;
                    if (score != null && score.EnableClamp)
                    {
                        gate.RelatedNumber = EditorGUI.Slider(new Rect(0, yOffset, width, 20),
                                                              "Required Score", gate.RelatedNumber, score.Min, score.Max);
                    }
                    else
                    {
                        gate.RelatedNumber = EditorGUI.FloatField(new Rect(0, yOffset, width, 20),
                                                                  "Required Score", gate.RelatedNumber);
                    }
                }
                yOffset += 20;
            }
            else if (gate.Type == GateType.VirtualItemGate)
            {
                if (!calculateHeight)
                {
                    gate.RelatedNumber = Mathf.Max(0,
                                                   (float)EditorGUI.IntField(new Rect(0, yOffset, width, 20),
                                                                             "Required Balance", (int)gate.RelatedNumber));
                }
                yOffset += 20;
            }
            else if (gate.Type == GateType.GateListAnd || gate.Type == GateType.GateListOr)
            {
                if (!calculateHeight)
                {
                    EditorGUI.LabelField(new Rect(0, yOffset, width, yOffset), "Sub Gates");
                }
                yOffset += 20;
                float height = _subGateListControl.CalculateListHeight(_subGateListAdaptor);
                if (!calculateHeight)
                {
                    _subGateListControl.Draw(new Rect(0, yOffset, width, height), _subGateListAdaptor);
                }
                yOffset += height;
            }

            return(yOffset);
        }
 public NullableGateDelegate(Gate gate)
     : base(gate)
 {
 }