feat: added ascension meter, done 0-1 asc logic, fixed mysterious man behaviours
This commit is contained in:
@@ -16,13 +16,18 @@ He says nothing.
|
||||
|
||||
local state = STATE_TEXT
|
||||
local text_y = Config.screen.height
|
||||
local text_speed = 0.4
|
||||
local text_speed = 0.2
|
||||
local day_timer = 0
|
||||
local day_display_frames = 120
|
||||
local text_done = false
|
||||
local text_done_timer = 0
|
||||
local TEXT_DONE_HOLD_FRAMES = 120
|
||||
local selected_choice = 1
|
||||
local text = DEFAULT_TEXT
|
||||
local day_text_override = nil
|
||||
local on_text_complete = nil
|
||||
local show_mysterious_screen = true
|
||||
local trigger_flash_on_wake = false
|
||||
|
||||
local choices = {
|
||||
{
|
||||
@@ -47,16 +52,30 @@ end
|
||||
--- * text (string) Override for the scrolling text.<br/>
|
||||
--- * day_text (string) Override for the centered day label.<br/>
|
||||
--- * on_text_complete (function) Callback fired once when the text phase ends.<br/>
|
||||
--- * skip_text (boolean) If true, skip the text phase and go straight to day display.<br/>
|
||||
function MysteriousManWindow.start(options)
|
||||
options = options or {}
|
||||
state = STATE_TEXT
|
||||
text_y = Config.screen.height
|
||||
day_timer = 0
|
||||
text_done = false
|
||||
text_done_timer = 0
|
||||
selected_choice = 1
|
||||
text = options.text or DEFAULT_TEXT
|
||||
local line_count = 1
|
||||
for _ in string.gmatch(text, "\n") do line_count = line_count + 1 end
|
||||
local text_block_h = line_count * 8
|
||||
text_y = math.floor((Config.screen.height - text_block_h) / 2)
|
||||
day_text_override = options.day_text
|
||||
on_text_complete = options.on_text_complete
|
||||
Meter.hide()
|
||||
trigger_flash_on_wake = not options.skip_text
|
||||
if options.skip_text then
|
||||
show_mysterious_screen = false
|
||||
state = STATE_DAY
|
||||
day_timer = day_display_frames
|
||||
else
|
||||
show_mysterious_screen = true
|
||||
state = STATE_TEXT
|
||||
end
|
||||
Window.set_current("mysterious_man")
|
||||
end
|
||||
|
||||
@@ -86,6 +105,10 @@ local function wake_up()
|
||||
Audio.music_play_wakingup()
|
||||
Context.home_norman_visible = true
|
||||
Meter.show()
|
||||
if trigger_flash_on_wake then
|
||||
trigger_flash_on_wake = false
|
||||
Ascension.start_flash()
|
||||
end
|
||||
Window.set_current("game")
|
||||
end,
|
||||
})
|
||||
@@ -101,26 +124,34 @@ end
|
||||
--- @within MysteriousManWindow
|
||||
function MysteriousManWindow.update()
|
||||
if state == STATE_TEXT then
|
||||
text_y = text_y - text_speed
|
||||
if not text_done then
|
||||
text_y = text_y - text_speed
|
||||
|
||||
local lines = 1
|
||||
for _ in string.gmatch(text, "\n") do
|
||||
lines = lines + 1
|
||||
end
|
||||
local lines = 1
|
||||
for _ in string.gmatch(text, "\n") do
|
||||
lines = lines + 1
|
||||
end
|
||||
|
||||
if text_y < -lines * 8 then
|
||||
go_to_day_state()
|
||||
end
|
||||
|
||||
if Input.select() then
|
||||
go_to_day_state()
|
||||
if text_y < -lines * 8 then
|
||||
text_done = true
|
||||
text_done_timer = TEXT_DONE_HOLD_FRAMES
|
||||
end
|
||||
else
|
||||
text_done_timer = text_done_timer - 1
|
||||
if text_done_timer <= 0 then
|
||||
go_to_day_state()
|
||||
end
|
||||
end
|
||||
elseif state == STATE_DAY then
|
||||
day_timer = day_timer - 1
|
||||
|
||||
if day_timer <= 0 or Input.select() then
|
||||
state = STATE_CHOICE
|
||||
selected_choice = 1
|
||||
if trigger_flash_on_wake or Ascension.get_level() < 1 then
|
||||
wake_up()
|
||||
else
|
||||
state = STATE_CHOICE
|
||||
selected_choice = 1
|
||||
end
|
||||
end
|
||||
elseif state == STATE_CHOICE then
|
||||
selected_choice = UI.update_menu(choices, selected_choice)
|
||||
@@ -140,11 +171,17 @@ end
|
||||
--- @within MysteriousManWindow
|
||||
function MysteriousManWindow.draw()
|
||||
rect(0, 0, Config.screen.width, Config.screen.height, Config.colors.black)
|
||||
Screen.draw_the_mysterious_screen()
|
||||
if show_mysterious_screen then
|
||||
Screen.draw_the_mysterious_screen()
|
||||
end
|
||||
|
||||
if state == STATE_TEXT then
|
||||
local x = (Config.screen.width - 132) / 2
|
||||
Print.text(text, x, text_y, Config.colors.light_grey)
|
||||
local cx = Config.screen.width / 2
|
||||
local line_y = text_y
|
||||
for line in (text .. "\n"):gmatch("(.-)\n") do
|
||||
Print.text_center(line, cx, line_y, Config.colors.light_grey)
|
||||
line_y = line_y + 8
|
||||
end
|
||||
elseif state == STATE_DAY then
|
||||
local day_text = day_text_override or ("Day " .. Context.day_count)
|
||||
Print.text_center(
|
||||
|
||||
Reference in New Issue
Block a user