//creates each template notification private void createNotification(string title, string content, string colour, string hour, string minute, int ID) { newNotif = new SerializableNotificationClass(); newNotif.notifPrompt = new List <SerialisableTriggerClass>(); //assigns details to new notification newNotif.notifID = ID; newNotif.active = 0; newNotif.notifTitle = title; newNotif.notifText = content; newNotif.colour = colour; //creates each of the triggers and adds each to the notification newNotif.notifPrompt.Add(createTrigger("Monday", hour, minute, ID, 1)); newNotif.notifPrompt.Add(createTrigger("Tuesday", hour, minute, ID, 2)); newNotif.notifPrompt.Add(createTrigger("Wednesday", hour, minute, ID, 3)); newNotif.notifPrompt.Add(createTrigger("Thursday", hour, minute, ID, 4)); newNotif.notifPrompt.Add(createTrigger("Friday", hour, minute, ID, 5)); newNotif.notifPrompt.Add(createTrigger("Saturday", hour, minute, ID, 6)); newNotif.notifPrompt.Add(createTrigger("Sunday", hour, minute, ID, 7)); }
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); }