Ejemplo n.º 1
0
    public void TransferItems()
    {
        Debug.Log("went through");
        if (amount != 0)
        {
            //money transfer
            currInv.money  += amount * selectedItem.cost;
            otherInv.money -= amount * selectedItem.cost;

            //item transfer
            currInv.RemoveItems(selectedItem, amount); //should never return false
            otherInv.AddItems(selectedItem, amount);

            //update item lists
            itemList  = new List <Item>(currInv.itemDict.Keys);
            itemIndex = 0;
            UpdateItemList(itemList, currInv, itemIndex);
        }

        //exit back to item scrolling
        if (itemList.Count == 0)
        {
            //inventory has no more items to display
            Debug.Log("No more items to buy/sell");

            int lastType = menuType;
            menuType = 0;
            ItemButton.GetComponent <Button>().interactable = false;
            switch (lastType)
            {
            case -1:
                BuyButton.SetActive(true);
                SellButton.GetComponent <Button>().enabled = true;
                ES.SetSelectedGameObject(SellButton);
                StartCoroutine("MoveLeft");
                break;

            case 1:
                SellButton.SetActive(true);
                BuyButton.GetComponent <Button>().enabled = true;
                ES.SetSelectedGameObject(BuyButton);
                StartCoroutine("MoveRight");
                break;
            }
        }
        else
        {
            Button button = ItemList.GetComponentInChildren <Button>();
            button.interactable = true;
            ES.SetSelectedGameObject(button.gameObject);
            itemScrolling = true;
        }

        AmountSelection.SetActive(false);
        selectedItem = null;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (CurrentPlanet != null)
        {
            MineCostText.text     = "Add a Mine" + " - " + CurrentPlanet.MineCost.ToString();
            Lifeaddtext.text      = "Sell Life" + " +" + (CurrentPlanet.Life / 6).ToString();
            LifeSlider.value      = CurrentPlanet.Life;
            ReasourceSlider.value = CurrentPlanet.Reasource;
        }
        MoneyText.text   = Player.Currency.ToString();
        EarningText.text = "Income: " + Player.EarningRate.ToString();
        if (CurrentPlanet != null)
        {
            ToolTip.IsTooltipVisable(false);
            PlanetDislpay.SetActive(true);
            if (!changename)
            {
                NameText.text = CurrentPlanet.name;
            }
            PlanetPicture.sprite = CurrentPlanet.image;
            if (CurrentPlanet.Owned)
            {
                //button off
                BuyButton.SetActive(false);

                PlanetShopDisplay.SetActive(true);
            }
            else
            {
                //button on
                PlanetShopDisplay.SetActive(false);
                BuyButton.SetActive(true);
                NameText.text = "Purchase " + CurrentPlanet.name + " \n  " + CurrentPlanet.Cost.ToString();
            }
        }
        else
        {
            PoorText.text = " ";
            NameText.text = " ";
            PlanetDislpay.SetActive(false);
        }
        if (CurrentPlanet != null && !CurrentPlanet.Owned)
        {
            NameText.interactable = false;
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            CurrentPlanet = null;
        }
    }
Ejemplo n.º 3
0
    public void OpenSell()
    {
        menuType = -1;
        menu.transform.localPosition            = new Vector3(-180, 0, 0);
        AmountSelection.transform.localPosition = new Vector3(95, -55, 0);
        BuyButton.SetActive(false);
        SellButton.GetComponent <Button>().enabled      = false;
        ItemButton.GetComponent <Button>().interactable = true;
        ES.SetSelectedGameObject(ItemButton);

        itemList = new List <Item>(playerInv.itemDict.Keys);
        currInv  = playerInv;
        otherInv = npcInv;
        UpdateItemList(itemList, currInv, 0);
        if (itemList.Count == 0)
        {
            //the button throws exceptions when there are no items selected, this prevents that
            ItemButton.GetComponent <Button>().interactable = false;
        }

        StartCoroutine("MoveRight");
    }
Ejemplo n.º 4
0
 public static void ShowBuyButton(bool show)
 {
     BuyButton.GetComponent <Button>().interactable = false;
     BuyButton.SetActive(show);
 }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        int lastType = menuType;

        if (Input.GetButtonDown("Cancel"))
        {
            if (!itemScrolling)
            {
                //exit back to buy/sell menus
                AmountSelection.SetActive(false);
                Button button = ItemList.GetComponentInChildren <Button>();
                button.interactable = true;
                ES.SetSelectedGameObject(button.gameObject);
                selectedItem  = null;
                itemScrolling = true;
            }
            else if (menuType != 0)
            {
                menuType = 0;
                ItemButton.GetComponent <Button>().interactable = false;
                switch (lastType)
                {
                case -1:
                    BuyButton.SetActive(true);
                    SellButton.GetComponent <Button>().enabled = true;
                    ES.SetSelectedGameObject(SellButton);
                    StartCoroutine("MoveLeft");
                    break;

                case 1:
                    SellButton.SetActive(true);
                    BuyButton.GetComponent <Button>().enabled = true;
                    ES.SetSelectedGameObject(BuyButton);
                    StartCoroutine("MoveRight");
                    break;
                }
            }
            else
            {
                //exit out of the shop altogether
                ReturnToLast();
            }
        }

        if (Input.GetButtonDown("Vertical"))
        {
            if (menuType != 0 && itemScrolling && itemList.Count != 0)
            {
                if (Input.GetAxisRaw("Vertical") > 0)
                {
                    //scroll items up
                    itemIndex--;
                }
                else
                {
                    //scroll items down
                    itemIndex++;
                }
                //loop around
                itemIndex += itemList.Count;
                itemIndex %= itemList.Count;
                UpdateItemList(itemList, currInv, itemIndex);
            }
            else if (menuType != 0 && !itemScrolling)
            {
                //amount select
                if (Input.GetAxisRaw("Vertical") > 0)
                {
                    //increase amount
                    changeItemAmount(1);
                }
                else
                {
                    //decrease amount
                    changeItemAmount(-1);
                }
            }
        }
    }