Added multiplayer win/loss notice at end of level.

This commit is contained in:
Nick Winter 2015-09-03 13:32:20 -07:00
parent 454f66e10b
commit df60ecd09c
5 changed files with 37 additions and 5 deletions

View file

@ -9,6 +9,7 @@ module.exports = class PlaybackOverScreen extends CocoClass
options ?= {}
@camera = options.camera
@layer = options.layer
@playerNames = options.playerNames
console.error @toString(), 'needs a camera.' unless @camera
console.error @toString(), 'needs a layer.' unless @layer
@build()
@ -22,6 +23,18 @@ module.exports = class PlaybackOverScreen extends CocoClass
@dimLayer.alpha = 0
@layer.addChild @dimLayer
makeVictoryText: ->
s = ''
size = Math.ceil @camera.canvasHeight / 6
text = new createjs.Text s, "#{size}px Open Sans Condensed", '#F7B42C'
text.shadow = new createjs.Shadow '#000', Math.ceil(@camera.canvasHeight / 300), Math.ceil(@camera.canvasHeight / 300), Math.ceil(@camera.canvasHeight / 120)
text.textAlign = 'center'
text.textBaseline = 'middle'
text.x = 0.5 * @camera.canvasWidth
text.y = 0.8 * @camera.canvasHeight
@dimLayer.addChild text
@text = text
show: ->
return if @showing
@showing = true
@ -43,6 +56,7 @@ module.exports = class PlaybackOverScreen extends CocoClass
incomplete = not success and not failure and not timedOut
color = if failure then 'rgba(255, 128, 128, 0.4)' else 'rgba(255, 255, 255, 0.4)'
@updateColor color
@updateText success, timedOut, incomplete
updateColor: (color) ->
return if color is @color
@ -50,5 +64,23 @@ module.exports = class PlaybackOverScreen extends CocoClass
if @color
@dimLayer.updateCache()
else
@dimLayer.cache 0, 0, @camera.canvasWidth, @camera.canvasHeight # I wonder if caching is even worth it for just a rect fill.
@dimLayer.cache 0, 0, @camera.canvasWidth, @camera.canvasHeight
@color = color
updateText: (success, timedOut, incomplete) ->
return unless _.size @playerNames # Only on multiplayer levels
@makeVictoryText() unless @text
# TODO: i18n this
if (success and me.team is 'humans') or (not success and me.team is 'ogres')
@text.color = '#E62B1E'
@text.text = (@playerNames.humans ? 'HUMAN AI').toLocaleUpperCase() + ' WINS'
else if (success and me.team is 'ogres') or (not success and me.team is 'humans')
@text.color = '#0597FF'
@text.text = (@playerNames.ogres ? 'OGRE AI').toLocaleUpperCase() + ' WINS'
else
@text.color = '#F7B42C'
if timedOut
@text.text = 'TIMED OUT'
else
@text.text = 'INCOMPLETE'
@dimLayer.updateCache()

View file

@ -114,7 +114,7 @@ module.exports = Surface = class Surface extends CocoClass
@lankBoss = new LankBoss camera: @camera, webGLStage: @webGLStage, surfaceTextLayer: @surfaceTextLayer, world: @world, thangTypes: @options.thangTypes, choosing: @options.choosing, navigateToSelection: @options.navigateToSelection, showInvisible: @options.showInvisible, playerNames: @options.playerNames
@countdownScreen = new CountdownScreen camera: @camera, layer: @screenLayer, showsCountdown: @world.showsCountdown
@playbackOverScreen = new PlaybackOverScreen camera: @camera, layer: @screenLayer
@playbackOverScreen = new PlaybackOverScreen camera: @camera, layer: @screenLayer, playerNames: @options.playerNames
@normalStage.addChildAt @playbackOverScreen.dimLayer, 0 # Put this below the other layers, actually, so we can more easily read text on the screen.
@waitingScreen = new WaitingScreen camera: @camera, layer: @screenLayer
@initCoordinates()

View file

@ -112,7 +112,7 @@ module.exports = class GoalManager extends CocoClass
goalStates: @goalStates
goals: @goals
overallStatus: overallStatus
timedOut: @world.totalFrames is @world.maxTotalFrames
timedOut: @world.totalFrames is @world.maxTotalFrames and overallStatus not in ['success', 'failure']
Backbone.Mediator.publish('goal-manager:new-goal-states', event)
checkOverallStatus: (ignoreIncomplete=false) ->

View file

@ -85,7 +85,7 @@ module.exports = class DuelStatsView extends CocoView
'griffin-rider': 50
paladin: 80
artillery: 75
'arrow-tower': 75
'arrow-tower': 100
palisade: 10
peasant: 50
powers = humans: 0, ogres: 0

View file

@ -323,7 +323,7 @@ module.exports = class PlayLevelView extends RootView
@surface.camera.zoomTo({x: 0, y: 0}, 0.1, 0)
findPlayerNames: ->
return {} unless @observing
return {} unless @level.get('type') in ['ladder', 'hero-ladder', 'course-ladder']
playerNames = {}
for session in [@session, @otherSession] when session?.get('team')
playerNames[session.get('team')] = session.get('creatorName') or 'Anoner'