var crateIds = [11, 12, 13, 14, 15, 16]; var platformIds = new Array();

var currentObjective = 0; var crateLoaded = 0;

function initNextObjective() { addBringCrateToPlatformObjective(crateIds[currentObjective], platformIds[currentObjective]); gameControl.getObjectById(crateIds[currentObjective]).show(); }

function init() { crateIds = shuffle(crateIds); for (var i=0; i<6; i++) { do { // The target platforms are selected random with the following constraints: // - The target platform must not be the crate's platform. // - The target platform must not be the next crate's platform.

var platformId = 21 + random(5); } while (platformId-10 == crateIds[i] || (i < 5 && platformId-10 == crateIds[i+1])); platformIds[i] = platformId; }

initNextObjective(); }

function onCratePickup(crate) { gameControl.setPopUpText("please", (platformIds[currentObjective]-20)); crateLoaded = 1; }

function onLanded(platform) { if (crateLoaded == 1 && platform.getID() != platformIds[currentObjective]) { gameControl.setPopUpText("angry", (platformIds[currentObjective]-20)); } }

function onObjectiveReached() { switch (++currentObjective) { case 6: addLandOnPlatformObjective(1); if (player.isActive()) { gameControl.setPopUpText("thanks_finish"); } crateLoaded = 0; break;

case 7: gameControl.finish(); break;

default: if (player.isActive()) { gameControl.setPopUpText("thanks"); } crateLoaded = 0; initNextObjective(); } }