aboutsummaryrefslogtreecommitdiff
path: root/src/level9.moon
blob: aab46b17488f1040b3a181a34ef600b2bed5996e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
layer = require "layers"
game = require "game"
state = require "global"
graph = require "graph"
import Layer from layer
ui = require "ui"

mod = ...

mod.setup_level = () ->
	state.current_level = 9
	--ret = am.group!
	state.move_out_done = false
	state.clear_layers!
	flayer = Layer("fuel","fuel pipe",50,"data/layer_fuel.png")
	elayer = Layer("electric","electric wire",10,"data/layer_electric.png")
	state.add_layer(flayer)
	state.add_layer(elayer)
	state.money = 840
	state.ship("position").x = 800
	state.ship\action(coroutine.create(game.ship_move_in_co))
	state.ship("sprite").source = "data/level_9.png"
	t1 = flayer\mark_square(21,5,"liquid fuel thruster")
	t2 = elayer\mark_square(21,6,"ion thruster")
	t3 = flayer\mark_square(21,7,"liquid fuel thruster")
	t4 = flayer\mark_square(21,8,"liquid fuel thruster")
	t5 = elayer\mark_square(21,9,"ion thruster")
	t6 = flayer\mark_square(21,10,"liquid fuel thruster")

	t7 = flayer\mark_square(13,8,"generator")
	t8 = elayer\mark_square(13,8,"generator")

	p1 = flayer\mark_square(7,7,"liquid fuel tank")

	elayer.node.hidden = true
	state.selected_layer = flayer
	state.update = () ->
		flat_tiles = flayer\flat_tiles!
		flat_tiles2 = elayer\flat_tiles!

		path1 = graph.path(t1,p1,flat_tiles,true,flayer.tiles_adjacent)
		path3 = graph.path(t3,p1,flat_tiles,true,flayer.tiles_adjacent)
		path4 = graph.path(t4,p1,flat_tiles,true,flayer.tiles_adjacent)
		path6 = graph.path(t6,p1,flat_tiles,true,flayer.tiles_adjacent)

		path5 = graph.path(t5,t8,flat_tiles2,true,flayer.tiles_adjacent)
		path2 = graph.path(t2,t8,flat_tiles2,true,flayer.tiles_adjacent)

		path7 = graph.path(t7,p1,flat_tiles,true,flayer.tiles_adjacent)

		if path1 and path2 and path3 and path4 and path5 and path6 and path7
			state.ship\action(coroutine.create(game.ship_move_out_co))

	ui.reload_ui_layers!

mod