private void SetupRunnerMenu() { runnerContext.SetActive(true); hackerContext.SetActive(false); currentCardCarosel = runnerCardCarosel; switch (context) { case ItemDetailsMenu.ItemDetailMenuContextType.Inventory: runnerShopInventoryContext.SetActive(true); runnerUpgradeContext.SetActive(false); break; case ItemDetailsMenu.ItemDetailMenuContextType.Loadout: runnerShopInventoryContext.SetActive(true); runnerUpgradeContext.SetActive(false); break; case ItemDetailsMenu.ItemDetailMenuContextType.Shop: if (shopMenu.GetOpenShopTab() == "upgrade") { // We only go to the upgrade context if the shop is in upgrade mode, // because we do not want to upgrade items that are for sale or being sold... runnerUpgradeContext.SetActive(true); runnerShopInventoryContext.SetActive(false); SetupUpgradeButtons(runnerUpgradeButtons); } else { runnerShopInventoryContext.SetActive(true); runnerUpgradeContext.SetActive(false); } break; } SetupGeneralInfo(); SetupLevelMarkers(); SetupCardCarosels(); }
private void SetupShopDetails(Item.HackerRunner hackerOrRunner, bool isInstall = false) { switch (shopMenu.GetOpenShopTab()) { case "buy": GameObject activeBuyButton = runnerShopContextBuyBtn; TextMeshProUGUI currentBuyPriceAmountField = runnerShopPriceAmountField; TextMeshProUGUI currentBuyPriceLabel = runnerShopPriceLabel; if (hackerOrRunner == Item.HackerRunner.Runner) { runnerShopContextBuyBtn.SetActive(true); runnerShopContextSellBtn.SetActive(false); runnerShopContextUpgradeBtn.SetActive(false); runnerShopPriceAmountField.text = item.GetItemPrice().ToString(); activeBuyButton = runnerShopContextBuyBtn; currentBuyPriceAmountField = runnerShopPriceAmountField; currentBuyPriceLabel = runnerShopPriceLabel; } else if (hackerOrRunner == Item.HackerRunner.Hacker && !isInstall) { hackerModShopContextBuyBtn.SetActive(true); hackerModShopContextSellBtn.SetActive(false); hackerModShopContextUpgradeBtn.SetActive(false); hackerModShopPriceAmountField.text = item.GetItemPrice().ToString(); activeBuyButton = hackerModShopContextBuyBtn; currentBuyPriceAmountField = hackerModShopPriceAmountField; currentBuyPriceLabel = hackerModPriceLabel; } else if (hackerOrRunner == Item.HackerRunner.Hacker && isInstall) { hackerInstallShopContextBuyBtn.SetActive(true); hackerInstallShopContextSellBtn.SetActive(false); hackerInstallShopContextUpgradeBtn.SetActive(false); hackerInstallShopPriceAmountField.text = item.GetItemPrice().ToString(); activeBuyButton = hackerInstallShopContextBuyBtn; currentBuyPriceAmountField = hackerInstallShopPriceAmountField; currentBuyPriceLabel = hackerInstallPriceLabel; } PlayerData playerData1 = FindObjectOfType <PlayerData>(); if (item.GetItemPrice() > playerData1.GetCreditsAmount()) { // If the item is unaffordable, disable the buy button but show the price fields activeBuyButton.GetComponent <Button>().interactable = false; currentBuyPriceAmountField.gameObject.SetActive(true); currentBuyPriceLabel.gameObject.SetActive(true); } break; case "sell": break; case "upgrade": GameObject activeUpgradeButton = runnerShopContextUpgradeBtn; TextMeshProUGUI currentUpgradePriceAmountField = runnerShopPriceAmountField; TextMeshProUGUI currentUpgradePriceLabel = runnerShopPriceLabel; if (hackerOrRunner == Item.HackerRunner.Runner) { runnerShopContextBuyBtn.SetActive(false); runnerShopContextSellBtn.SetActive(false); runnerShopContextUpgradeBtn.SetActive(true); runnerShopPriceAmountField.text = shopMenu.GetPrice(item).ToString(); activeUpgradeButton = runnerShopContextUpgradeBtn; currentUpgradePriceAmountField = runnerShopPriceAmountField; currentUpgradePriceLabel = runnerShopPriceLabel; } else if (hackerOrRunner == Item.HackerRunner.Hacker && !isInstall) { hackerModShopContextBuyBtn.SetActive(false); hackerModShopContextSellBtn.SetActive(false); hackerModShopContextUpgradeBtn.SetActive(true); hackerModShopPriceAmountField.text = shopMenu.GetPrice(item).ToString(); activeUpgradeButton = hackerModShopContextUpgradeBtn; currentUpgradePriceAmountField = hackerModShopPriceAmountField; currentUpgradePriceLabel = hackerModPriceLabel; } else if (hackerOrRunner == Item.HackerRunner.Hacker && isInstall) { hackerInstallShopContextBuyBtn.SetActive(false); hackerInstallShopContextSellBtn.SetActive(false); hackerInstallShopContextUpgradeBtn.SetActive(true); hackerInstallShopPriceAmountField.text = shopMenu.GetPrice(item).ToString(); activeUpgradeButton = hackerInstallShopContextUpgradeBtn; currentUpgradePriceAmountField = hackerInstallShopPriceAmountField; currentUpgradePriceLabel = hackerInstallPriceLabel; } PlayerData playerData = FindObjectOfType <PlayerData>(); if (item.GetCurrentItemLevel() >= item.GetItemMaxLevel()) { // If the item is max level: Disable the button and hide the price fields activeUpgradeButton.GetComponent <Button>().interactable = false; currentUpgradePriceAmountField.gameObject.SetActive(false); currentUpgradePriceLabel.gameObject.SetActive(false); } else if (shopMenu.GetPrice(item) > playerData.GetCreditsAmount()) { // If the item just is unaffordable, disable the button but display the price activeUpgradeButton.GetComponent <Button>().interactable = false; currentUpgradePriceAmountField.gameObject.SetActive(true); currentUpgradePriceLabel.gameObject.SetActive(true); } else { // if the item is affordable and not max level, enable the button and show the price activeUpgradeButton.GetComponent <Button>().interactable = true; currentUpgradePriceAmountField.gameObject.SetActive(true); currentUpgradePriceLabel.gameObject.SetActive(true); } break; } }