public void AddCurrency(Bos.Data.Currency currency) { switch (currency.Type) { case Data.CurrencyType.Coins: { AddCoins((int)currency.Value); } break; case Data.CurrencyType.CompanyCash: { AddCompanyCash(currency.Value); } break; case Data.CurrencyType.PlayerCash: { AddPlayerCash(currency.Value.ToCurrencyNumber()); } break; case Data.CurrencyType.Securities: { AddSecurities(currency.Value.ToCurrencyNumber()); } break; default: { throw new InvalidOperationException($"invalid currency type {currency.Type}"); } } }
public bool IsEnough(Bos.Data.Currency currency) { switch (currency.Type) { case Data.CurrencyType.Coins: { return(Coins >= (int)currency.Value); } case Data.CurrencyType.CompanyCash: { return(CompanyCash.Value >= currency.Value); } case Data.CurrencyType.PlayerCash: { return(((double)PlayerCash.Value) >= currency.Value); } case Data.CurrencyType.Securities: { return(((double)Securities.Value) >= currency.Value); } default: { throw new InvalidOperationException($"invalid currency type {currency.Type}"); } } }
public ManagerTransactionState GetBuyRollbackLevelStatus(int managerId) { var manager = GetManager(managerId); var mgrLevel = GetManagerEfficiencyRollbackLevel(managerId); if (!manager.IsHired) { return(ManagerTransactionState.ManagerIsNotHired); } IManagerImprovementRepository improveRepo = Services.ResourceService.ManagerImprovements; if (mgrLevel.RollbackImrpoveLevel >= improveRepo.MaxLevel) { return(ManagerTransactionState.AlreadyMaxLevel); } int currentLevel = mgrLevel.RollbackImrpoveLevel; int nextLevel = currentLevel + 1; var improveData = improveRepo.GetRollbackImproveData(nextLevel); Bos.Data.Currency price = Bos.Data.Currency.CreateCoins(improveData.CoinsPrice); if (!Services.PlayerService.IsEnough(price)) { return(ManagerTransactionState.DontEnoughCoins); } return(ManagerTransactionState.Success); }
public ManagerTransactionState BuyMegaUpgrade(int managerId) { var manager = GetManager(managerId); var mgrLevel = GetManagerEfficiencyRollbackLevel(managerId); IManagerImprovementRepository improveRepo = Services.ResourceService.ManagerImprovements; if (!manager.IsHired) { return(ManagerTransactionState.ManagerIsNotHired); } if (!mgrLevel.IsRollbackMaxLevel(improveRepo) || !mgrLevel.IsEfficiencyMaxLevel(improveRepo)) { return(ManagerTransactionState.ManagerCantUpgradeMega); } var improveData = improveRepo.MegaImprovement.CoinPrice; Bos.Data.Currency price = Bos.Data.Currency.CreateCoins(improveData); if (!Services.PlayerService.IsEnough(price)) { return(ManagerTransactionState.DontEnoughCoins); } Services.PlayerService.RemoveCurrency(price); manager.AddMaxRollback(improveRepo.MegaImprovement.RollbackIncrement); manager.AddMaxEfficiency(improveRepo.MegaImprovement.EfficiencyIncrement, Services); mgrLevel.ApplyMega(); return(ManagerTransactionState.Success); }
public static string GetCurrencyStringSimple(Bos.Data.Currency currency) { switch (currency.Type) { case Data.CurrencyType.Coins: { string result = ((int)currency.Value).ToString(); return(result); } default: { return(GetCurrencyStringSimple(new CurrencyNumber(currency.Value))); } } }
public static string GetCurrencyString(Bos.Data.Currency currency, string numberComponentColor = "", string suffixColor = "#FFE565") { switch (currency.Type) { case Data.CurrencyType.Coins: { string result = ((int)currency.Value).ToString(); if (!string.IsNullOrEmpty(numberComponentColor)) { result = result.Colored(numberComponentColor); } return(result); } default: { return(GetCurrencyString(new CurrencyNumber(currency.Value), numberComponentColor, suffixColor)); } } }
public bool IsAllowBuySecretary(int managerId, out BosError error) { bool isManagerHired = Services.ManagerService.IsHired(managerId); if (!isManagerHired) { error = BosError.ManagerNotHired; return(false); } int planetId = Services.PlanetService.CurrentPlanet.Id; Bos.Data.Currency price = Bos.Data.Currency.CreateCoins(GetNextSecretaryPrice(managerId)); bool isEnoughCurrency = Services.PlayerService.IsEnough(price); if (!isEnoughCurrency) { error = BosError.NoEnoughCoins; return(false); } error = BosError.Ok; return(isManagerHired && isEnoughCurrency); }
public TransactionState PurchaseProduct(ProductData data) { if (!IsProductPurchased(data.id)) { var price = data.price; Bos.Data.Currency currency = Bos.Data.Currency.CreatePlayerCash(price); if (IsEnough(currency)) { RemoveCurrency(currency); AddStatusPoints(data.status_points); PurchasedProducts.Add(data.id); GameEvents.OnProductPurchased(data); return(TransactionState.Success); } else { return(TransactionState.DontEnoughCurrency); } } else { return(TransactionState.AlreadyPurchased); } }
public void Setup(Bos.Data.Currency currency) { ActivateOnlyCurrencyType(currency.Type); GetTextForCurrencyType(currency.Type).text = currency.DisplayString; }