Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- init: function(elevators, floors) {
- var requestedFloors = [];
- for (var i = 0; i < floors.length; i++) {
- (function (i) {
- var floor = floors[i];
- floor.on('up_button_pressed', function () {
- if (i % 2) {
- elevators[0].goToFloor(i);
- } else {
- elevators[1].goToFloor(i);
- }
- });
- floor.on('down_button_pressed', function () {
- if (i % 2) {
- elevators[0].goToFloor(i);
- } else {
- elevators[1].goToFloor(i);
- }
- });
- })(i);
- };
- for (var i = 0; i < elevators.length; i++) {
- (function (i) {
- var elevator = elevators[i];
- elevator.on('idle', function() {
- elevator.goToFloor(0);
- });
- elevator.on('floor_button_pressed', function (floorNum) {
- elevator.goToFloor(floorNum);
- });
- elevator.on('stopped_at_floor', function (floorNum) {
- // if (floorNum == (1)) {
- // elevator.goToFloor(0, true);
- // };
- });
- elevator.on('passing_floor', function (floorNum, direction) {
- console.log(floorNum, direction);
- });
- })(i);
- };
- },
- update: function(dt, elevators, floors) {
- // We normally don't need to do anything here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement