Exemplo n.º 1
0
    void UpdateDescription(int i)   //Changes description for item
    {
        if (warningTimer > 0f)
        {
            return;
        }
        ShopTestItem item = inventory.inventory[i];

        description.text = item.name + "\n" + item.description;
    }
Exemplo n.º 2
0
    void Update()
    {
        float rawInput = Input.GetAxisRaw("Vertical");

        if (delay <= 0f)   //Moving the visual selection arrow
        {
            if (rawInput > 0.2f)
            {
                currentSelection--;
                delay = 0.2f;
            }
            else if (rawInput < -0.2f)
            {
                currentSelection++;
                delay = 0.2f;
            }
            currentSelection %= inventory.inventory.Length;
            if (currentSelection < 0)
            {
                currentSelection += inventory.inventory.Length;
            }
            UpdateList(currentSelection);
            UpdateDescription(currentSelection);
        }
        else if (Mathf.Abs(rawInput) < 0.2f)
        {
            delay = 0;
        }
        delay -= Time.deltaTime;
        ShopTestItem currentItem = inventory.inventory[currentSelection];

        if (Input.GetButtonDown("Submit"))   //Checks money for item
        {
            if (money >= currentItem.price)
            {
                money -= currentItem.price;
                //TODO: Give item to the player
            }
            else
            {
                warningTimer     = 3f;
                description.text = "Not enough money to buy this item!"; //Changes Description to Warning
            }
        }
        UpdateMoney();
        warningTimer -= Time.deltaTime;
        if (Input.GetButtonDown("Cancel"))   //Exiting Shop
        {
            IsShopping.shopping = false;
            shopMenuCanvas.SetActive(false);
            Time.timeScale = 1f;
        }
    }
Exemplo n.º 3
0
    public void Purchase(ShopTestItem currentItem)
    {
        if (money >= currentItem.price)
        {
            money         -= currentItem.price;
            moneyText.text = "Money: " + money;
            //TODO: Give item to the player
        }

        /*else
         * {
         *  warningTimer = 3f;
         *  description.text = "Not enough money to buy this item!"; //Changes Description to Warning
         * }*/
    }
Exemplo n.º 4
0
    void UpdateList(int i)
    {
        string tempInvList = "";

        for (int x = 0; x < inventory.inventory.Length; x++)
        {
            ShopTestItem item = inventory.inventory[x];
            if (x == i)
            {
                tempInvList += "> ";
            }
            tempInvList += item.name + ": $" + item.price + "\n\n\n";
        }
        itemsList.text = tempInvList;
    }