<level>
  <playground map="barriers.map">
    <decorations>
      <platform id="1" x="16" y="23" w="8" left="yellow" right="yellow"/>
      <platform x="2" y="6" w="9"/>
      <platform x="29" y="6" w="9"/>
      <platform x="2" y="13" w="9"/>
      <platform x="29" y="13" w="9"/>
      <platform x="2" y="20" w="9"/>
      <platform x="29" y="20" w="9"/>

      <barrier id="20" x="12" y="1" h="6" activated="0"/>
      <barrier id="21" x="27" y="1" h="6" activated="1"/>
      <barrier id="22" x="12" y="8" h="6" activated="1"/>
      <barrier id="23" x="27" y="8" h="6" activated="1"/>
      <barrier id="24" x="12" y="15" h="6" activated="1"/>
      <barrier id="25" x="27" y="15" h="6" activated="1"/>

      <crate id="10" type="big" x="6" y="6"/>
      <crate id="11" type="big" x="33" y="6"/>
      <crate id="12" type="big" x="6" y="13"/>
      <crate id="13" type="big" x="33" y="13"/>
      <crate id="14" type="big" x="6" y="20"/>
      <crate id="15" type="big" x="33" y="20"/>
    </decorations>
  </playground>

  <startposition platform="1"/>

  <gamecontrol>
  <![CDATA[
	var crateIds =      [10, 13, 11, 14, 15, 12];
	var platformIds =   [ 1,  1,  1,  1,  1,  1];
	var deactivateIds = [23, 21, 24, 25, 22, -1];
	var activateIds =   [20, 23, 21, 24, 25, 22];
	var currentObjective = 0;

	function initObjective() {
		addBringCrateToPlatformObjective(
			crateIds[currentObjective], platformIds[currentObjective]);
	}
	
	function init() {
		initObjective();
	}
	
	function onCratePickup() {
		var id = deactivateIds[currentObjective];
		if (id != -1) {
			gameControl.getObjectById(id).deactivate();
		}
	}
	
	function onObjectiveReached() {
		gameControl.getObjectById(activateIds[currentObjective]).activate();
		if (++currentObjective < 6) {
			initObjective();
		} else {
			gameControl.finish();
		}
	}
  ]]>
  </gamecontrol>
</level>
