Exemplo n.º 1
0
    void populate()
    {
        Text textField;

        foreach (Item item in player.items)
        {
            itemUI = itemList.Find(item.name);
            if (item.count < 1)
            {
                itemUI.gameObject.SetActive(false);
                continue;
            }
            itemUI.gameObject.SetActive(true);
            textField      = itemUI.Find("Quantity").GetComponent <Text>();;
            textField.text = item.count.ToString();              //TODO: Write util to change 1200 to 1.2k

            textField      = itemUI.Find("Price").GetComponent <Text>();;
            textField.text = item.price.ToString();              //TODO: make price equal to "city sell" + "base price"

            ShopItemCtrl itemCtrl = itemUI.GetComponent <ShopItemCtrl>();
            itemCtrl.isCity = false;
        }

        Item playerCheese = player.items.Find(x => x.name == "Cheese");

        cheeseProgressLabel.text = "Goal Progress: " + playerCheese.count + " of 1,000 Cheeses needed to win";
        Vector3 barReached = Vector3.one;

        barReached.x = (playerCheese.count / 1000.0f);
        cheeseProgressBar.localScale = barReached;
    }
Exemplo n.º 2
0
    public void UpdateUI()
    {
        //haveMoney.text = PlayerEx.TotalMoney.ToString();
        page.text = curPage + "/" + totalPage;
        if (curPage == totalPage)
        {
            NextPage.gameObject.SetActive(false);
        }
        else
        {
            NextPage.gameObject.SetActive(true);
        }
        if (curPage == 1)
        {
            PrevPage.gameObject.SetActive(false);
        }
        else
        {
            PrevPage.gameObject.SetActive(true);
        }
        if (MonsterSelect == -1)
        {
            selectMonsterText.text = "";
            number.text            = "";
            totalPrice.text        = "";
        }
        else
        {
        }

        int k = 1;

        for (int i = 0; i < PageItem; i++)
        {
            PageItems[i] = -1;
            ShopItem[i].gameObject.SetActive(false);
        }

        foreach (var each in DstArmyType)
        {
            if (k > (curPage - 1) * PageItem && k <= (curPage * PageItem))
            {
                //MonsterUnit it = GameData.FindMonsterById(each);
                //PageItems[k - (curPage - 1) * PageItem - 1] = it.Idx;
                ShopItemCtrl item = ShopItem[k - (curPage - 1) * PageItem - 1].GetComponent <ShopItemCtrl>();
                //item.ItemName.text = it.Name;
                //item.ItemPrice.text = it.Coin.ToString();
                //ShopItem[k - (curPage - 1) * PageItem - 1].GetComponentInChildren<Text>().text = it.Name;
                ShopItem[k - (curPage - 1) * PageItem - 1].gameObject.SetActive(true);
            }
            k++;
        }

        k = 0;
        for (int i = 0; i < ShopItem.Length; i++)
        {
            if (ShopItem[i].IsActive())
            {
                k++;
            }
        }
        ShopItemRoot.sizeDelta = new Vector2(ShopItemRoot.sizeDelta.x, k * 100 + 20 + 20 + (k - 1) * 20);
    }
Exemplo n.º 3
0
    public void populate(Player selectedPlayer)
    {
        Text textField;

        player = selectedPlayer;
        amount = 1;
        foreach (Item item in city.items)
        {
            itemUI = cityItemsList.Find(item.name);
            if (itemUI == null)
            {
                Debug.LogError("Item not found in city list " + item.name + ". Perhaps spelled wrong in City?");
            }
            if (item.count < 1)
            {
                Debug.Log(item.name);
                itemUI.gameObject.SetActive(false);
                continue;
            }

            itemUI.gameObject.SetActive(true);
            textField      = itemUI.Find("Quantity").GetComponent <Text>();
            textField.text = shopNumberFormat(item.count);

            textField = itemUI.Find("Price").GetComponent <Text>();
            float slope1    = (float)item.price / (float)item.maxAmount * -1;
            int   unitPrice = (int)(item.count * slope1 + item.price);

            textField.text = unitPrice.ToString();              //TODO: make price equal to "city markup" + "base price"
            ShopItemCtrl itemCtrl = itemUI.GetComponent <ShopItemCtrl>();
            itemCtrl.isCity = true;
        }

        Item playerItem = player.items.Find(x => x.name == "Cheese");

        if (playerItem.count >= 1000)
        {
            Debug.Log("YOU RUINED THE ELF ECONOMY. VICTORY! TAKE THAT, ELVES");
            SceneManager.LoadScene("EndScene");
            return;
        }


        foreach (Item item in player.items)
        {
            itemUI = playerItemsList.Find(item.name);
            if (item.count < 1)
            {
                itemUI.gameObject.SetActive(false);
                continue;
            }
            itemUI.gameObject.SetActive(true);
            textField      = itemUI.Find("Quantity").GetComponent <Text>();;
            textField.text = shopNumberFormat(item.count);

            textField      = itemUI.Find("Price").GetComponent <Text>();;
            textField.text = shopNumberFormat(item.price);

            ShopItemCtrl itemCtrl = itemUI.GetComponent <ShopItemCtrl>();
            itemCtrl.isCity = false;
        }
    }