Migrated getting nextLevelURL to the new campaign organization.

This commit is contained in:
Nick Winter 2014-12-01 13:46:55 -08:00
parent 74e97ecb7b
commit ca6c95b0f7
2 changed files with 4 additions and 17 deletions

View file

@ -176,7 +176,7 @@ module.exports = class LevelLoader extends CocoClass
for obj in objUniq articleVersions
url = "/db/article/#{obj.original}/version/#{obj.majorVersion}"
@maybeLoadURL url, Article, 'article'
if obj = @level.get 'nextLevel'
if obj = @level.get 'nextLevel' # TODO: update to get next level from campaigns, not this old property
url = "/db/level/#{obj.original}/version/#{obj.majorVersion}"
@maybeLoadURL url, Level, 'level'

View file

@ -417,7 +417,6 @@ module.exports = class PlayLevelView extends RootView
onShowVictory: (e) ->
$('#level-done-button').show() unless @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']
@showVictory() if e.showModal
setTimeout(@preloadNextLevel, 3000)
return if @victorySeen
@victorySeen = true
victoryTime = (new Date()) - @loadEndTime
@ -457,14 +456,10 @@ module.exports = class PlayLevelView extends RootView
viewClass: PlayLevelView,
viewArgs: [{supermodel: if @hasReceivedMemoryWarning then null else @supermodel}, nextLevelID]}
getNextLevel: ->
return null unless nextLevelOriginal = @level.get('nextLevel')?.original
levels = @supermodel.getModels(Level)
return l for l in levels when l.get('original') is nextLevelOriginal
getNextLevelID: ->
return null unless nextLevel = @getNextLevel()
nextLevelID = nextLevel.get('slug') or nextLevel.id
for campaign in require('views/play/WorldMapView').campaigns
for level in campaign.levels
return level.nextLevels?.continue if level.id is @level.get('slug')
getNextLevelURL: ->
return null unless @getNextLevelID()
@ -483,14 +478,6 @@ module.exports = class PlayLevelView extends RootView
@bus.removeFirebaseData =>
@bus.disconnect()
preloadNextLevel: =>
# TODO: Loading models in the middle of gameplay causes stuttering. Most of the improvement in loading time is simply from passing the supermodel from this level to the next, but if we can find a way to populate the level early without it being noticeable, that would be even better.
# return if @destroyed
# return if @preloaded
# nextLevel = @getNextLevel()
# @supermodel.populateModel nextLevel
# @preloaded = true
onSessionWillSave: (e) ->
# Something interesting has happened, so (at a lower frequency), we'll save a screenshot.
#@saveScreenshot e.session