-
Notifications
You must be signed in to change notification settings - Fork 320
Solutions by reaperes
Kim Namhoon edited this page Mar 3, 2015
·
1 revision
Just insert this code on init function. It will work until #5 level.
_.each(elevators, function(elevator) {
elevator.on("floor_button_pressed", function (floorNum) {
addToDestinationQuque(elevator, floorNum);
});
});
_.each(floors, function (floor) {
floor.on("up_button_pressed down_button_pressed", function () {
addToRandomDestinationQueue(floor.level);
});
});
function addToDestinationQuque(elevator, floor) {
if (elevator.destinationQueue.indexOf(floor) === -1)
elevator.destinationQueue.push(floor);
elevator.checkDestinationQueue();
}
var rotator = 0;
function addToRandomDestinationQueue(floor) {
var elevator = elevators[(rotator++) % elevators.length];
if (elevator.destinationQueue.indexOf(floor) === -1)
elevator.destinationQueue.push(floor);
elevator.checkDestinationQueue();
}
Play it yourself at play.elevatorsaga.com