Exemple #1
0
    public bool SetAchievementContent(string achievementCode)
    {
        GameAchievement achievementMeta = GameAchievements.Instance.GetById(achievementCode);

        if (achievementMeta == null)
        {
            string tempCode = achievementCode.Replace("_" + GamePacks.Current.code, "");
            achievementMeta = GameAchievements.Instance.GetById(tempCode);
        }

        if (achievementMeta != null)
        {
            GameNotificationItem item = new GameNotificationItem();
            item.title            = achievementMeta.display_name;
            item.description      = FormatUtil.GetStringTrimmedWithBreaks(achievementMeta.description, 40);
            item.score            = "+" + achievementMeta.data.points.ToString();
            item.notificationType = GameNotificationType.Achievement;
            QueueNotification(item);

            return(true);
        }
        else
        {
            LogUtil.Log("SetAchievmentContent:: null achievementMeta: " + achievementCode);
            return(false);
        }
    }
    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);
        }
    }