Beispiel #1
0
    private void RemovingUpdate()
    {
        float t = tForState();

        if (t > 1.0f)
        {
            if (currentNotificationIndex == (activeNotifications.Count - 1))
            {
                // then we are in the rightmost position (dont have to worry about shifting)
                current_state = NotificationSystemState.STATIC;
                activeNotifications.Remove(currentNotification);
                stateStartTime = Time.time;
            }
            else
            {
                // then we have to worry about shifting
                current_state  = NotificationSystemState.SHIFTING_LEFT;
                stateStartTime = Time.time;
            }
        }
        else
        {
            moveNotificationByYOffset(NotificationInstances[currentNotification] as GameObject, startYOffset, t);
        }
    }
Beispiel #2
0
    // -- Actual logic -- //

    private void addNotification(NotificationType typeToAdd)
    {
        if (current_state == NotificationSystemState.STATIC)
        {
            GameObject prefabToAdd    = retriveNotificatioinPrefab(typeToAdd);
            bool       mainRecipeType = isMainRecipeType(typeToAdd);
            currentNotification = typeToAdd;
            stateStartTime      = Time.time;

            if (mainRecipeType)
            {
                // then we have to insert to the front of the notifications
                currentNotificationIndex = 0;
                if (activeNotifications.Count > 0)
                {
                    current_state = NotificationSystemState.SHIFTING_RIGHT;
                }
                else
                {
                    current_state = NotificationSystemState.ADDING;
                }
            }
            else
            {
                // then we are simply adding it to the back of the notifications
                current_state            = NotificationSystemState.ADDING;
                currentNotificationIndex = activeNotifications.Count;
            }

            // instantiate object at currentNotificationIndex, and off screen
            Vector3    rectTransformPos = gameObject.GetComponent <RectTransform>().position;
            GameObject instanceToAdd    = Instantiate(prefabToAdd, canvas.transform) as GameObject;
            //// set up rectTransform
            RectTransform instanceRectTransform = instanceToAdd.GetComponent <RectTransform>();
            instanceRectTransform.SetParent(canvas.transform, false);
            instanceRectTransform.localScale       = Vector3.one;
            instanceRectTransform.localPosition    = Vector3.one;
            instanceRectTransform.anchorMin        = new Vector2(0.0f, 1.0f);
            instanceRectTransform.anchorMax        = new Vector2(0.0f, 1.0f);
            instanceRectTransform.pivot            = new Vector2(0.5f, 0.5f);
            instanceRectTransform.anchoredPosition = new Vector2(getStartXFromIndex(currentNotificationIndex), firstNotificationLoc.y);

            NotificationInstances[typeToAdd] = instanceToAdd;
        }
        else
        {
            toAddBuffer.Enqueue(typeToAdd);
        }
    }
Beispiel #3
0
 private void removeNotification(NotificationType typeToRemove)
 {
     if (current_state == NotificationSystemState.STATIC)
     {
         currentNotification = typeToRemove;
         int index = findIndexFromList(activeNotifications, typeToRemove);
         currentNotificationIndex = index;
         stateStartTime           = Time.time;
         current_state            = NotificationSystemState.REMOVING;
     }
     else
     {
         toRemoveBuffer.Enqueue(typeToRemove);
     }
 }
Beispiel #4
0
    private void AddingUpdate()
    {
        float t = tForState();

        if (t > 1.0f)
        {
            current_state  = NotificationSystemState.STATIC;
            stateStartTime = Time.time;
            activeNotifications.Insert(currentNotificationIndex, currentNotification);
        }
        else
        {
            moveNotificationByYOffset(NotificationInstances[currentNotification] as GameObject, -startYOffset, t);
        }
    }
Beispiel #5
0
    // -- Update functions -- //
    private void ShiftingRightUpdate()
    {
        float t = tForState();

        if (t > 1.0f)
        {
            // then we are ready to add object
            current_state  = NotificationSystemState.ADDING;
            stateStartTime = Time.time;
        }
        else
        {
            moveAllToRightOfIndex(currentNotificationIndex, notificationRadius * 2.0f, t);
        }
    }
Beispiel #6
0
    private void ShiftingLeftUpdate()
    {
        float t = tForState();

        if (t > 1.0f)
        {
            // then we have finished removing the object
            current_state = NotificationSystemState.STATIC;
            activeNotifications.Remove(currentNotification);
            stateStartTime = Time.time;
        }
        else
        {
            moveAllToRightOfIndex(currentNotificationIndex, -(2.0f * notificationRadius), t);
        }
    }