Nicholas Hayashi 4 years ago
parent
commit
0cc62960ad
  1. 36
      src/game.lua
  2. 8
      src/mob.lua
  3. 32
      src/tower.lua

36
src/game.lua

@ -84,23 +84,15 @@ local function get_top_right_display_text(hex, evenq, centered_evenq, display_ty
end
-- initialized later, as part of the init of the toolbelt
function select_tower_type(tower_type) end
function select_toolbelt_button(i)
state.selected_toolbelt_button = i
if i <= 10 then
select_tower_type(i)
else
select_tower_type(nil)
end
end
local function select_tower_type(tower_type) end
local function select_toolbelt_button(i) end
local function get_wave_time(current_wave)
return 15
return 90
end
local function get_break_time(current_wave)
return 90
return 15
end
function do_day_night_cycle()
@ -150,7 +142,7 @@ local function game_action(scene)
state.current_wave = state.current_wave + 1
state.spawning = false
state.time_until_next_wave = get_wave_time(state.current_wave)
state.time_until_next_wave = get_break_time(state.current_wave)
end
else
state.time_until_next_wave = state.time_until_next_wave - am.delta_time
@ -159,7 +151,7 @@ local function game_action(scene)
state.time_until_next_wave = 0
state.spawning = true
state.time_until_next_break = get_break_time(state.current_wave)
state.time_until_next_break = get_wave_time(state.current_wave)
end
end
@ -224,9 +216,9 @@ local function game_action(scene)
elseif WIN:key_pressed"tab" then
if WIN:key_down"lshift" then
select_toolbelt_button((state.selected_toolbelt_button + 12 - 2) % 12 + 1)
select_toolbelt_button((state.selected_toolbelt_button + table.count(TOWER_TYPE) - 2) % table.count(TOWER_TYPE) + 1)
else
select_toolbelt_button((state.selected_toolbelt_button) % 12 + 1)
select_toolbelt_button((state.selected_toolbelt_button) % table.count(TOWER_TYPE) + 1)
end
elseif WIN:key_pressed"1" then select_toolbelt_button(1)
elseif WIN:key_pressed"2" then select_toolbelt_button(2)
@ -354,7 +346,7 @@ local function make_game_toolbelt()
TOWER_TYPE.RADAR,
TOWER_TYPE.LIGHTHOUSE
}
for i = 1, #keys do
for i,v in pairs(tower_type_values) do
local icon_texture = get_tower_icon_texture(tower_type_values[i])
toolbelt:append(
toolbelt_button(
@ -394,6 +386,16 @@ local function make_game_toolbelt()
end
end
select_toolbelt_button = function(i)
state.selected_toolbelt_button = i
if tower_type_values[i] then
select_tower_type(i)
else
select_tower_type(nil)
end
end
return toolbelt
end

8
src/mob.lua

@ -33,13 +33,15 @@ function get_mob_spec(mob_type)
end
local function grow_mob_health(mob_type, spec_health, time)
return spec_health * math.log(time)
return spec_health * (time / 100 + 1)
end
local function grow_mob_speed(mob_type, spec_speed, time)
return spec_speed
-- @TODO maybe speed shouldn't grow with time at all.
-- if it does, a small amount with a horizontal asymptote
return spec_speed --* math.abs(math.log(time / 100))
end
local function grow_mob_bounty(mob_type, spec_speed, time)
return spec_speed * math.log(time)
return spec_speed * (time / 100 + 1)
end
function mobs_on_hex(hex)

32
src/tower.lua

@ -112,7 +112,7 @@ function get_tower_fire_rate(tower_type)
return TOWER_SPECS[tower_type].fire_rate
end
function get_tower_size(tower_type)
return TOWER_SPECS[tower_type.size]
return TOWER_SPECS[tower_type].size
end
local function make_tower_sprite(tower_type)
@ -212,15 +212,24 @@ end
function towers_on_hex(hex)
local t = {}
for tower_index,tower in pairs(TOWERS) do
if tower and tower.hex == hex then
table.insert(t, tower_index, tower)
if tower then
for _,h in pairs(tower.hexes) do
if h == hex then
table.insert(t, tower_index, tower)
break
end
end
end
end
return t
end
function tower_on_hex(hex)
return table.find(TOWERS, function(tower) return tower.hex == hex end)
return table.find(TOWERS, function(tower)
for _,h in pairs(tower.hexes) do
if h == hex then return true end
end
end)
end
function tower_type_is_buildable_on(hex, tile, tower_type)
@ -229,8 +238,17 @@ function tower_type_is_buildable_on(hex, tile, tower_type)
-- @TODO remove this shit
if hex == HEX_GRID_CENTER then return false end
local blocking_towers = towers_on_hex(hex)
local blocking_mobs = mobs_on_hex(hex)
local blocking_towers = {}
local blocking_mobs = {}
for _,h in pairs(spiral_map(hex, get_tower_size(tower_type))) do
table.append(blocking_towers, towers_on_hex(hex))
table.append(blocking_mobs, mobs_on_hex(hex))
end
if WIN:key_down"space" then
log(table.tostring(blocking_towers))
end
local towers_blocking = table.count(blocking_towers) ~= 0
local mobs_blocking = table.count(blocking_mobs) ~= 0
@ -403,6 +421,8 @@ function make_and_register_tower(hex, tower_type)
tower.range = spec.range
tower.fire_rate = spec.fire_rate
tower.last_shot_time = -spec.fire_rate
tower.size = spec.size
tower.hexes = spiral_map(tower.hex, tower.size)
if tower_type == TOWER_TYPE.REDEYE then
local tile = state.map.get(hex.x, hex.y)

Loading…
Cancel
Save