2017-08-22 00:58:41 +02:00
|
|
|
(function() {
|
2017-08-25 17:03:26 +02:00
|
|
|
var stasis = {};
|
2017-08-22 00:58:41 +02:00
|
|
|
|
2017-08-25 17:03:26 +02:00
|
|
|
var background, backgroundDark = null;
|
2017-08-24 22:00:19 +02:00
|
|
|
var doorAnimationSheet = null;
|
|
|
|
var doorSprite = null;
|
|
|
|
var roomState = {
|
2017-08-25 17:03:26 +02:00
|
|
|
isDoorOpen: false,
|
|
|
|
isLightOn: false
|
2017-08-24 22:00:19 +02:00
|
|
|
};
|
2017-08-23 23:31:50 +02:00
|
|
|
|
2017-08-25 17:03:26 +02:00
|
|
|
stasis.init = function() {
|
2017-08-24 22:00:19 +02:00
|
|
|
doorAnimationSheet = kontra.spriteSheet({
|
2017-08-28 21:29:27 +02:00
|
|
|
image: kontra.assets.images.stasis_doorSheet,
|
|
|
|
frameWidth: 24, frameHeight: 21,
|
2017-08-24 17:06:46 +02:00
|
|
|
animations: {
|
2017-08-28 21:29:27 +02:00
|
|
|
closed: {frames: 0},
|
|
|
|
opened: {frames: 2},
|
|
|
|
open: {frames: '0..3', frameRate: 6},
|
|
|
|
close: {frames: '3..0', frameRate: 6}
|
2017-08-24 17:06:46 +02:00
|
|
|
}
|
|
|
|
});
|
2017-08-24 22:00:19 +02:00
|
|
|
doorSprite = kontra.sprite({
|
2017-08-24 17:06:46 +02:00
|
|
|
x: 72, y: 8,
|
2017-08-24 22:00:19 +02:00
|
|
|
animations: doorAnimationSheet.animations
|
2017-08-24 17:06:46 +02:00
|
|
|
});
|
|
|
|
|
2017-08-25 17:03:26 +02:00
|
|
|
background = muri.bg('stasis');
|
|
|
|
backgroundDark = muri.bg('stasis_dark');
|
|
|
|
|
2017-08-28 21:29:27 +02:00
|
|
|
muri.get('entity')
|
|
|
|
.create('stasis.lightSwitch',
|
|
|
|
kontra.sprite({x: 16, y: 13, width: 3, height: 2,
|
|
|
|
image: kontra.assets.images.stasis_lightSwitch}))
|
|
|
|
.addCallback(function() {
|
|
|
|
if (!roomState.isLightOn) {
|
|
|
|
roomState.isLightOn = true;
|
|
|
|
muri.get('bubble')
|
|
|
|
.talk([
|
|
|
|
'Ah, much better.',
|
|
|
|
'Looks like something happened to my stasis capsule.'
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
muri.get('bubble')
|
|
|
|
.talk(['No, I will not turn off the light again!']);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-08-25 17:03:26 +02:00
|
|
|
if (!roomState.isLightOn) {
|
2017-08-23 23:31:50 +02:00
|
|
|
muri.get('bubble')
|
|
|
|
.story([
|
|
|
|
[['Beep', 'Bip, Bip'], [20, 15]],
|
|
|
|
[['Urgh ... ...', 'Where I am?', 'What happened?'], [35, 40]],
|
|
|
|
[['I can\'t see a thing ...', '... need to turn on the light ...'], [35, 40]]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
};
|
2017-08-22 00:58:41 +02:00
|
|
|
|
2017-08-25 17:03:26 +02:00
|
|
|
stasis.update = function() {
|
2017-08-28 21:29:27 +02:00
|
|
|
if (roomState.isLightOn &&
|
|
|
|
!muri.get('entity').get('stasis.door')) {
|
|
|
|
muri.get('entity')
|
|
|
|
.create('stasis.door', doorSprite)
|
|
|
|
.addCallback(function() {
|
|
|
|
if (!roomState.isDoorOpen) {
|
|
|
|
doorSprite.playAnimation('open');
|
|
|
|
roomState.isDoorOpen = true;
|
|
|
|
} else {
|
|
|
|
doorSprite.playAnimation('close');
|
|
|
|
roomState.isDoorOpen = false;
|
|
|
|
}
|
|
|
|
});
|
2017-08-23 23:31:50 +02:00
|
|
|
}
|
2017-08-22 00:58:41 +02:00
|
|
|
};
|
|
|
|
|
2017-08-25 17:03:26 +02:00
|
|
|
stasis.render = function() {
|
|
|
|
if (roomState.isLightOn) {
|
|
|
|
background.render();
|
|
|
|
} else {
|
|
|
|
backgroundDark.render();
|
|
|
|
}
|
2017-08-22 00:58:41 +02:00
|
|
|
};
|
|
|
|
|
2017-08-25 21:53:22 +02:00
|
|
|
stasis.name = 'stasis';
|
|
|
|
muri.rooms.push(stasis);
|
2017-08-22 00:58:41 +02:00
|
|
|
}());
|