/// <summary> /// Initialises new notification with given values, creates gameobject and adds notification component. /// Notification is inserted in database. /// </summary> /// <param name="messageType">message type of notification</param> /// <param name="state">state of notification</param> /// <param name="objectName">name of Roboy body part notification is related to (can be null)</param> /// <param name="timeFrame">time frame in which notification is valid</param> /// <returns></returns> public Notification AddNewNotification(DummyStates.MessageType messageType, DummyStates.State state, string objectName, float timeFrame) { GameObject obj = new GameObject(); obj.name = "Notification"; //unity automatically changes name if multiple instances occure -> e.g. "Notification(3)" Notification note = obj.AddComponent <Notification>(); note.Initialize(messageType, state, objectName, timeFrame); AddNotification(note); note.transform.SetParent(m_NotificationsContainer.transform); return(note); }
/// <summary> /// Basic Notification constructor, creating note with specified type and state /// </summary> /// <param name="type">What type of message (warning, error ...)</param> /// <param name="state">What state is the notification depicting</param> /// <param name="objName">The name of the concerned body part</param> /// <param name="timeFrame">time this notification is valid in seconds</param> public void Initialize(DummyStates.MessageType type, DummyStates.State state, string objName, double timeFrame) { m_State = state; m_Type = type; m_Content = new Content(); SetConcernedRoboyPart(objName); if (m_BodyPart) { m_BodyPart.GetComponent <RoboyPart>().AddNotification(this); m_BodyPart.GetComponent <RoboyPart>().UpdateNotificationsDisplay(); } m_Timestamp = DateTime.Now; m_TimeFrame = timeFrame; //TODO: small time difference might occure //get rid of this notification after specified amount of time Invoke("DeleteNotification", (float)m_TimeFrame); }