Example #1
0
    /// <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);
    }
Example #2
0
 /// <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);
 }
Example #3
0
    /// <summary>
    /// Returns respective texture for passed message type
    /// </summary>
    /// <param name="iconType">message type for which texture is requested</param>
    /// <returns></returns>
    public Texture GetIconTexture(DummyStates.MessageType iconType)
    {
        switch (iconType)
        {
        case DummyStates.MessageType.INFO:
            return(m_info);

        case DummyStates.MessageType.DEBUG:
            return(m_debug);

        case DummyStates.MessageType.WARNING:
            return(m_warning);

        case DummyStates.MessageType.ERROR:
            return(m_error);

        default:
            return(null);
        }
    }