action
This commit is contained in:
parent
23cd85bf04
commit
2e755f1d68
|
@ -60,12 +60,15 @@ class Action
|
|||
if @object? then @object.removeAction @
|
||||
@deleted = true
|
||||
|
||||
init: () -> @object.initAction @
|
||||
perform: () -> @object.performAction @
|
||||
finish: () -> @object.finishAction @
|
||||
init: () -> @object.initAction? @
|
||||
perform: () -> @object.performAction? @
|
||||
finish: () -> @object.finishAction? @
|
||||
finished: () ->
|
||||
# log "Action.finished #{@name} #{@object?.actionFinished?}"
|
||||
@object.actionFinished @
|
||||
if _.isFunction @object
|
||||
@object @
|
||||
else
|
||||
@object.actionFinished @
|
||||
return if @deleted
|
||||
@reset()
|
||||
# if @current >= @getDuration() # if keepRest wasn't called -> reset start and current values
|
||||
|
@ -121,7 +124,7 @@ class Action
|
|||
@last = 0
|
||||
|
||||
if @mode == Action.CONTINUOUS
|
||||
log 'Action.CONTINUOUS'
|
||||
log "action.performWithEvent #{@name} mode == Action.CONTINUOUS"
|
||||
@current = @rest
|
||||
@start = eventTime
|
||||
@last = 0
|
||||
|
|
|
@ -14,7 +14,7 @@ Vector = require './lib/vector'
|
|||
Quaternion = require './lib/quaternion'
|
||||
|
||||
class Bot extends Pushable
|
||||
|
||||
|
||||
constructor: () ->
|
||||
|
||||
@direction = new Vector
|
||||
|
@ -316,7 +316,7 @@ class Bot extends Pushable
|
|||
finishAction: (action) ->
|
||||
|
||||
log "Bot.finishAction #{action.id} #{action.name}" if action.name != 'noop'
|
||||
|
||||
|
||||
switch action.id
|
||||
when Action.NOOP, Action.SHOOT
|
||||
return
|
||||
|
@ -349,11 +349,12 @@ class Bot extends Pushable
|
|||
else
|
||||
@orientation = @orientation.mul Quaternion.rotationAroundVector(-90.0, new Vector(0,1,0)).mul @rest_orientation
|
||||
@rest_orientation = Quaternion.rotationAroundVector 90.0, new Vector 0,1,0
|
||||
|
||||
if action.id != Action.CLIMB_UP
|
||||
world.objectMovedFromPos @, @position # update world @position
|
||||
@position = @current_position.round()
|
||||
|
||||
if action.id != Action.CLIMB_UP
|
||||
targetPos = @current_position.round()
|
||||
world.objectMoved @, @position, targetPos # update world @position
|
||||
@position = targetPos
|
||||
|
||||
if action.id != Action.JUMP_FORWARD and @rotate_action == null # if not jumping forward
|
||||
@orientation = @orientation.mul @rest_orientation # update rotation @orientation
|
||||
@rest_orientation.reset()
|
||||
|
@ -365,7 +366,7 @@ class Bot extends Pushable
|
|||
# 000 000 000 000 000 0000000 000 000 00000000 0000000
|
||||
|
||||
actionFinished: (action) ->
|
||||
# log "bot.actionFinished #{action.name} #{action.id}"a
|
||||
# log "bot.actionFinished #{action.name} #{action.id}"
|
||||
|
||||
# if @isDead()
|
||||
# log "DIE!"
|
||||
|
@ -386,7 +387,7 @@ class Bot extends Pushable
|
|||
return
|
||||
|
||||
if @move_action # action was not a move action -> return
|
||||
log 'action was not a move action -> return'
|
||||
# log 'bot.actionFinished was not a move action!'
|
||||
return
|
||||
|
||||
# find next action depending on type of finished action and surrounding environment
|
||||
|
|
|
@ -21,13 +21,14 @@ class Cell
|
|||
getOccupant: -> _.find @objects, (o) -> o.isSpaceEgoistic()
|
||||
|
||||
removeObject: (object) ->
|
||||
# log 'cell.removeObject ', @objects.length
|
||||
# log 'cell.removeObject', @objects.length
|
||||
for o in @objects
|
||||
o.cellMateLeft object if o != object
|
||||
_.remove @objects, (o) -> o == object or o.object == object
|
||||
# log 'cell.removedObject ', (o.name for o in @objects)
|
||||
|
||||
addObject: (object) ->
|
||||
# log "cell.addObject #{object.name}"
|
||||
for o in @objects
|
||||
o.newCellMate object
|
||||
@objects.push object
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
|
||||
log = require "/Users/kodi/s/ko/js/tools/log"
|
||||
|
||||
Vector = require './lib/vector'
|
||||
Switch = require './switch'
|
||||
Action = require './action'
|
||||
|
||||
class Gate extends Switch
|
||||
|
||||
isSpaceEgoistic: -> false
|
||||
|
||||
constructor: (active) ->
|
||||
super active
|
||||
|
@ -19,12 +22,33 @@ class Gate extends Switch
|
|||
@sound_on = 'GATE_OPEN'
|
||||
@sound_off = 'GATE_CLOSE'
|
||||
|
||||
createMesh: () -> super
|
||||
# log 'gate.createMesh'
|
||||
createMesh: () ->
|
||||
torusRadius = 0.05
|
||||
t1 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
||||
@mat = new THREE.MeshPhongMaterial
|
||||
color: 0xff0000
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.SmoothShading
|
||||
shininess: 5
|
||||
|
||||
@mesh = new THREE.Mesh t1, @mat
|
||||
|
||||
t2 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
||||
t3 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
||||
t2.rotateY Vector.DEG2RAD 90
|
||||
t3.rotateX Vector.DEG2RAD 90
|
||||
t2.merge t3
|
||||
@tors = new THREE.Mesh t2, @mat
|
||||
@mesh.add @tors
|
||||
@mesh
|
||||
|
||||
bulletImpact: ->
|
||||
|
||||
newCellMate: (object) ->
|
||||
if object == world.player and @active
|
||||
log "gate.newCellMate --------------------------- #{object.name} #{@active}"
|
||||
if object.name == 'player' and @active
|
||||
world.playSound 'GATE_WARP'
|
||||
log "gate.newCellMate --------------------------- trigger enter event actions"
|
||||
@events[@ENTER_EVENT].triggerActions()
|
||||
|
||||
renderBar: (r,b,h) ->
|
||||
|
|
|
@ -24,6 +24,7 @@ class Item extends Actor
|
|||
@move_action = null
|
||||
|
||||
del: ->
|
||||
log "item del!!!!!!!!!!!!!!!!!!!!!! #{@name}"
|
||||
world.scene.remove @mesh if @mesh?
|
||||
world.removeObject @
|
||||
@emit 'deleted'
|
||||
|
@ -33,7 +34,7 @@ class Item extends Actor
|
|||
bulletImpact: ->
|
||||
render: ->
|
||||
|
||||
isSpaceEgoistic: -> true
|
||||
isSpaceEgoistic: -> false
|
||||
isSlippery: -> false
|
||||
|
||||
setPosition: (x,y,z) ->
|
||||
|
|
|
@ -30,8 +30,8 @@ module.exports =
|
|||
]
|
||||
create: ->
|
||||
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,0,3
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,-1,1
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,-2,-1
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,-3,-3
|
||||
world.addObjectAtPos 'KikiStone', world.decenter 0,0,3
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,-1,1
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,-2,-1
|
||||
world.addObjectAtPos 'KikiWall', world.decenter 0,-3,-3
|
||||
|
|
@ -10,6 +10,8 @@ Action = require './action'
|
|||
Vector = require './lib/vector'
|
||||
|
||||
class Pushable extends Item
|
||||
|
||||
isSpaceEgoistic: -> true
|
||||
|
||||
constructor: () ->
|
||||
super
|
||||
|
@ -48,7 +50,7 @@ class Pushable extends Item
|
|||
switch action.id
|
||||
when Action.PUSH, Action.FALL
|
||||
@move_action = null
|
||||
world.objectMovedFromPos @, @position
|
||||
world.objectMoved @, @position, @current_position
|
||||
# log "Pushable.finishAction setPosition #{@current_position}"
|
||||
@setPosition @current_position
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
# 000 000 000 000 000 0000 000
|
||||
# 0000000 000 0000000 000 000 00000000
|
||||
|
||||
Item = require './item'
|
||||
Pushable = require './pushable'
|
||||
|
||||
class Stone extends Item
|
||||
class Stone extends Pushable
|
||||
|
||||
constructor: ->
|
||||
constructor: (@slippery=false) ->
|
||||
|
||||
@geom = new THREE.BoxGeometry 1,1,1
|
||||
|
||||
@mat = new THREE.MeshPhongMaterial
|
||||
color: 0xffffff
|
||||
color: 0xff8800
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.SmoothShading
|
||||
transparent: true
|
||||
|
@ -24,5 +24,7 @@ class Stone extends Item
|
|||
world.scene.add @mesh
|
||||
@mesh.matrixAutoUpdate = true
|
||||
super
|
||||
|
||||
isSlippery: -> return @slippery
|
||||
|
||||
module.exports = Stone
|
||||
|
|
|
@ -12,6 +12,8 @@ Light = require './light'
|
|||
Item = require './item'
|
||||
|
||||
class Switch extends Item
|
||||
|
||||
isSpaceEgoistic: -> true
|
||||
|
||||
constructor: (active=false) ->
|
||||
|
||||
|
@ -33,16 +35,13 @@ class Switch extends Item
|
|||
@setActive active
|
||||
|
||||
createMesh: () ->
|
||||
log 'switch createMesh'
|
||||
torusRadius = 0.05
|
||||
t1 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
||||
@mat = new THREE.MeshPhongMaterial
|
||||
color: 0x0000ff
|
||||
side: THREE.FrontSide
|
||||
shading: THREE.SmoothShading
|
||||
transparent: true
|
||||
opacity: 0.9
|
||||
shininess: 0.99
|
||||
shininess: 5
|
||||
@mesh = new THREE.Mesh t1, @mat
|
||||
|
||||
t2 = new THREE.TorusGeometry 0.5-torusRadius, torusRadius, 16, 32
|
||||
|
@ -54,7 +53,7 @@ class Switch extends Item
|
|||
@mesh.add @tors
|
||||
@mesh
|
||||
|
||||
bulletImpact: -> @setActive not @active
|
||||
bulletImpact: -> @setActive not @active
|
||||
|
||||
del: () -> @light?.del()
|
||||
|
||||
|
@ -70,7 +69,6 @@ class Switch extends Item
|
|||
@startTimedAction @getActionWithId Action.ROTATE
|
||||
world.playSound @sound_on
|
||||
@events[@SWITCH_ON_EVENT].triggerActions()
|
||||
# log 'createLight at pos:', @position
|
||||
@light = new Light @position, 10.0
|
||||
@light.on 'deleted', @lightDeleted
|
||||
else
|
||||
|
@ -86,7 +84,6 @@ class Switch extends Item
|
|||
@events[@SWITCHED_EVENT].triggerActions()
|
||||
|
||||
setPosition: (pos) ->
|
||||
# log "setPosition #{@light?} pos:", pos
|
||||
super pos
|
||||
@light?.setPosition @position
|
||||
|
||||
|
@ -104,10 +101,4 @@ class Switch extends Item
|
|||
else
|
||||
@animate action.getRelativeDelta()
|
||||
|
||||
# render: () ->
|
||||
|
||||
# if (active)
|
||||
# colors[KikiSwitch_sphere_color].glColor()
|
||||
# kDisplaySolidSphere(0.3);
|
||||
|
||||
module.exports = Switch
|
||||
|
|
|
@ -16,6 +16,7 @@ class Timer
|
|||
@event = world.getEventWithId @eventID
|
||||
# log "Timer.init @eventID:#{@eventID} #{@event.name}"
|
||||
|
||||
@removeAllActions: -> @event.removeAllActions()
|
||||
@removeActionsOfObject: (o) ->
|
||||
# log "Timer.removeActionsOfObject"
|
||||
@event.removeActionsOfObject o
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
# 000 000 0 000 000 000 000 000 000 000 000 000 000 000
|
||||
# 000 000 000 000 0000000 0000000 0000000 00000000 0000000 000
|
||||
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
|
||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
||||
Item = require './item'
|
||||
|
||||
class TmpObject extends Item
|
||||
|
||||
@tmpID = 0
|
||||
isSpaceEgoistic: -> true
|
||||
|
||||
constructor: (o) ->
|
||||
TmpObject.tmpID += 1
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
Item = require './item'
|
||||
|
||||
class Wall extends Item
|
||||
|
||||
isSpaceEgoistic: -> true
|
||||
|
||||
constructor: ->
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ Player = require './player'
|
|||
Cage = require './cage'
|
||||
Timer = require './timer'
|
||||
Actor = require './actor'
|
||||
Action = require './action'
|
||||
TmpObject = require './tmpobject'
|
||||
Quaternion = require './lib/quaternion'
|
||||
Vector = require './lib/vector'
|
||||
|
@ -106,7 +107,6 @@ class World extends Actor
|
|||
@preview = false
|
||||
@objects = []
|
||||
@lights = []
|
||||
@moved_objects = []
|
||||
@cells = []
|
||||
@size = new Pos()
|
||||
@depth = -Number.MAX_SAFE_INTEGER
|
||||
|
@ -149,8 +149,8 @@ class World extends Actor
|
|||
|
||||
@levelList = [
|
||||
# intro
|
||||
# "start",
|
||||
"steps",
|
||||
"start",
|
||||
#"move", "electro", "elevate",
|
||||
# "throw",
|
||||
# easy
|
||||
|
@ -203,7 +203,8 @@ class World extends Actor
|
|||
|
||||
# ............................................................ appearance
|
||||
|
||||
@setSize @dict["size"]
|
||||
@setSize @dict["size"] # this removes all objects
|
||||
|
||||
# log "world size set", @size
|
||||
|
||||
# if "scheme" in @dict
|
||||
|
@ -243,7 +244,12 @@ class World extends Actor
|
|||
|
||||
# exit_action = @once "exit #{exit_id}"
|
||||
# delay_action = @once (a=exit_action) -> Timer.addAction a
|
||||
# exit_gate.getEventWithName("enter").addAction(delay_action)
|
||||
exitAction = new Action
|
||||
func: @exitLevel
|
||||
name: "exit #{exit_id}"
|
||||
mode: Action.ONCE
|
||||
|
||||
exit_gate.getEventWithName("enter").addAction exitAction
|
||||
if entry.position?
|
||||
pos = @decenter entry.position
|
||||
else if entry.coordinates?
|
||||
|
@ -298,8 +304,9 @@ class World extends Actor
|
|||
@create()
|
||||
|
||||
finish: () ->
|
||||
log 'world.levelFinished'
|
||||
# saves the current level status in highscore file
|
||||
highscore.levelFinished world.level_name, Controller.player.getStatus().getMoves()
|
||||
# highscore.levelFinished world.level_name, Controller.player.getStatus().getMoves()
|
||||
|
||||
# 00000000 00000000 0000000 00000000 000000000 00000000 000 0000000 000 000 00000000 00000000
|
||||
# 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
|
||||
|
@ -328,22 +335,20 @@ class World extends Actor
|
|||
# 000 000 000 000 000 000 000 000 0000
|
||||
# 000 000 0000000 000 000 0000000 000 000
|
||||
|
||||
performAction: (name, time) ->
|
||||
# log "world.performAction #{name}"
|
||||
# action callback. used to exit current world
|
||||
if /exit/.test name
|
||||
@finish()
|
||||
@player.status.setMoves 0
|
||||
if "world" in @dict["exits"][parseInt name.slice 5]
|
||||
w = @dict["exits"][parseInt name.slice 5]["world"]
|
||||
if w instanceof World
|
||||
w.create()
|
||||
else if _.isFunction w
|
||||
w()
|
||||
# else
|
||||
# exec "World().create(" + world + ")"
|
||||
else
|
||||
world.create levelList[world.level_index+1]
|
||||
|
||||
exitLevel: (action) =>
|
||||
log "world.exitLevel #{action}"
|
||||
@finish()
|
||||
# @player.status.setMoves 0
|
||||
exitIndex = parseInt action.name.slice 5
|
||||
log "world.exitLevel exitIndex:#{exitIndex}"
|
||||
# if @dict.exits[exitIndex]?.world?
|
||||
# w = @dict.exits[exitIndex].world
|
||||
# w() if _.isFunction w
|
||||
# else
|
||||
# world = world.create levelList[world.level_index+1]
|
||||
log "world.level_index #{world.level_index} nextLevel #{World.levelList[world.level_index+1]}"
|
||||
world.create World.levelList[world.level_index+1]
|
||||
|
||||
activate: (objectName) ->
|
||||
# activates object with name objectName
|
||||
|
@ -537,11 +542,11 @@ class World extends Actor
|
|||
lrest = index % lsize
|
||||
new Pos index/lsize, lrest/@size.z, lrest%@size.z
|
||||
|
||||
# 0000000 0000000 000 00000000 0000000 000000000 0000000
|
||||
# 000 000 000 000 000 000 000 000 000
|
||||
# 000 000 0000000 000 0000000 000 000 0000000
|
||||
# 000 000 000 000 000 000 000 000 000 000
|
||||
# 0000000 0000000 0000000 00000000 0000000 000 0000000
|
||||
# 0000000 0000000 000 00000000 0000000 000000000 0000000
|
||||
# 000 000 000 000 000 000 000 000 000
|
||||
# 000 000 0000000 000 0000000 000 000 0000000
|
||||
# 000 000 000 000 000 000 000 000 000 000
|
||||
# 0000000 0000000 0000000 00000000 0000000 000 0000000
|
||||
|
||||
getObjectsOfType: (clss) -> @objects.filter (o) -> o instanceof clss
|
||||
getObjectsOfTypeAtPos: (clss, pos) -> @getCellAtPos(pos)?.getObjectsOfType clss
|
||||
|
@ -566,7 +571,7 @@ class World extends Actor
|
|||
if occupant.time > 0
|
||||
log "World.setObjectAtPos [WARNING] already occupied pos:", pos
|
||||
log "World.setObjectAtPos [WARNING] already occupied time:", occupant.time
|
||||
occupant.del() # temporary object at new pos will vanish anyway . delete it
|
||||
occupant.del() # temporary object at new pos will vanish anyway . delete it
|
||||
|
||||
cell = @getCellAtPos pos
|
||||
if not cell?
|
||||
|
@ -630,6 +635,7 @@ class World extends Actor
|
|||
# 0000000 00000000 0000000 00000000 000 00000000
|
||||
|
||||
deleteObject: (object) ->
|
||||
log "world.deleteObject #{object.name}"
|
||||
if not object?
|
||||
log "WARNING: World.deleteObject null"
|
||||
return
|
||||
|
@ -637,8 +643,7 @@ class World extends Actor
|
|||
object.del()
|
||||
|
||||
deleteAllObjects: () ->
|
||||
@picked_pickable = null
|
||||
@moved_objects = []
|
||||
log 'world.deleteAllObjects'
|
||||
|
||||
if @player?
|
||||
@player.finishRotateAction()
|
||||
|
@ -685,17 +690,9 @@ class World extends Actor
|
|||
# 000 000 0000000 000 000000000 000 000 000 000 0000000
|
||||
# 000 000 000 000 000 000 000 0 000 000 000 000 000
|
||||
# 0000000 0000000 0000000 000 000 0000000 0 00000000
|
||||
|
||||
objectMovedFromPos: (object, pos) ->
|
||||
|
||||
if cell = @getCellAtPos(pos)
|
||||
if tmpObject = cell.getObjectOfType TmpObject
|
||||
if tmpObject.object == object
|
||||
tmpObject.del()
|
||||
@moved_objects.push object
|
||||
|
||||
|
||||
objectWillMoveToPos: (object, pos, duration) ->
|
||||
# log "world.objectWillMoveToPos", pos
|
||||
# log "world.objectWillMoveToPos #{object.name} #{duration}", pos
|
||||
|
||||
if @isInvalidPos pos
|
||||
log "world.objectWillMoveToPos [WARNING] invalid pos:", pos
|
||||
|
@ -716,8 +713,8 @@ class World extends Actor
|
|||
else
|
||||
log "world.objectWillMoveToPos [WARNING] already occupied:", pos
|
||||
|
||||
if object != @player
|
||||
log '---------- tmpObjects'
|
||||
if object.name != 'player'
|
||||
log "---------- tmpObjects not player? #{object.name}"
|
||||
@unsetObject object # remove object from cell grid
|
||||
# log 'tmpObject at new pos', pos
|
||||
tmpObject = new TmpObject object # insert tmp object at new pos
|
||||
|
@ -729,27 +726,55 @@ class World extends Actor
|
|||
tmpObject.setPosition object.position
|
||||
tmpObject.time = -duration
|
||||
@addObjectAtPos tmpObject, object.getPos()
|
||||
else @player.targetPos = pos
|
||||
|
||||
updateStatus: () ->
|
||||
objectMoved: (movedObject, from, to) ->
|
||||
sourcePos = new Pos from
|
||||
targetPos = new Pos to
|
||||
|
||||
# log "world.objectMoved #{movedObject.name}", sourcePos
|
||||
|
||||
# if cell = @getCellAtPos sourcePos
|
||||
# if tmpObject = cell.getObjectOfType TmpObject
|
||||
# if tmpObject.object == object
|
||||
# tmpObject.del()
|
||||
|
||||
while @moved_objects.length
|
||||
movedObject = last @moved_objects
|
||||
pos = new Pos movedObject.position
|
||||
|
||||
if @isInvalidPos pos
|
||||
log "World.updateStatus invalid new pos"
|
||||
return
|
||||
|
||||
if tmpObject = @getObjectOfTypeAtPos TmpObject, pos
|
||||
if tmpObject.object == movedObject
|
||||
tmpObject.del()
|
||||
else
|
||||
log "World.updateStatus wrong tmp object at pos:", pos
|
||||
else if @isOccupiedPos pos
|
||||
log "World.updateStatus object moved to occupied pos:", pos
|
||||
|
||||
@setObjectAtPos movedObject, pos
|
||||
@moved_objects.pop()
|
||||
if @isInvalidPos targetPos
|
||||
log "World.objectMoved invalid targetPos:", targetPos
|
||||
return
|
||||
|
||||
# if tmpObject = @getObjectOfTypeAtPos TmpObject, pos
|
||||
# if tmpObject.object == movedObject
|
||||
# tmpObject.del()
|
||||
# else
|
||||
# log "World.updateStatus wrong tmp object at pos:", pos
|
||||
# else
|
||||
|
||||
if @isOccupiedPos targetPos
|
||||
log "World.objectMoved object moved to occupied pos:", targetPos
|
||||
|
||||
# log 'World.objectMovedFromPos sourcePos:', sourcePos
|
||||
# log 'World.objectMovedFromPos targetPos:', targetPos
|
||||
|
||||
sourceCell = @getCellAtPos sourcePos
|
||||
targetCell = @getCellAtPos targetPos
|
||||
|
||||
if sourceCell?
|
||||
sourceCell.removeObject movedObject
|
||||
if sourceCell.isEmpty()
|
||||
# log 'world.objectMoved remove empty cell at pos:', sourcePos
|
||||
@cells[@posToIndex(sourcePos)] = null
|
||||
|
||||
if not targetCell?
|
||||
cellIndex = @posToIndex targetPos
|
||||
targetCell = new Cell()
|
||||
# log "world.objectMoved created cell at index #{cellIndex}", targetPos
|
||||
@cells[cellIndex] = targetCell
|
||||
|
||||
if targetCell?
|
||||
targetCell.addObject movedObject
|
||||
else
|
||||
log 'world.objectMoved [WARNING] no target cell?'
|
||||
|
||||
setObjectColor: (color_name, color) ->
|
||||
if color_name == 'base'
|
||||
|
@ -768,11 +793,9 @@ class World extends Actor
|
|||
step: (step) ->
|
||||
if false
|
||||
quat = @camera.quaternion.clone()
|
||||
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(1,0,0), step.dsecs*0.2)
|
||||
quat.multiply (new THREE.Quaternion).setFromAxisAngle(new THREE.Vector3(0,1,0), step.dsecs*0.1)
|
||||
# center = @decenter 0,0,0
|
||||
quat.multiply new THREE.Quaternion().setFromAxisAngle new THREE.Vector3(1,0,0), step.dsecs*0.2
|
||||
quat.multiply new THREE.Quaternion().setFromAxisAngle new THREE.Vector3(0,1,0), step.dsecs*0.1
|
||||
center = @size.div 2
|
||||
# log center
|
||||
@camera.position.set(center.x,center.y,center.z+@dist).applyQuaternion quat
|
||||
@camera.quaternion.copy quat
|
||||
|
||||
|
@ -786,7 +809,6 @@ class World extends Actor
|
|||
when World.CAMERA_BEHIND then @projection = @player.getBehindProjection()
|
||||
when World.CAMERA_FOLLOW then @projection = @player.getFollowProjection()
|
||||
@projection.apply @camera
|
||||
|
||||
@sun.position.copy @camera.position
|
||||
@renderer.render @scene, @camera
|
||||
|
||||
|
@ -799,12 +821,8 @@ class World extends Actor
|
|||
getTime: -> now().toFixed 0
|
||||
setSpeed: (s) -> @speed = s
|
||||
getSpeed: -> @speed
|
||||
mapMsTime: (unmapped) ->
|
||||
# log "mapMsTime #{unmapped} #{@speed} #{parseInt 10.0 * unmapped/@speed}"
|
||||
parseInt 10.0 * unmapped/@speed
|
||||
unmapMsTime: (mapped) ->
|
||||
# log "unmapMsTime #{mapped} #{@speed} #{parseInt mapped * @speed/10.0}"
|
||||
parseInt mapped * @speed/10.0
|
||||
mapMsTime: (unmapped) -> parseInt 10.0 * unmapped/@speed
|
||||
unmapMsTime: (mapped) -> parseInt mapped * @speed/10.0
|
||||
|
||||
continuous: (cb) ->
|
||||
new Action
|
||||
|
|
Loading…
Reference in New Issue
Block a user