mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-29 18:45:48 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
5cf6a2fae7
10 changed files with 42 additions and 27 deletions
|
@ -391,7 +391,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
rotationType = @thangType.get('rotationType')
|
rotationType = @thangType.get('rotationType')
|
||||||
return if rotationType is 'fixed'
|
return if rotationType is 'fixed'
|
||||||
rotation = @getRotation()
|
rotation = @getRotation()
|
||||||
if @thangType.get('name') in ['Arrow', 'Spear']
|
if @thangType.get('name') in ['Arrow', 'Spear'] and @thang.velocity
|
||||||
# Rotates the arrow to see it arc based on velocity.z.
|
# Rotates the arrow to see it arc based on velocity.z.
|
||||||
# Notice that rotation here does not affect thang's state - it is just the effect.
|
# Notice that rotation here does not affect thang's state - it is just the effect.
|
||||||
# Thang's rotation is always pointing where it is heading.
|
# Thang's rotation is always pointing where it is heading.
|
||||||
|
|
|
@ -180,7 +180,11 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
adjustSpriteExistence: ->
|
adjustSpriteExistence: ->
|
||||||
# Add anything new, remove anything old, update everything current
|
# Add anything new, remove anything old, update everything current
|
||||||
updateCache = false
|
updateCache = false
|
||||||
|
itemsJustEquipped = []
|
||||||
for thang in @world.thangs when thang.exists
|
for thang in @world.thangs when thang.exists
|
||||||
|
if thang.equip and not thang.equipped
|
||||||
|
thang.equip() # Pretty hacky, since initialize may not be called
|
||||||
|
itemsJustEquipped.push thang
|
||||||
if sprite = @sprites[thang.id]
|
if sprite = @sprites[thang.id]
|
||||||
sprite.setThang thang # make sure Sprite has latest Thang
|
sprite.setThang thang # make sure Sprite has latest Thang
|
||||||
else
|
else
|
||||||
|
@ -188,6 +192,7 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
Backbone.Mediator.publish 'surface:new-thang-added', thang:thang, sprite:sprite
|
Backbone.Mediator.publish 'surface:new-thang-added', thang:thang, sprite:sprite
|
||||||
updateCache = updateCache or sprite.imageObject.parent is @spriteLayers['Obstacle']
|
updateCache = updateCache or sprite.imageObject.parent is @spriteLayers['Obstacle']
|
||||||
sprite.playSounds()
|
sprite.playSounds()
|
||||||
|
item.modifyStats() for item in itemsJustEquipped
|
||||||
for thangID, sprite of @sprites
|
for thangID, sprite of @sprites
|
||||||
missing = not (sprite.notOfThisWorld or @world.thangMap[thangID]?.exists)
|
missing = not (sprite.notOfThisWorld or @world.thangMap[thangID]?.exists)
|
||||||
isObstacle = sprite.imageObject.parent is @spriteLayers['Obstacle']
|
isObstacle = sprite.imageObject.parent is @spriteLayers['Obstacle']
|
||||||
|
|
|
@ -240,7 +240,7 @@ module.exports = class World
|
||||||
calculateBounds: ->
|
calculateBounds: ->
|
||||||
bounds = {left: 0, top: 0, right: 0, bottom: 0}
|
bounds = {left: 0, top: 0, right: 0, bottom: 0}
|
||||||
hasLand = _.some @thangs, 'isLand'
|
hasLand = _.some @thangs, 'isLand'
|
||||||
for thang in @thangs when thang.isLand or not hasLand # Look at Lands only
|
for thang in @thangs when thang.isLand or (not hasLand and thang.rectangle) # Look at Lands only
|
||||||
rect = thang.rectangle().axisAlignedBoundingBox()
|
rect = thang.rectangle().axisAlignedBoundingBox()
|
||||||
bounds.left = Math.min(bounds.left, rect.x - rect.width / 2)
|
bounds.left = Math.min(bounds.left, rect.x - rect.width / 2)
|
||||||
bounds.right = Math.max(bounds.right, rect.x + rect.width / 2)
|
bounds.right = Math.max(bounds.right, rect.x + rect.width / 2)
|
||||||
|
|
|
@ -105,7 +105,7 @@ _.extend ThangTypeSchema.properties,
|
||||||
shapes: c.object {title: 'Shapes', additionalProperties: ShapeObjectSchema}
|
shapes: c.object {title: 'Shapes', additionalProperties: ShapeObjectSchema}
|
||||||
containers: c.object {title: 'Containers', additionalProperties: ContainerObjectSchema}
|
containers: c.object {title: 'Containers', additionalProperties: ContainerObjectSchema}
|
||||||
animations: c.object {title: 'Animations', additionalProperties: RawAnimationObjectSchema}
|
animations: c.object {title: 'Animations', additionalProperties: RawAnimationObjectSchema}
|
||||||
kind: c.shortString {enum: ['Unit', 'Floor', 'Wall', 'Doodad', 'Misc', 'Mark'], default: 'Misc', title: 'Kind'}
|
kind: c.shortString {enum: ['Unit', 'Floor', 'Wall', 'Doodad', 'Misc', 'Mark', 'Item'], default: 'Misc', title: 'Kind'}
|
||||||
|
|
||||||
actions: c.object {title: 'Actions', additionalProperties: {$ref: '#/definitions/action'}}
|
actions: c.object {title: 'Actions', additionalProperties: {$ref: '#/definitions/action'}}
|
||||||
soundTriggers: c.object {title: 'Sound Triggers', additionalProperties: c.array({}, {$ref: '#/definitions/sound'})},
|
soundTriggers: c.object {title: 'Sound Triggers', additionalProperties: c.array({}, {$ref: '#/definitions/sound'})},
|
||||||
|
|
|
@ -110,6 +110,12 @@ $mobile: 1050px
|
||||||
.treema-node.treema-Wall
|
.treema-node.treema-Wall
|
||||||
display: block
|
display: block
|
||||||
|
|
||||||
|
&.hide-except-Item
|
||||||
|
.treema-node
|
||||||
|
display: none
|
||||||
|
.treema-node.treema-Item
|
||||||
|
display: block
|
||||||
|
|
||||||
&.hide-except-Misc
|
&.hide-except-Misc
|
||||||
.treema-node
|
.treema-node
|
||||||
display: none
|
display: none
|
||||||
|
|
|
@ -15,6 +15,8 @@ button.navbar-toggle.toggle.btn-primary#thangs-palette-toggle(type="button", dat
|
||||||
i.icon-globe
|
i.icon-globe
|
||||||
button.btn.btn-primary(value="Doodad", title="Doodad")
|
button.btn.btn-primary(value="Doodad", title="Doodad")
|
||||||
i.icon-leaf
|
i.icon-leaf
|
||||||
|
button.btn.btn-primary(value="Item", title="Item")
|
||||||
|
i.icon-gift
|
||||||
button.btn.btn-primary(value="Misc", title="Misc")
|
button.btn.btn-primary(value="Misc", title="Misc")
|
||||||
i.icon-question-sign
|
i.icon-question-sign
|
||||||
.editor-nano-container.nano
|
.editor-nano-container.nano
|
||||||
|
|
|
@ -47,7 +47,7 @@ module.exports = class SaveLevelModal extends SaveVersionModal
|
||||||
|
|
||||||
shouldSaveEntity: (m) ->
|
shouldSaveEntity: (m) ->
|
||||||
return false unless m.hasWriteAccess()
|
return false unless m.hasWriteAccess()
|
||||||
return false unless m.hasLocalChanges()
|
return true if m.hasLocalChanges()
|
||||||
return true if (m.get('version').major is 0 and m.get('version').minor is 0) or not m.isPublished() and not m.collection
|
return true if (m.get('version').major is 0 and m.get('version').minor is 0) or not m.isPublished() and not m.collection
|
||||||
# Sometimes we have two versions: one in a search collection and one with a URL. We only save changes to the latter.
|
# Sometimes we have two versions: one in a search collection and one with a URL. We only save changes to the latter.
|
||||||
false
|
false
|
||||||
|
|
|
@ -10,35 +10,35 @@ clusters = {
|
||||||
'trees': {
|
'trees': {
|
||||||
'thangs': ['Tree 1', 'Tree 2', 'Tree 3', 'Tree 4']
|
'thangs': ['Tree 1', 'Tree 2', 'Tree 3', 'Tree 4']
|
||||||
'margin': 0
|
'margin': 0
|
||||||
}
|
}
|
||||||
'shrubs': {
|
'shrubs': {
|
||||||
'thangs': ['Shrub 1', 'Shrub 2', 'Shrub 3']
|
'thangs': ['Shrub 1', 'Shrub 2', 'Shrub 3']
|
||||||
'margin': 0
|
'margin': 0
|
||||||
}
|
}
|
||||||
'houses': {
|
'houses': {
|
||||||
'thangs': ['House 1', 'House 2', 'House 3', 'House 4']
|
'thangs': ['House 1', 'House 2', 'House 3', 'House 4']
|
||||||
'margin': 4
|
'margin': 4
|
||||||
}
|
}
|
||||||
'animals': {
|
'animals': {
|
||||||
'thangs': ['Cow', 'Horse']
|
'thangs': ['Cow', 'Horse']
|
||||||
'margin': 1
|
'margin': 1
|
||||||
}
|
}
|
||||||
'wood': {
|
'wood': {
|
||||||
'thangs': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel']
|
'thangs': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel']
|
||||||
'margin': 1
|
'margin': 1
|
||||||
}
|
}
|
||||||
'farm': {
|
'farm': {
|
||||||
'thangs': ['Farm']
|
'thangs': ['Farm']
|
||||||
'margin': 9
|
'margin': 9
|
||||||
}
|
}
|
||||||
'cave': {
|
'cave': {
|
||||||
'thangs': ['Cave']
|
'thangs': ['Cave']
|
||||||
'margin': 5
|
'margin': 5
|
||||||
}
|
}
|
||||||
'stone': {
|
'stone': {
|
||||||
'thangs': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3']
|
'thangs': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3']
|
||||||
'margin': 1
|
'margin': 1
|
||||||
}
|
}
|
||||||
'doors': {
|
'doors': {
|
||||||
'thangs': ['Dungeon Door']
|
'thangs': ['Dungeon Door']
|
||||||
'margin': -1
|
'margin': -1
|
||||||
|
@ -46,15 +46,15 @@ clusters = {
|
||||||
'grass_floor': {
|
'grass_floor': {
|
||||||
'thangs': ['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05']
|
'thangs': ['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05']
|
||||||
'margin': -1
|
'margin': -1
|
||||||
}
|
}
|
||||||
'dungeon_wall': {
|
'dungeon_wall': {
|
||||||
'thangs': ['Dungeon Wall']
|
'thangs': ['Dungeon Wall']
|
||||||
'margin': -1
|
'margin': 2
|
||||||
}
|
}
|
||||||
'dungeon_floor': {
|
'dungeon_floor': {
|
||||||
'thangs': ['Dungeon Floor']
|
'thangs': ['Dungeon Floor']
|
||||||
'margin': -1
|
'margin': -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
presets = {
|
presets = {
|
||||||
|
@ -79,7 +79,7 @@ presets = {
|
||||||
'width': [12, 20]
|
'width': [12, 20]
|
||||||
'height': [8, 16]
|
'height': [8, 16]
|
||||||
'thickness': [2,2]
|
'thickness': [2,2]
|
||||||
'cluster': 'dungeon_wall'
|
'cluster': 'dungeon_wall'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
'height':decoration.height
|
'height':decoration.height
|
||||||
}
|
}
|
||||||
break if @addRect rect
|
break if @addRect rect
|
||||||
|
|
||||||
for cluster, range of decoration.clusters
|
for cluster, range of decoration.clusters
|
||||||
for i in _.range(_.random(range[0], range[1]))
|
for i in _.range(_.random(range[0], range[1]))
|
||||||
while not @addThang {
|
while not @addThang {
|
||||||
|
@ -259,11 +259,14 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
while true
|
while true
|
||||||
rect = {
|
rect = {
|
||||||
'width':sizeFactor * (room.width[0] + preset.borderSize * _.random(0, (room.width[1] - room.width[0])/preset.borderSize))
|
'width':sizeFactor * (room.width[0] + preset.borderSize * _.random(0, (room.width[1] - room.width[0])/preset.borderSize))
|
||||||
'height':sizeFactor * (room.height[0] + preset.borderSize * _.random(0, (room.height[1] - room.height[0])/preset.borderSize))
|
'height':sizeFactor * (room.height[0] + preset.borderSize * _.random(0, (room.height[1] - room.height[0])/preset.borderSize))
|
||||||
}
|
}
|
||||||
roomThickness = _.random(room.thickness[0], room.thickness[1])
|
roomThickness = _.random(room.thickness[0], room.thickness[1])
|
||||||
rect.x = _.random(rect.width/2 + preset.borderSize * (roomThickness+1), presetSize.x - rect.width/2 - preset.borderSize * (roomThickness+1))
|
rect.x = _.random(rect.width/2 + preset.borderSize * (roomThickness+1), presetSize.x - rect.width/2 - preset.borderSize * (roomThickness+1))
|
||||||
rect.y = _.random(rect.height/2 + preset.borderSize * (roomThickness+1), presetSize.y - rect.height/2 - preset.borderSize * (roomThickness+1))
|
rect.y = _.random(rect.height/2 + preset.borderSize * (roomThickness+1), presetSize.y - rect.height/2 - preset.borderSize * (roomThickness+1))
|
||||||
|
# Snap room walls to the wall grid.
|
||||||
|
rect.x = Math.round((rect.x - preset.borderSize / 2) / preset.borderSize) * preset.borderSize + preset.borderSize / 2
|
||||||
|
rect.y = Math.round((rect.y - preset.borderSize / 2) / preset.borderSize) * preset.borderSize + preset.borderSize / 2
|
||||||
break if @addRect {
|
break if @addRect {
|
||||||
'x': rect.x
|
'x': rect.x
|
||||||
'y': rect.y
|
'y': rect.y
|
||||||
|
@ -333,9 +336,9 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
for existingThang in @thangs
|
for existingThang in @thangs
|
||||||
if existingThang.margin is -1 or thang.margin is -1
|
if existingThang.margin is -1 or thang.margin is -1
|
||||||
continue
|
continue
|
||||||
if Math.abs(existingThang.pos.x - thang.pos.x) <= thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) <= thang.margin + existingThang.margin
|
if Math.abs(existingThang.pos.x - thang.pos.x) < thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) < thang.margin + existingThang.margin
|
||||||
@falseCount++
|
@falseCount++
|
||||||
return false
|
return false
|
||||||
@thangs.push thang
|
@thangs.push thang
|
||||||
true
|
true
|
||||||
|
|
||||||
|
@ -345,9 +348,9 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
@falseCount = 0
|
@falseCount = 0
|
||||||
return true
|
return true
|
||||||
for existingRect in @rects
|
for existingRect in @rects
|
||||||
if Math.abs(existingRect.x - rect.x) <= rect.width/2 + existingRect.width/2 and Math.abs(existingRect.y - rect.y) <= rect.height/2 + existingRect.height/2
|
if Math.abs(existingRect.x - rect.x) < rect.width/2 + existingRect.width/2 and Math.abs(existingRect.y - rect.y) < rect.height/2 + existingRect.height/2
|
||||||
@falseCount++
|
@falseCount++
|
||||||
return false
|
return false
|
||||||
@rects.push rect
|
@rects.push rect
|
||||||
true
|
true
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
$(window).resize @onWindowResize
|
$(window).resize @onWindowResize
|
||||||
@addThangsView = @insertSubView new AddThangsView world: @world, supermodel: @supermodel
|
@addThangsView = @insertSubView new AddThangsView world: @world, supermodel: @supermodel
|
||||||
@buildInterface() # refactor to not have this trigger when this view re-renders?
|
@buildInterface() # refactor to not have this trigger when this view re-renders?
|
||||||
if @thangsTreema.data.length
|
if @thangsTreema.data.length
|
||||||
@$el.find('#canvas-overlay').css('display', 'none')
|
@$el.find('#canvas-overlay').css('display', 'none')
|
||||||
|
|
||||||
onFilterExtantThangs: (e) ->
|
onFilterExtantThangs: (e) ->
|
||||||
|
@ -500,7 +500,7 @@ class ThangNode extends TreemaObjectNode
|
||||||
s = "#{@data.thangType}"
|
s = "#{@data.thangType}"
|
||||||
if isObjectID s
|
if isObjectID s
|
||||||
unless name = ThangNode.thangNameMap[s]
|
unless name = ThangNode.thangNameMap[s]
|
||||||
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s
|
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s and m.get('kind')
|
||||||
name = ThangNode.thangNameMap[s] = thangType.get 'name'
|
name = ThangNode.thangNameMap[s] = thangType.get 'name'
|
||||||
ThangNode.thangKindMap[s] = thangType.get 'kind'
|
ThangNode.thangKindMap[s] = thangType.get 'kind'
|
||||||
kind = ThangNode.thangKindMap[s]
|
kind = ThangNode.thangKindMap[s]
|
||||||
|
|
|
@ -166,7 +166,7 @@ module.exports = class Handler
|
||||||
ids = ids.split(',') if _.isString ids
|
ids = ids.split(',') if _.isString ids
|
||||||
ids = _.uniq ids
|
ids = _.uniq ids
|
||||||
|
|
||||||
project = {name:1, original:1}
|
project = {name:1, original:1, kind:1}
|
||||||
sort = {'version.major':-1, 'version.minor':-1}
|
sort = {'version.major':-1, 'version.minor':-1}
|
||||||
|
|
||||||
makeFunc = (id) =>
|
makeFunc = (id) =>
|
||||||
|
@ -450,4 +450,3 @@ module.exports = class Handler
|
||||||
projection = {}
|
projection = {}
|
||||||
projection[field] = 0 for field in model.privateProperties
|
projection[field] = 0 for field in model.privateProperties
|
||||||
projection
|
projection
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue