/// <summary>Initializes the game on startup.</summary> private void Initialize() { if (PlayerPreferences.GetBool(PlayerPreferencesKeys.hasSeenTutorial)) { //determine how much money the player has earned since last play float offlineEarnings = PlayerManager.instance.DetermineEarningsSinceLastPlay(); if (offlineEarnings > 0) { mainCanvas.SetInteractable(false); offlineEarningsPopup.Initialize(NumberFormatter.ToString(number: offlineEarnings, showDecimalPlaces: true, showDollarSign: true)); offlineEarningsPopup.Display(); } Debug.Log("offlineEarnings: " + offlineEarnings); } else { //show tutorial PlayerPreferences.SetBool(PlayerPreferencesKeys.hasSeenTutorial, true); } //create business panels CreateBusinessPanels(); //initialize specific ui elements bulkLevelUpButtonText.text = Constants.BULK_UPGRADE_OPTIONS[bulkLevelUpIndex]; prestigePanel.SetActive(false); //inialize dynamic ui elements UpdateUI(); //finally start a game save coroutine StartOrStopGameSaveCoroutine(true); }
public void Initialize(int numberOfBuilding, string name, float cost, float timerToUnlock) { this.numberOfBuilding = numberOfBuilding; this._name = name; this.timerToUnlock = timerToUnlock; this.cost = cost; costText.text = NumberFormatter.ToString(cost, showDecimalPlaces: false); buyButton.onClick.AddListener(() => { FindObjectOfType <TasksPopup>().Show(this.gameObject.GetComponent <TasksManager>()); //OnBuyBusinessButtonPressed(); }); adsButton.GetComponent <Button>().onClick.AddListener(() => { UnityADSManager.instance.indexOfSlotForBenefits = index; UnityADSManager.instance.ShowRewardedVideo(UnityADSManager.BoosterType.cutTimerToUnlockSlot); }); finishRepairButton.GetComponent <Button>().onClick.AddListener(() => { FindObjectOfType <RepairFinishPopup>().GetComponent <RepairFinishPopup>().ShowPopup(this, secondsLeft); }); RefreshLanguageBuySlotPanel(); }
private void CashTask() { //icon... if (icon.sprite == null) { for (int i = 0; i < icons.Length; i++) { if (icons[i].name.Equals(TaskType.CASH.ToString())) { icon.sprite = icons[i].icon; break; } } } info.text = string.Format("{0}/ {1}", NumberFormatter.ToString(PlayerManager.instance.cash, false, true), NumberFormatter.ToString(task.ValueToCollect, false, true)); if (PlayerManager.instance.cash < task.ValueToCollect) { statusImage.sprite = statusSprites[0]; info.color = GameColors.disableColorForButtons; status = false; } else { statusImage.sprite = statusSprites[1]; info.color = GameColors.availableColorGreen; status = true; } }
public IEnumerator CallConfirmationPanel(string textTag, int indexOfPanel = 0, float xp = 0) { if (xp > 0) { this.XP = NumberFormatter.ToString(xp, false, false); this.xpValue = xp; } result = ConfirmationPopupStatus.NONE; TurnCorrectPanel(indexOfPanel); SetText(textTag, indexOfPanel); small_noButton_Text.text = LocalizationManager.instance.StringForKey("NoButtonText"); small_yesButton_Text.text = LocalizationManager.instance.StringForKey("YesButtonText"); big_noButton_Text.text = LocalizationManager.instance.StringForKey("NoButtonText"); big_yesButton_Text.text = LocalizationManager.instance.StringForKey("YesButtonText"); Show(); yield return(StartCoroutine(ConfirmationLogic())); Hide(); if (result == ConfirmationPopupStatus.YES) { afterConfirmationDelegate(); } }
public void Display() { title.text = LocalizationManager.instance.StringForKey("OfficePanel_Title"); headingText.text = LocalizationManager.instance.StringForKey("OfficePanel_Heading"); numberOfContracts_text.text = LocalizationManager.instance.StringForKey("OfficePanel_ContractNumbers"); int numberOfContracts = PlayerManager.instance.level - 1; numberOfContracts_Value.text = numberOfContracts.ToString(); youKeep_text.text = LocalizationManager.instance.StringForKey("OfficePanel_YouKeep"); otherBuildings_text.text = LocalizationManager.instance.StringForKey("OfficePanel_OtherBuildings"); goldCoins_text.text = LocalizationManager.instance.StringForKey("OfficePanel_GoldCoins"); profitText_leftSide.text = NumberFormatter.ToString(Mathf.Pow(Constant.percentageContractValue, PlayerManager.instance.level - 1) * 100, false, false, false) + "%"; valueText_leftSide.text = LocalizationManager.instance.StringForKey("OfficePanel_ValueText"); profitText_rightSide.text = NumberFormatter.ToString(Mathf.Pow(Constant.percentageContractValue, PlayerManager.instance.level) * 100, false, false, false) + "%"; valueText_rightSide.text = LocalizationManager.instance.StringForKey("OfficePanel_ValueText"); levelPriceText.text = "$" + NumberFormatter.ToString(PlayerManager.instance.contractPrice, true, false); contractButtonText.text = LocalizationManager.instance.StringForKey("blockyButtonText"); if (PlayerPrefs.GetInt("OfficePopup") != 1) { FindObjectOfType <TutorialManager>().PlayTutorialStep(4); PlayerPrefs.SetInt("OfficePopup", 1); } animator.SetTrigger("Show"); isShow = true; }
/// <summary>Initializes the panel for a given upgrade.</summary> /// <param name="upgradeIndex">The upgrade (as an index).</param> public void Initialize(int upgradeIndex) { Assert.IsFalse(PlayerManager.instance.HasBoughtUpgrade(upgradeIndex)); //get a reference to the upgrade's data UpgradeData data = GameData.instance.GetDataForUpgrade(upgradeIndex); //and upgrade the UI image.sprite = data.image; nameText.text = data.name; descripionText.text = data.description; costText.text = NumberFormatter.ToString(number: data.cost, showDecimalPlaces: false); bool canAffordManager = PlayerManager.instance.cash >= data.cost; buyButton.SetInteractableAndColor(canAffordManager); if (canAffordManager) { //if the player can afford the upgrade, then add a callback buyButton.onClick.AddListener(() => { //firstly disable the button buyButton.interactable = false; //next process the purchase PlayerManager.instance.BoughtUpgrade(upgradeIndex); PlayerManager.instance.DecrementCashBy(data.cost); int businessIndex = (int)data.business; PlayerManager.instance.GetBusiness(businessIndex).UpdateUpgradeProfitMultiplier(data.profitMultiplier); //finally destroy the panel Destroy(gameObject); }); } }
public void ClickedAction() { if (canBeClickable) { int versionOfBonus = UnityEngine.Random.Range(0, 10); if (versionOfBonus < 6) //ads bonus { cash = 100f; float value = GameManager.instance.CountExtraCash() / 2; if (value > 100f) { cash = value; } RandomBonusPopup.afterConfirmationDelegate = DelegateAfterConfirmation_RandomBonusWithAds; StartCoroutine(randomBonusPopup.CallConfirmationPanel("ConfirmationPanel_RandomBonus", cash)); anim.SetTrigger("ShowWithAds"); } else //standard bonus { cash = 100f; if (GameManager.instance.CountExtraCash() > 100f) { cash = GameManager.instance.CountExtraCash() / 5; } bonusCashText.text = NumberFormatter.ToString(cash, true, true); PlayerManager.instance.IncrementCashBy(cash); anim.SetTrigger("Show"); } canBeClickable = false; } }
/// <summary>Initializes the panel for a given business.</summary> /// <param name="name">The business' name.</param> /// <param name="cost">The business' cost.</param> public void Initialize(string name, float cost) { nameText.text = name; costText.text = NumberFormatter.ToString(cost, showDecimalPlaces: false); buyButton.onClick.AddListener(() => { OnBuyBusinessButtonPressed(); }); }
/// <summary> /// Returns a string representing a number in fixed-point notation. /// </summary> /// <param name="fractionDigits"> Number of digits after the decimal point. Must be in the /// range 0 – 20, inclusive. </param> /// <returns> A string representation of a number in fixed-point notation. The string /// contains one digit before the significand's decimal point, and must contain /// fractionDigits digits after it. /// If fractionDigits is not supplied or undefined, the toFixed method assumes the value /// is zero. </returns> public static string ToFixed(ScriptEngine engine, double thisObj, int fractionDigits) { // Check the parameter is within range. if (fractionDigits < 0 || fractionDigits > 20) { throw new JavaScriptException(engine, "RangeError", "toFixed() argument must be between 0 and 20."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(thisObj, 10, NumberFormatter.Style.Fixed, fractionDigits)); }
public string ToFixed(int fractionDigits = 0) { // Check the parameter is within range. if (fractionDigits < 0 || fractionDigits > 20) { throw new JavaScriptException(this.Engine, ErrorType.RangeError, "toFixed() argument must be between 0 and 20."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(this.value, 10, NumberFormatter.Style.Fixed, fractionDigits)); }
public string ToStringJS(int radix = 10) { // Check the parameter is in range. if (radix < 2 || radix > 36) { throw new JavaScriptException(this.Engine, ErrorType.RangeError, "The radix must be between 2 and 36, inclusive."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(this.value, radix, NumberFormatter.Style.Regular)); }
private void SetParam(Text priceText, float offlineEarning) { if (offlineEarning * 2 < 1000f) { priceText.text = NumberFormatter.ToString(offlineEarning * 2, true, true, false); } else { priceText.text = NumberFormatter.ToString(offlineEarning * 2, false, true, false); } }
private void ExtraCash() { float value = CountExtraCash(); if (value > 0) { extraCashText.text = "+" + NumberFormatter.ToString(number: value, showDecimalPlaces: true); PlayerManager.instance.IncrementCashBy(value); extraCashGO.GetComponent <Animator>().SetTrigger("Show"); } }
public string ToStringJS([DefaultParameterValue(10)] object radixArg) { var radix = JurassicHelper.GetTypedArgumentValue(this.Engine, radixArg, 10); // Check the parameter is in range. if (radix < 2 || radix > 36) { throw new JavaScriptException(this.Engine, "RangeError", "The radix must be between 2 and 36, inclusive."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(this.m_value, radix, NumberFormatter.Style.Regular, 0)); }
public string ToFixed([DefaultParameterValue(0)] object fractionDigitsArg) { var fractionDigits = JurassicHelper.GetTypedArgumentValue(this.Engine, fractionDigitsArg, 0); // Check the parameter is within range. if (fractionDigits < 0 || fractionDigits > 20) { throw new JavaScriptException(this.Engine, "RangeError", "toFixed() argument must be between 0 and 20."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(this.m_value, 10, NumberFormatter.Style.Fixed, fractionDigits)); }
private void SetLockedPanelPropertyWhenLevelWasReached(InteriorElement interiorElement) { lockedPanel_LevelText.text = NumberFormatter.ToString(interiorElement.price, false, true, false); lockedPanel_ToUnlockText.text = LocalizationManager.instance.StringForKey("to_buy_text"); if (PlayerManager.instance.cash >= interiorElement.price) { SetMainButtonInterectable(); } else { SetMainButtonNotInterectable(); } }
/// <summary> /// Returns the textual representation of the number. /// </summary> /// <param name="radix"> Specifies a radix for converting numeric values to strings. </param> /// <returns> The textual representation of the number. </returns> public static string ToString(ScriptEngine engine, double thisObj, int radix) { if (radix == 0) { radix = 10; } // Check the parameter is in range. if (radix < 2 || radix > 36) { throw new JavaScriptException(engine, "RangeError", "The radix must be between 2 and 36, inclusive."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(thisObj, radix, NumberFormatter.Style.Regular)); }
private void Update() { if (isActive) { if (slot.GetInformationsAboutObjectToUnlock(index)) { //BOUGHT TurnOffUiElements(); } if (interiorElement.status != InteriorElementStatus.BOUGHT && slot.level < slot.GetMilestoneLevelTarget(index)) { //NOT AVAILABLE icon.sprite = hammerIcon; firstTextInfo.text = slot.GetMilestoneLevelTarget(index).ToString() + " lvl"; secondTextInfo.text = LocalizationManager.instance.StringForKey("to_unlock_text"); TurnOnUiElements(false); } if (interiorElement.status != InteriorElementStatus.BOUGHT && slot.level >= slot.GetMilestoneLevelTarget(index)) { //AVAILABLE if (PlayerManager.instance.cash >= interiorElement.price) { anim.ResetTrigger("PlayIdleAnim"); anim.SetTrigger("PlayAvailableAnim"); playAvailableAnimation = true; TurnOnUiElements(true); } else { if (playAvailableAnimation) { anim.ResetTrigger("PlayAvailableAnim"); anim.SetTrigger("PlayIdleAnim"); playAvailableAnimation = false; } TurnOnUiElements(false); } icon.sprite = hammerIcon; firstTextInfo.text = NumberFormatter.ToString(interiorElement.price, false, true, false); secondTextInfo.text = LocalizationManager.instance.StringForKey("to_buy_text"); } } }
/// <summary>Initializes the panel for a given manager.</summary> /// <param name="managerIndex">The manager (as an index).</param> public void Initialize(int managerIndex) { Assert.IsFalse(PlayerManager.instance.HasBoughtManager(managerIndex)); //get a reference to the upgrade's data ManagerData data = GameData.instance.GetDataForManager(managerIndex); //and upgrade the UI image.sprite = data.image; nameText.text = data.name; descripionText.text = data.description; costText.text = NumberFormatter.ToString(number: data.cost, showDecimalPlaces: false); bool canAffordManager = PlayerManager.instance.cash >= data.cost; buyButton.SetInteractableAndColor(canAffordManager); if (canAffordManager) { //if the player can afford the upgrade, then add a callback buyButton.onClick.AddListener(() => { //firstly disable the button buyButton.interactable = false; //next process the purchase PlayerManager.instance.BoughtManager(managerIndex); PlayerManager.instance.DecrementCashBy(data.cost); int businessIndex = (int)data.business; if (data.type == ManagerData.ManagerType.Standard) //manager starts running the business { Assert.IsFalse(PlayerManager.instance.GetBusiness(businessIndex).hasManager); PlayerManager.instance.GetBusiness(businessIndex).AssignManager(Business.ManagerType.RunsBusiness); } else if (data.type == ManagerData.ManagerType.Efficient) //manager reduces costs, shows cash per second { PlayerManager.instance.GetBusiness(businessIndex).AssignManager(Business.ManagerType.ReducesCost); PlayerManager.instance.GetBusiness(businessIndex).SetCostReductionMultiplier(data.costReductionMultiplier); if (data.showCashPerSecond) { PlayerManager.instance.GetBusiness(businessIndex).SetShouldShowCashPerSecond(true); } } //finally destroy the panel Destroy(gameObject); }); } }
/// <summary>Updates the UI.</summary> private void UpdateUI() { //update player's cash playerCashText.text = NumberFormatter.ToString(number: PlayerManager.instance.cash, showDecimalPlaces: true); //update business panels for (int i = 0; i < panels.Length; i++) { if (panels[i].GetComponent <BuyBusinessPanel>() != null) { (panels[i] as BuyBusinessPanel).interactable = PlayerManager.instance.cash >= PlayerManager.instance.GetBusiness(i).costToUnlock; } else if (panels[i].GetComponent <BusinessPanel>() != null) { (panels[i] as BusinessPanel).Refresh(); } } //show the prestige panel if it'd be advantageous for the player to prestige prestigePanel.SetActive(PlayerManager.instance.shouldConsiderPrestige); }
public string ToExponential(object fractionDigits) { // If precision is undefined, the number of digits is dependant on the number. if (TypeUtilities.IsUndefined(fractionDigits)) { return(NumberFormatter.ToString(this.value, 10, NumberFormatter.Style.Exponential, -1)); } // Convert the parameter to an integer. int fractionDigits2 = TypeConverter.ToInteger(fractionDigits); // Check the parameter is within range. if (fractionDigits2 < 0 || fractionDigits2 > 20) { throw new JavaScriptException(this.Engine, ErrorType.RangeError, "toExponential() argument must be between 0 and 20."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(this.value, 10, NumberFormatter.Style.Exponential, fractionDigits2)); }
public string ToPrecision(object precision) { // If precision is undefined, delegate to "toString()". if (TypeUtilities.IsUndefined(precision)) { return(this.ToStringJS()); } // Convert the parameter to an integer. int precision2 = TypeConverter.ToInteger(precision); // Check the precision is in range. if (precision2 < 1 || precision2 > 21) { throw new JavaScriptException(this.Engine, ErrorType.RangeError, "toPrecision() argument must be between 0 and 21."); } // NumberFormatter does the hard work. return(NumberFormatter.ToString(this.value, 10, NumberFormatter.Style.Precision, precision2)); }
public void Initialize() { //textDay.text = string.Format("Day {0}", day.ToString()); textDay.text = LocalizationManager.instance.StringForKey("DailyReward_UIElementDayText") + day.ToString(); if (reward.reward > 0) { if (showRewardName) { textReward.text = NumberFormatter.ToString(reward.reward, false, false, false) + " " + reward.unit; } else { textReward.text = NumberFormatter.ToString(reward.reward, false, false, false); } } else { textReward.text = reward.unit.ToString(); } imageReward.sprite = reward.sprite; }
public void SetNumberOfFloorsAndCashPerSecondTextValue(int index) { int numberOfFloors = 0; float totalCashPerSecond = 0; for (int i = (index + 1) * 10 - 10; i < (index + 1) * 10; i++) { if (GameManager.instance.panels[i].GetComponent <SlotPanel>() != null) { numberOfFloors++; } Slot slot = PlayerManager.instance.GetSlot(i); if (slot.isUnlocked && PlayerManager.instance.HasBoughtManager(i)) { totalCashPerSecond += slot.cashPerSecond; } } buildingNumberOfAvailableFloors.text = LocalizationManager.instance.StringForKey("NumberOfFloorsText") + " " + numberOfFloors + "/10"; buildingCashPerSeconds.text = NumberFormatter.ToString(totalCashPerSecond * 60, true, false) + "/min"; }
private void SetUpTexts(int index) { title.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_Title"); downPanelTitle.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_DownPanelTitle"); upgradeButton_Text.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_UpgradeButtonText"); levelText.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_Level"); moneyText.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_Money"); profitText.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_Profit"); costText.text = LocalizationManager.instance.StringForKey("UpgradeEachFloor_Cost"); if (index >= 3 && slot.DetermineMaximumNumberOfLevelsPlayerCanUpgrade() <= 0f) { levelValue.text = slot.level + "+" + slot.DetermineMaximumNumberOfLevelsPlayerCanUpgrade(); moneyValue.text = "-"; profitValue.text = "-"; costValue.text = "-"; return; } levelValue.text = index < 3 ? slot.level + "<color=#8FFF64>" + "+" + Constant.BULK_UPGRADE_LEVELS[index] + "</color>" : slot.level + "<color=#8FFF64>" + "+" + slot.DetermineMaximumNumberOfLevelsPlayerCanUpgrade() + "</color>"; moneyValue.text = index < 3 ? moneyValue.text = "<color=#8FFF64>" + "+" + NumberFormatter.ToString(slot.CashPerSecondForLevel(Constant.BULK_UPGRADE_LEVELS[index]), true, true) + "/s" + "</color>" : moneyValue.text = "<color=#8FFF64>" + "+" + NumberFormatter.ToString(slot.CashPerSecondForLevel(slot.DetermineMaximumNumberOfLevelsPlayerCanUpgrade()), true, true) + "/s" + "</color>"; profitValue.text = index < 3 ? LocalizationManager.instance.StringForKey("UpgradeEachFloor_Speed") + "<color=#8FFF64>" + " +" + Math.Round(slot.timeSpeedAfterEachUpgrade * Constant.BULK_UPGRADE_LEVELS[index], 2) + "s" + "</color>": LocalizationManager.instance.StringForKey("UpgradeEachFloor_Speed") + "<color=#8FFF64>" + " +" + Math.Round(slot.timeSpeedAfterEachUpgrade * slot.DetermineMaximumNumberOfLevelsPlayerCanUpgrade(), 2) + "s" + "</color>"; costValue.text = index < 3 ? NumberFormatter.ToString(slot.UpgreadeXLevelsCost(Constant.BULK_UPGRADE_LEVELS[index]), true) : NumberFormatter.ToString(slot.UpgreadeMaxLevelsCost(), true); }
public void Initialize(int managerIndex) { Assert.IsFalse(PlayerManager.instance.HasBoughtManager(managerIndex)); data = GameData.instance.GetDataForManager(managerIndex); numberOfBuilding = data.numberOfBuilding; index = managerIndex; if (index % 2 == 0) { backgroundImage.sprite = backgroundSprites[0]; nameText.color = GameColors.managerOrUpgradeSlot_TitleColor_v1; } else { backgroundImage.sprite = backgroundSprites[1]; nameText.color = GameColors.managerOrUpgradeSlot_TitleColor_v2; nameText.color = GameColors.managerOrUpgradeSlot_TitleColor_v2; } image.sprite = data.image; nameText.text = data.name; symbolOfSlotImage.sprite = GameManager.instance.slotPanelSymbols[index % 10]; //descriptionText.text = LocalizationManager.instance.StringForKey(data.description); descriptionText.text = data.description; cost = data.cost; buyButton_text.text = LocalizationManager.instance.StringForKey("ManagersPanel_HireButtonText"); costText.text = NumberFormatter.ToString(number: data.cost, showDecimalPlaces: false); buyByGoldButton_text.text = NumberFormatter.ToString(number: data.costByGold, showDecimalPlaces: false, showDollarSign: false); canBuyManager = PlayerManager.instance.cash >= data.cost; haveListener = false; haveListenerGoldBuy = false; //Format buyButton RefreshBuyButtonStatus(canBuyManager); }
private void FloorEntityCollectionTask(int indexOfFloor) { if (!iconIsSet) { icon.sprite = GameManager.instance.slotPanelSymbols[indexOfFloor % 10]; iconIsSet = true; } task.CurrentValueOfCollection = PlayerManager.instance.GetValueSlotsCounter(indexOfFloor); info.text = string.Format("Entity: {0}({1})", NumberFormatter.ToString(task.ValueToCollect, false, false, false), NumberFormatter.ToString(task.CurrentValueOfCollection, false, false, false)); if (task.CurrentValueOfCollection < task.ValueToCollect) { statusImage.sprite = statusSprites[0]; info.color = GameColors.disableColorForButtons; status = false; } else { statusImage.sprite = statusSprites[1]; info.color = GameColors.availableColorGreen; status = true; } }
public void Initialize(float offlineEarning) { this.offlineEarning = offlineEarning; /*if(LocalizationManager.instance != null) * { * titleText.text = LocalizationManager.instance.StringForKey("offlinePopupTitle"); * description_one.text = LocalizationManager.instance.StringForKey("offlinePopupDescOne"); * descriptionMoneyText.text = NumberFormatter.ToString(number: offlineEarning, showDecimalPlaces: true, showDollarSign: true); * description_two.text = LocalizationManager.instance.StringForKey("offlinePopupDescTwo"); * collectText_one.text = LocalizationManager.instance.StringForKey("offlinePopupCollectOne"); * collectText_two.text = LocalizationManager.instance.StringForKey("offlinePopupCollectTwo"); * } * else * {*/ titleText.text = "Welcome back!"; description_one.text = "You earn"; descriptionMoneyText.text = NumberFormatter.ToString(number: offlineEarning, showDecimalPlaces: true, showDollarSign: true); description_two.text = "when you weren't in your business!"; collectText_one.text = "Collect"; collectText_two.text = "Double up!"; //} }
/// <summary>Refreshes the panel.</summary> public void Refresh() { //firstly update the levelFill and levelText levelFill.fillAmount = business.nextMilestonePercentage; levelText.text = business.level.ToString(); //if the business can be updated to a higher level, determine the cost for the selected bulkLeveUpIndex and set the button's interactibility and text if (business.upgradeLevelExists) { float costToUpgradeForBulkLevelUpIndex = (GameManager.instance.bulkLevelUpIndex < Constants.NUMBER_BULK_UPGRADE_OPTIONS - 1 ? business.UpgradeXLevelsCost(GameManager.instance.bulkLevelUpAmount) : business.UpgradeMaxLevelsCost()); bool canAffordUpgrade = PlayerManager.instance.cash >= costToUpgradeForBulkLevelUpIndex; upgradeButton.SetInteractableAndColor(canAffordUpgrade); upgradeCostText.text = NumberFormatter.ToString(costToUpgradeForBulkLevelUpIndex, showDecimalPlaces: true); } else //otherwise display maxed out { upgradeButton.SetInteractableAndColor(false); upgradeCostText.text = LocalizationManager.instance.StringForKey(LocalizationManagerKeys.Max); } //determine what to present in the profitText, profit per unit (black) or cash per second (green) if (business.shouldShowCashPerSecond) { progressBarFill.fillAmount = 1; //no fill profitText.text = string.Format("${0} /{1}", NumberFormatter.ToString(number: business.profit, showDecimalPlaces: true, showDollarSign: false), LocalizationManager.instance.StringForKey(LocalizationManagerKeys.Sec)); } else { progressBarFill.fillAmount = (business.timeToProduce >= Constants.MINIMUM_TIME_TO_UPDATE_PRODUCTION_FILL ? business.unitCompletePercentage : 1); profitText.text = NumberFormatter.ToString(number: business.profit, showDecimalPlaces: true); } //finally update the time to produce current unit (no unit in production returns 00:00:00) timeText.text = business.timeDisplayString; }
/// <summary> /// Serializes a value into a JSON string. Does not serialize "undefined", check for that /// value before calling this method. /// </summary> /// <param name="value"> The value to serialize. </param> /// <param name="result"> The StringBuilder to write the JSON representation of the /// value to. </param> private void SerializePropertyValue(object value, StringBuilder result) { // Transform boolean, numeric and string objects into their primitive equivalents. if (value is NumberInstance) { value = ((NumberInstance)value).Value; } else if (value is StringInstance) { value = ((StringInstance)value).Value; } else if (value is BooleanInstance) { value = ((BooleanInstance)value).Value; } // Serialize a null value. if (value == Null.Value) { result.Append("null"); return; } // Serialize a boolean value. if (value is bool) { if ((bool)value == false) { result.Append("false"); } else { result.Append("true"); } return; } // Serialize a string value. if (value is string || value is ConcatenatedString) { QuoteString(value.ToString(), result); return; } // Serialize a numeric value. if (value is double) { if (double.IsInfinity((double)value) == true || double.IsNaN((double)value)) { result.Append("null"); } else { result.Append(NumberFormatter.ToString((double)value, 10, NumberFormatter.Style.Regular)); } return; } if (value is int) { result.Append(((int)value).ToString()); return; } // Serialize an array. if (value is ArrayInstance) { SerializeArray((ArrayInstance)value, result); return; } // Serialize an object. if (value is ObjectInstance && (value is FunctionInstance) == false) { SerializeObject((ObjectInstance)value, result); return; } // The value is of a type we cannot serialize. throw new NotSupportedException(string.Format("Unsupported value type: {0}", value.GetType())); }