mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-29 02:25:37 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
cb01a30b1d
6 changed files with 45 additions and 8 deletions
|
@ -12,6 +12,8 @@ module.exports = class MusicPlayer extends CocoClass
|
|||
subscriptions:
|
||||
'music-player:play-music': 'onPlayMusic'
|
||||
'audio-player:loaded': 'onAudioLoaded'
|
||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
||||
'playback:real-time-playback-ended': 'onRealTimePlaybackEnded'
|
||||
|
||||
constructor: ->
|
||||
super arguments...
|
||||
|
@ -62,6 +64,17 @@ module.exports = class MusicPlayer extends CocoClass
|
|||
createjs.Tween.removeTweens(@currentMusic)
|
||||
@currentMusic.volume = if me.get('music') then MUSIC_VOLUME else 0.0
|
||||
|
||||
onRealTimePlaybackStarted: (e) ->
|
||||
@previousMusic = @currentMusic
|
||||
trackNumber = _.random 0, 2
|
||||
Backbone.Mediator.publish 'music-player:play-music', file: "/music/music_real_time_#{trackNumber}", play: true
|
||||
|
||||
onRealTimePlaybackEnded: (e) ->
|
||||
@fadeOutCurrentMusic()
|
||||
if @previousMusic
|
||||
@currentMusic = @previousMusic
|
||||
@restartCurrentMusic()
|
||||
|
||||
destroy: ->
|
||||
me.off 'change:music', @onMusicSettingChanged, @
|
||||
super()
|
||||
|
|
|
@ -19,6 +19,8 @@ PointChooser = require './PointChooser'
|
|||
RegionChooser = require './RegionChooser'
|
||||
MusicPlayer = require './MusicPlayer'
|
||||
|
||||
resizeDelay = 500 # At least as much as $level-resize-transition-time.
|
||||
|
||||
module.exports = Surface = class Surface extends CocoClass
|
||||
stage: null
|
||||
|
||||
|
@ -88,7 +90,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@options = _.extend(@options, givenOptions) if givenOptions
|
||||
@initEasel()
|
||||
@initAudio()
|
||||
@onResize = _.debounce @onResize, 500 # At least as much as $level-resize-transition-time.
|
||||
@onResize = _.debounce @onResize, resizeDelay
|
||||
$(window).on 'resize', @onResize
|
||||
if @world.ended
|
||||
_.defer => @setWorld @world
|
||||
|
@ -545,6 +547,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
return unless @realTime
|
||||
@realTime = false
|
||||
@onResize()
|
||||
_.delay @onResize, resizeDelay + 100 # Do it again just to be double sure that we don't stay zoomed in due to timing problems.
|
||||
@spriteBoss.selfWizardSprite?.toggle true
|
||||
@canvas.removeClass 'flag-color-selected'
|
||||
if @previousCameraZoom
|
||||
|
|
|
@ -98,6 +98,7 @@ module.exports = class World
|
|||
continueLaterFn = =>
|
||||
@loadFrames(loadedCallback, errorCallback, loadProgressCallback, preloadedCallback, skipDeferredLoading, loadUntilFrame) unless @destroyed
|
||||
if @realTime and not @countdownFinished
|
||||
@realTimeSpeedFactor ?= 1
|
||||
return setTimeout @finishCountdown(continueLaterFn), REAL_TIME_COUNTDOWN_DELAY
|
||||
t1 = now()
|
||||
@t0 ?= t1
|
||||
|
@ -136,18 +137,18 @@ module.exports = class World
|
|||
|
||||
shouldDelayRealTimeSimulation: (t) ->
|
||||
return false unless @realTime
|
||||
timeSinceStart = t - @worldLoadStartTime
|
||||
timeSinceStart = (t - @worldLoadStartTime) * @realTimeSpeedFactor
|
||||
timeLoaded = @frames.length * @dt * 1000
|
||||
timeBuffered = timeLoaded - timeSinceStart
|
||||
timeBuffered > REAL_TIME_BUFFER_MAX
|
||||
timeBuffered > REAL_TIME_BUFFER_MAX * @realTimeSpeedFactor
|
||||
|
||||
shouldUpdateRealTimePlayback: (t) ->
|
||||
return false unless @realTime
|
||||
return false if @frames.length * @dt is @lastRealTimeUpdate
|
||||
timeLoaded = @frames.length * @dt * 1000
|
||||
timeSinceStart = t - @worldLoadStartTime
|
||||
timeSinceStart = (t - @worldLoadStartTime) * @realTimeSpeedFactor
|
||||
remainingBuffer = @lastRealTimeUpdate * 1000 - timeSinceStart
|
||||
remainingBuffer < REAL_TIME_BUFFER_MIN
|
||||
remainingBuffer < REAL_TIME_BUFFER_MIN * @realTimeSpeedFactor
|
||||
|
||||
shouldContinueLoading: (t1, loadProgressCallback, skipDeferredLoading, continueLaterFn) ->
|
||||
t2 = now()
|
||||
|
@ -192,6 +193,8 @@ module.exports = class World
|
|||
@flagHistory.push flagEvent
|
||||
|
||||
loadFromLevel: (level, willSimulate=true) ->
|
||||
if level.slug in ['the-first-kithmaze', 'the-second-kithmaze', 'the-final-kithmaze']
|
||||
@realTimeSpeedFactor = 3
|
||||
@levelComponents = level.levelComponents
|
||||
@thangTypes = level.thangTypes
|
||||
@loadSystemsFromLevel level
|
||||
|
|
|
@ -378,7 +378,7 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
|
|||
done: "Concluir"
|
||||
customize_wizard: "Personalizar Feiticeiro"
|
||||
home: "Início"
|
||||
# skip: "Skip"
|
||||
skip: "Saltar"
|
||||
game_menu: "Menu do Jogo"
|
||||
guide: "Guia"
|
||||
restart: "Reiniciar"
|
||||
|
@ -400,7 +400,7 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
|
|||
victory_rate_the_level: "Classifica este nível: "
|
||||
victory_return_to_ladder: "Voltar à Classificação"
|
||||
victory_play_next_level: "Jogar Próximo Nível"
|
||||
# victory_play_continue: "Continue"
|
||||
victory_play_continue: "Continuar"
|
||||
victory_go_home: "Ir para o Início"
|
||||
victory_review: "Conta-nos mais!"
|
||||
victory_hour_of_code_done: "Terminaste?"
|
||||
|
@ -419,7 +419,7 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
|
|||
tome_select_spell: "Seleciona um Feitiço"
|
||||
tome_select_a_thang: "Seleciona Alguém para "
|
||||
tome_available_spells: "Feitiços Disponíveis"
|
||||
# tome_your_skills: "Your Skills"
|
||||
tome_your_skills: "As Tuas Habilidades"
|
||||
hud_continue: "Continuar (shift-espaço)"
|
||||
spell_saved: "Feitiço Guardado"
|
||||
skip_tutorial: "Saltar (esc)"
|
||||
|
|
|
@ -33,9 +33,13 @@ module.exports = class WorldMapView extends RootView
|
|||
@listenToOnce @sessions, 'sync', @onSessionsLoaded
|
||||
@getLevelPlayCounts()
|
||||
$(window).on 'resize', @onWindowResize
|
||||
@playAmbientSound()
|
||||
|
||||
destroy: ->
|
||||
$(window).off 'resize', @onWindowResize
|
||||
if ambientSound = @ambientSound
|
||||
# Doesn't seem to work; stops immediately.
|
||||
createjs.Tween.get(ambientSound).to({volume: 0.0}, 1500).call -> ambientSound.stop()
|
||||
super()
|
||||
|
||||
getLevelPlayCounts: ->
|
||||
|
@ -156,6 +160,19 @@ module.exports = class WorldMapView extends RootView
|
|||
resultingMarginY = (pageHeight - resultingHeight) / 2
|
||||
@$el.find('.map').css(width: resultingWidth, height: resultingHeight, 'margin-left': resultingMarginX, 'margin-top': resultingMarginY)
|
||||
|
||||
playAmbientSound: ->
|
||||
return if @ambientSound
|
||||
terrain = 'Grass'
|
||||
return unless file = {Dungeon: 'ambient-map-dungeon', Grass: 'ambient-map-grass'}[terrain]
|
||||
src = "/file/interface/#{file}#{AudioPlayer.ext}"
|
||||
unless AudioPlayer.getStatus(src)?.loaded
|
||||
AudioPlayer.preloadSound src
|
||||
Backbone.Mediator.subscribeOnce 'audio-player:loaded', @playAmbientSound, @
|
||||
return
|
||||
@ambientSound = createjs.Sound.play src, loop: -1, volume: 0.1
|
||||
createjs.Tween.get(@ambientSound).to({volume: 1.0}, 1000)
|
||||
|
||||
|
||||
tutorials = [
|
||||
{
|
||||
name: 'Rescue Mission'
|
||||
|
|
|
@ -312,6 +312,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'real-time-playback-end', volume: 1
|
||||
|
||||
onStopRealTimePlayback: (e) ->
|
||||
Backbone.Mediator.publish 'level:set-letterbox', on: false
|
||||
Backbone.Mediator.publish 'playback:real-time-playback-ended', {}
|
||||
|
||||
onSetDebug: (e) ->
|
||||
|
|
Loading…
Reference in a new issue