mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
gui + thingies
This commit is contained in:
parent
4ce0a40327
commit
c0b02ed725
@ -77,6 +77,7 @@ require "modules.autostash"
|
||||
--require "maps.territorial_control"
|
||||
--require "maps.cave_choppy.cave_miner"
|
||||
--require "maps.wave_of_death.WoD"
|
||||
--require "maps.pitch_black.main"
|
||||
--require "maps.planet_prison"
|
||||
--require "maps.stone_maze.main"
|
||||
--require "maps.choppy"
|
||||
|
@ -2,6 +2,23 @@ local Public = {}
|
||||
|
||||
local math_abs = math.abs
|
||||
|
||||
local score_values = {
|
||||
["small-spitter"] = 1,
|
||||
["small-biter"] = 1,
|
||||
["medium-spitter"] = 3,
|
||||
["medium-biter"] = 3,
|
||||
["big-spitter"] = 5,
|
||||
["big-biter"] = 5,
|
||||
["behemoth-spitter"] = 10,
|
||||
["behemoth-biter"] = 10,
|
||||
["small-worm-turret"] = 4,
|
||||
["medium-worm-turret"] = 6,
|
||||
["big-worm-turret"] = 8,
|
||||
["behemoth-worm-turret"] = 10,
|
||||
["biter-spawner"] = 16,
|
||||
["spitter-spawner"] = 16
|
||||
}
|
||||
|
||||
function Public.set_daytime_difficulty(surface, tick)
|
||||
local daytime = surface.daytime
|
||||
if daytime < 0.30 then
|
||||
@ -17,10 +34,16 @@ function Public.set_biter_difficulty()
|
||||
local daytime_extra_life_modifier = (-0.30 + daytime) * 2
|
||||
if daytime_extra_life_modifier < 0 then daytime_extra_life_modifier = 0 end
|
||||
|
||||
local extra_lifes = global.map_score * 0.001 * daytime + daytime_extra_life_modifier
|
||||
local extra_lifes = global.map_score * 0.0001 * daytime + daytime_extra_life_modifier
|
||||
global.biter_reanimator.forces[2] = extra_lifes
|
||||
end
|
||||
|
||||
function Public.add_score(entity)
|
||||
local value = score_values[entity.name]
|
||||
if not value then return end
|
||||
global.map_score = global.map_score + value
|
||||
end
|
||||
|
||||
function Public.fleeing_biteys(entity, cause)
|
||||
local surface = entity.surface
|
||||
if not surface.peaceful_mode then return end
|
||||
|
49
maps/pitch_black/gui.lua
Normal file
49
maps/pitch_black/gui.lua
Normal file
@ -0,0 +1,49 @@
|
||||
local Public = {}
|
||||
|
||||
local tooltip = "Difficulty increases with higher score."
|
||||
|
||||
local function create_score_gui(player)
|
||||
local frame = player.gui.left.add({type = "frame", name = "pitch_black_score", direction = "vertical"})
|
||||
local t = frame.add({type = "table", column_count = 2})
|
||||
|
||||
frame.tooltip = tooltip
|
||||
t.tooltip = tooltip
|
||||
|
||||
local element = t.add({type = "label", caption = "Score: "})
|
||||
element.style.font = "heading-1"
|
||||
element.style.font_color = {175, 175, 200}
|
||||
element.style.horizontal_align = "right"
|
||||
element.style.maximal_width = 56
|
||||
element.style.minimal_width = 56
|
||||
element.tooltip = tooltip
|
||||
|
||||
local element = t.add({type = "label", caption = 0})
|
||||
element.style.font = "heading-1"
|
||||
element.style.font_color = {100, 0, 255}
|
||||
element.style.horizontal_align = "left"
|
||||
element.style.minimal_width = 32
|
||||
element.tooltip = tooltip
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
local function update_score_gui(player)
|
||||
local frame = player.gui.left.pitch_black_score
|
||||
if not player.gui.left.pitch_black_score then frame = create_score_gui(player) end
|
||||
|
||||
local frame_table = frame.children[1]
|
||||
|
||||
local score_value = frame_table.children[2]
|
||||
score_value.caption = global.map_score
|
||||
|
||||
local score_value = frame_table.children[4]
|
||||
score_value.caption = global.daytime
|
||||
end
|
||||
|
||||
function Public.update()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
update_score_gui(player)
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
@ -1,6 +1,7 @@
|
||||
require "modules.biter_reanimator"
|
||||
|
||||
local Blood_moon = require "maps.pitch_black.blood_moon"
|
||||
local Gui = require "maps.pitch_black.gui"
|
||||
local Difficulty = require "maps.pitch_black.difficulty"
|
||||
|
||||
local function on_entity_died(event)
|
||||
@ -8,6 +9,7 @@ local function on_entity_died(event)
|
||||
if not entity.valid then return end
|
||||
local cause = event.cause
|
||||
Difficulty.fleeing_biteys(entity, cause)
|
||||
Difficulty.add_score(entity)
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
@ -18,9 +20,11 @@ local function on_tick()
|
||||
|
||||
Blood_moon.set_daytime(surface, tick)
|
||||
|
||||
if tick % 20 ~= 0 then return end
|
||||
if tick % 30 ~= 0 then return end
|
||||
Difficulty.set_daytime_difficulty(surface, tick)
|
||||
Difficulty.set_biter_difficulty()
|
||||
|
||||
Gui.update()
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
|
Loading…
x
Reference in New Issue
Block a user