public void ActivateDailyReward(bool debug = true) { this.FillContent(); if (TimeManager.gotDateTime) { this.currentDate = TimeManager.CurrentDateTime; this.type = this.CanGetReward(debug); this.ActivateCurrentDay(); } else { this.type = StreakType.Unknown; DataLoader.gui.OpenDaily(false); } }
public void ClaimReward() { if ((this.type == StreakType.GetToday) || (this.type == StreakType.StreakEnded)) { DataLoader.Instance.SetTotalDays(DataLoader.playerData.totalDaysInRow + 1, false); if (this.type == StreakType.StreakEnded) { PlayerPrefs.SetString(StaticConstants.DailyRewardKey, this.currentDate.Date.Ticks.ToString()); } this.dailyContent[(DataLoader.Instance.currentDayInRow < 7) ? DataLoader.Instance.currentDayInRow : (DataLoader.Instance.currentDayInRow - 7)].ActivateReward(); this.type = StreakType.OnStreak; this.ActivateDailyReward(false); Debug.Log("Got Daily reward"); } }
public static void Add(List <Streak <T> > streaks, StreakType streakType, T content) { Streak <T> streak = streaks.LastOrDefault(); if (streak == null || streak.StreakType != streakType) { streaks.Add(new Streak <T> { Content = new List <T> { content }, StreakType = streakType, }); } else { streak.Content.Add(content); } }
/// <summary> /// Save the current record. /// </summary> /// <returns></returns> private void SaveRecord() { var streakType = GetStreakType(); var streakTypeService = GetStreakTypeService(); var isNew = streakType == null; if (isNew) { streakType = new StreakType(); streakTypeService.Add(streakType); } // Can only set the start date if the streak type is new if (isNew) { var frequencySelected = GetEnumSelected <StreakOccurrenceFrequency>(ddlFrequencyOccurrence) ?? StreakOccurrenceFrequency.Daily; var isDaily = frequencySelected == StreakOccurrenceFrequency.Daily; streakType.OccurrenceFrequency = frequencySelected; var selectedDate = rdpStartDate.SelectedDate ?? RockDateTime.Today; streakType.StartDate = isDaily ? selectedDate : selectedDate.SundayDate(); } streakType.Name = tbName.Text; streakType.IsActive = cbActive.Checked; streakType.Description = tbDescription.Text; streakType.EnableAttendance = cbEnableAttendance.Checked; streakType.RequiresEnrollment = cbRequireEnrollment.Checked; streakType.StructureType = GetEnumSelected <StreakStructureType>(ddlStructureType); streakType.StructureEntityId = GetStructureEntityIdSelected(); if (streakType.OccurrenceFrequency == StreakOccurrenceFrequency.Weekly) { streakType.FirstDayOfWeek = dowPicker.SelectedDayOfWeek; } else { streakType.FirstDayOfWeek = null; } if (streakType.StructureType == StreakStructureType.FinancialTransaction) { streakType.StructureSettings.IncludeChildAccounts = cbIncludeChildAccounts.Checked; } if (!streakType.IsValid) { // Controls will render the error messages return; } try { var rockContext = GetRockContext(); rockContext.SaveChanges(); if (!streakType.IsAuthorized(Authorization.VIEW, CurrentPerson)) { streakType.AllowPerson(Authorization.VIEW, CurrentPerson, rockContext); } if (!streakType.IsAuthorized(Authorization.EDIT, CurrentPerson)) { streakType.AllowPerson(Authorization.EDIT, CurrentPerson, rockContext); } if (!streakType.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson)) { streakType.AllowPerson(Authorization.ADMINISTRATE, CurrentPerson, rockContext); } } catch (Exception ex) { ShowBlockException(nbEditModeMessage, ex); return; } // If the save was successful, reload the page using the new record Id. NavigateToPage(RockPage.Guid, new Dictionary <string, string> { { PageParameterKey.StreakTypeId, streakType.Id.ToString() } }); }