public void queueNotification(UINotificationItem notificationItem)
    {
        foreach (UINotificationItem item in notificationQueue)
        {
            if (item.title == notificationItem.title)
            {
                return;
            }
        }

        if (currentItem != null)
        {
            if (currentItem.title == notificationItem.title)
            {
                return;
            }
        }

        notificationQueue.Enqueue(notificationItem);

        LogUtil.Log("Notification Queue("
                    + notificationQueue.Count + ") "
                    + "Notification Added:title:"
                    + notificationItem.title
                    + " notificationType:"
                    + notificationItem.notificationType

                    );

        ProcessNotifications();
    }
    // NOTIFICATION MAIN

    public void QueueNotification(UINotificationItem notificationItem)
    {
        if (Instance != null)
        {
            Instance.queueNotification(notificationItem);
        }
    }
    public void queueNotification(
        string title,
        string description,
        double score,
        UINotificationType notificationType)
    {
        UINotificationItem notification = new UINotificationItem();

        notification.title            = title;
        notification.description      = description;
        notification.notificationType = notificationType;
        notification.score            = score.ToString("N0");
        QueueNotification(notification);
    }
示例#4
0
    public void ShowDialog()
    {
        TweenUtil.MoveToObject(notificationPanel, Vector3.zero.WithY(positionYOpenInGame), .6f, 0f);

        //UITweenerUtil.MoveTo(notificationPanel, .6f, 0f, Vector3.zero.WithY(positionYOpenInGame));

        Invoke("HideDialog", 4.5f);

        SetStateShowing();

        bool audioPlaySuccess = false;

        if (currentItem != null)
        {
            if (currentItem.notificationType == UINotificationType.Achievement)
            {
                audioPlaySuccess = true;
            }
            else if (currentItem.notificationType == UINotificationType.Error)
            {
            }
            else if (currentItem.notificationType == UINotificationType.Info)
            {
                audioPlaySuccess = true;
            }
            else if (currentItem.notificationType == UINotificationType.Point)
            {
                audioPlaySuccess = true;
            }
            else if (currentItem.notificationType == UINotificationType.Tip)
            {
            }
        }

        if (audioPlaySuccess)
        {
            //GameAudio.PlayEffect(GameAudioEffects.audio_effect_achievement_1);
            //GameAudio.PlayEffect(GameAudioEffects.audio_effect_achievement_2);
            //GameAudio.PlayEffect(GameAudioEffects.audio_effect_achievement_3);
        }

        currentItem = null;
    }
    public void ProcessNextNotification()
    {
        if (!Paused)
        {
            if (notificationQueue.Count > 0)
            {
                currentItem = notificationQueue.Dequeue();

                bool found = false;


                if (currentItem.notificationType == UINotificationType.Achievement)
                {
                    ShowNotificationContainerType(currentItem.notificationType);
                    UIUtil.SetLabelValue(achievementTitle, currentItem.title);
                    UIUtil.SetLabelValue(achievementDescription, currentItem.description);

                    if (GameConfigs.useCoinRewardsForAchievements)
                    {
                        double score = Convert.ToDouble(currentItem.score);
                        score            *= 50; // 50 coins per
                        lastScore         = 0;
                        currentScore      = score;
                        currentItem.score = currentScore.ToString("N0");
                        GameProfileRPGs.Current.AddCurrency(currentScore);
                    }

                    UIUtil.SetLabelValue(achievementScore, "+" + currentItem.score);

                    found = true;
                }
                else if (currentItem.notificationType == UINotificationType.Point)
                {
                    ShowNotificationContainerType(currentItem.notificationType);
                    UIUtil.SetLabelValue(pointTitle, currentItem.title);
                    UIUtil.SetLabelValue(pointDescription, currentItem.description);
                    UIUtil.SetLabelValue(pointScore, "+" + currentItem.score);

                    found = true;
                }
                else if (currentItem.notificationType == UINotificationType.Info)
                {
                    ShowNotificationContainerType(currentItem.notificationType);
                    UIUtil.SetLabelValue(infoTitle, currentItem.title);
                    UIUtil.SetLabelValue(infoDescription, currentItem.description);
                    UIUtil.SetLabelValue(infoScore, "");


                    found = true;
                }
                else if (currentItem.notificationType == UINotificationType.Tip)
                {
                    ShowNotificationContainerType(currentItem.notificationType);
                    UIUtil.SetLabelValue(tipTitle, currentItem.title);
                    UIUtil.SetLabelValue(tipDescription, currentItem.description);
                    UIUtil.SetLabelValue(tipScore, "");

                    found = true;
                }
                else if (currentItem.notificationType == UINotificationType.Error)
                {
                    ShowNotificationContainerType(currentItem.notificationType);
                    UIUtil.SetLabelValue(errorTitle, currentItem.title);
                    UIUtil.SetLabelValue(errorDescription, currentItem.description);
                    UIUtil.SetLabelValue(errorScore, "");

                    found = true;
                }

                if (found)
                {
                    LogUtil.Log("Notification Queue("
                                + notificationQueue.Count + ") "
                                + "Notification Removed:title:"
                                + currentItem.title
                                + " notificationType:"
                                + currentItem.notificationType

                                );

                    ShowDialog();
                }
            }
        }
    }
    public void QueueAchievement(string achievementCode)
    {
        LogUtil.Log("Queueing Achievement:achievementCode:" + achievementCode);
        string packCode          = GamePacks.Current.code;
        string app_state         = AppStates.Current.code;
        string app_content_state = AppContentStates.Current.code;

        string achievementBaseCode = achievementCode;

        achievementBaseCode = achievementBaseCode.Replace("-" + app_state, "");
        achievementBaseCode = achievementBaseCode.Replace("_" + GameAchievementCodes.formatAchievementCode(app_state), "");
        achievementBaseCode = achievementBaseCode.Replace("-" + app_content_state, "");
        achievementBaseCode = achievementBaseCode.Replace("_" + GameAchievementCodes.formatAchievementCode(app_content_state), "");
        achievementBaseCode = achievementBaseCode.Replace("-" + packCode, "");
        achievementBaseCode = achievementBaseCode.Replace("_" + GameAchievementCodes.formatAchievementCode(packCode), "");

        GameAchievement achievement
            = GameAchievements.Instance.GetByCodeAndPack(
                  achievementCode,
                  packCode              //,
                  //app_content_state
                  );


        if (achievement != null)
        {
            //achievement.description = GameAchievements.Instance.FormatAchievementTags(
            //	app_state,
            //	app_content_state,
            //	achievement.description);
            //LogUtil.Log("Queueing Achievement display:" + achievement.display_name);
        }
        else
        {
            LogUtil.Log("Achievement not found:" + achievementCode);
        }

        if (achievement != null)
        {
            UINotificationItem item = new UINotificationItem();
            item.code             = achievement.code;
            item.description      = achievement.description;
            item.icon             = "";
            item.notificationType = UINotificationType.Achievement;
            item.score            = achievement.data.points.ToString();
            item.title            = achievement.display_name;
            QueueNotification(item);
        }

        if (achievementCode == "achieve_test1")
        {
            UINotificationItem item = new UINotificationItem();
            item.code             = achievementCode;
            item.description      = "This is an achievement test, you did awesome!";
            item.icon             = "";
            item.notificationType = UINotificationType.Achievement;
            item.score            = 3.ToString();
            item.title            = "First Achievement Tested";
            QueueNotification(item);
        }
    }