Exemple #1
0
    private void InitObjects()
    {
        newGood = new ZFGood();

        goods             = new List <ZFGood> ();
        singleUseGoodsIDs = new List <string> ();

        newCurrency      = new ZFCurrency();
        newCurrency.name = "Currency Name";

        currencies      = new List <ZFCurrency> ();
        newCurrencyPack = new ZFCurrencyPack();
        currencyPacks   = new List <ZFCurrencyPack> ();
        newCategory     = new ZFCategory();
        categories      = new List <ZFCategory> ();
    }
Exemple #2
0
    public bool areUniqueGoods()
    {
        for (int i = 0; i < this.goods.Count; i++)
        {
            ZFGood good1 = this.goods[i];

            for (int j = 0; j < this.goods.Count; j++)
            {
                ZFGood good2 = this.goods[j];
                if (good1.ID == good2.ID && i != j)
                {
                    rememberSameItems("Goods", good1.name, good2.name);
                    return(false);
                }
            }
        }
        return(true);
    }
	public void ParseJSONObject(JSONObject json)
	{
		JSONObject jsonCurrencies = json.GetField ("currencies");
		JSONObject jsonGoods = json.GetField ("goods");
		JSONObject jsonCurrencyPacks = json.GetField ("currencyPacks");
		if (jsonCurrencies.IsNull == false) 
		{
			foreach(JSONObject jsonCurrency in jsonCurrencies.list)
			{
				ZFCurrency currency = new ZFCurrency();
				currency.fromJSONObject(jsonCurrency);
				currencies.Add(currency);
			}
		}
		if (jsonGoods.IsNull == false) 
		{
			JSONObject jsonEquippableVGs = jsonGoods.GetField("equippable");
			JSONObject jsonLifetimeVGs = jsonGoods.GetField("lifetime");
			JSONObject jsonSingleUsePackVGs = jsonGoods.GetField("goodPacks");
			JSONObject jsonSingleUseVGs = jsonGoods.GetField("singleUse");
			JSONObject jsonUpgradeVGs = jsonGoods.GetField("goodUpgrades");
			
			foreach(JSONObject jsonEquippableVG in jsonEquippableVGs.list)
			{
				ZFGood good = new ZFGood();
				good.fromJSONObject(jsonEquippableVG);
				good.goodType = ZFGood.GoodType.EquippableVG;
				goods.Add(good);
			}
			
			foreach(JSONObject jsonLifetimeVG in jsonLifetimeVGs.list)
			{
				ZFGood good = new ZFGood();
				good.fromJSONObject(jsonLifetimeVG);
				good.goodType = ZFGood.GoodType.LifetimeVG;
				goods.Add(good);
			}
			
			foreach(JSONObject jsonSingleUsePackVG in jsonSingleUsePackVGs.list)
			{
				ZFGood good = new ZFGood();
				good.goodType = ZFGood.GoodType.SingleUsePackVG;
				good.fromJSONObject(jsonSingleUsePackVG);
				goods.Add(good);
			}
			
			foreach(JSONObject jsonSingleUseVG in jsonSingleUseVGs.list)
			{
				ZFGood good = new ZFGood();
				good.fromJSONObject(jsonSingleUseVG);
				good.goodType = ZFGood.GoodType.SingleUseVG;
				goods.Add(good);
			}
			
			foreach(JSONObject jsonUpgradeVG in jsonUpgradeVGs.list)
			{
				ZFGood good = new ZFGood();
				good.fromJSONObject(jsonUpgradeVG);
				good.goodType = ZFGood.GoodType.UpgradeVG;
				goods.Add(good);
			}
		}
		
		if (jsonCurrencyPacks.IsNull == false)
		{
			foreach(JSONObject jsonCurrencyPack in jsonCurrencyPacks.list)
			{
				ZFCurrencyPack currencyPack = new ZFCurrencyPack();
				currencyPack.fromJSONObject(jsonCurrencyPack);
				currencyPacks.Add(currencyPack);
			}
		}
	}
	public void DeleteGood(ZFGood good)
	{
		for ( int i = 0; i < goods.Count; i++)
		{
			if (goods[i].goodType == ZFGood.GoodType.SingleUsePackVG && goods[i].good_itemId == good.ID)
			{
				goods.Remove(goods[i]);
			}
		}
		goods.Remove (good);
	}
	public void AddGood(ZFGood.GoodType goodType) {
		ZFGood good = new ZFGood(newGood);
		good.goodType = goodType;
		int goodItemNumber = goods.Count + 1;
		good.ID = "item_" + goodItemNumber;
		goods.Add(good);
		while (!areUniqueGoods()) {
			goodItemNumber++;
			good.ID = "item_" + goodItemNumber;
		}
	}
	private void InitObjects()	
	{
		newGood = new ZFGood();

		goods = new List<ZFGood> ();
		singleUseGoodsIDs = new List<string> ();

		newCurrency = new ZFCurrency ();
		newCurrency.name = "Currency Name";
        
        currencies = new List<ZFCurrency> ();
		newCurrencyPack = new ZFCurrencyPack ();
		currencyPacks = new List<ZFCurrencyPack> ();
		newCategory = new ZFCategory ();
		categories = new List<ZFCategory> ();
	}
	public ZFGood(ZFGood goodInfo)
	{
		this.ID = goodInfo.ID;
		this.name = goodInfo.name;
		this.description = goodInfo.description;
		this.typePurchase = goodInfo.typePurchase;
		this.marketInfo = new MarketInfo(goodInfo.marketInfo);
		this.virtualInfo = new VirtualInfo(goodInfo.virtualInfo);
		this.goodType = goodInfo.goodType;
	}
Exemple #8
0
    public void ParseJSONObject(JSONObject json)
    {
        JSONObject jsonCurrencies    = json.GetField("currencies");
        JSONObject jsonGoods         = json.GetField("goods");
        JSONObject jsonCurrencyPacks = json.GetField("currencyPacks");

        if (jsonCurrencies.IsNull == false)
        {
            foreach (JSONObject jsonCurrency in jsonCurrencies.list)
            {
                ZFCurrency currency = new ZFCurrency();
                currency.fromJSONObject(jsonCurrency);
                currencies.Add(currency);
            }
        }
        if (jsonGoods.IsNull == false)
        {
            JSONObject jsonEquippableVGs    = jsonGoods.GetField("equippable");
            JSONObject jsonLifetimeVGs      = jsonGoods.GetField("lifetime");
            JSONObject jsonSingleUsePackVGs = jsonGoods.GetField("goodPacks");
            JSONObject jsonSingleUseVGs     = jsonGoods.GetField("singleUse");
            JSONObject jsonUpgradeVGs       = jsonGoods.GetField("goodUpgrades");

            foreach (JSONObject jsonEquippableVG in jsonEquippableVGs.list)
            {
                ZFGood good = new ZFGood();
                good.fromJSONObject(jsonEquippableVG);
                good.goodType = ZFGood.GoodType.EquippableVG;
                goods.Add(good);
            }

            foreach (JSONObject jsonLifetimeVG in jsonLifetimeVGs.list)
            {
                ZFGood good = new ZFGood();
                good.fromJSONObject(jsonLifetimeVG);
                good.goodType = ZFGood.GoodType.LifetimeVG;
                goods.Add(good);
            }

            foreach (JSONObject jsonSingleUsePackVG in jsonSingleUsePackVGs.list)
            {
                ZFGood good = new ZFGood();
                good.goodType = ZFGood.GoodType.SingleUsePackVG;
                good.fromJSONObject(jsonSingleUsePackVG);
                goods.Add(good);
            }

            foreach (JSONObject jsonSingleUseVG in jsonSingleUseVGs.list)
            {
                ZFGood good = new ZFGood();
                good.fromJSONObject(jsonSingleUseVG);
                good.goodType = ZFGood.GoodType.SingleUseVG;
                goods.Add(good);
            }

            foreach (JSONObject jsonUpgradeVG in jsonUpgradeVGs.list)
            {
                ZFGood good = new ZFGood();
                good.fromJSONObject(jsonUpgradeVG);
                good.goodType = ZFGood.GoodType.UpgradeVG;
                goods.Add(good);
            }
        }

        if (jsonCurrencyPacks.IsNull == false)
        {
            foreach (JSONObject jsonCurrencyPack in jsonCurrencyPacks.list)
            {
                ZFCurrencyPack currencyPack = new ZFCurrencyPack();
                currencyPack.fromJSONObject(jsonCurrencyPack);
                currencyPacks.Add(currencyPack);
            }
        }
    }
Exemple #9
0
    void ShowGood(int goodIndex)
    {
        ZFGood good = editorData.goods [goodIndex];

        EditorGUILayout.BeginHorizontal();

        good.render = EditorGUILayout.Foldout(good.render, "<" + good.name + "> (" + good.goodType + ")");

        if (goodIndex != 0)
        {
            GUIContent btnMoveUp = new GUIContent(char.ConvertFromUtf32(8593), "Move Up");
            if (GUILayout.Button(btnMoveUp, EditorStyles.miniButton, GUILayout.Width(20f)))
            {
                editorData.goods[goodIndex]     = editorData.goods[goodIndex - 1];
                editorData.goods[goodIndex - 1] = good;
            }
        }

        if (goodIndex != editorData.goods.Count - 1)
        {
            GUIContent btnMoveDown = new GUIContent(char.ConvertFromUtf32(8595), "Move Down");
            if (GUILayout.Button(btnMoveDown, EditorStyles.miniButton, GUILayout.Width(20f)))
            {
                editorData.goods[goodIndex]     = editorData.goods[goodIndex + 1];
                editorData.goods[goodIndex + 1] = good;
            }
        }

        GUIContent deleteButtonContent = new GUIContent("X", "Delete");

        if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButton, GUILayout.Width(20)))
        {
            editorData.DeleteGood(good);
        }

        EditorGUILayout.EndHorizontal();

        if (good.render)
        {
            EditorGUI.indentLevel++;
            good.ID           = EditorGUILayout.TextField("Item ID ", good.ID);
            good.name         = EditorGUILayout.TextField("Name", good.name);
            good.name         = Regex.Replace(good.name, "\n", "");
            good.description  = EditorGUILayout.TextField("Description", good.description);
            good.description  = Regex.Replace(good.description, "\n", "");
            good.typePurchase = (ZFGood.PurchaseInfo)EditorGUILayout.EnumPopup("Purchase With", good.typePurchase);
            EditorGUI.indentLevel++;
            if (good.typePurchase == ZFGood.PurchaseInfo.Market)
            {
                good.marketInfo.price = EditorGUILayout.FloatField("Price", good.marketInfo.price);

                good.marketInfo.productId = EditorGUILayout.TextField("Product ID", good.marketInfo.productId);
            }
            else
            {
                if (editorData.currencies.Count > 0)
                {
                    good.virtualInfo.pvi_amount = EditorGUILayout.IntField("Price", good.virtualInfo.pvi_amount);

                    int           indexInArray  = 0;
                    List <string> currencyNames = new List <string>();
                    for (int i = 0; i < editorData.currencies.Count; i++)
                    {
                        currencyNames.Add(editorData.currencies[i].name);
                        if (good.virtualInfo.pvi_itemId == null)
                        {
                            indexInArray = 0;
                        }
                        else if (editorData.currencies[i].ID == good.virtualInfo.pvi_itemId)
                        {
                            indexInArray = i;
                        }
                    }

                    int index = EditorGUILayout.Popup("Item", indexInArray, currencyNames.ToArray());
                    good.virtualInfo.pvi_itemId = editorData.currencies[index].ID;
                }
                else
                {
                    EditorGUILayout.HelpBox("You have no defined currencies", MessageType.Warning, true);
                }
            }
            EditorGUI.indentLevel--;

            if (good.goodType == ZFGood.GoodType.SingleUsePackVG)
            {
                editorData.updateSingleUseItems();
                if (editorData.singleUseGoodsIDs.Count > 0)
                {
                    int indexInArray = 0;
                    if (editorData.singleUseGoodsIDs.Count != 0)
                    {
                        for (int i = 0; i < editorData.singleUseGoodsIDs.Count; i++)
                        {
                            if (editorData.singleUseGoodsIDs[i] == good.good_itemId)
                            {
                                indexInArray = i;
                            }
                        }
                    }
                    int index = EditorGUILayout.Popup("Single Use Item", indexInArray, editorData.singleUseGoodsIDs.ToArray());
                    good.good_itemId = editorData.singleUseGoodsIDs[index];

                    EditorGUI.indentLevel++;
                    good.good_amount = EditorGUILayout.IntField("Amount", good.good_amount);
                    EditorGUI.indentLevel--;
                }
                else
                {
                    EditorGUILayout.HelpBox("You should define a Single Use Item before", MessageType.Warning, true);
                }
            }

            EditorGUI.indentLevel--;
        }
    }