Example #1
0
 // Start is called before the first frame update
 void Start()
 {
     fuelCross.SetActive(false);
     stationUI.SetActive(false);
     foreach (GameObject shopItemObject in shopItems)
     {
         ShopItemUIHandler shopItemUI = shopItemObject.GetComponent <ShopItemUIHandler>();
     }
 }
Example #2
0
 void UpdateStock()
 {
     foreach (GameObject shopElement in shopItems)
     {
         ShopItemUIHandler itemUI = shopElement.GetComponent <ShopItemUIHandler>();
         int currentIndex         = System.Array.IndexOf(shopItems, shopElement);
         if (sellMode)
         {
             itemUI.shopItemStock.text = "Stock: " + stationData.stock[currentIndex].ToString();
         }
         else
         {
             itemUI.shopItemStock.text = "Stock: " + ship.stock[currentIndex].ToString();
         }
     }
 }
Example #3
0
    public void ConnectToStation(StationData station)
    {
        ship.soundEffects.Connect();

        // Turn on the station UI
        stationUI.SetActive(true);
        isDisplayed = true;

        // Set the UI elements
        displayText.text  = stationData.welcomeText;
        displayText.color = stationData.textColour;
        catName.text      = stationData.catName;
        shopUIBG.sprite   = stationData.shopUIBG;

        buySell.text   = "Seller's Stock (press T to switch)";
        guideText.text = "Press Space to buy";
        if (station.isTom)
        {
            buySell.text = "Emergency fuel for sale";
        }
        fuelCross.SetActive(false);

        // Adjust item prices etc
        ShopItem favItem   = stationData.favItem;
        ShopItem hatedItem = stationData.hatedItem;

        foreach (GameObject shopElement in shopItems)
        {
            ShopItemUIHandler itemUI = shopElement.GetComponent <ShopItemUIHandler>();

            itemUI.favIcon.SetActive(false);
            itemUI.hatedIcon.SetActive(false);

            if (itemUI.shopItem == favItem)
            {
                itemUI.shopItemValue.text = "¥" + (itemUI.shopItem.itemValue * favMulti).ToString();
                itemUI.favIcon.SetActive(true);
            }
            else if (itemUI.shopItem == hatedItem)
            {
                itemUI.shopItemValue.text = "¥" + (itemUI.shopItem.itemValue * hatedMulti).ToString();
                itemUI.hatedIcon.SetActive(true);
            }
            else
            {
                itemUI.shopItemValue.text = "¥" + itemUI.shopItem.itemValue.ToString();
            }

            // If the station is Tom's Garage and the item is fuel then the price is increased, otherwise the value is ¥0
            if (station.isTom)
            {
                if (itemUI.shopItem.name == "Fuel")
                {
                    itemUI.shopItemValue.text = "¥" + (itemUI.shopItem.itemValue * fuelMulti).ToString();
                }
                else
                {
                    itemUI.shopItemValue.text = "¥0";
                }
            }

            if (station.isBlackCat)
            {
                if (itemUI.shopItem.name == "Pyramids")
                {
                    itemUI.shopItemValue.text = "¥" + (itemUI.shopItem.itemValue * pyramidMulti).ToString();
                }
            }

            if (station.isBusinessCat)
            {
                if (itemUI.shopItem.name == "Money")
                {
                    itemUI.shopItemValue.text = "¥" + (itemUI.shopItem.itemValue * moneyMulti).ToString();
                }
            }

            int currentIndex = System.Array.IndexOf(shopItems, shopElement);
            itemUI.shopItemStock.text = stationData.stock[currentIndex].ToString();
        }

        sellMode = true;

        selectedX = 0;
        selectedY = 0;
    }