Forest Troll Encounter has been updated to include a couple rough ideas for tutorials. All in all, this took me about 30 minutes to flesh out, which isn’t bad. The engine supports some high level operations that I can chain together in different ways, so I made a new SuccessObjective and spawned a couple placeholder units (the tree). Maybe I’ll continue to add new encounters like this to teach the player how to play, which I think also adds a certain level of gameplay fun too.
Here’s some code for the curious:
This code spawns the controllable BlockMan
var blockMan:BlockManRed = new BlockManRed();
blockMan.Abilities = [];
blockMan.SetAnimationState(AnimationName.IDLE_NORTHEAST);
SpawnUnit(blockMan, new Point(160, 485));
This code creates the tree unit that becomes the Target to touch in the new objective
var tree1:Tree1 = new Tree1();
SpawnUnit(tree1, new Point(511, 228));
ObjectivesForSuccess.push(new SuccessObjectivePlayerReachTarget(tree1));
And the code for the SuccessObjective? Kinda simple, but cool to object-orient it this way.
public class SuccessObjectivePlayerReachTarget extends DungeonEncounterObjective
{
public function SuccessObjectivePlayerReachTarget(targetUnit:Unit)
{
_target = targetUnit;
}
private var _target:Unit = null;
override public function EvaluateObjective(encounter:DungeonEncounter):Boolean
{
for each (var unit:Unit in encounter.Units)
{
if (unit.NPC || unit.Neutral)
continue;
// A playable unit has reached the _target unit's hit shape
if (_target.HitShape.hitTestObject(unit.HitShape))
return true;
}
return false;
}
}
If I put more effort into this, I think it would come together a lot faster, but I’ve lost some steam.
Also in serious need of syntax highlighting if I’m going to be posting code…Alex help?
