mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Use WizardSprite
This commit is contained in:
parent
8cc8103288
commit
7ea9260322
4 changed files with 18 additions and 22 deletions
|
@ -22,7 +22,6 @@ module.exports = class LevelBus extends Bus
|
|||
'level-show-victory': 'onVictory'
|
||||
'tome:spell-changed': 'onSpellChanged'
|
||||
'tome:spell-created': 'onSpellCreated'
|
||||
'self-wizard:move': 'moveWizard'
|
||||
|
||||
constructor: ->
|
||||
super(arguments...)
|
||||
|
@ -241,12 +240,3 @@ module.exports = class LevelBus extends Bus
|
|||
destroy: ->
|
||||
@session.off 'change:multiplayer', @onMultiplayerChanged, @
|
||||
super()
|
||||
|
||||
moveWizard : (x, y) =>
|
||||
wizardSprite = @getSelfWizard()
|
||||
position = wizardSprite.getCurrentPosition()
|
||||
position.x += x
|
||||
position.y += y
|
||||
wizardSprite.setTarget(position,1000)
|
||||
wizardSprite.updatePosition()
|
||||
Backbone.Mediator.publish 'camera-zoom-to', position
|
||||
|
|
|
@ -42,7 +42,6 @@ module.exports = class Camera extends CocoClass
|
|||
'level:restarted': 'onLevelRestarted'
|
||||
'sprite:mouse-down': 'onMouseDown'
|
||||
'sprite:dragged': 'onMouseDragged'
|
||||
'camera-zoom-to': 'onZoomTo'
|
||||
|
||||
# TODO: Fix tests to not use mainLayer
|
||||
constructor: (@canvasWidth, @canvasHeight, angle=Math.asin(0.75), hFOV=d2r(30)) ->
|
||||
|
@ -309,6 +308,3 @@ module.exports = class Camera extends CocoClass
|
|||
createjs.Tween.removeTweens @
|
||||
@finishTween = null
|
||||
super()
|
||||
|
||||
onZoomTo: (pos) ->
|
||||
@zoomTo(@worldToSurface(pos), @zoom)
|
||||
|
|
|
@ -21,6 +21,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
'surface:sprite-selected': 'onSpriteSelected'
|
||||
'echo-self-wizard-sprite': 'onEchoSelfWizardSprite'
|
||||
'echo-all-wizard-sprites': 'onEchoAllWizardSprites'
|
||||
'self-wizard:move': 'moveWizard'
|
||||
|
||||
constructor: (thangType, options) ->
|
||||
if options?.isSelf
|
||||
|
@ -102,7 +103,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
defaultPos: -> x: 35, y: 24, z: @thang.depth / 2 + @thang.bobHeight
|
||||
move: (pos, duration) -> @setTarget(pos, duration)
|
||||
|
||||
setTarget: (newTarget, duration) ->
|
||||
setTarget: (newTarget, duration, isLinear=false) ->
|
||||
# ignore targets you're already heading for
|
||||
targetPos = @getPosFromTarget(newTarget)
|
||||
return if @targetPos and @targetPos.x is targetPos.x and @targetPos.y is targetPos.y
|
||||
|
@ -115,7 +116,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
@shoveOtherWizards(true) if @targetSprite
|
||||
@targetSprite = if isSprite then newTarget else null
|
||||
@targetPos = targetPos
|
||||
@beginMoveTween(duration)
|
||||
@beginMoveTween(duration, isLinear)
|
||||
@shoveOtherWizards()
|
||||
Backbone.Mediator.publish('self-wizard:target-changed', {sender:@}) if @isSelf
|
||||
|
||||
|
@ -127,7 +128,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
return target if target.x?
|
||||
return target.thang.pos
|
||||
|
||||
beginMoveTween: (duration=1000) ->
|
||||
beginMoveTween: (duration=1000, isLinear=false) ->
|
||||
# clear the old tween
|
||||
createjs.Tween.removeTweens(@)
|
||||
|
||||
|
@ -140,8 +141,11 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
@updatePosition()
|
||||
@endMoveTween()
|
||||
return
|
||||
if isLinear
|
||||
ease = createjs.Ease.linear
|
||||
else
|
||||
ease = createjs.Ease.getPowInOut(3.0)
|
||||
|
||||
ease = createjs.Ease.getPowInOut(3.0)
|
||||
createjs.Tween
|
||||
.get(@)
|
||||
.to({tweenPercentage:0.0}, duration, ease)
|
||||
|
@ -225,3 +229,9 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
|
||||
updateMarks: ->
|
||||
super() if @displayObject.visible # not if we hid the wiz
|
||||
|
||||
moveWizard : (x, y) =>
|
||||
console.log x, y
|
||||
position = {x: @targetPos.x+x, y: @targetPos.y+y}
|
||||
@setTarget(position, 500, true)
|
||||
@updatePosition()
|
||||
|
|
|
@ -221,13 +221,13 @@ module.exports = class PlaybackView extends View
|
|||
super()
|
||||
|
||||
onMoveUpKey: ->
|
||||
Backbone.Mediator.publish 'self-wizard:move', 0, 10
|
||||
Backbone.Mediator.publish 'self-wizard:move', 0, 1
|
||||
|
||||
onMoveDownKey: ->
|
||||
Backbone.Mediator.publish 'self-wizard:move', 0, -10
|
||||
Backbone.Mediator.publish 'self-wizard:move', 0, -1
|
||||
|
||||
onMoveLeftKey: ->
|
||||
Backbone.Mediator.publish 'self-wizard:move', -10, 0
|
||||
Backbone.Mediator.publish 'self-wizard:move', -1, 0
|
||||
|
||||
onMoveRightKey: ->
|
||||
Backbone.Mediator.publish 'self-wizard:move', 10, 0
|
||||
Backbone.Mediator.publish 'self-wizard:move', 1, 0
|
||||
|
|
Loading…
Reference in a new issue