示例#1
0
    //------------------------------------------------------
    public void Setup(Item currentItem, ShopScrollList currentScrollList, GameObject tempPainel, int slotIdTemp, ItemOnShop shopTemp)
    {
        slotId           = slotIdTemp;
        item             = currentItem;
        nameLabel.text   = item.itemName;
        iconImage.sprite = item.artwork;
        tempShopPrices   = shopTemp;

        season = currentScrollList.tempData.season;
        switch (season)
        {
        case 0: buyValue = shopTemp.SpringBuy;
            sellValue    = shopTemp.SpringSell;
            break;

        case 1:
            buyValue  = shopTemp.SummerBuy;
            sellValue = shopTemp.SummerSell;
            break;

        case 2:
            buyValue  = shopTemp.AutumBuy;
            sellValue = shopTemp.AutumSell;
            break;

        case 3:
            buyValue  = shopTemp.WinterBuy;
            sellValue = shopTemp.WinterSell;
            break;

        default:
            break;
        }
        if (tempPainel.name == "PlayerContentPainel" || tempPainel.name == "SellContent")
        {
            priceText.text = "<color=green>" + sellValue.ToString() + "G</color>";
        }
        else
        {
            priceText.text = "<color=red>-" + buyValue.ToString() + "G</color>";
        }
        if (tempPainel.name == "ShopContent")
        {
            amount.text = "";
        }
        if (tempPainel.name == "CartContent")
        {
            nameLabel.text = "x1";
        }

        scrollList           = currentScrollList;
        tempPainelGameObject = tempPainel;
    }
示例#2
0
 //--------------------------------------------------------------------
 public void PlayerSellCartPlayerToCart(ItemOnShop itemToAdd, int buyValue, int id)
 {
     balance += buyValue;
     UpdateBalance();
     playerSellList.Add(itemToAdd);
     for (int i = 0; i < playerButtonList.Count; i++)
     {
         if (playerButtonList[i].slotId == id)
         {
             playerList.RemoveAt(i);
         }
     }
     RefreshPlayerContent();
     RefreshSellCart();
 }
示例#3
0
 //--------------------------------------------------------------------
 public void PlayerSellCartRemoveFromSellCart(int slotIdTemp)
 {
     for (int i = 0; i < playerSellList.Count; i++)
     {
         if (playerSellButtonList[i].slotId == slotIdTemp)
         {
             itmTemp = playerSellList[i];
             playerSellList.RemoveAt(i);
             playerList.Add(itmTemp);
             balance -= playerSellButtonList[i].sellValue;
         }
     }
     UpdateBalance();
     RefreshPlayerContent();
     RefreshSellCart();
 }
示例#4
0
    //------------------------------------------------------
    public ItemOnShop CreateNewitemOnShop()
    {
        ItemOnShop itmShopTemp = new ItemOnShop();

        itmShopTemp.itemShop   = this.tempShopPrices.itemShop;
        itmShopTemp.amount     = this.tempShopPrices.amount;
        itmShopTemp.showInShop = this.tempShopPrices.showInShop;
        itmShopTemp.AutumBuy   = this.tempShopPrices.AutumBuy;
        itmShopTemp.SpringBuy  = this.tempShopPrices.SpringBuy;
        itmShopTemp.WinterBuy  = this.tempShopPrices.WinterBuy;
        itmShopTemp.AutumSell  = this.tempShopPrices.AutumSell;
        itmShopTemp.SpringSell = this.tempShopPrices.SpringSell;
        itmShopTemp.SummerBuy  = this.tempShopPrices.SummerBuy;
        itmShopTemp.SummerSell = this.tempShopPrices.SummerSell;
        itmShopTemp.WinterSell = this.tempShopPrices.WinterSell;
        return(itmShopTemp);
    }
示例#5
0
    //------------------------------------------------------
    public void Setup(Item currentItem, ShopScrollList currentScrollList, GameObject tempPainel, int slotIdTemp)
    {
        slotId           = slotIdTemp;
        item             = currentItem;
        nameLabel.text   = item.itemName;
        iconImage.sprite = item.artwork;
        tempShopPrices   = null;
        shopHaveItem     = false;

        if (tempPainel.name == "PlayerContentPainel")
        {
            priceText.text = "<color=green>" + item.sellValue.ToString() + "G</color>";
        }
        else
        {
            priceText.text = "<color=red>-" + item.buyValue.ToString() + "G</color>";
        }

        scrollList           = currentScrollList;
        tempPainelGameObject = tempPainel;
    }
示例#6
0
 //--------------------------------------------------------------------
 //-Player to sell cart code ------------------------------------------
 //--------------------------------------------------------------------
 private void PlayerSellCartAddButton()
 {
     for (int i = 0; i < playerSellList.Count; i++)
     {
         Item       item      = playerSellList[i].itemShop;
         GameObject newButton = playerSellObjectPool.GetObject();
         newButton.transform.SetParent(playerSellContentPainel.transform);
         SampleButton sampleButton = newButton.GetComponent <SampleButton>();
         for (int j = 0; j < shopItemList.Count; j++)
         {
             if (item.itemName == shopItemList[j].itemShop.itemName)
             {
                 findItemOnShopToCopyValue = true;
                 shopPositonItemPriceTemp  = j;
             }
         }
         if (!findItemOnShopToCopyValue)
         {
             ItemOnShop itm = new ItemOnShop();
             itm.SpringBuy  = item.buyValue;
             itm.AutumBuy   = item.buyValue;
             itm.WinterBuy  = item.buyValue;
             itm.SummerBuy  = item.buyValue;
             itm.SpringSell = item.sellValue;
             itm.AutumSell  = item.sellValue;
             itm.WinterSell = item.sellValue;
             itm.SummerSell = item.sellValue;
             sampleButton.Setup(item, this, playerSellContentPainel, i, itm);
             playerSellButtonList.Add(sampleButton);
         }
         else
         {
             sampleButton.Setup(item, this, playerSellContentPainel, i, shopItemList[shopPositonItemPriceTemp]);
             playerSellButtonList.Add(sampleButton);
         }
         findItemOnShopToCopyValue = false;
     }
 }
示例#7
0
    //--------------------------------------------------------------------
    //add to Cart \/ code ------------------------------------------------
    //--------------------------------------------------------------------
    public void AddToCart(ItemOnShop itemToAdd, int buyValue)
    {
        balance -= buyValue;
        UpdateBalance();
        encounterAStack = false;
        stackPosition   = 0;

        if (cartList.Count > 0)
        {
            for (int i = 0; i < cartList.Count; i++)
            {
                if (cartList[i].itemShop.itemName == itemToAdd.itemShop.itemName && cartList[i].itemShop.maxStack > cartList[i].amount)
                {
                    encounterAStack = true;
                    stackPosition   = i;
                }
            }
            if (encounterAStack)
            {
                if ((cartList[stackPosition].amount + quantity) < cartList[stackPosition].itemShop.maxStack)
                {
                    cartList[stackPosition].amount += quantity;
                }
                else
                {
                    leftOver = quantity - (cartList[stackPosition].itemShop.maxStack - cartList[stackPosition].amount);
                    cartList[stackPosition].amount = cartList[stackPosition].itemShop.maxStack;
                    while (leftOver > 0)
                    {
                        if (leftOver > itemToAdd.itemShop.maxStack)
                        {
                            leftOver -= itemToAdd.itemShop.maxStack;
                            cartList.Add(itemToAdd);
                            cartList[cartList.Count - 1].amount = cartList[cartList.Count - 1].itemShop.maxStack;
                        }
                        else
                        {
                            cartList.Add(itemToAdd);
                            cartList[cartList.Count - 1].amount = leftOver;
                            leftOver = 0;
                        }
                    }
                }
            }
            else
            {
                if (quantity > itemToAdd.itemShop.maxStack)
                {
                    leftOver = quantity - (cartList[stackPosition].itemShop.maxStack - cartList[stackPosition].amount);
                    cartList[stackPosition].amount = cartList[stackPosition].itemShop.maxStack;
                    while (leftOver > 0)
                    {
                        if (leftOver > itemToAdd.itemShop.maxStack)
                        {
                            leftOver -= itemToAdd.itemShop.maxStack;
                            cartList.Add(itemToAdd);
                            cartList[cartList.Count - 1].amount = cartList[cartList.Count - 1].itemShop.maxStack;
                        }
                        else
                        {
                            cartList.Add(itemToAdd);
                            cartList[cartList.Count - 1].amount = leftOver;
                            leftOver = 0;
                        }
                    }
                }
                else
                {
                    cartList.Add(itemToAdd);
                    cartList[cartList.Count - 1].amount = quantity;
                    leftOver = 0;
                }
            }
        }
        else
        {
            cartList.Add(itemToAdd);
            cartList[cartList.Count - 1].amount = 1;
        }
        encounterAStack = false;
        //cartList.Add(itemToAdd);
        RemoveButtonsCart();
        AddButtonsToCart();
    }