//sorts the triggers into each day public void SortingTime(SerialisableTriggerClass newSortEntry) { string day = newSortEntry.day; if (day == "Monday") { insertNewSort(ref so.monday, newSortEntry); } else if (day == "Tuesday") { insertNewSort(ref so.tuesday, newSortEntry); } else if (day == "Wednesday") { insertNewSort(ref so.wednesday, newSortEntry); } else if (day == "Thursday") { insertNewSort(ref so.thursday, newSortEntry); } else if (day == "Friday") { insertNewSort(ref so.friday, newSortEntry); } else if (day == "Saturday") { insertNewSort(ref so.saturday, newSortEntry); } else if (day == "Sunday") { insertNewSort(ref so.sunday, newSortEntry); } }
//creates the triggers for the notification private SerialisableTriggerClass createTrigger(string day, string hour, string minute, int ID, int triggerID) { SerialisableTriggerClass newNotifTrigger = new SerialisableTriggerClass(); newNotifTrigger.active = 0; newNotifTrigger.timeHour = hour; newNotifTrigger.timeMinute = minute; newNotifTrigger.day = day; newNotifTrigger.active = 0; newNotifTrigger.TriggerID = triggerID; newNotifTrigger.NotifID = ID; SortingTime(newNotifTrigger); return(newNotifTrigger); }
//calculates where the trigger will be inserted private void insertNewSort(ref List <SerialisableTriggerClass> day, SerialisableTriggerClass newSortEntry) { //loop through each trigger in day bucket for (int k = 0; k < day.Count; k++) { string temp = day[k].timeHour + day[k].timeMinute; string temp2 = newSortEntry.timeHour + newSortEntry.timeMinute; //compare times if (int.Parse(temp) > int.Parse(temp2)) { //insert the new trigger in correct place day.Insert(k, newSortEntry); return; } } day.Add(newSortEntry); }
public void CreateNotificationFunc() { //retrieve input list of triggers triggerList = triggerListObjects.GetComponent <TriggerListControl>().AllClassTriggers; checkErrors(); if (errors > 0) { return; } so = SaveManager.Load(); //check if when button clicked will edit or create new notification if (edit == 1) { DeleteCurrentEdit(); } newNotification = new SerializableNotificationClass(); // create new notification object newNotification.notifPrompt = new List <SerialisableTriggerClass>(); // Create new trigger list //creates ID of notification if (so.notifications.Count == 0) { newNotification.notifID = 0; } else { newNotification.notifID = so.notifications[so.notifications.Count - 1].notifID + 1; } //set content for notification newNotification.active = 0; newNotification.notifTitle = notifTitleText.text; newNotification.notifText = notifContentText.text; newNotification.colour = colourObject.GetComponent <SelectColour>().ColourSelectedHex; //loop through list of triggers adding to the new notification for (int i = 0; i < triggerList.Count; i++) { individualTrigger = new SerialisableTriggerClass(); individualTrigger.timeHour = triggerList[i].hour; individualTrigger.timeMinute = triggerList[i].minute; individualTrigger.day = triggerList[i].day; individualTrigger.active = triggerList[i].active; //assigns new TriggerIDs int NewTriggerID; if (newNotification.notifPrompt.Count == 0) { NewTriggerID = 0; } else { NewTriggerID = newNotification.notifPrompt[newNotification.notifPrompt.Count - 1].TriggerID + 1; } individualTrigger.TriggerID = NewTriggerID; individualTrigger.NotifID = newNotification.notifID; newNotification.notifPrompt.Add(individualTrigger); //sorts the triggers SortingTime(individualTrigger); } so.notifications.Add(newNotification); SaveManager.Save(so); SceneManager.LoadScene(SceneToLoad); }