|
@ -25,6 +25,7 @@ TOWER_SPECS = { |
|
|
cost = 10, |
|
|
cost = 10, |
|
|
range = 0, |
|
|
range = 0, |
|
|
fire_rate = 2, |
|
|
fire_rate = 2, |
|
|
|
|
|
size = 0, |
|
|
}, |
|
|
}, |
|
|
[TOWER_TYPE.HOWITZER] = { |
|
|
[TOWER_TYPE.HOWITZER] = { |
|
|
name = "Howitzer", |
|
|
name = "Howitzer", |
|
@ -35,6 +36,7 @@ TOWER_SPECS = { |
|
|
cost = 20, |
|
|
cost = 20, |
|
|
range = 10, |
|
|
range = 10, |
|
|
fire_rate = 4, |
|
|
fire_rate = 4, |
|
|
|
|
|
size = 1, |
|
|
}, |
|
|
}, |
|
|
[TOWER_TYPE.REDEYE] = { |
|
|
[TOWER_TYPE.REDEYE] = { |
|
|
name = "Redeye", |
|
|
name = "Redeye", |
|
@ -45,6 +47,7 @@ TOWER_SPECS = { |
|
|
cost = 20, |
|
|
cost = 20, |
|
|
range = 12, |
|
|
range = 12, |
|
|
fire_rate = 1, |
|
|
fire_rate = 1, |
|
|
|
|
|
size = 1, |
|
|
}, |
|
|
}, |
|
|
[TOWER_TYPE.MOAT] = { |
|
|
[TOWER_TYPE.MOAT] = { |
|
|
name = "Moat", |
|
|
name = "Moat", |
|
@ -55,6 +58,7 @@ TOWER_SPECS = { |
|
|
cost = 10, |
|
|
cost = 10, |
|
|
range = 0, |
|
|
range = 0, |
|
|
fire_rate = 2, |
|
|
fire_rate = 2, |
|
|
|
|
|
size = 0, |
|
|
}, |
|
|
}, |
|
|
[TOWER_TYPE.RADAR] = { |
|
|
[TOWER_TYPE.RADAR] = { |
|
|
name = "Radar", |
|
|
name = "Radar", |
|
@ -65,6 +69,7 @@ TOWER_SPECS = { |
|
|
cost = 20, |
|
|
cost = 20, |
|
|
range = 0, |
|
|
range = 0, |
|
|
fire_rate = 1, |
|
|
fire_rate = 1, |
|
|
|
|
|
size = 1, |
|
|
}, |
|
|
}, |
|
|
[TOWER_TYPE.LIGHTHOUSE] = { |
|
|
[TOWER_TYPE.LIGHTHOUSE] = { |
|
|
name = "Lighthouse", |
|
|
name = "Lighthouse", |
|
@ -75,6 +80,7 @@ TOWER_SPECS = { |
|
|
cost = 20, |
|
|
cost = 20, |
|
|
range = 8, |
|
|
range = 8, |
|
|
fire_rate = 1, |
|
|
fire_rate = 1, |
|
|
|
|
|
size = 1, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -105,43 +111,14 @@ end |
|
|
function get_tower_fire_rate(tower_type) |
|
|
function get_tower_fire_rate(tower_type) |
|
|
return TOWER_SPECS[tower_type].fire_rate |
|
|
return TOWER_SPECS[tower_type].fire_rate |
|
|
end |
|
|
end |
|
|
|
|
|
function get_tower_size(tower_type) |
|
|
|
|
|
return TOWER_SPECS[tower_type.size] |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
local function make_tower_sprite(tower_type) |
|
|
local function make_tower_sprite(tower_type) |
|
|
return pack_texture_into_sprite(get_tower_texture(tower_type), HEX_PIXEL_WIDTH, HEX_PIXEL_HEIGHT) |
|
|
return pack_texture_into_sprite(get_tower_texture(tower_type), HEX_PIXEL_WIDTH, HEX_PIXEL_HEIGHT) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
do |
|
|
|
|
|
local tower_cursors = {} |
|
|
|
|
|
for _,i in pairs(TOWER_TYPE) do |
|
|
|
|
|
local tower_sprite = make_tower_sprite(i) |
|
|
|
|
|
tower_sprite.color = COLORS.TRANSPARENT |
|
|
|
|
|
|
|
|
|
|
|
local coroutine_ = coroutine.create(function(node) |
|
|
|
|
|
local flash_on = {} |
|
|
|
|
|
local flash_off = {} |
|
|
|
|
|
while true do |
|
|
|
|
|
for _,n in node:child_pairs() do |
|
|
|
|
|
table.insert(flash_on, am.tween(n, 1, { color = vec4(0.4) })) |
|
|
|
|
|
table.insert(flash_off, am.tween(n, 1, { color = vec4(0) })) |
|
|
|
|
|
end |
|
|
|
|
|
am.wait(am.parallel(flash_on)) |
|
|
|
|
|
am.wait(am.parallel(flash_off)) |
|
|
|
|
|
flash_on = {} |
|
|
|
|
|
flash_off = {} |
|
|
|
|
|
end |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
tower_cursors[i] = am.group{ |
|
|
|
|
|
make_hex_cursor(get_tower_range(i), vec4(0), coroutine_), |
|
|
|
|
|
tower_sprite |
|
|
|
|
|
} |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function get_tower_cursor(tower_type) |
|
|
|
|
|
return tower_cursors[tower_type] |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function make_tower_node(tower_type) |
|
|
local function make_tower_node(tower_type) |
|
|
if tower_type == TOWER_TYPE.REDEYE then |
|
|
if tower_type == TOWER_TYPE.REDEYE then |
|
|
return make_tower_sprite(tower_type) |
|
|
return make_tower_sprite(tower_type) |
|
@ -188,6 +165,38 @@ local function make_tower_node(tower_type) |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
do |
|
|
|
|
|
local tower_cursors = {} |
|
|
|
|
|
for _,i in pairs(TOWER_TYPE) do |
|
|
|
|
|
local tower_sprite = make_tower_sprite(i) |
|
|
|
|
|
tower_sprite.color = COLORS.TRANSPARENT |
|
|
|
|
|
|
|
|
|
|
|
local coroutine_ = coroutine.create(function(node) |
|
|
|
|
|
local flash_on = {} |
|
|
|
|
|
local flash_off = {} |
|
|
|
|
|
while true do |
|
|
|
|
|
for _,n in node:child_pairs() do |
|
|
|
|
|
table.insert(flash_on, am.tween(n, 1, { color = vec4(0.4) })) |
|
|
|
|
|
table.insert(flash_off, am.tween(n, 1, { color = vec4(0) })) |
|
|
|
|
|
end |
|
|
|
|
|
am.wait(am.parallel(flash_on)) |
|
|
|
|
|
am.wait(am.parallel(flash_off)) |
|
|
|
|
|
flash_on = {} |
|
|
|
|
|
flash_off = {} |
|
|
|
|
|
end |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
tower_cursors[i] = am.group{ |
|
|
|
|
|
make_hex_cursor(get_tower_range(i), vec4(0), coroutine_), |
|
|
|
|
|
tower_sprite |
|
|
|
|
|
} |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function get_tower_cursor(tower_type) |
|
|
|
|
|
return tower_cursors[tower_type] |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
local function get_tower_update_function(tower_type) |
|
|
local function get_tower_update_function(tower_type) |
|
|
if tower_type == TOWER_TYPE.REDEYE then |
|
|
if tower_type == TOWER_TYPE.REDEYE then |
|
|
return update_tower_redeye |
|
|
return update_tower_redeye |
|
|