mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-01 07:40:22 -04:00
Added a button to switch between world maps.
This commit is contained in:
parent
1e51ad7111
commit
02eacbbc8f
5 changed files with 72 additions and 50 deletions
app
|
@ -89,6 +89,7 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
'play/ladder': go('play/ladder/MainLadderView')
|
||||
'play/level/:levelID': go('play/level/PlayLevelView')
|
||||
'play/spectate/:levelID': go('play/SpectateView')
|
||||
'play/:map': go('play/WorldMapView')
|
||||
|
||||
'preview': go('HomeView')
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@
|
|||
campaign_player_created_description: "... in which you battle against the creativity of your fellow <a href=\"/contribute#artisan\">Artisan Wizards</a>."
|
||||
campaign_classic_algorithms: "Classic Algorithms"
|
||||
campaign_classic_algorithms_description: "... in which you learn the most popular algorithms in Computer Science."
|
||||
campaign_forest: "Forest Campaign"
|
||||
campaign_dungeon: "Dungeon Campaign"
|
||||
|
||||
login:
|
||||
sign_up: "Create Account"
|
||||
|
|
|
@ -206,7 +206,17 @@ $gameControlMargin: 30px
|
|||
margin-left: $gameControlMargin
|
||||
width: $gameControlSize
|
||||
height: $gameControlSize
|
||||
|
||||
background: url(/images/pages/play/menu_icons.png) no-repeat
|
||||
|
||||
position: relative
|
||||
img
|
||||
position: absolute
|
||||
left: 0
|
||||
top: 0
|
||||
width: 100%
|
||||
height: 100%
|
||||
|
||||
background-size: cover
|
||||
@include transition(0.5s ease)
|
||||
@include box-shadow(2px 2px 4px black)
|
||||
|
|
|
@ -6,32 +6,31 @@
|
|||
img.map-background(src="/images/pages/play/map_" + mapType + ".jpg", alt="")
|
||||
|
||||
- var seenNext = nextLevel;
|
||||
each campaign in campaigns
|
||||
each level in campaign.levels
|
||||
if level.hidden
|
||||
continue;
|
||||
- var next = level.id == nextLevel || (!seenNext && levelStatusMap[level.id] != "complete" && !level.locked && !level.disabled);
|
||||
- seenNext = seenNext || next;
|
||||
div(style="left: #{level.x}%; bottom: #{level.y}%; background-color: #{level.color}", class="level" + (next ? " next" : "") + (level.disabled ? " disabled" : "") + (level.locked ? " locked" : "") + " " + levelStatusMap[level.id] || "", data-level-id=level.id, title=level.name)
|
||||
a(href=level.type == 'hero' ? '#' : level.disabled ? "/play" : "/play/#{level.levelPath || 'level'}/#{level.id}", disabled=level.disabled, data-level-id=level.id, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
div(style="left: #{level.x}%; bottom: #{level.y}%", class="level-shadow" + (next ? " next" : "") + " " + levelStatusMap[level.id] || "")
|
||||
.level-info-container(data-level-id=level.id, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
div(class="level-info " + (levelStatusMap[level.id] || ""))
|
||||
h3= level.name + (level.disabled ? " (Coming soon!)" : (level.locked ? " (Locked)" : ""))
|
||||
.level-description= level.description
|
||||
span(data-i18n="play.level_difficulty") Difficulty:
|
||||
each i in Array(level.difficulty)
|
||||
i.icon-star
|
||||
- var playCount = levelPlayCountMap[level.id]
|
||||
if playCount && playCount.sessions > 20
|
||||
div
|
||||
span.spr #{playCount.sessions}
|
||||
span(data-i18n="play.players") players
|
||||
span.spr , #{Math.round(playCount.playtime / 3600)}
|
||||
span(data-i18n="play.hours_played") hours played
|
||||
.campaign-label(style="color: #{campaign.color}")= campaign.name
|
||||
if isIPadApp
|
||||
button.btn.btn-success.btn-lg.start-level(data-i18n="common.play") Play
|
||||
each level in campaign.levels
|
||||
if level.hidden
|
||||
continue;
|
||||
- var next = level.id == nextLevel || (!seenNext && levelStatusMap[level.id] != "complete" && !level.locked && !level.disabled);
|
||||
- seenNext = seenNext || next;
|
||||
div(style="left: #{level.x}%; bottom: #{level.y}%; background-color: #{level.color}", class="level" + (next ? " next" : "") + (level.disabled ? " disabled" : "") + (level.locked ? " locked" : "") + " " + levelStatusMap[level.id] || "", data-level-id=level.id, title=level.name)
|
||||
a(href=level.type == 'hero' ? '#' : level.disabled ? "/play" : "/play/#{level.levelPath || 'level'}/#{level.id}", disabled=level.disabled, data-level-id=level.id, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
div(style="left: #{level.x}%; bottom: #{level.y}%", class="level-shadow" + (next ? " next" : "") + " " + levelStatusMap[level.id] || "")
|
||||
.level-info-container(data-level-id=level.id, data-level-path=level.levelPath || 'level', data-level-name=level.name)
|
||||
div(class="level-info " + (levelStatusMap[level.id] || ""))
|
||||
h3= level.name + (level.disabled ? " (Coming soon!)" : (level.locked ? " (Locked)" : ""))
|
||||
.level-description= level.description
|
||||
span(data-i18n="play.level_difficulty") Difficulty:
|
||||
each i in Array(level.difficulty)
|
||||
i.icon-star
|
||||
- var playCount = levelPlayCountMap[level.id]
|
||||
if playCount && playCount.sessions > 20
|
||||
div
|
||||
span.spr #{playCount.sessions}
|
||||
span(data-i18n="play.players") players
|
||||
span.spr , #{Math.round(playCount.playtime / 3600)}
|
||||
span(data-i18n="play.hours_played") hours played
|
||||
.campaign-label(style="color: #{campaign.color}")= campaign.name
|
||||
if isIPadApp
|
||||
button.btn.btn-success.btn-lg.start-level(data-i18n="common.play") Play
|
||||
|
||||
.game-controls.header-font
|
||||
if me.isAdmin()
|
||||
|
@ -47,6 +46,13 @@
|
|||
a.btn.achievements(href="/user/#{me.getSlugOrID()}/stats", data-i18n="[title]play.achievements")
|
||||
a.btn.account(href="/user/#{me.getSlugOrID()}", data-i18n="[title]play.account")
|
||||
a.btn.settings(href='/account', data-i18n="[title]play.settings")
|
||||
|
||||
if mapType === 'forest'
|
||||
a.btn(href="/play/dungeon", data-i18n="[title]play.campaign_dungeon")
|
||||
img(src="/images/pages/play/map_dungeon_icon.jpg").img-thumbnail
|
||||
if mapType === 'dungeon'
|
||||
a.btn(href="/play/forest", data-i18n="[title]play.campaign_forest")
|
||||
img(src="/images/pages/play/map_forest_icon.jpg").img-thumbnail
|
||||
|
||||
.old-levels
|
||||
a(href="/play-old", data-i18n="play.older_campaigns").header-font Older Campaigns
|
||||
|
|
|
@ -19,7 +19,6 @@ class LevelSessionsCollection extends CocoCollection
|
|||
module.exports = class WorldMapView extends RootView
|
||||
id: 'world-map-view'
|
||||
template: template
|
||||
terrain: 'Dungeon' # or Grass
|
||||
|
||||
events:
|
||||
'click .map-background': 'onClickMap'
|
||||
|
@ -30,7 +29,8 @@ module.exports = class WorldMapView extends RootView
|
|||
'mousemove .map': 'onMouseMoveMap'
|
||||
'click #volume-button': 'onToggleVolume'
|
||||
|
||||
constructor: (options) ->
|
||||
constructor: (options, @terrain) ->
|
||||
@terrain ?= 'dungeon' # or 'forest'
|
||||
super options
|
||||
@nextLevel = @getQueryVariable 'next'
|
||||
@levelStatusMap = {}
|
||||
|
@ -78,18 +78,17 @@ module.exports = class WorldMapView extends RootView
|
|||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
context.campaigns = campaigns
|
||||
for campaign in context.campaigns
|
||||
for level, index in campaign.levels
|
||||
level.x ?= 10 + 80 * Math.random()
|
||||
level.y ?= 10 + 80 * Math.random()
|
||||
level.locked = index > 0 and not me.earnedLevel level.original
|
||||
window.levelUnlocksNotWorking = true if level.locked and level.id is @nextLevel # Temporary
|
||||
level.locked = false if window.levelUnlocksNotWorking # Temporary; also possible in HeroVictoryModal
|
||||
level.color = campaign.color
|
||||
if level.practice
|
||||
level.color = 'rgb(80, 130, 200)' unless me.getBranchingGroup() is 'all-practice'
|
||||
level.hidden = true if me.getBranchingGroup() is 'no-practice'
|
||||
context.campaign = _.find campaigns, { id: @terrain }
|
||||
for level, index in context.campaign.levels
|
||||
level.x ?= 10 + 80 * Math.random()
|
||||
level.y ?= 10 + 80 * Math.random()
|
||||
level.locked = index > 0 and not me.earnedLevel level.original
|
||||
window.levelUnlocksNotWorking = true if level.locked and level.id is @nextLevel # Temporary
|
||||
level.locked = false if window.levelUnlocksNotWorking # Temporary; also possible in HeroVictoryModal
|
||||
level.color = 'rgb(255, 80, 60)'
|
||||
if level.practice
|
||||
level.color = 'rgb(80, 130, 200)' unless me.getBranchingGroup() is 'all-practice'
|
||||
level.hidden = true if me.getBranchingGroup() is 'no-practice'
|
||||
context.levelStatusMap = @levelStatusMap
|
||||
context.levelPlayCountMap = @levelPlayCountMap
|
||||
context.isIPadApp = application.isIPadApp
|
||||
|
@ -176,7 +175,7 @@ module.exports = class WorldMapView extends RootView
|
|||
|
||||
onWindowResize: (e) =>
|
||||
mapHeight = iPadHeight = 1536
|
||||
mapWidth = if @terrain is 'Dungeon' then 2350 else 2500
|
||||
mapWidth = if @terrain is 'dungeon' then 2350 else 2500
|
||||
iPadWidth = 2048
|
||||
aspectRatio = mapWidth / mapHeight
|
||||
iPadAspectRatio = iPadWidth / iPadHeight
|
||||
|
@ -185,7 +184,7 @@ module.exports = class WorldMapView extends RootView
|
|||
widthRatio = pageWidth / mapWidth
|
||||
heightRatio = pageHeight / mapHeight
|
||||
iPadWidthRatio = pageWidth / iPadWidth
|
||||
if @terrain is 'Dungeon'
|
||||
if @terrain is 'dungeon'
|
||||
# Make sure we can see almost the whole map, fading to background in one dimension.
|
||||
if heightRatio <= iPadWidthRatio
|
||||
# Full width, full height, left and right margin
|
||||
|
@ -213,7 +212,7 @@ module.exports = class WorldMapView extends RootView
|
|||
|
||||
playAmbientSound: ->
|
||||
return if @ambientSound
|
||||
return unless file = {Dungeon: 'ambient-dungeon', Grass: 'ambient-map-grass'}[@terrain]
|
||||
return unless file = {dungeon: 'ambient-dungeon', forest: 'ambient-map-grass'}[@terrain]
|
||||
src = "/file/interface/#{file}#{AudioPlayer.ext}"
|
||||
unless AudioPlayer.getStatus(src)?.loaded
|
||||
AudioPlayer.preloadSound src
|
||||
|
@ -224,7 +223,7 @@ module.exports = class WorldMapView extends RootView
|
|||
|
||||
playMusic: ->
|
||||
@musicPlayer = new MusicPlayer()
|
||||
musicFile = {Dungeon: '/music/music-menu-dungeon', Grass: '/music/music-menu-grass'}[@terrain]
|
||||
musicFile = {dungeon: '/music/music-menu-dungeon', forest: '/music/music-menu-grass'}[@terrain]
|
||||
Backbone.Mediator.publish 'music-player:play-music', play: true, file: musicFile
|
||||
storage.save("loaded-menu-music-#{@terrain}", true) unless @probablyCachedMusic
|
||||
|
||||
|
@ -597,7 +596,7 @@ playerCreated = [
|
|||
}
|
||||
]
|
||||
|
||||
hero = [
|
||||
dungeon = [
|
||||
{
|
||||
name: 'Dungeons of Kithgard'
|
||||
type: 'hero'
|
||||
|
@ -866,6 +865,9 @@ hero = [
|
|||
nextLevels:
|
||||
continue: 'defense-of-plainswood'
|
||||
}
|
||||
]
|
||||
|
||||
forest = [
|
||||
{
|
||||
name: 'Defense of Plainswood'
|
||||
type: 'hero'
|
||||
|
@ -873,8 +875,8 @@ hero = [
|
|||
id: 'defense-of-plainswood'
|
||||
original: '541b67f71ccc8eaae19f3c62'
|
||||
description: 'Protect the peasants from the pursuing ogres.'
|
||||
x: 95.31
|
||||
y: 88.26
|
||||
x: 48
|
||||
y: 65
|
||||
}
|
||||
{
|
||||
name: 'Dueling Grounds'
|
||||
|
@ -884,8 +886,8 @@ hero = [
|
|||
original: '5442ba0e1e835500007eb1c7'
|
||||
description: 'Battle head-to-head against another hero in this basic beginner combat arena.'
|
||||
disabled: not me.isAdmin()
|
||||
x: 17.54
|
||||
y: 78.39
|
||||
x: 26
|
||||
y: 77
|
||||
}
|
||||
#{
|
||||
# name: ''
|
||||
|
@ -941,5 +943,6 @@ WorldMapView.campaigns = campaigns = [
|
|||
#{id: 'dev', name: 'Random Harder Levels', description: '... in which you learn the interface while doing something a little harder.', levels: experienced, color: "rgb(80, 60, 255)"}
|
||||
#{id: 'classic_algorithms' ,name: 'Classic Algorithms', description: '... in which you learn the most popular algorithms in Computer Science.', levels: classicAlgorithms, color: "rgb(110, 80, 120)"}
|
||||
#{id: 'player_created', name: 'Player-Created', description: '... in which you battle against the creativity of your fellow <a href=\"/contribute#artisan\">Artisan Wizards</a>.', levels: playerCreated, color: "rgb(160, 160, 180)"}
|
||||
{id: 'beginner', name: 'Beginner Campaign', levels: hero, color: 'rgb(255, 80, 60)'}
|
||||
{id: 'dungeon', name: 'Dungeon Campaign', levels: dungeon }
|
||||
{id: 'forest', name: 'Forest Campaign', levels: forest }
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue