The first improvement I can think of is to make it work with FlashPunk. This could be done by dropping all framework-specific code and allow the user to provide function hooks to achievement notifications.
A singleton class would be ideal, since there should really only be one achievement manager running. If you were asking for help on how to “do this (singletons) the best,” there’s a good article on gskinner.com that provides a singleton implementation for AS3.
Another improvement I’d like to see in a drop-in system like this would be to allow it to manage itself. I want to be able to create achievement types and have the achievement system track them for me.
Achievement Setup
// Get a handle to the Achievement System.
var cheevos:AchievementSystem = AchievementSystem.getInstance();
// Add an achievement that continues to build up to a target value.
cheevos.add(new IncrementalAchievement("Kissed one million enemies.", 1000000));
// Add an achievement that will trigger once a minimum value is reached.
cheevos.add(new MinimumValueAchievement("Kissed five enemies at once.", 5));
// Add a new achievement that is unlocked manually.
cheevos.add(new BooleanAchievement("Kissed the biggest boss."));
Updating Achievements
// Called in an enemy's onKissed function.
cheevos.getAchievement("Kissed one million enemies.").update();
// Called in the player's update once the kiss streak ends.
cheevos.getAchievement("Kissed five enemies at once.").update(currentKissStreak);
// Called from BiggestBoss's overloaded onKissed function.
cheevos.getAchievement("Kissed the biggest boss.").update();
Creating Custom Achievements
public class CostumeAchievement extends Achievement implements IAchievement
{
private var _headApparel:String;
private var _chestApparel:String;
public function CostumeAchievement(name:String, head:String, chest:String)
{
_headApparel = head;
_chestApparel = chest;
super(name);
}
public function update(args:*):Boolean
{
// If both "head" and "chest" exist and match the requirements, award cheevo.
return args != null && args["head"] != null && args["chest"] != null &&
args["head"] == _headApparel && args["chest"] == _chestApparel;
}
}
cheevos.add(new CostumeAchievement ("I am a blood ninja.", "wizard hat", "robe"));
// Called from the player's onEquip function.
cheevos.getAchievement("I am a blood ninja.").update(
{head:currentHat, chest:currentArmor});
Also, the ability to authenticate with an external server. 