private FlashSaleItem GetNextSale() { var items = Services.ResourceService.Products.Promotions.ToArray(); //GlobalRefs.IAP.Promotions.ToArray(); var curPromo = Player.LegacyPlayerData.CurrentPromotionIndex % items.Length; FlashSaleItem rv = new FlashSaleItem() { Listing = items[curPromo].ToListing(), ExpirationDate = DateTime.Now.AddHours(2), }; Player.LegacyPlayerData.CurrentPromotionIndex++; return(rv); }
public void Show() { var fs = Player.LegacyPlayerData.CurrentFlashSale; if (fs == null) { return; } _current = fs; CoinText.text = string.Format("{0} " + "COINS".GetLocalizedString(), fs.Listing.Coins); string storeId = _current.Listing.StoreIdentifier; #if UNITY_IOS && !BOS if (!storeId.StartsWith("bos2_")) { storeId = "bos2_" + storeId; } #endif Debug.Log($"flash store id: {storeId}"); Services.Inap.GetProductByStoreId(storeId).Match(() => { PriceText.text = string.Empty; return(F.None); }, product => { PriceText.text = product.metadata.localizedPriceString; return(F.Some(product)); }); SaveText.text = string.Format("SAVE20".GetLocalizedString(), fs.Listing.AmountSaved); RewardText.text = GetRewardText(fs.Listing.BonusType, fs.Listing.BonusValue); DescriptionText.text = string.Format("BONUS.DESC".GetLocalizedString(), fs.Listing.AmountSaved, fs.Listing.Coins, RewardText.text, PriceText.text); RewardImage.sprite = fs.Sprite; gameObject.SetActive(true); _current.ActiveOnScreen = true; Analytics.CustomEvent($"FLASH_SALE_{fs.Listing.StoreIdentifier}_OPEN"); }
public void Load() { var json = PlayerPrefs.GetString(KEY, null); if (!string.IsNullOrEmpty(json)) { var pdata = JsonConvert.DeserializeObject <PlayerData>(json); #region LocalData LocalDataPorted = pdata.LocalDataPorted; if (!LocalDataPorted) { //LifetimeEarnings = OLD_LocalData.LifetimeSavings; LastPauseBalance = OLD_LocalData.LastPauseBalance; LocalDataPorted = true; } else { //LifetimeEarnings = pdata.LifetimeEarnings; LastPauseBalance = pdata.LastPauseBalance; } #endregion FreeCoinsFB = pdata.FreeCoinsFB; FreeCoinsTW = pdata.FreeCoinsTW; GameFinished = pdata.GameFinished; CurrentFlashSale = pdata.CurrentFlashSale; CurrentPromotionIndex = pdata.CurrentPromotionIndex; SessionCount = pdata.SessionCount; ConsecutiveDaysEntered = pdata.ConsecutiveDaysEntered; CurrentOfferExpires = pdata.CurrentOfferExpires; DailyBonusGathered = pdata.DailyBonusGathered; DateOfferClicked = pdata.DateOfferClicked; rewardedVideoAchievmentStatus = pdata.rewardedVideoAchievmentStatus; } //if (managers == null || managers.Count == 0) ManagerInit(); }
public override void Update() { base.Update(); var dt = _current.ExpirationDate - DateTime.Now; if (dt.TotalHours < 0) { _current = Player.LegacyPlayerData.CurrentFlashSale; dt = _current.ExpirationDate - DateTime.Now; if (dt.TotalHours < 0) { gameObject.SetActive(false); Debug.LogError("Current offer expiration"); } } ExpirationText.text = dt.ToString(@"hh\:mm\:ss"); if (_current.ShouldHide) { gameObject.SetActive(false); } }