misc
This commit is contained in:
parent
a92788c788
commit
8da4ab64a8
|
@ -419,8 +419,8 @@ class Bot extends Pushable
|
||||||
else
|
else
|
||||||
@dir_sgn = 1
|
@dir_sgn = 1
|
||||||
@jump_once = false if action.id != Action.NOOP
|
@jump_once = false if action.id != Action.NOOP
|
||||||
log "bot.actionFinished '#{action.name}' position:", @position if action.id in [Action.FORWARD, Action.JUMP_FORWARD, Action.CLIMB_DOWN]
|
# log "bot.actionFinished '#{action.name}' position:", @position if action.id in [Action.FORWARD, Action.JUMP_FORWARD, Action.CLIMB_DOWN]
|
||||||
log "bot.actionFinished '#{action.name}' orientation:", @orientation.rounded().name if action.id in [Action.TURN_LEFT, Action.TURN_RIGHT, Action.CLIMB_UP]
|
# log "bot.actionFinished '#{action.name}' orientation:", @orientation.rounded().name if action.id in [Action.TURN_LEFT, Action.TURN_RIGHT, Action.CLIMB_UP]
|
||||||
|
|
||||||
if world.getRealOccupantAtPos(@position.plus @getDown())?.isMutant?()
|
if world.getRealOccupantAtPos(@position.plus @getDown())?.isMutant?()
|
||||||
# keep action chain flowinwg in order to detect environment changes
|
# keep action chain flowinwg in order to detect environment changes
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Bullet extends Item
|
||||||
|
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
@size = 0.2
|
@size = 0.2
|
||||||
@src_object = null
|
@shooter = null
|
||||||
super
|
super
|
||||||
@addAction new Action @, Action.FLY, "fly", 40
|
@addAction new Action @, Action.FLY, "fly", 40
|
||||||
@addAction new Action @, Action.EXPLODE, "explode", 200
|
@addAction new Action @, Action.EXPLODE, "explode", 200
|
||||||
|
@ -21,8 +21,8 @@ class Bullet extends Item
|
||||||
del: ->
|
del: ->
|
||||||
if @mesh?
|
if @mesh?
|
||||||
world.scene.remove @mesh
|
world.scene.remove @mesh
|
||||||
_.pull world.objects, @
|
|
||||||
Timer.removeActionsOfObject @
|
Timer.removeActionsOfObject @
|
||||||
|
_.pull world.objects, @
|
||||||
@mesh = null
|
@mesh = null
|
||||||
|
|
||||||
createMesh: ->
|
createMesh: ->
|
||||||
|
@ -35,7 +35,7 @@ class Bullet extends Item
|
||||||
world.addObject bullet
|
world.addObject bullet
|
||||||
bullet.direction = bot.currentDir()
|
bullet.direction = bot.currentDir()
|
||||||
bullet.setPosition bot.position.plus bullet.direction.mul 0.8
|
bullet.setPosition bot.position.plus bullet.direction.mul 0.8
|
||||||
bullet.src_object = bot
|
bullet.shooter = bot
|
||||||
bullet.mesh.material.color.set bot.mesh.material.color
|
bullet.mesh.material.color.set bot.mesh.material.color
|
||||||
world.playSound 'BULLET_SHOT', bot.getPos()
|
world.playSound 'BULLET_SHOT', bot.getPos()
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class Bullet extends Item
|
||||||
@current_position = @position.plus @direction.mul relTime
|
@current_position = @position.plus @direction.mul relTime
|
||||||
else if action.id == Action.EXPLODE
|
else if action.id == Action.EXPLODE
|
||||||
@size = 0.2 + relTime/2.0
|
@size = 0.2 + relTime/2.0
|
||||||
@mesh.material.opacity = 0.8 * (1.0-relTime)
|
@mesh?.material.opacity = 0.8 * (1.0-relTime)
|
||||||
|
|
||||||
step: (step) ->
|
step: (step) ->
|
||||||
@mesh.position.copy @current_position
|
@mesh.position.copy @current_position
|
||||||
|
@ -61,7 +61,7 @@ class Bullet extends Item
|
||||||
|
|
||||||
if world.isInvalidPos(pos) or world.isOccupiedPos pos
|
if world.isInvalidPos(pos) or world.isOccupiedPos pos
|
||||||
hitObject = world.getRealOccupantAtPos pos
|
hitObject = world.getRealOccupantAtPos pos
|
||||||
if hitObject != @src_object
|
if hitObject != @shooter
|
||||||
if hitObject?
|
if hitObject?
|
||||||
hitObject.bulletImpact()
|
hitObject.bulletImpact()
|
||||||
world.playSound hitObject.bulletHitSound?() ? 'BULLET_HIT_OBJECT'
|
world.playSound hitObject.bulletHitSound?() ? 'BULLET_HIT_OBJECT'
|
||||||
|
|
|
@ -79,13 +79,13 @@ module.exports =
|
||||||
|
|
||||||
Switch = require '../switch'
|
Switch = require '../switch'
|
||||||
switch1 = new Switch
|
switch1 = new Switch
|
||||||
switch1.getEventWithName("switched").addAction world.continuous (sw=switch1) -> switched sw
|
switch1.getEventWithName("switched").addAction world.continuous -> switched switch1
|
||||||
switch2 = new Switch
|
switch2 = new Switch
|
||||||
switch2.getEventWithName("switched").addAction world.continuous (sw=switch2) -> switched sw
|
switch2.getEventWithName("switched").addAction world.continuous -> switched switch2
|
||||||
switch3 = new Switch
|
switch3 = new Switch
|
||||||
switch3.getEventWithName("switched").addAction world.continuous (sw=switch3) -> switched sw
|
switch3.getEventWithName("switched").addAction world.continuous -> switched switch3
|
||||||
switch4 = new Switch
|
switch4 = new Switch
|
||||||
switch4.getEventWithName("switched").addAction world.continuous (sw=switch4) -> switched sw
|
switch4.getEventWithName("switched").addAction world.continuous -> switched switch4
|
||||||
|
|
||||||
world.addObjectAtPos switch1, world.decenter -s.x/2+1, 4, 0
|
world.addObjectAtPos switch1, world.decenter -s.x/2+1, 4, 0
|
||||||
world.addObjectAtPos switch2, world.decenter s.x/2, 4, 0
|
world.addObjectAtPos switch2, world.decenter s.x/2, 4, 0
|
||||||
|
|
|
@ -30,13 +30,14 @@ module.exports =
|
||||||
create: ->
|
create: ->
|
||||||
|
|
||||||
switched = ->
|
switched = ->
|
||||||
unoccupied = false
|
occupied = true
|
||||||
for i in [3...6]
|
for i in [3...6]
|
||||||
for j in [3...6]
|
for j in [3...6]
|
||||||
if world.isUnoccupiedPos i,j,0
|
if world.isUnoccupiedPos [i,j,0]
|
||||||
unoccupied=true
|
log "isUnoccupiedPos #{i} #{j}"
|
||||||
|
occupied = false
|
||||||
world.toggle "exit" if not unoccupied
|
log "toggle? #{occupied}"
|
||||||
|
world.toggle "exit" if occupied
|
||||||
|
|
||||||
Switch = require '../switch'
|
Switch = require '../switch'
|
||||||
swtch = new Switch
|
swtch = new Switch
|
||||||
|
|
|
@ -488,8 +488,8 @@ class World extends Actor
|
||||||
cell.removeObject object
|
cell.removeObject object
|
||||||
if cell.isEmpty()
|
if cell.isEmpty()
|
||||||
@cells[@posToIndex(pos)] = null
|
@cells[@posToIndex(pos)] = null
|
||||||
else
|
# else
|
||||||
log 'world.unsetObject [WARNING] no cell at pos:', pos
|
# log 'world.unsetObject [WARNING] no cell at pos:', pos
|
||||||
|
|
||||||
newObject: (object) ->
|
newObject: (object) ->
|
||||||
if _.isString object
|
if _.isString object
|
||||||
|
|
Loading…
Reference in New Issue
Block a user