コード例 #1
0
    public void DisplayRegularNotification(Notification notification, NotificationThumbnail currentlyOpenThumbnail = null)
    {
        currentlyOpenNoteThumbnail = currentlyOpenThumbnail;

        // Close all the other menus first
        HideAllNotifications();
        menuController.CloseAllOtherMenus();
        menuController.SetMenuStatusToClose();

        currentNoteToshow = notification;
        notificationPanel.SetActive(true);


        noteTitle.text = currentNoteToshow.title;
        noteBody.text  = currentNoteToshow.body;

        noteIsShowing = true;

        noteImage.gameObject.SetActive(false);


        if (notification.image)
        {
            noteImage.gameObject.SetActive(true);
            noteImage.GetComponent <Image>().sprite = notification.image;
        }

        if (notification.button1Label != "")
        {
            button1.gameObject.SetActive(true);
            button1.onClick.RemoveAllListeners();
            button1.onClick.AddListener(HideAllNotifications);
            button1.onClick.AddListener(() => HideAllNotifications());
            button1.GetComponentInChildren <Text>().text = notification.button1Label;
        }

        button2.onClick.RemoveAllListeners();
        button2.gameObject.SetActive(false);

        currentlyOpenNoteThumbnail.gameObject.SetActive(false);
        currentlyOpenNoteThumbnail = null;
    }
コード例 #2
0
    public void DisplayAChoiceNotification(Notification notification, NotificationThumbnail currentlyOpenThumbnail = null,
                                           UnityAction firstButtonAction = null, UnityAction secondButtonAction = null)
    {
        if (currentlyOpenThumbnail)
        {
            currentlyOpenNoteThumbnail = currentlyOpenThumbnail;
        }

        // Close all the other menus first
        HideAllNotifications();
        menuController.CloseAllOtherMenus();
        menuController.SetMenuStatusToClose();

        currentNoteToshow = notification;
        notificationPanel.SetActive(true);


        noteTitle.text = currentNoteToshow.title;
        noteBody.text  = currentNoteToshow.body;

        noteIsShowing = true;

        noteImage.gameObject.SetActive(false);


        if (notification.image)
        {
            noteImage.gameObject.SetActive(true);
            noteImage.GetComponent <Image>().sprite = notification.image;
        }

        button1.gameObject.SetActive(false);


        if (notification.button1Label != "")
        {
            button1.gameObject.SetActive(true);
            button1.onClick.RemoveAllListeners();
            button1.onClick.AddListener(HideAllNotifications);

            button1.onClick.AddListener(firstButtonAction);

            button1.GetComponentInChildren <Text>().text = notification.button1Label;

            if (notification.affectsGameplay)
            {
                foreach (Attribute attr in notification.attributesIAffect)
                {
                    if (attr.id == 0)
                    {
                        // Mining speed effect
                        button1.onClick.AddListener(() => miningController.IncreaseMinMaxMiningSpeed(notification.button1EffectOnAttribute));
                    }
                    else if (attr.id == 1)
                    {
                        // Dust timer effect
                        button1.onClick.AddListener(() => miningController.AddTimeToDustTimer((int)notification.button1EffectOnAttribute));
                    }
                }
            }
        }

        button2.gameObject.SetActive(false);

        if (notification.button2Label != "")
        {
            button2.gameObject.SetActive(true);
            button2.onClick.RemoveAllListeners();
            button2.onClick.AddListener(HideAllNotifications);

            button2.onClick.AddListener(secondButtonAction);

            button2.GetComponentInChildren <Text>().text = notification.button2Label;
        }
    }