mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
Merge pull request #222 from anubisthejackle/issue80
This commit is contained in:
+27
-2
@@ -74,7 +74,8 @@
|
|||||||
state: null,
|
state: null,
|
||||||
debug: false,
|
debug: false,
|
||||||
log: false,
|
log: false,
|
||||||
dropbox: false
|
dropbox: false,
|
||||||
|
doubleTime: false
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function(options) {
|
init: function(options) {
|
||||||
@@ -137,7 +138,19 @@
|
|||||||
.text(_('lights off.'))
|
.text(_('lights off.'))
|
||||||
.click(Engine.turnLightsOff)
|
.click(Engine.turnLightsOff)
|
||||||
.appendTo(menu);
|
.appendTo(menu);
|
||||||
|
|
||||||
|
$('<span>')
|
||||||
|
.addClass('menuBtn')
|
||||||
|
.text(_('hyper.'))
|
||||||
|
.click(function(){
|
||||||
|
Engine.options.doubleTime = !Engine.options.doubleTime;
|
||||||
|
if(Engine.options.doubleTime)
|
||||||
|
$(this).text(_('classic.'));
|
||||||
|
else
|
||||||
|
$(this).text(_('hyper.'));
|
||||||
|
})
|
||||||
|
.appendTo(menu);
|
||||||
|
|
||||||
$('<span>')
|
$('<span>')
|
||||||
.addClass('menuBtn')
|
.addClass('menuBtn')
|
||||||
.text(_('restart.'))
|
.text(_('restart.'))
|
||||||
@@ -680,7 +693,19 @@
|
|||||||
if(lang && typeof Storage != 'undefined' && localStorage) {
|
if(lang && typeof Storage != 'undefined' && localStorage) {
|
||||||
localStorage.lang = lang;
|
localStorage.lang = lang;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setTimeout: function(callback, timeout, skipDouble){
|
||||||
|
|
||||||
|
if( Engine.options.doubleTime && !skipDouble ){
|
||||||
|
Engine.log('Double time, cutting timeout in half');
|
||||||
|
timeout /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return setTimeout(callback, timeout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function eventNullifier(e) {
|
function eventNullifier(e) {
|
||||||
|
|||||||
+8
-8
@@ -113,7 +113,7 @@ var Events = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up the enemy attack timer
|
// Set up the enemy attack timer
|
||||||
Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
|
Events._enemyAttackTimer = Engine.setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
createEatMeatButton: function(cooldown) {
|
createEatMeatButton: function(cooldown) {
|
||||||
@@ -354,7 +354,7 @@ var Events = {
|
|||||||
if(dmg == 'stun') {
|
if(dmg == 'stun') {
|
||||||
msg = _('stunned');
|
msg = _('stunned');
|
||||||
enemy.data('stunned', true);
|
enemy.data('stunned', true);
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
enemy.data('stunned', false);
|
enemy.data('stunned', false);
|
||||||
}, Events.STUN_DURATION);
|
}, Events.STUN_DURATION);
|
||||||
}
|
}
|
||||||
@@ -399,7 +399,7 @@ var Events = {
|
|||||||
if(dmg == 'stun') {
|
if(dmg == 'stun') {
|
||||||
msg = _('stunned');
|
msg = _('stunned');
|
||||||
enemy.data('stunned', true);
|
enemy.data('stunned', true);
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
enemy.data('stunned', false);
|
enemy.data('stunned', false);
|
||||||
}, Events.STUN_DURATION);
|
}, Events.STUN_DURATION);
|
||||||
}
|
}
|
||||||
@@ -438,14 +438,14 @@ var Events = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
|
Events._enemyAttackTimer = Engine.setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
winFight: function() {
|
winFight: function() {
|
||||||
Events.won = true;
|
Events.won = true;
|
||||||
clearTimeout(Events._enemyAttackTimer);
|
clearTimeout(Events._enemyAttackTimer);
|
||||||
$('#enemy').animate({opacity: 0}, 300, 'linear', function() {
|
$('#enemy').animate({opacity: 0}, 300, 'linear', function() {
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
try {
|
try {
|
||||||
var scene = Events.activeEvent().scenes[Events.activeScene];
|
var scene = Events.activeEvent().scenes[Events.activeScene];
|
||||||
var desc = $('#description', Events.eventPanel());
|
var desc = $('#description', Events.eventPanel());
|
||||||
@@ -482,7 +482,7 @@ var Events = {
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
// It is possible to die and win if the timing is perfect. Just let it fail.
|
// It is possible to die and win if the timing is perfect. Just let it fail.
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000, true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -742,7 +742,7 @@ var Events = {
|
|||||||
// every 3 seconds change title to '*** EVENT ***', then 1.5 seconds later, change it back to the original title.
|
// every 3 seconds change title to '*** EVENT ***', then 1.5 seconds later, change it back to the original title.
|
||||||
Events.BLINK_INTERVAL = setInterval(function() {
|
Events.BLINK_INTERVAL = setInterval(function() {
|
||||||
document.title = _('*** EVENT ***');
|
document.title = _('*** EVENT ***');
|
||||||
setTimeout(function() {document.title = title;}, 1500);
|
Engine.setTimeout(function() {document.title = title;}, 1500, true);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -824,7 +824,7 @@ var Events = {
|
|||||||
var nextEvent = Math.floor(Math.random()*(Events._EVENT_TIME_RANGE[1] - Events._EVENT_TIME_RANGE[0])) + Events._EVENT_TIME_RANGE[0];
|
var nextEvent = Math.floor(Math.random()*(Events._EVENT_TIME_RANGE[1] - Events._EVENT_TIME_RANGE[0])) + Events._EVENT_TIME_RANGE[0];
|
||||||
if(scale > 0) { nextEvent *= scale; }
|
if(scale > 0) { nextEvent *= scale; }
|
||||||
Engine.log('next event scheduled in ' + nextEvent + ' minutes');
|
Engine.log('next event scheduled in ' + nextEvent + ' minutes');
|
||||||
Events._eventTimeout = setTimeout(Events.triggerEvent, nextEvent * 60 * 1000);
|
Events._eventTimeout = Engine.setTimeout(Events.triggerEvent, nextEvent * 60 * 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
endEvent: function() {
|
endEvent: function() {
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ Events.Room = [
|
|||||||
],
|
],
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
if(Math.random() < 0.5) {
|
if(Math.random() < 0.5) {
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
$SM.add('stores.wood', 300);
|
$SM.add('stores.wood', 300);
|
||||||
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
|
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
@@ -314,7 +314,7 @@ Events.Room = [
|
|||||||
],
|
],
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
if(Math.random() < 0.3) {
|
if(Math.random() < 0.3) {
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
$SM.add('stores.wood', 1500);
|
$SM.add('stores.wood', 1500);
|
||||||
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
|
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
@@ -366,7 +366,7 @@ Events.Room = [
|
|||||||
],
|
],
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
if(Math.random() < 0.5) {
|
if(Math.random() < 0.5) {
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
$SM.add('stores.fur', 300);
|
$SM.add('stores.fur', 300);
|
||||||
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
|
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
@@ -385,7 +385,7 @@ Events.Room = [
|
|||||||
],
|
],
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
if(Math.random() < 0.3) {
|
if(Math.random() < 0.3) {
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
$SM.add('stores.fur', 1500);
|
$SM.add('stores.fur', 1500);
|
||||||
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
|
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
|
||||||
}, 60 * 1000);
|
}, 60 * 1000);
|
||||||
|
|||||||
+1
-1
@@ -220,7 +220,7 @@ var Outside = {
|
|||||||
schedulePopIncrease: function() {
|
schedulePopIncrease: function() {
|
||||||
var nextIncrease = Math.floor(Math.random()*(Outside._POP_DELAY[1] - Outside._POP_DELAY[0])) + Outside._POP_DELAY[0];
|
var nextIncrease = Math.floor(Math.random()*(Outside._POP_DELAY[1] - Outside._POP_DELAY[0])) + Outside._POP_DELAY[0];
|
||||||
Engine.log('next population increase scheduled in ' + nextIncrease + ' minutes');
|
Engine.log('next population increase scheduled in ' + nextIncrease + ' minutes');
|
||||||
Outside._popTimeout = setTimeout(Outside.increasePopulation, nextIncrease * 60 * 1000);
|
Outside._popTimeout = Engine.setTimeout(Outside.increasePopulation, nextIncrease * 60 * 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateWorkersView: function() {
|
updateWorkersView: function() {
|
||||||
|
|||||||
+11
-11
@@ -521,8 +521,8 @@ var Room = {
|
|||||||
Room.updateIncomeView();
|
Room.updateIncomeView();
|
||||||
Room.updateBuildButtons();
|
Room.updateBuildButtons();
|
||||||
|
|
||||||
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
Room._fireTimer = Engine.setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
||||||
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
Room._tempTimer = Engine.setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Builder states:
|
* Builder states:
|
||||||
@@ -533,12 +533,12 @@ var Room = {
|
|||||||
* 4 - Helping
|
* 4 - Helping
|
||||||
*/
|
*/
|
||||||
if($SM.get('game.builder.level') >= 0 && $SM.get('game.builder.level') < 3) {
|
if($SM.get('game.builder.level') >= 0 && $SM.get('game.builder.level') < 3) {
|
||||||
Room._builderTimer = setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
Room._builderTimer = Engine.setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
||||||
}
|
}
|
||||||
if($SM.get('game.builder.level') == 1 && $SM.get('stores.wood', true) < 0) {
|
if($SM.get('game.builder.level') == 1 && $SM.get('stores.wood', true) < 0) {
|
||||||
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
Engine.setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
||||||
}
|
}
|
||||||
setTimeout($SM.collectIncome, 1000);
|
Engine.setTimeout($SM.collectIncome, 1000);
|
||||||
|
|
||||||
Notifications.notify(Room, _("the room is {0}", Room.TempEnum.fromInt($SM.get('game.temperature.value')).text));
|
Notifications.notify(Room, _("the room is {0}", Room.TempEnum.fromInt($SM.get('game.temperature.value')).text));
|
||||||
Notifications.notify(Room, _("the fire is {0}", Room.FireEnum.fromInt($SM.get('game.fire.value')).text));
|
Notifications.notify(Room, _("the fire is {0}", Room.FireEnum.fromInt($SM.get('game.fire.value')).text));
|
||||||
@@ -671,10 +671,10 @@ var Room = {
|
|||||||
if($SM.get('game.fire.value') > 1 && $SM.get('game.builder.level') < 0) {
|
if($SM.get('game.fire.value') > 1 && $SM.get('game.builder.level') < 0) {
|
||||||
$SM.set('game.builder.level', 0);
|
$SM.set('game.builder.level', 0);
|
||||||
Notifications.notify(Room, _("the light from the fire spills from the windows, out into the dark"));
|
Notifications.notify(Room, _("the light from the fire spills from the windows, out into the dark"));
|
||||||
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
Engine.setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
||||||
}
|
}
|
||||||
window.clearTimeout(Room._fireTimer);
|
window.clearTimeout(Room._fireTimer);
|
||||||
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
Room._fireTimer = Engine.setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
||||||
Room.updateButton();
|
Room.updateButton();
|
||||||
Room.setTitle();
|
Room.setTitle();
|
||||||
},
|
},
|
||||||
@@ -689,7 +689,7 @@ var Room = {
|
|||||||
}
|
}
|
||||||
if($SM.get('game.fire.value') > 0) {
|
if($SM.get('game.fire.value') > 0) {
|
||||||
$SM.set('game.fire',Room.FireEnum.fromInt($SM.get('game.fire.value') - 1));
|
$SM.set('game.fire',Room.FireEnum.fromInt($SM.get('game.fire.value') - 1));
|
||||||
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
Room._fireTimer = Engine.setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
||||||
Room.onFireChange();
|
Room.onFireChange();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -707,7 +707,7 @@ var Room = {
|
|||||||
if($SM.get('game.temperature.value') != old) {
|
if($SM.get('game.temperature.value') != old) {
|
||||||
Room.changed = true;
|
Room.changed = true;
|
||||||
}
|
}
|
||||||
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
Room._tempTimer = Engine.setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
||||||
},
|
},
|
||||||
|
|
||||||
unlockForest: function() {
|
unlockForest: function() {
|
||||||
@@ -723,7 +723,7 @@ var Room = {
|
|||||||
if(lBuilder === 0) {
|
if(lBuilder === 0) {
|
||||||
Notifications.notify(Room, _("a ragged stranger stumbles through the door and collapses in the corner"));
|
Notifications.notify(Room, _("a ragged stranger stumbles through the door and collapses in the corner"));
|
||||||
lBuilder = $SM.setget('game.builder.level', 1);
|
lBuilder = $SM.setget('game.builder.level', 1);
|
||||||
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
Engine.setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
||||||
}
|
}
|
||||||
else if(lBuilder < 3 && $SM.get('game.temperature.value') >= Room.TempEnum.Warm.value) {
|
else if(lBuilder < 3 && $SM.get('game.temperature.value') >= Room.TempEnum.Warm.value) {
|
||||||
var msg = "";
|
var msg = "";
|
||||||
@@ -741,7 +741,7 @@ var Room = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(lBuilder < 3) {
|
if(lBuilder < 3) {
|
||||||
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
Engine.setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
||||||
}
|
}
|
||||||
Engine.saveGame();
|
Engine.saveGame();
|
||||||
},
|
},
|
||||||
|
|||||||
+5
-5
@@ -166,7 +166,7 @@ var Space = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!Space.done) {
|
if(!Space.done) {
|
||||||
setTimeout(Space.createAsteroid, 1000 - (Space.altitude * 10));
|
Engine.setTimeout(Space.createAsteroid, 1000 - (Space.altitude * 10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -261,7 +261,7 @@ var Space = {
|
|||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
Space._panelTimeout = setTimeout(function() {
|
Space._panelTimeout = Engine.setTimeout(function() {
|
||||||
if (Engine.isLightsOff())
|
if (Engine.isLightsOff())
|
||||||
$('#spacePanel, .menu, select.menuBtn').animate({color: '#272823'}, 500, 'linear');
|
$('#spacePanel, .menu, select.menuBtn').animate({color: '#272823'}, 500, 'linear');
|
||||||
else
|
else
|
||||||
@@ -315,7 +315,7 @@ var Space = {
|
|||||||
left: left
|
left: left
|
||||||
}).appendTo(el2);
|
}).appendTo(el2);
|
||||||
if(num < Space.NUM_STARS) {
|
if(num < Space.NUM_STARS) {
|
||||||
setTimeout(function() { Space.drawStarAsync(el, el2, num + 1); }, 100);
|
Engine.setTimeout(function() { Space.drawStarAsync(el, el2, num + 1); }, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ var Space = {
|
|||||||
top: '350px',
|
top: '350px',
|
||||||
left: '240px'
|
left: '240px'
|
||||||
}, 3000, 'linear', function() {
|
}, 3000, 'linear', function() {
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
Space.ship.animate({
|
Space.ship.animate({
|
||||||
top: '-100px'
|
top: '-100px'
|
||||||
}, 200, 'linear', function() {
|
}, 200, 'linear', function() {
|
||||||
@@ -393,7 +393,7 @@ var Space = {
|
|||||||
$('#outerSlider').css({'left': '0px', 'top': '0px'});
|
$('#outerSlider').css({'left': '0px', 'top': '0px'});
|
||||||
$('#locationSlider, #worldPanel, #spacePanel, #notifications').remove();
|
$('#locationSlider, #worldPanel, #spacePanel, #notifications').remove();
|
||||||
$('#header').empty();
|
$('#header').empty();
|
||||||
setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
$('body').stop();
|
$('body').stop();
|
||||||
var container_color;
|
var container_color;
|
||||||
if (Engine.isLightsOff())
|
if (Engine.isLightsOff())
|
||||||
|
|||||||
+2
-2
@@ -818,12 +818,12 @@ var World = {
|
|||||||
Engine.activeModule = Room;
|
Engine.activeModule = Room;
|
||||||
$('div.headerButton').removeClass('selected');
|
$('div.headerButton').removeClass('selected');
|
||||||
Room.tab.addClass('selected');
|
Room.tab.addClass('selected');
|
||||||
setTimeout(function(){
|
Engine.setTimeout(function(){
|
||||||
Room.onArrival();
|
Room.onArrival();
|
||||||
$('#outerSlider').animate({opacity:'1'}, 600, 'linear');
|
$('#outerSlider').animate({opacity:'1'}, 600, 'linear');
|
||||||
Button.cooldown($('#embarkButton'));
|
Button.cooldown($('#embarkButton'));
|
||||||
Engine.keyLock = false;
|
Engine.keyLock = false;
|
||||||
}, 2000);
|
}, 2000, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user