This commit is contained in:
monsterkodi 2016-08-30 21:01:02 +02:00
parent a92788c788
commit 8da4ab64a8
5 changed files with 19 additions and 18 deletions

View File

@ -419,8 +419,8 @@ class Bot extends Pushable
else
@dir_sgn = 1
@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}' orientation:", @orientation.rounded().name if action.id in [Action.TURN_LEFT, Action.TURN_RIGHT, Action.CLIMB_UP]
# 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]
if world.getRealOccupantAtPos(@position.plus @getDown())?.isMutant?()
# keep action chain flowinwg in order to detect environment changes

View File

@ -13,7 +13,7 @@ class Bullet extends Item
constructor: () ->
@size = 0.2
@src_object = null
@shooter = null
super
@addAction new Action @, Action.FLY, "fly", 40
@addAction new Action @, Action.EXPLODE, "explode", 200
@ -21,8 +21,8 @@ class Bullet extends Item
del: ->
if @mesh?
world.scene.remove @mesh
_.pull world.objects, @
Timer.removeActionsOfObject @
_.pull world.objects, @
@mesh = null
createMesh: ->
@ -35,7 +35,7 @@ class Bullet extends Item
world.addObject bullet
bullet.direction = bot.currentDir()
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
world.playSound 'BULLET_SHOT', bot.getPos()
@ -49,7 +49,7 @@ class Bullet extends Item
@current_position = @position.plus @direction.mul relTime
else if action.id == Action.EXPLODE
@size = 0.2 + relTime/2.0
@mesh.material.opacity = 0.8 * (1.0-relTime)
@mesh?.material.opacity = 0.8 * (1.0-relTime)
step: (step) ->
@mesh.position.copy @current_position
@ -61,7 +61,7 @@ class Bullet extends Item
if world.isInvalidPos(pos) or world.isOccupiedPos pos
hitObject = world.getRealOccupantAtPos pos
if hitObject != @src_object
if hitObject != @shooter
if hitObject?
hitObject.bulletImpact()
world.playSound hitObject.bulletHitSound?() ? 'BULLET_HIT_OBJECT'

View File

@ -79,13 +79,13 @@ module.exports =
Switch = require '../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.getEventWithName("switched").addAction world.continuous (sw=switch2) -> switched sw
switch2.getEventWithName("switched").addAction world.continuous -> switched switch2
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.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 switch2, world.decenter s.x/2, 4, 0

View File

@ -30,13 +30,14 @@ module.exports =
create: ->
switched = ->
unoccupied = false
occupied = true
for i in [3...6]
for j in [3...6]
if world.isUnoccupiedPos i,j,0
unoccupied=true
world.toggle "exit" if not unoccupied
if world.isUnoccupiedPos [i,j,0]
log "isUnoccupiedPos #{i} #{j}"
occupied = false
log "toggle? #{occupied}"
world.toggle "exit" if occupied
Switch = require '../switch'
swtch = new Switch

View File

@ -488,8 +488,8 @@ class World extends Actor
cell.removeObject object
if cell.isEmpty()
@cells[@posToIndex(pos)] = null
else
log 'world.unsetObject [WARNING] no cell at pos:', pos
# else
# log 'world.unsetObject [WARNING] no cell at pos:', pos
newObject: (object) ->
if _.isString object