forked from Yonokid/PyTaikoGreen
195 lines
7.4 KiB
Lua
195 lines
7.4 KiB
Lua
FCAnimation = {}
|
|
FCAnimation.__index = FCAnimation
|
|
|
|
function FCAnimation.new(is_2p, donderful)
|
|
local self = setmetatable({}, FCAnimation)
|
|
|
|
self.is_2p = is_2p
|
|
self.idx = is_2p and 1 or 0
|
|
self.draw_clear_full = false
|
|
self.name = "in"
|
|
self.frame = 0
|
|
|
|
local has_dfc_tex = donderful
|
|
and tex.get_texture("game/ending_donderful/full_combo") ~= nil
|
|
and tex.get_texture("game/ending_donderful/full_combo_highlight") ~= nil
|
|
and tex.get_texture("game/ending_donderful/full_combo_overlay") ~= nil
|
|
|
|
local subset = has_dfc_tex and "ending_donderful/" or "ending_anim/"
|
|
self.combo_tex = tex.get_texture("game/" .. subset .. "full_combo")
|
|
self.combo_highlight_tex = tex.get_texture("game/" .. subset .. "full_combo_highlight")
|
|
self.combo_overlay_tex = tex.get_texture("game/" .. subset .. "full_combo_overlay")
|
|
|
|
self.has_panel = has_dfc_tex and tex.get_texture("game/ending_donderful/background") ~= nil
|
|
self.panel_tex = self.has_panel and tex.get_texture("game/ending_donderful/background") or nil
|
|
self.panel_fade_in = anim.fade(250, { initial_opacity = 0.0, final_opacity = 1.0, delay = 0 })
|
|
|
|
local has_dfc_sound = donderful and audio.has_sound("donderful_combo")
|
|
self.combo_sound = has_dfc_sound and "donderful_combo" or "full_combo"
|
|
self.combo_voice = (donderful and audio.has_sound("donderful_combo_voice")) and "donderful_combo_voice" or "full_combo_voice"
|
|
|
|
self.bachio_fade_in = tex.get_animation(46, "game")
|
|
self.bachio_texture_change = tex.get_animation(47, "game")
|
|
self.bachio_out = tex.get_animation(55, "game")
|
|
self.bachio_move_out = tex.get_animation(49, "game")
|
|
|
|
self.bachio_fade_in:start()
|
|
self.bachio_texture_change:start()
|
|
self.bachio_out:start()
|
|
self.bachio_move_out:start()
|
|
|
|
self.clear_separate_fade_in = {}
|
|
self.clear_separate_stretch = {}
|
|
for i = 0, 4 do
|
|
local fade = anim.fade(100, { initial_opacity = 1.0, final_opacity = 0.0, delay = i * 50 })
|
|
fade:start()
|
|
self.clear_separate_fade_in[i + 1] = fade
|
|
|
|
local stretch = anim.text_stretch(200, { delay = i * 50 })
|
|
stretch:start()
|
|
self.clear_separate_stretch[i + 1] = stretch
|
|
end
|
|
|
|
self.clear_highlight_fade_in = tex.get_animation(56, "game")
|
|
self.fc_highlight_up = tex.get_animation(57, "game")
|
|
self.fc_highlight_fade_out = tex.get_animation(58, "game")
|
|
self.bachio_move_out_2 = tex.get_animation(59, "game")
|
|
self.bachio_move_up = tex.get_animation(60, "game")
|
|
self.fan_fade_in = tex.get_animation(61, "game")
|
|
self.fan_texture_change = tex.get_animation(62, "game")
|
|
|
|
self.clear_highlight_fade_in:start()
|
|
self.fc_highlight_up:start()
|
|
|
|
audio.play_sound(self.combo_sound, "sound")
|
|
|
|
self.t_fan_l = tex.get_texture("game/ending_anim/fan_l")
|
|
self.t_fan_r = tex.get_texture("game/ending_anim/fan_r")
|
|
self.t_clear_separated = tex.get_texture("game/ending_anim/clear_separated")
|
|
self.t_clear_highlight = tex.get_texture("game/ending_anim/clear_highlight")
|
|
self.t_bachio_l_in = tex.get_texture("game/ending_anim/bachio_l_in")
|
|
self.t_bachio_l_out = tex.get_texture("game/ending_anim/bachio_l_out")
|
|
self.t_bachio_r_in = tex.get_texture("game/ending_anim/bachio_r_in")
|
|
self.t_bachio_r_out = tex.get_texture("game/ending_anim/bachio_r_out")
|
|
|
|
local spacing = tex.get_skin_config("clear_animation_x_spacing")
|
|
self.clear_anim_x_spacing = (spacing and spacing.x) or 0
|
|
|
|
return self
|
|
end
|
|
|
|
function FCAnimation:update(current_ms)
|
|
self.bachio_fade_in:update(current_ms)
|
|
self.bachio_texture_change:update(current_ms)
|
|
self.bachio_out:update(current_ms)
|
|
self.bachio_move_out:update(current_ms)
|
|
self.clear_highlight_fade_in:update(current_ms)
|
|
self.fc_highlight_up:update(current_ms)
|
|
self.fc_highlight_fade_out:update(current_ms)
|
|
self.bachio_move_out_2:update(current_ms)
|
|
self.bachio_move_up:update(current_ms)
|
|
self.fan_fade_in:update(current_ms)
|
|
self.fan_texture_change:update(current_ms)
|
|
|
|
if self.fc_highlight_up.is_finished and not self.fc_highlight_fade_out.is_started then
|
|
self.fc_highlight_fade_out:start()
|
|
self.bachio_move_out_2:start()
|
|
self.bachio_move_up:start()
|
|
self.fan_fade_in:start()
|
|
self.fan_texture_change:start()
|
|
audio.play_sound(self.combo_voice, "voice")
|
|
end
|
|
|
|
if self.clear_highlight_fade_in.is_finished then
|
|
if not self.draw_clear_full and self.has_panel then
|
|
self.panel_fade_in:start()
|
|
end
|
|
self.draw_clear_full = true
|
|
end
|
|
self.panel_fade_in:update(current_ms)
|
|
|
|
for i = 1, 5 do
|
|
self.clear_separate_fade_in[i]:update(current_ms)
|
|
self.clear_separate_stretch[i]:update(current_ms)
|
|
end
|
|
|
|
if self.bachio_texture_change.is_finished then
|
|
self.name = "out"
|
|
self.frame = math.floor(self.bachio_out.attribute)
|
|
else
|
|
self.frame = math.floor(self.bachio_texture_change.attribute)
|
|
end
|
|
end
|
|
|
|
function FCAnimation:draw()
|
|
if self.draw_clear_full then
|
|
if self.has_panel then
|
|
tex.draw_texture(self.panel_tex, {
|
|
fade = self.panel_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
end
|
|
|
|
tex.draw_texture(self.t_fan_l, {
|
|
frame = math.floor(self.fan_texture_change.attribute),
|
|
fade = self.fan_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
tex.draw_texture(self.t_fan_r, {
|
|
frame = math.floor(self.fan_texture_change.attribute),
|
|
fade = self.fan_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
|
|
tex.draw_texture(self.combo_overlay_tex, {
|
|
y = -self.fc_highlight_up.attribute,
|
|
fade = 0.5,
|
|
index = self.idx,
|
|
})
|
|
tex.draw_texture(self.combo_tex, {
|
|
y = -self.fc_highlight_up.attribute,
|
|
index = self.idx,
|
|
})
|
|
tex.draw_texture(self.combo_highlight_tex, {
|
|
y = -self.fc_highlight_up.attribute,
|
|
fade = self.fc_highlight_fade_out.attribute,
|
|
index = self.idx,
|
|
})
|
|
else
|
|
for i = 5, 1, -1 do
|
|
local j = i - 1
|
|
tex.draw_texture(self.t_clear_separated, {
|
|
frame = j,
|
|
x = j * self.clear_anim_x_spacing,
|
|
y = -self.clear_separate_stretch[i].attribute,
|
|
y2 = self.clear_separate_stretch[i].attribute,
|
|
fade = self.clear_separate_fade_in[i].attribute,
|
|
index = self.idx,
|
|
})
|
|
end
|
|
end
|
|
|
|
tex.draw_texture(self.t_clear_highlight, {
|
|
fade = self.clear_highlight_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
|
|
local ltex = (self.name == "in") and self.t_bachio_l_in or self.t_bachio_l_out
|
|
local rtex = (self.name == "in") and self.t_bachio_r_in or self.t_bachio_r_out
|
|
|
|
tex.draw_texture(ltex, {
|
|
frame = self.frame,
|
|
x = (-self.bachio_move_out.attribute - self.bachio_move_out_2.attribute) * 1.15,
|
|
y = -self.bachio_move_up.attribute,
|
|
fade = self.bachio_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
tex.draw_texture(rtex, {
|
|
frame = self.frame,
|
|
x = (self.bachio_move_out.attribute + self.bachio_move_out_2.attribute) * 1.15,
|
|
y = -self.bachio_move_up.attribute,
|
|
fade = self.bachio_fade_in.attribute,
|
|
index = self.idx,
|
|
})
|
|
end
|