Exemple #1
0
        public void buildHiddenWaves(Generator notificationGenerator, Coordinate traysCoordinates)
        {
            try
            {
                var storage = FindObjectOfType <Storage>();
                Dictionary <string, NotificationsStorage> orderedNotifications = storage.getStorage();
                Notification n           = orderedNotifications.Values.First().Storage.Peek();
                int          columnIndex = 1;
                int          notififcationsNumberInTraysColumnNow = 0;
                Debug.Log("TRAYHOLD1 " + trayHolder);
                if ((!n.isSilent && trayHolder == null) || (!n.isSilent && trayHolder != null && !trayHolder.activeSelf))
                {
                    GameObject wave = Instantiate(notification) as GameObject;
                    Color      c    = n.Color;
                    c.a = 0.5f;

                    if (n.SourceName == "YouTube")
                    {
                        wave.GetComponentInChildren <Image>().material = red;
                    }
                    if (n.SourceName == "Telegram")
                    {
                        wave.GetComponentInChildren <Image>().material = blue;
                    }
                    if (n.SourceName == "Яндекс.Почта")
                    {
                        wave.GetComponentInChildren <Image>().material = yellow;
                    }
                    if (n.SourceName == "WhatsApp")
                    {
                        wave.GetComponentInChildren <Image>().material = green;
                    }
                    if (n.SourceName == GlobalCommon.silentGroupKey)
                    {
                        wave.GetComponentInChildren <Image>().material = grey;
                    }
                    wave.GetComponentInChildren <Image>().material.SetFloat("_Glossiness", 1f);
                    try
                    {
                        wave.transform.SetParent(notificationsHolder.GetComponent <Transform>());
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }
                Debug.Log("TRAYHOLD2 " + trayHolder);
                if (trayHolder != null && trayHolder.activeSelf)
                {
                    clearScene();
                    List <Coordinates> coordinates = traysCoordinates();
                    int indexPosition          = 0;
                    int maxNotificationsInTray = GlobalCommon.notificationsInColumnTray * GlobalCommon.notificationColumnsTray;
                    foreach (KeyValuePair <string, NotificationsStorage> notificationGroup in orderedNotifications)
                    {
                        Stack <Notification> groupNotifications = notificationGroup.Value.Storage;
                        for (int i = 0; i < groupNotifications.Count; i++)
                        {
                            Notification notification          = groupNotifications.ToArray()[i];
                            bool         doesHaveGroupIconTray = i == groupNotifications.Count - 1 || indexPosition == columnIndex * GlobalCommon.notificationsInColumnTray - 1;
                            if (indexPosition < maxNotificationsInTray)
                            {
                                Vector3    position = coordinates[indexPosition].Position;
                                Quaternion rotation = Quaternion.Euler(coordinates[indexPosition].Rotation.x, coordinates[indexPosition].Rotation.y, coordinates[indexPosition].Rotation.z);
                                Vector3    scale    = coordinates[indexPosition].Scale;
                                GameObject trayN    = notificationGenerator(trayNotification, notification, position, scale, rotation, doesHaveGroupIconTray);
                                try
                                {
                                    trayN.transform.parent        = trayHolder.transform;
                                    trayN.transform.localPosition = position;
                                    trayN.transform.localRotation = rotation;
                                }
                                catch (Exception e) { }
                                indexPosition += 1;
                                notififcationsNumberInTraysColumnNow += 1;
                                if (notififcationsNumberInTraysColumnNow == GlobalCommon.notificationsInColumnTray)
                                {
                                    notififcationsNumberInTraysColumnNow = 0;
                                    columnIndex += 1;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
        public void buildInFrontOf(Generator notificationGenerator, Coordinate notificationCoordinates, Coordinate traysCoordinates)
        {
            var storage = FindObjectOfType <Storage>();
            Dictionary <string, NotificationsStorage> orderedNotifications = storage.getStorage();

            clearScene();
            List <Coordinates> coordinates     = notificationCoordinates();
            List <Coordinates> trayCoordinates = traysCoordinates();
            int usualCoordinatesIndex          = 0;
            int trayCoordinatesIndex           = 0;
            int columnIndex = 1;
            int notififcationsNumberInTraysColumnNow = 0;
            int maxNotifications       = notificationsInColumn * notificationColumns;
            int maxNotificationsInTray = GlobalCommon.notificationsInColumnTray * GlobalCommon.notificationColumnsTray;

            foreach (KeyValuePair <string, NotificationsStorage> notificationGroup in orderedNotifications)
            {
                Stack <Notification> groupNotifications = notificationGroup.Value.Storage;
                for (int i = 0; i < groupNotifications.Count; i++)
                {
                    Notification notificationInGroup = groupNotifications.ToArray()[i];
                    if (trayCoordinatesIndex < maxNotificationsInTray) // tray case
                    {
                        bool       doesHaveGroupIconTray = i == groupNotifications.Count - 1 || trayCoordinatesIndex == columnIndex * GlobalCommon.notificationsInColumnTray - 1;
                        Vector3    position = trayCoordinates[trayCoordinatesIndex].Position;
                        Quaternion rotation = Quaternion.Euler(trayCoordinates[trayCoordinatesIndex].Rotation.x, trayCoordinates[trayCoordinatesIndex].Rotation.y, trayCoordinates[trayCoordinatesIndex].Rotation.z);
                        Vector3    scale    = trayCoordinates[trayCoordinatesIndex].Scale;
                        GameObject trayN    = notificationGenerator(trayNotification,
                                                                    notificationInGroup,
                                                                    scale,
                                                                    doesHaveGroupIconTray);
                        try
                        {
                            trayN.transform.parent        = trayHolder.transform;
                            trayN.transform.localPosition = position;
                            trayN.transform.localRotation = rotation;
                        }
                        catch (Exception e) {  }
                        trayCoordinatesIndex += 1;
                        notififcationsNumberInTraysColumnNow += 1;
                        if (notififcationsNumberInTraysColumnNow == GlobalCommon.notificationsInColumnTray)
                        {
                            notififcationsNumberInTraysColumnNow = 0;
                            columnIndex += 1;
                        }
                    }
                    if (usualCoordinatesIndex < maxNotifications &&
                        trayHolder != null &&
                        !trayHolder.activeSelf &&
                        notificationInGroup != null &&
                        !notificationInGroup.isMarkedAsRead &&
                        !notificationInGroup.isSilent)    // usual case
                    {
                        bool       doesHaveGroupIcon = i == groupNotifications.Count - 1 || usualCoordinatesIndex == notificationsInColumn - 1;
                        Vector3    position          = coordinates[usualCoordinatesIndex].Position;
                        Quaternion rotation          = Quaternion.Euler(coordinates[usualCoordinatesIndex].Rotation.x, coordinates[usualCoordinatesIndex].Rotation.y, coordinates[usualCoordinatesIndex].Rotation.z);
                        Vector3    scale             = coordinates[usualCoordinatesIndex].Scale;
                        GameObject n = notificationGenerator(notification,
                                                             notificationInGroup,
                                                             scale,
                                                             doesHaveGroupIcon);
                        n.transform.parent        = notificationsHolder.transform;
                        n.transform.localPosition = position;
                        n.transform.localRotation = rotation;
                        usualCoordinatesIndex    += 1;
                    }
                }
            }
        }