This commit is contained in:
monsterkodi 2016-08-31 22:19:39 +02:00
parent 8a3e6e43f9
commit 8ec96ec4f0
55 changed files with 180 additions and 266 deletions

View File

@ -16,7 +16,7 @@ _ = require 'lodash'
class Actor extends Emitter class Actor extends Emitter
constructor: -> constructor: ->
@actions = [] @actions = {}
@events = [] @events = []
super super
@ -49,7 +49,8 @@ class Actor extends Emitter
# 000 000 000 000 000 000 000 000 0000 # 000 000 000 000 000 000 000 000 0000
# 000 000 0000000 000 000 0000000 000 000 # 000 000 0000000 000 000 0000000 000 000
addAction: (action) -> @actions[action.id] = action # addAction: (action) -> @actions[action.id] = action
addAction: (action) -> @actions[action.name] = action
del: -> @deleteActions() del: -> @deleteActions()
@ -57,23 +58,11 @@ class Actor extends Emitter
a?.del() for a in @actions a?.del() for a in @actions
@actions = [] @actions = []
removeAction: (action) -> @actions[action.id] = null # removeAction: (action) -> @actions[action.id] = null
removeAction: (action) -> @actions[action.name] = null
getActionWithId: (actionId) -> _.find @actions, (a) -> a?.id == actionId getActionWithId: (actionId) -> _.find @actions, (a) -> a?.id == actionId
# if @actions[actionId]?.id? and @actions[actionId].id != actionId getActionWithName: (name) -> _.find @actions, (a) -> a?.name == name
# throw new Error
# @actions[actionId]
# if actionId < @actions.length and @actions[actionId].id == actionId
# return @actions[actionId]
#
# # to be deleted...
# log "[WARNING] Actor.getActionWithId #{actionId} [#{@actions.length}]", (a?.id for a in @actions)
# for a in @actions
# return a if a?.id == actionId
getActionWithName: (name) ->
for a in @actions
return a if a?.name == name
initAction: -> initAction: ->
performAction: -> performAction: ->

View File

@ -10,11 +10,8 @@ module.exports =
scheme: "red" scheme: "red"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
use the bombs use the bombs.
""" """
player: player:
coordinates: [4,0,4] coordinates: [4,0,4]

View File

@ -10,16 +10,14 @@ module.exports =
scheme: "red" scheme: "red"
size: [9,9,5] size: [9,9,5]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit, to activate the exit,
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor.
place a wire stone place a wire stone
next to the exit next to the exit.
""" """
player: player:
coordinates: [4,1,0] coordinates: [4,1,0]

View File

@ -10,16 +10,13 @@ module.exports =
scheme: "bronze" scheme: "bronze"
size: [9,6,9] size: [9,6,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit to activate the exit
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor
and close the circuit and close the circuit
with the wire stones" with the wire stones.
""" """
player: player:
coordinates: [4,0,5] coordinates: [4,0,5]

View File

@ -12,11 +12,8 @@ module.exports =
scheme: "default" scheme: "default"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
move the stones move the stones.
""" """
player: player:
coordinates: [2,3,2] coordinates: [2,3,2]

View File

@ -11,9 +11,6 @@ module.exports =
scheme: "yellow" scheme: "yellow"
size: [11,12,7] size: [11,12,7]
help: """ help: """
$scale(1.5)mission:
activate the exit.
to activate the exit, to activate the exit,
activate all switches. activate all switches.
""" """

View File

@ -10,17 +10,14 @@ module.exports =
scheme: "bronze" scheme: "bronze"
size: [5,7,5] size: [5,7,5]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit, to activate the exit,
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor.
place a wire stone place a wire stone
next to the exit next to the exit.
""" """
player: player:
coordinates: [2,1,1] coordinates: [2,1,1]

View File

@ -12,11 +12,8 @@ module.exports =
scheme: "tron" scheme: "tron"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit to activate the exit
feed it with electricity feed it with electricity.
""" """
player: player:
coordinates: [4,5,3] coordinates: [4,5,3]

View File

@ -10,11 +10,8 @@ module.exports =
scheme: "green" scheme: "green"
size: [7,9,7] size: [7,9,7]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
use the stones use the stones.
""" """
player: player:
coordinates: [3,7,0] coordinates: [3,7,0]

View File

@ -11,17 +11,14 @@ module.exports =
scheme: "default" scheme: "default"
size: [11,9,11] size: [11,9,11]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit to activate the exit
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor.
and place a powered wirestone and place a powered wirestone
next to the exit next to the exit.
""" """
player: player:
coordinates: [6,2,0] coordinates: [6,2,0]

View File

@ -10,7 +10,7 @@ module.exports =
design: "Michael Abel" design: "Michael Abel"
scheme: "candy" scheme: "candy"
size: [7,7,7] size: [7,7,7]
help: "$scale(1.5)mission:\nget to the exit!" help: "get to the exit!"
player: player:
coordinates: [3,0,5] coordinates: [3,0,5]
orientation: ZupY orientation: ZupY

View File

@ -10,14 +10,11 @@ module.exports =
scheme: "metal" scheme: "metal"
size: [9,7,9] size: [9,7,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit to activate the exit
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor.
""" """
player: player:
coordinates: [2,3,5] coordinates: [2,3,5]

View File

@ -10,19 +10,12 @@ module.exports =
scheme: "bronze" scheme: "bronze"
size: [9,5,7] size: [9,5,7]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit,
feed it with electricity
use the bombs use the bombs
to elevate the gears to elevate the gears
and the generator.
and the generator
the bombs will detonate the bombs will detonate
if you shoot them if you shoot them.
""" """
player: player:
coordinates: [8,0,3] coordinates: [8,0,3]

View File

@ -10,11 +10,8 @@ module.exports =
scheme: "default" scheme: "default"
size: [9,17,9] size: [9,17,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit, to activate the exit,
shoot the 4 switches shoot the 4 switches.
""" """
player: player:
coordinates: [4,4,5] coordinates: [4,4,5]

View File

@ -12,10 +12,8 @@ module.exports =
scheme: "green" scheme: "green"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission: use the stones
get to the exit! to reach the exit.
use the stones to reach it
""" """
player: player:
coordinates: [4,3,2] coordinates: [4,3,2]

View File

@ -10,18 +10,12 @@ module.exports =
scheme: "metal" scheme: "metal"
size: [7,9,7] size: [7,9,7]
help: """ help: """
$scale(1.5)mission:
try to escape!
to escape,
activate the exit
to activate the exit, to activate the exit,
shoot the switch shoot the switch.
to be able to to be able to
shoot the switch, shoot the switch,
move the stones move the stones.
""" """
player: player:
coordinates: [3,0,4] coordinates: [3,0,4]

View File

@ -7,22 +7,18 @@
module.exports = module.exports =
name: "evil" name: "evil"
design: "Michael Abel?" design: "Michael Abel"
scheme: "red" scheme: "red"
size: [13,5,13] size: [13,5,13]
help: """ help: """
$scale(1.5)mission: place a powered wire stone
activate the exit! next to the exit.
place a powered
wire stone next to it.
a wirestone is powered by a wirestone is powered by
a rotating generator a rotating generator
or it shares at least or it shares at least
one edge with one edge with
another powered wirestone. another powered wirestone.
this one is hard, this one is hard,
really hard,
but it's possible. but it's possible.
good luck! good luck!

View File

@ -11,16 +11,10 @@ module.exports =
scheme: "blue" scheme: "blue"
size: [13,15,13] size: [13,15,13]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
jump and fall off the stones jump and fall off the stones.
try to jump so that you try to jump so that you
land on other stones land on other stones.
if you fall, there is a stone
on ground to help get back on
you have to fall of this stone, as well
""" """
player: player:
coordinates: [0,6,2] coordinates: [0,6,2]

View File

@ -6,11 +6,8 @@ module.exports =
scheme: "metal" scheme: "metal"
size: [7,7,11] size: [7,7,11]
help: """ help: """
$scale(1.5)mission:
get to the exit!
the green stone is slicky the green stone is slicky
you can't grab it while falling you can't grab it while falling.
""" """
player: player:
coordinates: [3,0,7] coordinates: [3,0,7]

View File

@ -13,10 +13,8 @@ module.exports =
scheme: "tron" scheme: "tron"
size: [10,10,10] size: [10,10,10]
help: """ help: """
$scale(1.5)mission: shoot at the 4 switches
activate the exit! to activate the exit.
shoot at the 4 switches to activate the exit
""" """
player: player:
coordinates: [5,5,4] coordinates: [5,5,4]

View File

@ -3,16 +3,13 @@ module.exports =
scheme: "blue" scheme: "blue"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit to activate the exit
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor
and close the circuit and close the circuit
with the wire stones with the wire stones.
""" """
player: player:
position: [0,0,0] position: [0,0,0]

View File

@ -10,10 +10,8 @@ module.exports =
scheme: "yellow" scheme: "yellow"
size: [3,11,3] size: [3,11,3]
help: """ help: """
$scale(1.5)mission: move the stones
get to the exit! to reach the exit.
move the stones to reach it
""" """
player: player:
coordinates: [1,1,0] coordinates: [1,1,0]

View File

@ -11,8 +11,6 @@ module.exports =
scheme: "blue" scheme: "blue"
size: [11,11,11] size: [11,11,11]
help: """ help: """
$scale(1.5)mission:activate the exit!
to shoot, press $key(shoot) to shoot, press $key(shoot)
""" """
player: player:

View File

@ -3,16 +3,17 @@ module.exports =
scheme: "green" scheme: "green"
size: [13,5,13] size: [13,5,13]
help: """ help: """
$scale(1.5)mission:
activate the exit!
place a powered place a powered
wire stone next to it. wire stone next to the exit.
a wirestone is powered by a wirestone is powered by
a rotating generator a rotating generator
or it shares at least one edge with or it shares at least one edge with
another powered wirestone. another powered wirestone.
this one is hard, really hard, but it's possible.
this one is hard,
but it's possible.
good luck! good luck!
""" """
player: position: [1,1,1] player: position: [1,1,1]

View File

@ -3,10 +3,8 @@ module.exports =
scheme: "crazy" scheme: "crazy"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
use the stones use the stones.
""" """
player: player:
coordinates: [3,4,8] coordinates: [3,4,8]

View File

@ -10,14 +10,11 @@ module.exports =
scheme: "metal" scheme: "metal"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit, to activate the exit,
activate the 5 switches activate the 5 switches.
use the stones to use the stones to
reach the exit reach the exit.
""" """
player: player:
coordinates: [4,8,2] coordinates: [4,8,2]

View File

@ -10,13 +10,14 @@ module.exports =
scheme: "red" scheme: "red"
size: [7,7,13] size: [7,7,13]
help: """ help: """
$scale(1.5)mission: jump on the stones
get to the exit! to reach the exit.
jump on the stones to reach it you can attach
to a stone
you can attach to a stone when falling when falling
if you move into its direction if you move
into its direction.
""" """
player: player:
coordinates: [3,6,4] coordinates: [3,6,4]

View File

@ -2,7 +2,7 @@ module.exports =
name: "love" name: "love"
scheme: "red" scheme: "red"
size: [13,13,13] size: [13,13,13]
help: "$scale(1.5)mission:\nget to the exit!" help: "get to the exit!"
player: player:
coordinates: [6,4,2] coordinates: [6,4,2]
orientation: minusZupY orientation: minusZupY

View File

@ -10,7 +10,7 @@ module.exports =
deisgn: 'Michael Abel' deisgn: 'Michael Abel'
scheme: "tron" scheme: "tron"
size: [5,5,9] size: [5,5,9]
help: "$scale(1.5)mission:\nactivate the exit!" help: "activate the exit!"
player: player:
coordinates: [1,2,2] coordinates: [1,2,2]
orientation: minusZupX orientation: minusZupX

View File

@ -13,7 +13,6 @@ module.exports =
size: [4,4,4] size: [4,4,4]
camera: 'inside' camera: 'inside'
help: """ help: """
$scale(1.5)mission:
get to the exit! get to the exit!
but don't get confused :) but don't get confused :)
""" """

View File

@ -10,7 +10,7 @@ module.exports =
design: 'Michael Abel' design: 'Michael Abel'
scheme: "default" scheme: "default"
size: [11,11,11] size: [11,11,11]
help: "$scale(1.5)mission:\nget to the exit!" help: "get to the exit!"
player: player:
coordinates: [6,10,5] coordinates: [6,10,5]
orientation: YdownZ orientation: YdownZ

View File

@ -10,7 +10,7 @@ module.exports =
design: 'Michael Abel' design: 'Michael Abel'
scheme: "tron" scheme: "tron"
size: [5,5,7] size: [5,5,7]
help: "$scale(1.5)mission:\nget to the exit!" help: "get to the exit!"
player: player:
coordinates: [2,1,0] coordinates: [2,1,0]
orientation: minusYupZ orientation: minusYupZ

View File

@ -10,12 +10,11 @@ module.exports =
scheme: "red" scheme: "red"
size: [7,7,7] size: [7,7,7]
help: """ help: """
$scale(1.5)mission: activate the exit! shoot the switch
to activate the exit, activate the switch to activate the exit.
to activate the switch,shoot it
to be able to shoot the switch, move the stones "shift+w" to move the stone.
to move a stone, press "$key(push)" while moving "return" to shoot.
to shoot, press "$key(shoot)"
""" """
player: player:
coordinates: [3,3,2] coordinates: [3,3,2]

View File

@ -3,15 +3,14 @@ module.exports =
scheme: "blue" scheme: "blue"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
deactivate the mutants! deactivate the mutants!
to deactivate a mutant, to deactivate a mutant,
shoot him until it get's transparent shoot him until it get's transparent.
the exit will open, the exit will open,
when all mutant bots when all mutant bots
are deactivated are deactivated.
""" """
player: player:
coordinates: [7,1,8] coordinates: [7,1,8]

View File

@ -11,7 +11,6 @@ module.exports =
scheme: "tron" scheme: "tron"
size: [11,11,11] size: [11,11,11]
help: """ help: """
$scale(1.5)mission:
get to the exit! get to the exit!
it looks simpler than it is. it looks simpler than it is.

View File

@ -11,7 +11,7 @@ module.exports =
design: 'Michael Abel' design: 'Michael Abel'
scheme: "tron" scheme: "tron"
size: [11,11,11] size: [11,11,11]
help: "$scale(1.5)mission:\nget to the exit!" help: "get to the exit!"
player: player:
coordinates: [7,4,0] coordinates: [7,4,0]
orientation: minusZdownY orientation: minusZdownY

View File

@ -10,7 +10,7 @@ module.exports =
design: 'Michael Abel' design: 'Michael Abel'
scheme: "green" scheme: "green"
size: [11,11,11] size: [11,11,11]
help: "$scale(1.5)mission:\nget to the exit!" help: "get to the exit!"
player: player:
coordinates: [5,9,6] coordinates: [5,9,6]
orientation: ZdownY orientation: ZdownY

View File

@ -11,10 +11,9 @@ module.exports =
scheme: "default" scheme: "default"
size: [21,21,21] size: [21,21,21]
help: """ help: """
$scale(1.5)mission:
get to the exit! get to the exit!
jump and try jump and try.
""" """
player: player:
coordinates: [0,10,1] coordinates: [0,10,1]

View File

@ -9,7 +9,7 @@ module.exports =
name: "regal" name: "regal"
scheme: "bronze" scheme: "bronze"
size: [7,3,9] size: [7,3,9]
help: "$scale(1.5)mission:\nactivate the exit!" help: "activate the exit!"
player: player:
coordinates: [3,2,4] coordinates: [3,2,4]
orientation: XdownY orientation: XdownY

View File

@ -10,10 +10,8 @@ module.exports =
scheme: "default" scheme: "default"
size: [9,7,9] size: [9,7,9]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
use the stones use the stones.
""" """
player: player:
coordinates: [4,4,2] coordinates: [4,4,2]

View File

@ -11,10 +11,9 @@ module.exports =
scheme: "bronze" scheme: "bronze"
size: [9,9,6] size: [9,9,6]
help: """ help: """
$scale(1.5)mission:
activate the exit! activate the exit!
All you have to do all you have to do
is to put nine stones is to put nine stones
into the sandbox into the sandbox
and shoot at the switch and shoot at the switch

View File

@ -12,10 +12,8 @@ module.exports =
scheme: "tron" scheme: "tron"
size: [9,11,15] size: [9,11,15]
help: """ help: """
$scale(1.5)mission: the green stone is slicky
get to the exit! you can't grab it while falling.
The green stone is slicky
you can't grab it while falling
""" """
player: player:
coordinates: [0,10,13] coordinates: [0,10,13]

View File

@ -10,15 +10,12 @@ module.exports =
scheme: "default" scheme: "default"
size: [7,5,11] size: [7,5,11]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
jump on the stone jump on the stones.
to jump,
press "$key(jump)" while moving "w" or "d" to move.
to move, press "$key(move forward)" or "$key(move backward)" "a" or "s" to turn.
to turn, press "$key(turn left)" or "$key(turn right)" "space" to jump.
""" """
player: player:
coordinates: [1,0,4] coordinates: [1,0,4]

View File

@ -7,17 +7,13 @@
module.exports = module.exports =
name: "steps" name: "steps"
# scheme: "blue"
size: [7,7,13] size: [7,7,13]
help: """ help: """
$scale(1.5)mission:
get to the exit!
to get to the exit, to get to the exit,
jump on the stones jump on the stones.
to jump, press "$key(jump)" while moving
to move, press "$key(move forward)" or "$key(move backward)", "w" to move forward.
to turn, press "$key(turn left)" or "$key(turn right)" "space" to jump.
""" """
player: player:
coordinates: [3,0,1] coordinates: [3,0,1]

View File

@ -3,13 +3,9 @@ module.exports =
scheme: "blue" scheme: "blue"
size: [11,11,12] size: [11,11,12]
help: """ help: """
$scale(1.5)mission:
get to the exit!
use the stones. use the stones.
to move a stone, to move a stone,
press "$key(push)" press "shift+w"
while moving
""" """
player: player:
coordinates: [4,5,3] coordinates: [4,5,3]

View File

@ -11,17 +11,14 @@ module.exports =
scheme: "default" scheme: "default"
size: [9,9,9] size: [9,9,9]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit, to activate the exit,
feed it with electricity: feed it with electricity:
connect the generator connect the generator
with the motor with the motor.
place a wire stone place a wire stone
next to the exit next to the exit.
""" """
player: player:
coordinates: [5,4,6] coordinates: [5,4,6]

View File

@ -10,9 +10,6 @@ module.exports =
scheme: "tron" scheme: "tron"
size: [7,7,7] size: [7,7,7]
help: """ help: """
$scale(1.5)mission:
activate the exit!
to activate the exit, to activate the exit,
activate the 4 switches. activate the 4 switches.
""" """

View File

@ -12,13 +12,11 @@ module.exports =
scheme: "tron" scheme: "tron"
size: [5,7,7] size: [5,7,7]
help: """ help: """
"$scale(1.5)mission: use the stones
get to the exit! to reach the exit.
use the stones to reach it
push a stone and it will fall down push a stone and it will fall down
if nothing is below it if nothing is below it.
but remember: but remember:
you decide where down and below is! you decide where down and below is!
""" """

View File

@ -10,7 +10,7 @@ module.exports =
design: 'Ben "mrthoughtful" Griffin' design: 'Ben "mrthoughtful" Griffin'
scheme: "metal" scheme: "metal"
size: [9,9,15] size: [9,9,15]
help: "$scale(1.5)mission:\nget to the exit!\n\nto get to the exit,\nmove the stones" help: "to get to the exit,\nmove the stones."
player: player:
coordinates: [4,5,3] coordinates: [4,5,3]
orientation: ZdownX orientation: ZdownX

View File

@ -11,13 +11,11 @@ module.exports =
scheme: "red" scheme: "red"
size: [7,5,5] size: [7,5,5]
help: """ help: """
$scale(1.5)mission:
get to the exit! get to the exit!
The exit is hidden The exit is hidden
in the middle of in the middle of
the central wall the central wall.
""" """
player: player:
coordinates: [0,4,2] coordinates: [0,4,2]

View File

@ -35,7 +35,11 @@ module.exports =
text: new THREE.MeshPhongMaterial text: new THREE.MeshPhongMaterial
side: THREE.FrontSide side: THREE.FrontSide
shading: THREE.SmoothShading shading: THREE.SmoothShading
specular: 0xffff00 transparent: true
menu: new THREE.MeshPhongMaterial
side: THREE.FrontSide
shading: THREE.SmoothShading
transparent: true transparent: true
mutant: new THREE.MeshPhongMaterial mutant: new THREE.MeshPhongMaterial

View File

@ -6,22 +6,61 @@
# 000 000 00000000 000 000 0000000 # 000 000 00000000 000 000 0000000
ScreenText = require './screentext' ScreenText = require './screentext'
Action = require './action'
Material = require './material'
class Menu extends ScreenText class Menu extends ScreenText
constructor: -> constructor: ->
@current = 0
@callbacks = []
@lineHeight = 1.1
super super
@getActionWithId(Action.SHOW).duration = 250
@getActionWithId(Action.HIDE).duration = 200
del: -> del: ->
world.menu = null world.menu = null
super super
addItem: (text, cb) -> addItem: (text, cb) ->
@callbacks.push cb
@addText text @addText text
show: ->
world.playSound 'MENU_FADE'
@setCurrent @current
super
setCurrent: (current) ->
@current = (@mesh.children.length + current) % @mesh.children.length
for ci in [0...@mesh.children.length]
m = ci == @current and Material.menu or Material.text
o = @mesh.children[ci].material.opacity
@mesh.children[ci].material = m.clone()
@mesh.children[ci].material.opacity = o
z = ci == @current and 4 or 0
@mesh.children[ci].position.set @mesh.children[ci].position.x, @mesh.children[ci].position.y, z
next: ->
world.playSound 'MENU_ITEM'
@setCurrent @current + 1
prev: ->
world.playSound 'MENU_ITEM'
@setCurrent @current - 1
modKeyComboEvent: (mod, key, combo, event) -> modKeyComboEvent: (mod, key, combo, event) ->
switch key switch key
when 'esc' when 'esc'
world.playSound 'MENU_ABORT'
@fadeOut()
when 'down', 'right', 's', 'd'
@next()
when 'left', 'up', 'w', 'a'
@prev()
when 'enter'
world.playSound 'MENU_SELECT'
@callbacks[@current]()
@fadeOut() @fadeOut()
module.exports = Menu module.exports = Menu

View File

@ -21,15 +21,14 @@ class ScreenText extends Actor
constructor: (text) -> constructor: (text) ->
super super
@addAction new Action @, Action.SHOW, "show#{@constructor.name}", 500
@addAction new Action @, Action.SHOW, "show", 500 @addAction new Action @, Action.HIDE, "hide#{@constructor.name}", 500
@addAction new Action @, Action.HIDE, "hide", 500
@scene = new THREE.Scene() @scene = new THREE.Scene()
@lineHeight = 1.3 if not @lineHeight?
sun = new THREE.PointLight 0xffffff @sun = new THREE.PointLight 0xffffff
sun.position.set -1,1,10 @sun.position.set -1,1,10
@scene.add sun @scene.add @sun
@width = @height = 0 @width = @height = 0
@mesh = new THREE.Object3D @mesh = new THREE.Object3D
@ -40,13 +39,15 @@ class ScreenText extends Actor
@far = 100 @far = 100
@camera = new THREE.PerspectiveCamera @fov, @aspect, @near, @far @camera = new THREE.PerspectiveCamera @fov, @aspect, @near, @far
if text? if text?
@addText text for l in text.split '\n'
@addText l
@show() @show()
del: -> del: ->
@scene.remove @mesh @scene.remove @mesh
@scene.remove @sun
Timer.removeActionsOfObject @ Timer.removeActionsOfObject @
world.text = null world.text = null if world.text == @
show: -> @startTimedAction @getActionWithId Action.SHOW show: -> @startTimedAction @getActionWithId Action.SHOW
@ -54,7 +55,7 @@ class ScreenText extends Actor
geom = new THREE.TextGeometry str, geom = new THREE.TextGeometry str,
font: ScreenText.font font: ScreenText.font
size: 1 size: 1
height: 0.5 height: 4
bevelEnabled: true bevelEnabled: true
bevelThickness: 0.1 bevelThickness: 0.1
bevelSize: 0.04 bevelSize: 0.04
@ -63,17 +64,23 @@ class ScreenText extends Actor
geom.computeBoundingBox() geom.computeBoundingBox()
min = geom.boundingBox.min min = geom.boundingBox.min
max = geom.boundingBox.max max = geom.boundingBox.max
mesh = new THREE.Mesh geom, Material.text mesh = new THREE.Mesh geom, Material.text.clone()
mesh.translateX -(max.x-min.x)/2 mesh.translateX -(max.x-min.x)/2
mesh.translateY -@height mesh.translateY -@height * @lineHeight
@mesh.add mesh @mesh.add mesh
@mesh.position.set 0, @height/2*0.9, 0 @mesh.position.set 0, @height/2*@lineHeight, 0
# adjust projection # adjust projection
@camera.position.copy new Vector 0,0,12+5*@height z = 20+4*@height
@camera.position.copy new Vector 0,0,z
@sun.position.set -z/5,z/5,z
@camera.lookAt new Vector 0,0,0 @camera.lookAt new Vector 0,0,0
@height += 1 @height += 1
setOpacity: (o) ->
for c in @mesh.children
c.material.opacity = o
resized: (w,h) -> resized: (w,h) ->
@aspect = w/h @aspect = w/h
@camera.aspect = @aspect @camera.aspect = @aspect
@ -82,16 +89,16 @@ class ScreenText extends Actor
performAction: (action) -> performAction: (action) ->
switch action.id switch action.id
when Action.SHOW when Action.SHOW
Material.text.opacity = action.getRelativeTime() @setOpacity action.getRelativeTime()
when Action.HIDE when Action.HIDE
Material.text.opacity = 1 - action.getRelativeTime() @setOpacity 1 - action.getRelativeTime()
actionFinished: (action) -> actionFinished: (action) ->
switch action.id switch action.id
when Action.HIDE when Action.HIDE
@del() @del()
when Action.SHOW when Action.SHOW
Material.text.opacity = 1 @setOpacity 1
fadeOut: -> fadeOut: ->
return if @fadingOut return if @fadingOut

View File

@ -29,9 +29,8 @@ class Sound
SWITCH_OFF: file: "switch_on.wav", volume: 0.5 SWITCH_OFF: file: "switch_on.wav", volume: 0.5
ATOM_BIRTH: file: "atom_digest.wav", volume: 1.0 ATOM_BIRTH: file: "atom_digest.wav", volume: 1.0
ATOM_DIGEST: file: "atom_digest.wav", volume: 1.0 ATOM_DIGEST: file: "atom_digest.wav", volume: 1.0
SPIKES_START: file: "bot_move.wav", volume: 1.0 MENU_FADE: file: "stone_land.wav", volume: 1.0
MENU_FADE: file: "menu_fade.wav", volume: 1.0 MENU_ITEM: file: "menu_item.wav", volume: 0.5
MENU_ITEM: file: "menu_item.wav", volume: 1.0
MENU_SELECT: file: "menu_select.wav", volume: 1.0 MENU_SELECT: file: "menu_select.wav", volume: 1.0
MENU_ABORT: file: "menu_abort.wav", volume: 1.0 MENU_ABORT: file: "menu_abort.wav", volume: 1.0
GATE_OPEN: file: "gate_open.wav", volume: 1.0 GATE_OPEN: file: "gate_open.wav", volume: 1.0

View File

@ -257,7 +257,7 @@ class World extends Actor
@creating = false @creating = false
restart: () -> @create @dict restart: => @create @dict
finish: () -> # TODO: save progress finish: () -> # TODO: save progress
@ -290,6 +290,8 @@ class World extends Actor
colors.plate.emissive ?= colors.plate.color colors.plate.emissive ?= colors.plate.color
colors.bulb.emissive ?= colors.bulb.color colors.bulb.emissive ?= colors.bulb.color
colors.menu ?= {}
colors.menu.color ?= colors.gear.color
colors.raster ?= {} colors.raster ?= {}
colors.raster.color ?= colors.plate.color colors.raster.color ?= colors.plate.color
colors.wall ?= {} colors.wall ?= {}
@ -778,38 +780,15 @@ class World extends Actor
false false
reinit: () ->
for o in @objects
if o instanceof Light
o.initialize()
# Text::reinit()
# 000 000 00000000 000 00000000 # 000 000 00000000 000 00000000
# 000 000 000 000 000 000 # 000 000 000 000 000 000
# 000000000 0000000 000 00000000 # 000000000 0000000 000 00000000
# 000 000 000 000 000 # 000 000 000 000 000
# 000 000 00000000 0000000 000 # 000 000 00000000 0000000 000
help: (index=0) -> showHelp: =>
# displays help messages # @menu.del()
@text = new ScreenText @dict['help']
# text_list = @dict["help"]
# more_text = index < len (text_list) - 1
# less_text = index > 0
#
# list = text_list[index].split("$key(")
# for i in range (1, len(list))
# close = list[i].find(")")
# list[i] = Controller.player.getKeyForAction (list[i][:close]) + list[i][close+1:]
#
# list.append ("\n\n$scale(0.5)(%d/%d)" % (index+1, len (text_list)))
# help_text = KikiPageText ("".join(list), more_text, less_text)
#
# if more_text:
# help_text.getEventWithName ("next").addAction (once (lambda i=index+1: @help (i)))
# if less_text:
# help_text.getEventWithName ("previous").addAction (once (lambda i=index-1: @help (i)))
outro: (index=0) -> outro: (index=0) ->
# well hidden outro :-) # well hidden outro :-)
@ -841,22 +820,22 @@ class World extends Actor
resetProjection: -> @player.camera.setViewport 0.0, 0.0, 1.0, 1.0 resetProjection: -> @player.camera.setViewport 0.0, 0.0, 1.0, 1.0
# 00 00 00000000 000 000 000 000
# 000 000 000 0000 000 000 000 # 000 000 000 0000 000 000 000
# 000 000 000 # 000000000 0000000 000 0 000 000 000
# 0000000 0000000 000 # 000 0 000 000 000 0000 000 000
# 000 000 000 # 000 000 00000000 000 000 0000000
# 00000000 0000000 0000000
localizedString: (str) -> str localizedString: (str) -> str
escape: (self) -> # handles an ESC key event showMenu: (self) -> # handles an ESC key event
@text?.del() # @text?.del()
@menu = new Menu() @menu = new Menu()
@menu.addItem @localizedString("help"), @help @menu.addItem @localizedString("help"), @showHelp
@menu.addItem @localizedString("restart"), @restart @menu.addItem @localizedString("restart"), @restart
@menu.addItem @localizedString("load level"), @levelSelection @menu.addItem @localizedString("load level"), @showLevels
@menu.addItem @localizedString("setup"), @quickSetup @menu.addItem @localizedString("setup"), @showSetup
@menu.addItem @localizedString("about"), @displayAbout @menu.addItem @localizedString("about"), @showAbout
@menu.addItem @localizedString("quit"), @quit @menu.addItem @localizedString("quit"), @quit
@menu.show() @menu.show()
@ -913,7 +892,7 @@ class World extends Actor
@text?.fadeOut() @text?.fadeOut()
return if @player?.modKeyComboEventDown mod, key, combo, event return if @player?.modKeyComboEventDown mod, key, combo, event
switch combo switch combo
when 'esc' then @escape() when 'esc' then @showMenu()
when '=' then @speed = Math.min 10, @speed+1 when '=' then @speed = Math.min 10, @speed+1
when '-' then @speed = Math.max 1, @speed-1 when '-' then @speed = Math.max 1, @speed-1
when 'r' then @restart() when 'r' then @restart()