public void QuickBuy() { if (Services.UpgradeService.IsQuickBuyResearched) { List <UpgradeData> dataList = cashViews.DataList.Select(d => d).ToList(); foreach (var data in dataList) { if (Services.PlayerService.IsEnough(Bos.Data.Currency.Create(data.CurrencyType, data.Price(() => { return(BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data)); })))) { Services.UpgradeService.BuyUpgrade(data); } } Services.SoundService.PlayOneShot(SoundName.buyUpgrade); } }
private string ConstructPriceShortString(UpgradeData data) { switch (data.CurrencyType) { case CurrencyType.CompanyCash: { return("$" + BosUtils.GetCurrencyString(new CurrencyNumber(data.Price(() => { return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data); })), "#FFFFFF", "#FBEF20")); } case CurrencyType.Securities: { return(BosUtils.GetCurrencyString(new CurrencyNumber(data.Price(() => { return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data); })), "#FFFFFF", "#FBEF20")); } } return(string.Empty); }
private string ConstructPriceString(UpgradeData data) { switch (data.CurrencyType) { case CurrencyType.CompanyCash: { return(Currencies.DefaultCurrency.CreatePriceString(data.Price(() => { return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data); }), false, " ").ToUpper()); } case CurrencyType.Securities: { return(Currencies.Investors.CreatePriceString(data.Price(() => { return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data); }), false, " ").ToUpper()); } } return(string.Empty); }
public bool CanShowUpgradeAlert() { List <UpgradeData> allUpgrades = new List <UpgradeData>(); allUpgrades.AddRange(Services.ResourceService.CashUpgrades.UpgradeList); allUpgrades.AddRange(Services.ResourceService.SecuritiesUpgrades.UpgradeList); foreach (var upgrade in allUpgrades) { double price = upgrade.Price(() => { return(BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, upgrade)); }); if (!Services.UpgradeService.IsBought(upgrade) && Services.PlayerService.IsEnough(Bos.Data.Currency.Create(upgrade.CurrencyType, upgrade.Price(() => { return(BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, upgrade)); }))) && (Services.TransportService.HasUnits(upgrade.GeneratorId) || upgrade.GeneratorId == -1)) { return(true); } } return(false); }
private void Setup() { itemList.Setup(itemPrefab, layout, (data, view) => view.Setup(data), (data1, data2) => data1.Id == data2.Id, (data1, data2) => { IUpgradeService serv = Services.UpgradeService; bool isAllowBuyFirst = serv.IsAllowBuy(data1); bool isAllowBuySecond = serv.IsAllowBuy(data2); if (isAllowBuyFirst && !isAllowBuySecond) { return(-1); } if (!isAllowBuyFirst && isAllowBuySecond) { return(1); } return(data1.Price(() => { return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data1); }).CompareTo(data2.Price(() => { return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data2); }))); }); itemList.UpdateViews(DataSource); }