mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-25 12:20:32 -04:00
Option to choose between ground and floating layer for AOE circles. Fixed cleave AOEs.
This commit is contained in:
parent
ca3573653a
commit
45dd6fa9a6
1 changed files with 15 additions and 9 deletions
|
@ -204,39 +204,45 @@ module.exports = Lank = class Lank extends CocoClass
|
||||||
@handledDisplayEvents[event] = true
|
@handledDisplayEvents[event] = true
|
||||||
args = JSON.parse(event[4...])
|
args = JSON.parse(event[4...])
|
||||||
key = 'aoe-' + JSON.stringify(args[2..])
|
key = 'aoe-' + JSON.stringify(args[2..])
|
||||||
|
layerName = args[6] ? 'ground' # Can also specify 'floating'.
|
||||||
|
unless layer = @options[layerName + 'Layer']
|
||||||
|
console.error "#{@thang.id} couldn't find layer #{layerName}Layer for AOE effect #{key}; using ground layer."
|
||||||
|
layer = @options.groundLayer
|
||||||
|
|
||||||
unless key in @options.groundLayer.spriteSheet.getAnimations()
|
unless key in layer.spriteSheet.getAnimations()
|
||||||
args = JSON.parse(event[4...])
|
|
||||||
circle = new createjs.Shape()
|
circle = new createjs.Shape()
|
||||||
radius = args[2] * Camera.PPM
|
radius = args[2] * Camera.PPM
|
||||||
if args.length is 4
|
if args.length is 4
|
||||||
circle.graphics.beginFill(args[3]).drawCircle(0, 0, radius)
|
circle.graphics.beginFill(args[3]).drawCircle(0, 0, radius)
|
||||||
else
|
else
|
||||||
startAngle = args[4]
|
startAngle = args[4] or 0
|
||||||
endAngle = args[5]
|
endAngle = args[5] or 2 * Math.PI
|
||||||
|
if startAngle is endAngle
|
||||||
|
startAngle = 0
|
||||||
|
endAngle = 2 * Math.PI
|
||||||
circle.graphics.beginFill(args[3])
|
circle.graphics.beginFill(args[3])
|
||||||
.lineTo(0, 0)
|
.lineTo(0, 0)
|
||||||
.lineTo(radius * Math.cos(startAngle), radius * Math.sin(startAngle))
|
.lineTo(radius * Math.cos(startAngle), radius * Math.sin(startAngle))
|
||||||
.arc(0, 0, radius, startAngle, endAngle)
|
.arc(0, 0, radius, startAngle, endAngle)
|
||||||
.lineTo(0, 0)
|
.lineTo(0, 0)
|
||||||
@options.groundLayer.addCustomGraphic(key, circle, [-radius, -radius, radius*2, radius*2])
|
layer.addCustomGraphic(key, circle, [-radius, -radius, radius*2, radius*2])
|
||||||
|
|
||||||
circle = new createjs.Sprite(@options.groundLayer.spriteSheet)
|
circle = new createjs.Sprite(layer.spriteSheet)
|
||||||
circle.gotoAndStop(key)
|
circle.gotoAndStop(key)
|
||||||
pos = @options.camera.worldToSurface {x: args[0], y: args[1]}
|
pos = @options.camera.worldToSurface {x: args[0], y: args[1]}
|
||||||
circle.x = pos.x
|
circle.x = pos.x
|
||||||
circle.y = pos.y
|
circle.y = pos.y
|
||||||
resFactor = @options.groundLayer.resolutionFactor
|
resFactor = layer.resolutionFactor
|
||||||
circle.scaleY = @options.camera.y2x * 0.7 / resFactor
|
circle.scaleY = @options.camera.y2x * 0.7 / resFactor
|
||||||
circle.scaleX = 0.7 / resFactor
|
circle.scaleX = 0.7 / resFactor
|
||||||
circle.alpha = 0.2
|
circle.alpha = 0.2
|
||||||
@options.groundLayer.addChild circle
|
layer.addChild circle
|
||||||
createjs.Tween.get(circle)
|
createjs.Tween.get(circle)
|
||||||
.to({alpha: 0.6, scaleY: @options.camera.y2x / resFactor, scaleX: 1 / resFactor}, 100, createjs.Ease.circOut)
|
.to({alpha: 0.6, scaleY: @options.camera.y2x / resFactor, scaleX: 1 / resFactor}, 100, createjs.Ease.circOut)
|
||||||
.to({alpha: 0, scaleY: 0, scaleX: 0}, 700, createjs.Ease.circIn)
|
.to({alpha: 0, scaleY: 0, scaleX: 0}, 700, createjs.Ease.circIn)
|
||||||
.call =>
|
.call =>
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
@options.groundLayer.removeChild circle
|
layer.removeChild circle
|
||||||
delete @handledDisplayEvents[event]
|
delete @handledDisplayEvents[event]
|
||||||
|
|
||||||
showTextEvents: ->
|
showTextEvents: ->
|
||||||
|
|
Loading…
Add table
Reference in a new issue