public static bool BonusCoins() { DateTime dateTime = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyAskFriendsLastDate, UnbiasedTime.Instance.Now().AddDays(-1).ToString(CultureInfo.InvariantCulture))); if (dateTime.Date < UnbiasedTime.Instance.Now().Date) { // last invite was yesterday, reset all data PreferencesFactory.SetString(Constants.KeyAskFriendsLastDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture)); PreferencesFactory.SetInt(Constants.KeyAskFriendsTotal, 0); dateTime = UnbiasedTime.Instance.Now(); } bool addedCoins = false; int totalInvites = PreferencesFactory.GetInt(Constants.KeyAskFriendsTotal); if (dateTime.Date == UnbiasedTime.Instance.Now().Date&& totalInvites < Constants.AskFriendsPerDay) { GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(Constants.AskFriendsCoins, rect: GameObject.Find("BoardContainer").transform as RectTransform, showAnimation: false); addedCoins = true; } PreferencesFactory.SetInt(Constants.KeyAskFriendsTotal, totalInvites + 1); return(addedCoins); }
public static void RewardRate() { DateTime dateTime = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyRateRewardLastDate, UnbiasedTime.Instance.Now().AddDays(-1).ToString(CultureInfo.InvariantCulture))); if (dateTime.Date < UnbiasedTime.Instance.Now().Date) { // last rate was yesterday, reset all data PreferencesFactory.SetString(Constants.KeyRateRewardLastDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture)); PreferencesFactory.SetInt(Constants.KeyRateRewardTotal, 0); dateTime = UnbiasedTime.Instance.Now(); } int totalRates = PreferencesFactory.GetInt(Constants.KeyRateRewardTotal); if (dateTime.Date == UnbiasedTime.Instance.Now().Date&& totalRates < 1) { GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); RectTransform tr = null; GameObject _c = GameObject.Find("BoardContainer"); if (_c != null) { tr = _c.transform as RectTransform; } addCoins.AnimateCoinsAdding(Constants.RateRewardCoins, rect: tr, showAnimation: false); } PreferencesFactory.SetInt(Constants.KeyRateRewardTotal, totalRates + 1); PreferencesFactory.SetInt(Constants.KeyRateMaxRewardsTime, PreferencesFactory.GetInt(Constants.KeyRateMaxRewardsTime, 0) + 1); }
private void ProcessDailyBonus(bool doublePrize = true) { _prizeIsProcessed = true; int DaysInRow = PreferencesFactory.GetInt(Constants.KeyFreePrizeTakeDaysInRow, 0); int extraCoins = 0; if (DaysInRow == 7) // reset { extraCoins = Constants.DialyBonusCoins; // bonus coins at last day PreferencesFactory.SetInt(Constants.KeyFreePrizeTakeDaysInRow, 1); } PreferencesFactory.SetString(Constants.KeyDateLastFreePrizeTake, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture)); if (PrizeDialogClosedAudioClip != null) { GameManager.Instance.PlayEffect(PrizeDialogClosedAudioClip); } if ((prizeIsCoins && this.PrizeItems > 0) || extraCoins > 0) { // add extra coins to reward coins only of prize is coins if (prizeIsCoins) { extraCoins += this.PrizeItems; } GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(extraCoins); } if (prizeIsPoints) { GameObject animatedPoints = GameObject.Find("AddPointsAnimated"); GameObject _clone = Instantiate(animatedPoints, animatedPoints.transform.parent); AddPointsAnimated _add = _clone.GetComponent <AddPointsAnimated>(); _add.AnimateAdding(this.PrizeItems); GameSparksManager.Instance.SendPoints(this.PrizeItems, "FreePrize"); } SetCurrentPrizeAmount(); // Local notifications #if !UNITY_EDITOR CancelLocalNotifications(); RegisterLocalNotifications(); #endif if (doublePrize) { ShowDoubleScreen(); } }
void CompleteReward() { if (!Debug.isDebugBuild) { Flurry.Flurry.Instance.LogEvent("ExtraCoins_DailyBonus"); Fabric.Answers.Answers.LogCustom("ExtraCoins_DailyBonus"); } if (dialogInstance != null && dialogInstance.gameObject != null && this.PrizeItems > 0) { GameObject part2 = GameObjectHelper.GetChildNamedGameObject(dialogInstance.Content, "Part2", true); Text rewardsCoinsText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(part2, "RewardsCoins", true); if (prizeIsPoints) { rewardsCoinsText.text = LocaliseText.Format("FreePrize.NumberMorePoints", this.PrizeItems); } if (prizeIsCoins) { rewardsCoinsText.text = LocaliseText.Format("FreePrize.NumberMoreCoins", this.PrizeItems); } GameObject WatchAds = GameObjectHelper.GetChildNamedGameObject(part2, "WatchAds", true); WatchAds.SetActive(false); GameObject DoubleButton = GameObjectHelper.GetChildNamedGameObject(part2, "DoubleButton", true); DoubleButton.SetActive(false); if (prizeIsCoins && this.PrizeItems > 0) { GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(this.PrizeItems); } if (prizeIsPoints) { GameObject animatedPoints = GameObject.Find("AddPointsAnimated"); GameObject _clone = Instantiate(animatedPoints, animatedPoints.transform.parent); AddPointsAnimated _add = _clone.GetComponent <AddPointsAnimated>(); _add.AnimateAdding(this.PrizeItems); GameSparksManager.Instance.SendPoints(this.PrizeItems, "FreePrize-Double"); } } }
// void BonusCoins() { int coins = PreferencesFactory.GetInt(Constants.KeyDailyLoginBonusCoins, 0); if (coins > 0) { PreferencesFactory.DeleteKey(Constants.KeyDailyLoginBonusCoins); GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(coins); } }
public static bool InviteBonusCoins() { DateTime dateTime = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyInviteLastDate, UnbiasedTime.Instance.Now().AddDays(-1).ToString(CultureInfo.InvariantCulture))); if (dateTime.Date < UnbiasedTime.Instance.Now().Date) { // last invite was yesterday, reset all data PreferencesFactory.SetString(Constants.KeyInviteLastDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture)); PreferencesFactory.SetInt(Constants.KeyInvitesTotal, 0); dateTime = UnbiasedTime.Instance.Now(); } bool addedCoins = false; int totalInvites = PreferencesFactory.GetInt(Constants.KeyInvitesTotal); #if UNITY_EDITOR totalInvites = 0; #endif if (dateTime.Date == UnbiasedTime.Instance.Now().Date&& totalInvites < Constants.InviteMaxPerDay) { GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(Constants.InviteAwardCoins); addedCoins = true; } PreferencesFactory.SetInt(Constants.KeyInvitesTotal, totalInvites + 1); return(addedCoins); }
void CompleteReward() { GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(Constants.FreeCoinsDaily); // PreferencesFactory.SetString(Constants.KeyFreeCoinsAvailable, UnbiasedTime.Instance.Now().AddMinutes(Constants.MinutesBetweenFreeCoins).ToString(CultureInfo.InvariantCulture)); int TimesFreeCoins = PreferencesFactory.GetInt(Constants.KeyFreeCoinsCounter, 0); TimesFreeCoins += 1; PreferencesFactory.SetInt(Constants.KeyFreeCoinsCounter, TimesFreeCoins); if (TimesFreeCoins >= Constants.TimesFreeCoins) { GameObjectHelper.SafeSetActive(FreeCoinsObject, false); GameObjectHelper.SafeSetActive(FreeCoinsCounterObject, true); } }
bool ItemPurchasedHandler(BaseMessage message) { ItemPurchasedMessage msg = message as ItemPurchasedMessage; PaymentProductCoins[] coins = CustomPaymentManager.Coins; for (int i = 0; i < coins.Length; i++) { if (coins[i].Product.Name.Equals(msg.ProductID)) { if (coins [i].Coins > 0) { GameObject animatedCoins = GameObject.Find("AddCoinsAnimated"); if (animatedCoins != null) { GameObject addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent); AddCoinsAnimated addCoins = addCoinsClone.GetComponent <AddCoinsAnimated>(); addCoins.AnimateCoinsAdding(coins [i].Coins); } else { GameManager.Instance.Player.AddCoins(coins [i].Coins); GameManager.Instance.Player.UpdatePlayerPrefs(); } } if (coins[i].NoAds == 1) { PreferencesFactory.SetInt(Constants.KeyNoAds, 1); } PreferencesFactory.Save(); if (!Debug.isDebugBuild) { Flurry.Flurry.Instance.LogEvent(coins [i].EventCode); Fabric.Answers.Answers.LogPurchase(coins [i].Price, coins [i].Currency, true, coins [i].Description, coins [i].NoAds == 1 ? "Ads" : "Coins", msg.ProductID ); Branch.userCompletedAction("InApp"); } if (GameSparksManager.IsUserLoggedIn()) { GSRequestData json = new GSRequestData(); json.Add("package", msg.ProductID); json.Add("price", string.Format("{0} {1}", coins[i].Price, coins[i].Currency)); json.Add("date", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); new LogEventRequest() .SetEventKey("IAPPurchase") .SetEventAttribute("data", json) .Send(((response) => { })); } if (coins[i].NoAds == 1) { DialogManager.Instance.Show(prefabName: "GeneralMessageOkButton", title: LocaliseText.Get("Text.Success"), text: LocaliseText.Get("Payment.PurchaseSuccess"), dialogButtons: DialogInstance.DialogButtonsType.Ok); } break; } } return(true); }