mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-25 05:54:51 -05:00
Re-enabled effect marks.
This commit is contained in:
parent
91f33e49dc
commit
fb30f07f2e
6 changed files with 63 additions and 49 deletions
|
@ -31,7 +31,6 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
thang: null
|
thang: null
|
||||||
camera: null
|
camera: null
|
||||||
showInvisible: false
|
showInvisible: false
|
||||||
async: true
|
|
||||||
|
|
||||||
possessed: false
|
possessed: false
|
||||||
flipped: false
|
flipped: false
|
||||||
|
@ -109,6 +108,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
@imageObject = newImageObject
|
@imageObject = newImageObject
|
||||||
@configureMouse()
|
@configureMouse()
|
||||||
@imageObject.on 'animationend', @playNextAction
|
@imageObject.on 'animationend', @playNextAction
|
||||||
|
@trigger 'new-image-object', @imageObject
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# QUEUEING AND PLAYING ACTIONS
|
# QUEUEING AND PLAYING ACTIONS
|
||||||
|
@ -513,24 +513,26 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
createMarks: ->
|
createMarks: ->
|
||||||
return unless @options.camera
|
return unless @options.camera
|
||||||
if @thang
|
if @thang
|
||||||
allProps = []
|
# TODO: Add back ranges
|
||||||
allProps = allProps.concat (@thang.hudProperties ? [])
|
# allProps = []
|
||||||
allProps = allProps.concat (@thang.programmableProperties ? [])
|
# allProps = allProps.concat (@thang.hudProperties ? [])
|
||||||
allProps = allProps.concat (@thang.moreProgrammableProperties ? [])
|
# allProps = allProps.concat (@thang.programmableProperties ? [])
|
||||||
|
# allProps = allProps.concat (@thang.moreProgrammableProperties ? [])
|
||||||
|
#
|
||||||
|
# for property in allProps
|
||||||
|
# if m = property.match /.*(Range|Distance|Radius)$/
|
||||||
|
# if @thang[m[0]]? and @thang[m[0]] < 9001
|
||||||
|
# @ranges.push
|
||||||
|
# name: m[0]
|
||||||
|
# radius: @thang[m[0]]
|
||||||
|
#
|
||||||
|
# @ranges = _.sortBy @ranges, 'radius'
|
||||||
|
# @ranges.reverse()
|
||||||
|
#
|
||||||
|
# @addMark range.name for range in @ranges
|
||||||
|
|
||||||
for property in allProps
|
# TODO: add back bounds
|
||||||
if m = property.match /.*(Range|Distance|Radius)$/
|
# @addMark('bounds').toggle true if @thang?.drawsBounds
|
||||||
if @thang[m[0]]? and @thang[m[0]] < 9001
|
|
||||||
@ranges.push
|
|
||||||
name: m[0]
|
|
||||||
radius: @thang[m[0]]
|
|
||||||
|
|
||||||
@ranges = _.sortBy @ranges, 'radius'
|
|
||||||
@ranges.reverse()
|
|
||||||
|
|
||||||
@addMark range.name for range in @ranges
|
|
||||||
|
|
||||||
@addMark('bounds').toggle true if @thang?.drawsBounds
|
|
||||||
@addMark('shadow').toggle true unless @thangType.get('shadow') is 0
|
@addMark('shadow').toggle true unless @thangType.get('shadow') is 0
|
||||||
|
|
||||||
updateMarks: ->
|
updateMarks: ->
|
||||||
|
@ -550,30 +552,29 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
@updateEffectMarks() if @thang?.effectNames?.length or @previousEffectNames?.length
|
@updateEffectMarks() if @thang?.effectNames?.length or @previousEffectNames?.length
|
||||||
|
|
||||||
updateEffectMarks: ->
|
updateEffectMarks: ->
|
||||||
# TODO: get effect marks working again
|
return if _.isEqual @thang.effectNames, @previousEffectNames
|
||||||
# return if _.isEqual @thang.effectNames, @previousEffectNames
|
return if @stopped
|
||||||
# return if @stopped
|
for effect in @thang.effectNames
|
||||||
# for effect in @thang.effectNames
|
mark = @addMark effect, @options.floatingLayer, effect
|
||||||
# mark = @addMark effect, @options.floatingLayer, effect
|
mark.statusEffect = true
|
||||||
# mark.statusEffect = true
|
mark.toggle 'on'
|
||||||
# mark.toggle 'on'
|
mark.show()
|
||||||
# mark.show()
|
|
||||||
#
|
if @previousEffectNames
|
||||||
# if @previousEffectNames
|
for effect in @previousEffectNames
|
||||||
# for effect in @previousEffectNames
|
continue if effect in @thang.effectNames
|
||||||
# continue if effect in @thang.effectNames
|
mark = @marks[effect]
|
||||||
# mark = @marks[effect]
|
mark.toggle false
|
||||||
# mark.toggle false
|
|
||||||
#
|
if @thang.effectNames.length > 1 and not @effectInterval
|
||||||
# if @thang.effectNames.length > 1 and not @effectInterval
|
@rotateEffect()
|
||||||
# @rotateEffect()
|
@effectInterval = setInterval @rotateEffect, 1500
|
||||||
# @effectInterval = setInterval @rotateEffect, 1500
|
|
||||||
#
|
else if @effectInterval and @thang.effectNames.length <= 1
|
||||||
# else if @effectInterval and @thang.effectNames.length <= 1
|
clearInterval @effectInterval
|
||||||
# clearInterval @effectInterval
|
@effectInterval = null
|
||||||
# @effectInterval = null
|
|
||||||
#
|
@previousEffectNames = @thang.effectNames
|
||||||
# @previousEffectNames = @thang.effectNames
|
|
||||||
|
|
||||||
rotateEffect: =>
|
rotateEffect: =>
|
||||||
effects = (m.name for m in _.values(@marks) when m.on and m.statusEffect and m.mark)
|
effects = (m.name for m in _.values(@marks) when m.on and m.statusEffect and m.mark)
|
||||||
|
|
|
@ -57,6 +57,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
||||||
super()
|
super()
|
||||||
options ?= {}
|
options ?= {}
|
||||||
@name = options.name ? 'Unnamed'
|
@name = options.name ? 'Unnamed'
|
||||||
|
@defaultSpriteType = if @name is 'Default' then 'segmented' else 'singular'
|
||||||
@customGraphics = {}
|
@customGraphics = {}
|
||||||
@layerPriority = options.layerPriority ? 0
|
@layerPriority = options.layerPriority ? 0
|
||||||
@transformStyle = options.transform ? LayerAdapter.TRANSFORM_CHILD
|
@transformStyle = options.transform ? LayerAdapter.TRANSFORM_CHILD
|
||||||
|
@ -248,7 +249,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
||||||
actionNames = (bundle.actionName for bundle in bundleGrouping)
|
actionNames = (bundle.actionName for bundle in bundleGrouping)
|
||||||
args = [thangType, colorConfig, actionNames, builder]
|
args = [thangType, colorConfig, actionNames, builder]
|
||||||
if thangType.get('raw')
|
if thangType.get('raw')
|
||||||
if thangType.get('spriteType') is 'segmented'
|
if (thangType.get('spriteType') or @defaultSpriteType) is 'segmented'
|
||||||
@renderSegmentedThangType(args...)
|
@renderSegmentedThangType(args...)
|
||||||
else
|
else
|
||||||
@renderSingularThangType(args...)
|
@renderSingularThangType(args...)
|
||||||
|
|
|
@ -32,6 +32,8 @@ module.exports = class Mark extends CocoClass
|
||||||
|
|
||||||
onLayerMadeSpriteSheet: ->
|
onLayerMadeSpriteSheet: ->
|
||||||
return unless @mark
|
return unless @mark
|
||||||
|
return @update() if @markSprite
|
||||||
|
# need to update the mark display object manually...
|
||||||
@mark = null
|
@mark = null
|
||||||
@build()
|
@build()
|
||||||
@layer.addChild @mark
|
@layer.addChild @mark
|
||||||
|
@ -43,8 +45,14 @@ module.exports = class Mark extends CocoClass
|
||||||
@on = to
|
@on = to
|
||||||
delete @toggleTo
|
delete @toggleTo
|
||||||
if @on
|
if @on
|
||||||
|
if @markSprite
|
||||||
|
@layer.addCocoSprite(@markSprite)
|
||||||
|
else
|
||||||
@layer.addChild @mark
|
@layer.addChild @mark
|
||||||
@layer.updateLayerOrder()
|
@layer.updateLayerOrder()
|
||||||
|
else
|
||||||
|
if @markSprite
|
||||||
|
@layer.removeCocoSprite(@markSprite)
|
||||||
else
|
else
|
||||||
@layer.removeChild @mark
|
@layer.removeChild @mark
|
||||||
if @highlightTween
|
if @highlightTween
|
||||||
|
@ -221,10 +229,11 @@ module.exports = class Mark extends CocoClass
|
||||||
return @listenToOnce(@thangType, 'sync', @onLoadedThangType) if not @thangType.loaded
|
return @listenToOnce(@thangType, 'sync', @onLoadedThangType) if not @thangType.loaded
|
||||||
CocoSprite = require './CocoSprite'
|
CocoSprite = require './CocoSprite'
|
||||||
# don't bother with making these render async for now, but maybe later for fun and more complexity of code
|
# don't bother with making these render async for now, but maybe later for fun and more complexity of code
|
||||||
markSprite = new CocoSprite @thangType, {async: false}
|
markSprite = new CocoSprite @thangType
|
||||||
markSprite.queueAction 'idle'
|
markSprite.queueAction 'idle'
|
||||||
@mark = markSprite.imageObject
|
@mark = markSprite.imageObject
|
||||||
@markSprite = markSprite
|
@markSprite = markSprite
|
||||||
|
@listenTo @markSprite, 'new-image-object', (@mark) ->
|
||||||
|
|
||||||
loadThangType: ->
|
loadThangType: ->
|
||||||
name = @thangType
|
name = @thangType
|
||||||
|
|
|
@ -2,7 +2,7 @@ SpriteBuilder = require 'lib/sprites/SpriteBuilder'
|
||||||
|
|
||||||
floors = ['Dungeon Floor', 'Indoor Floor', 'Grass', 'Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05', 'Goal Trigger', 'Obstacle']
|
floors = ['Dungeon Floor', 'Indoor Floor', 'Grass', 'Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05', 'Goal Trigger', 'Obstacle']
|
||||||
|
|
||||||
module.exports = class WebGLSprite extends createjs.Sprite
|
module.exports = class SingularSprite extends createjs.Sprite
|
||||||
childMovieClips: null
|
childMovieClips: null
|
||||||
|
|
||||||
constructor: (@spriteSheet, @thangType, @spriteSheetPrefix, @resolutionFactor=SPRITE_RESOLUTION_FACTOR) ->
|
constructor: (@spriteSheet, @thangType, @spriteSheetPrefix, @resolutionFactor=SPRITE_RESOLUTION_FACTOR) ->
|
||||||
|
|
1
test/app/fixtures/curse.thang.type.js
Normal file
1
test/app/fixtures/curse.thang.type.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -6,6 +6,7 @@ ThangType = require 'models/ThangType'
|
||||||
treeData = require 'test/app/fixtures/tree1.thang.type'
|
treeData = require 'test/app/fixtures/tree1.thang.type'
|
||||||
munchkinData = require 'test/app/fixtures/ogre-munchkin-m.thang.type'
|
munchkinData = require 'test/app/fixtures/ogre-munchkin-m.thang.type'
|
||||||
fangriderData = require 'test/app/fixtures/ogre-fangrider.thang.type'
|
fangriderData = require 'test/app/fixtures/ogre-fangrider.thang.type'
|
||||||
|
curseData = require 'test/app/fixtures/curse.thang.type'
|
||||||
|
|
||||||
describe 'SpriteBoss', ->
|
describe 'SpriteBoss', ->
|
||||||
spriteBoss = null
|
spriteBoss = null
|
||||||
|
@ -82,7 +83,7 @@ describe 'SpriteBoss', ->
|
||||||
{id: 'Ogre N', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:0, y:8, z: 1}, action: 'move', health: 10, maxHealth: 10, rotation: -Math.PI/2, acts: true, scaleFactorX: 1.5, hudProperties: ['health'] }
|
{id: 'Ogre N', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:0, y:8, z: 1}, action: 'move', health: 10, maxHealth: 10, rotation: -Math.PI/2, acts: true, scaleFactorX: 1.5, hudProperties: ['health'] }
|
||||||
{id: 'Ogre W', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:-8, y:0, z: 1}, action: 'move', health: 8, maxHealth: 10, rotation: 0, acts: true, scaleFactorY: 1.5, hudProperties: ['health'] }
|
{id: 'Ogre W', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:-8, y:0, z: 1}, action: 'move', health: 8, maxHealth: 10, rotation: 0, acts: true, scaleFactorY: 1.5, hudProperties: ['health'] }
|
||||||
{id: 'Ogre E', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:8, y:0, z: 1}, action: 'move', health: 5, maxHealth: 10, rotation: Math.PI, acts: true, alpha: 0.5, hudProperties: ['health'] }
|
{id: 'Ogre E', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:8, y:0, z: 1}, action: 'move', health: 5, maxHealth: 10, rotation: Math.PI, acts: true, alpha: 0.5, hudProperties: ['health'] }
|
||||||
{id: 'Ogre S', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:0, y:-8, z: 1}, action: 'move', health: 2, maxHealth: 10, rotation: Math.PI/2, acts: true, hudProperties: ['health'] }
|
{id: 'Ogre S', spriteName: 'Segmented Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:0, y:-8, z: 1}, action: 'move', health: 2, maxHealth: 10, rotation: Math.PI/2, acts: true, hudProperties: ['health'], effectNames: ['curse'] }
|
||||||
|
|
||||||
# Set ogres side by side with different render strategies
|
# Set ogres side by side with different render strategies
|
||||||
{id: 'Singular Ogre', spriteName: 'Singular Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:-10, y:-8, z: 1}, action: 'move', health: 10, maxHealth: 10, rotation: -Math.PI/2, acts: true, alpha: 0.5 }
|
{id: 'Singular Ogre', spriteName: 'Singular Munchkin', exists: true, shape: 'disc', depth: 2, pos: {x:-10, y:-8, z: 1}, action: 'move', health: 10, maxHealth: 10, rotation: -Math.PI/2, acts: true, alpha: 0.5 }
|
||||||
|
@ -101,6 +102,7 @@ describe 'SpriteBoss', ->
|
||||||
_.find(world.thangs, {id: 'Disappearing Tree'}).exists = false
|
_.find(world.thangs, {id: 'Disappearing Tree'}).exists = false
|
||||||
world.thangMap[thang.id] = thang for thang in world.thangs
|
world.thangMap[thang.id] = thang for thang in world.thangs
|
||||||
spriteBoss.update(true)
|
spriteBoss.update(true)
|
||||||
|
jasmine.Ajax.requests.sendResponses({'/db/thang.type/curse': curseData})
|
||||||
|
|
||||||
# Test that the unrendered, animated sprites aren't showing anything
|
# Test that the unrendered, animated sprites aren't showing anything
|
||||||
midRenderExpectations.push([spriteBoss.sprites['Segmented Ogre'].imageObject.children.length,10,'animated segmented action'])
|
midRenderExpectations.push([spriteBoss.sprites['Segmented Ogre'].imageObject.children.length,10,'animated segmented action'])
|
||||||
|
|
Loading…
Reference in a new issue