Example #1
0
        public override object Call(params object[] args)
        {
            string msg = (string)args[0];

            switch (msg)
            {
            case "AddAchievement":
                if (Main.netMode != 0)
                {
                    break;
                }
                GenerateAchievement((Mod)args[1], (string)args[2], (string)args[3], (Texture2D)args[4], (Texture2D)args[5], (AchievementCategory)args[6]);
                //GetSaveData();
                break;

            case "UnlockLocal":
                ModAchievement.UnlockLocal((string)args[1], (string)args[2], (Player)args[3]);
                break;

            case "UnlockGlobal":
                ModAchievement.UnlockGlobal((string)args[1], (string)args[2]);
                break;

            case "GetAchievement":
                for (int k = 0; k < lines.Count; k++)
                {
                    if (lines[k] == (string)args[1] && lines[k + 1] == (string)args[2])
                    {
                        return(lines[k + 2] == "True" ? true : false);
                    }
                }
                break;
            }
            return("success");
        }
Example #2
0
        public void AutoLoad(Type type, Mod mod)
        {
            ModAchievement achievement = (ModAchievement)Activator.CreateInstance(type);

            Achievements.Add(achievement);
            achievement.mod = mod;
        }
Example #3
0
        internal void setProperties(ModAchievement achievement, int i)
        {
            this.achievement = achievement;
            picture          = new UIImage(achievement.texture);


            index = i;
        }
Example #4
0
 public void addAchievementToList(ModAchievement achievement)
 {
     foreach (string s in doneAchievementList)
     {
         if (s == achievement.name)
         {
             return;
         }
     }
     doneAchievementList.Add(achievement.name);
 }
Example #5
0
        private void GenerateAchievement(Mod mod, string name, string description, Texture2D lockedtex, Texture2D unlockedtex, AchievementCategory category)
        {
            ModAchievement ach = new ModAchievement();

            ach.mod             = mod;
            ach.Name            = name;
            ach.Description     = description;
            ach.LockedTexture   = lockedtex;
            ach.UnlockedTexture = unlockedtex;
            ach.Category        = category;
            Achievement cheev = ach.GetAchievement();
            FieldInfo   cat   = typeof(Achievement).GetField("_category", BindingFlags.NonPublic | BindingFlags.Instance);

            cat.SetValue(cheev, ach.Category);

            Achievements.Add(ach);
        }
Example #6
0
 public override bool CanUseItem(Player player)
 {
     ModAchievement.UnlockLocal <ExampleAchievement>(player); //This unlocks the "AchievementLib Tester" achievement when the item is used, for the player that used it.
     return(true);
 }
Example #7
0
 public void AddAchievement(ModAchievement achievement)
 {
     achievementsList.Add(achievement);
 }