Start hero levels playing from the beginning on unveil. Fixed some of the bugs with heroes not equipping.

This commit is contained in:
Nick Winter 2014-09-22 22:26:09 -07:00
parent 8640369b26
commit b0ee2224ae
3 changed files with 17 additions and 9 deletions

View file

@ -23,6 +23,7 @@ module.exports = class GameMenuModal extends ModalView
@options.showDevBits = me.isAdmin() or /https?:\/\/localhost/.test(window.location.href)
@options.showInventory = @options.level.get('type', true) is 'hero'
@options.levelID = @options.level.get('slug')
@options.startingSessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
getRenderData: (context={}) ->
context = super(context)
@ -51,7 +52,7 @@ module.exports = class GameMenuModal extends ModalView
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'game-menu-close', volume: 1
updateConfig: ->
sessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
sessionHeroConfig = @options.startingSessionHeroConfig
lastHeroConfig = me.get('heroConfig') ? {}
thangType = @subviews.choose_hero_view.selectedHero?.get 'original'
inventory = @subviews.inventory_view.getCurrentEquipmentConfig()

View file

@ -199,7 +199,11 @@ module.exports = class LevelHUDView extends CocoView
group.append('<span class="hud-hint">' + sk + '</span>')
group.append($('<button class="btn btn-small banner with-dot">' + s + ' <div class="dot"></div></button>'))
@lastResponses = null
@bubble.append($("<h3>#{@speaker ? 'Captain Anya'}</h3>"))
if @speaker is 'Hero Placeholder'
name = {knight: 'Tharin', captain: 'Anya'}[@speakerSprite?.thang?.id] ? 'Hero'
else
name = @speaker
@bubble.append($("<h3>#{name}</h3>"))
@animator = new DialogueAnimator(message, @bubble)
@messageInterval = setInterval(@addMoreMessage, 1000 / 30) # 30 FPS

View file

@ -369,16 +369,19 @@ module.exports = class PlayLevelView extends RootView
return if @alreadyLoadedState
@alreadyLoadedState = true
state = @originalSessionState
if state.frame and @level.get('type', true) isnt 'ladder' # https://github.com/codecombat/codecombat/issues/714
Backbone.Mediator.publish 'level:set-time', time: 0, frameOffset: state.frame
if @level.get('type', true) is 'hero'
Backbone.Mediator.publish 'tome:select-primary-sprite', {}
@surface.focusOnHero()
else if state.selected
# TODO: Should also restore selected spell here by saving spellName
Backbone.Mediator.publish 'level:select-sprite', thangID: state.selected, spellName: null
if state.playing?
Backbone.Mediator.publish 'level:set-playing', playing: state.playing
Backbone.Mediator.publish 'level:set-time', time: 0
Backbone.Mediator.publish 'level:set-playing', playing: true
else
if state.frame and @level.get('type', true) isnt 'ladder' # https://github.com/codecombat/codecombat/issues/714
Backbone.Mediator.publish 'level:set-time', time: 0, frameOffset: state.frame
if state.selected
# TODO: Should also restore selected spell here by saving spellName
Backbone.Mediator.publish 'level:select-sprite', thangID: state.selected, spellName: null
if state.playing?
Backbone.Mediator.publish 'level:set-playing', playing: state.playing
# callbacks