public void OnPurchaseShardsClicked(UXButton button) { int num = 1; bool flag = button == this.purchaseAllBtn; if (flag) { num = this.vto.RemainingShardsForSale; } CostVO costVO = (!flag) ? this.vto.CostOfNextShard : this.vto.CostOfAllShards; int crystals = costVO.Crystals; if (!ShardShopViewModule.warned && crystals >= GameConstants.CRYSTAL_SPEND_WARNING_MINIMUM) { ShardShopViewModule.warned = true; string currencyItemAssetName = UXUtils.GetCurrencyItemAssetName(CurrencyType.Crystals.ToString()); AlertScreen.ShowModalWithImage(false, this.lang.Get("shard_shop_crystal_warning_title", new object[0]), this.lang.Get("shard_shop_crystal_warning_body", new object[] { crystals }), currencyItemAssetName, new OnScreenModalResult(this.PurchaseShards), num); return; } this.PurchaseShards(button, num); }
public static bool ShowIfNotEnoughCurrency(int credits, int materials, int contraband, string purchaseContext, OnScreenModalResult onModalResult) { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); CurrencyType currencyType = GameUtils.GetCurrencyType(credits, materials, contraband); int num = 0; switch (currencyType) { case CurrencyType.Credits: num = credits - currentPlayer.CurrentCreditsAmount; break; case CurrencyType.Materials: num = materials - currentPlayer.CurrentMaterialsAmount; break; case CurrencyType.Contraband: num = contraband - currentPlayer.CurrentContrabandAmount; break; } if (num > 0) { if (GameUtils.HasEnoughCurrencyStorage(currencyType, num)) { Lang lang = Service.Get <Lang>(); string currencyStringId = LangUtils.GetCurrencyStringId(currencyType); string text = lang.Get(currencyStringId, new object[0]); string title = lang.Get("NEED_MORE", new object[] { text }); string message = lang.Get("NEED_MORE_BUY_MISSING", new object[] { lang.ThousandsSeparated(num), text }); int num2 = 0; switch (currencyType) { case CurrencyType.Credits: num2 = GameUtils.CreditsCrystalCost(num); break; case CurrencyType.Materials: num2 = GameUtils.MaterialsCrystalCost(num); break; case CurrencyType.Contraband: num2 = GameUtils.ContrabandCrystalCost(num); break; } string currencyItemAssetName = UXUtils.GetCurrencyItemAssetName(currencyType.ToString()); CurrencyTag modalResultCookie = new CurrencyTag(currencyType, num, num2, purchaseContext); PayMeScreen.ShowModal(num2, false, title, message, currencyItemAssetName, onModalResult, modalResultCookie); } else { onModalResult(null, null); } return(true); } return(false); }
protected DisableProtectionAlertScreen() : base(false, null, DisableProtectionAlertScreen.GetProtectionTimeRemaining(), UXUtils.GetCurrencyItemAssetName("protection"), false) { Service.Get <ViewTimeEngine>().RegisterClockTimeObserver(this, 1f); }
private static bool ShowIfNotEnoughMultipleCurrenciesInternal(int credits, int materials, int contraband, int reputation, string purchaseContext, object purchaseCookie, OnScreenModalResult onModalResult) { CurrentPlayer currentPlayer = Service.CurrentPlayer; Dictionary <CurrencyType, int> dictionary = new Dictionary <CurrencyType, int>(); int num = credits - currentPlayer.CurrentCreditsAmount; int num2 = materials - currentPlayer.CurrentMaterialsAmount; int num3 = contraband - currentPlayer.CurrentContrabandAmount; if (num > 0) { dictionary.Add(CurrencyType.Credits, num); } else { num = 0; } if (num2 > 0) { dictionary.Add(CurrencyType.Materials, num2); } else { num2 = 0; } if (num3 > 0) { dictionary.Add(CurrencyType.Contraband, num3); } else { num3 = 0; } if (dictionary.Count > 0) { Lang lang = Service.Lang; bool flag = true; List <string> list = new List <string>(); List <string> list2 = new List <string>(); foreach (KeyValuePair <CurrencyType, int> current in dictionary) { CurrencyType key = current.Key; int value = current.Value; flag &= GameUtils.HasEnoughCurrencyStorage(key, value); list.Add(UXUtils.GetCurrencyItemAssetName(key.ToString())); string currencyStringId = LangUtils.GetCurrencyStringId(key); string str = lang.Get(currencyStringId, new object[0]); list2.Add(lang.ThousandsSeparated(value) + " " + str); } if (flag) { string title = lang.Get("NEED_MORE_MULTI", new object[0]); string message = lang.Get("NEED_MORE_MULTI_BUY_MISSING", new object[0]); int num4 = GameUtils.MultiCurrencyCrystalCost(dictionary); MultiCurrencyTag modalResultCookie = new MultiCurrencyTag(num, num2, num3, num4, purchaseContext, purchaseCookie); MultiResourcePayMeScreen multiResourcePayMeScreen = new MultiResourcePayMeScreen(num4, title, message, list, list2); multiResourcePayMeScreen.OnModalResult = onModalResult; multiResourcePayMeScreen.ModalResultCookie = modalResultCookie; Service.ScreenController.AddScreen(multiResourcePayMeScreen); } else { onModalResult(null, null); } return(true); } dictionary.Clear(); dictionary = null; return(false); }
public static bool ShowIfNotEnoughMultipleCurrencies(string[] cost, string purchaseContext, OnScreenModalResult onModalResult) { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); int num; int num2; int num3; int num4; GameUtils.GetHQScaledCurrency(cost, out num, out num2, out num3, out num4); Dictionary <CurrencyType, int> dictionary = new Dictionary <CurrencyType, int>(); int num5 = num - currentPlayer.CurrentCreditsAmount; int num6 = num2 - currentPlayer.CurrentMaterialsAmount; int num7 = num3 - currentPlayer.CurrentContrabandAmount; if (num5 > 0) { dictionary.Add(CurrencyType.Credits, num5); } else { num5 = 0; } if (num6 > 0) { dictionary.Add(CurrencyType.Materials, num6); } else { num6 = 0; } if (num7 > 0) { dictionary.Add(CurrencyType.Contraband, num7); } else { num7 = 0; } if (dictionary.Count > 0) { Lang lang = Service.Get <Lang>(); bool flag = true; List <string> list = new List <string>(); List <string> list2 = new List <string>(); foreach (KeyValuePair <CurrencyType, int> current in dictionary) { CurrencyType key = current.get_Key(); int value = current.get_Value(); flag &= GameUtils.HasEnoughCurrencyStorage(key, value); list.Add(UXUtils.GetCurrencyItemAssetName(key.ToString())); string currencyStringId = LangUtils.GetCurrencyStringId(key); string text = lang.Get(currencyStringId, new object[0]); list2.Add(lang.ThousandsSeparated(value) + " " + text); } if (flag) { string title = lang.Get("NEED_MORE_MULTI", new object[0]); string message = lang.Get("NEED_MORE_MULTI_BUY_MISSING", new object[0]); int num8 = GameUtils.MultiCurrencyCrystalCost(dictionary); MultiCurrencyTag modalResultCookie = new MultiCurrencyTag(num5, num6, num7, num8, purchaseContext); MultiResourcePayMeScreen multiResourcePayMeScreen = new MultiResourcePayMeScreen(num8, title, message, list, list2); multiResourcePayMeScreen.OnModalResult = onModalResult; multiResourcePayMeScreen.ModalResultCookie = modalResultCookie; Service.Get <ScreenController>().AddScreen(multiResourcePayMeScreen); } else { onModalResult(null, null); } return(true); } dictionary.Clear(); dictionary = null; return(false); }