188 lines
7.5 KiB
Lua
188 lines
7.5 KiB
Lua
local DonBG4 = require("background/bg_objects/donbg/4")
|
|
local Fever = require("background/bg_objects/fever")
|
|
local Footer = require("background/bg_objects/footer")
|
|
local Dancer = require("background/bg_objects/dancer")
|
|
local RendaController = require("background/bg_objects/renda")
|
|
local ChibiController = require("background/bg_objects/chibi")
|
|
|
|
local COLLAB_PATH = "background/collab/kobayashi"
|
|
local MAX_DANCERS = 5
|
|
local SCREEN_WIDTH = 1280
|
|
|
|
local KobayashiBGNormal = {}
|
|
KobayashiBGNormal.__index = KobayashiBGNormal
|
|
|
|
function KobayashiBGNormal.new()
|
|
local self = setmetatable({}, KobayashiBGNormal)
|
|
self.name = "bg_0"
|
|
tex.load_folder(COLLAB_PATH, "bg_normal/" .. self.name)
|
|
|
|
local trim_info = tex.get_texture_info(self.name, "trim")
|
|
local trim_frames = (trim_info and trim_info.frame_count) or 1
|
|
local trim_textures = {}
|
|
for i = 0, trim_frames - 1 do
|
|
table.insert(trim_textures, { i * 300, (i + 1) * 300, i })
|
|
end
|
|
self.trim_blink = anim.texture_change(trim_frames * 300, trim_textures, { loop = true })
|
|
self.trim_blink:start()
|
|
|
|
self.bg_texture = tex.get_texture_info(self.name, "background")
|
|
self.trim_texture = tex.get_texture_info(self.name, "trim")
|
|
self._id_bg = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "background") or 0
|
|
self._id_trim = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "trim") or 0
|
|
|
|
self._id_platform_black = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "platform_black") or 0
|
|
self._id_prop1 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "prop1") or 0
|
|
self._id_mascot_yellow = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "mascot_yellow") or 0
|
|
self._id_prop2 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "prop2") or 0
|
|
self._id_platform_blue = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "platform_blue") or 0
|
|
self._id_shadow = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "shadow") or 0
|
|
self._id_sparkle = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "sparkle") or 0
|
|
self._id_singer = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "singer") or 0
|
|
return self
|
|
end
|
|
|
|
function KobayashiBGNormal:update(current_time_ms) self.trim_blink:update(current_time_ms) end
|
|
|
|
function KobayashiBGNormal:draw()
|
|
tex.draw_texture(self._id_bg)
|
|
tex.draw_texture(self._id_bg, { mirror = "horizontal", x = self.bg_texture.width })
|
|
tex.draw_texture(self._id_trim, { frame = self.trim_blink.attribute })
|
|
tex.draw_texture(self._id_trim, {
|
|
frame = self.trim_blink.attribute,
|
|
mirror = "horizontal",
|
|
x = SCREEN_WIDTH - self.trim_texture.width
|
|
})
|
|
tex.draw_texture(self._id_platform_black)
|
|
tex.draw_texture(self._id_shadow)
|
|
tex.draw_texture(self._id_platform_blue)
|
|
tex.draw_texture(self._id_prop1)
|
|
tex.draw_texture(self._id_prop2)
|
|
tex.draw_texture(self._id_mascot_yellow)
|
|
tex.draw_texture(self._id_singer)
|
|
tex.draw_texture(self._id_sparkle)
|
|
end
|
|
|
|
function KobayashiBGNormal:destroy() tex.unload_folder(COLLAB_PATH, "bg_normal/" .. self.name) end
|
|
|
|
local KobayashiBGFever = {}
|
|
KobayashiBGFever.__index = KobayashiBGFever
|
|
|
|
function KobayashiBGFever.new()
|
|
local self = setmetatable({}, KobayashiBGFever)
|
|
self.name = "bg_fever_0"
|
|
tex.load_folder(COLLAB_PATH, "bg_fever/" .. self.name)
|
|
self._id_prop1 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "prop1") or 0
|
|
self._id_platform_blue = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "platform_blue") or 0
|
|
self._id_queen = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "queen") or 0
|
|
self._id_crane_body = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "crane_body") or 0
|
|
self._id_crane_wing = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "crane_wing") or 0
|
|
return self
|
|
end
|
|
|
|
function KobayashiBGFever:start() end
|
|
function KobayashiBGFever:update(current_time_ms) end
|
|
|
|
function KobayashiBGFever:draw()
|
|
tex.draw_texture(self._id_platform_blue)
|
|
tex.draw_texture(self._id_prop1)
|
|
tex.draw_texture(self._id_crane_wing)
|
|
tex.draw_texture(self._id_crane_body)
|
|
tex.draw_texture(self._id_queen)
|
|
end
|
|
|
|
function KobayashiBGFever:destroy() tex.unload_folder(COLLAB_PATH, "bg_fever/" .. self.name) end
|
|
|
|
-- Background
|
|
|
|
local KobayashiBackground = {}
|
|
KobayashiBackground.__index = KobayashiBackground
|
|
|
|
function KobayashiBackground.new(player_num, bpm)
|
|
local self = setmetatable({}, KobayashiBackground)
|
|
self.donbg = DonBG4.new(1, player_num, COLLAB_PATH)
|
|
self.bg_normal = KobayashiBGNormal.new()
|
|
self.bg_fever = KobayashiBGFever.new()
|
|
self.footer = Footer.new(COLLAB_PATH, -1)
|
|
self.fever = Fever.create(0, bpm, COLLAB_PATH)
|
|
self.dancer = Dancer.BaseDancerGroup.new(0, bpm, MAX_DANCERS, COLLAB_PATH)
|
|
for i, d in ipairs(self.dancer.dancers) do
|
|
if d.index == 4 then
|
|
self.dancer.dancers[i], self.dancer.dancers[1] = self.dancer.dancers[1], self.dancer.dancers[i]
|
|
break
|
|
end
|
|
end
|
|
self.renda = RendaController.new(COLLAB_PATH, 0)
|
|
self.chibi = ChibiController.new(bpm, COLLAB_PATH, 1)
|
|
self.is_clear = false
|
|
self.is_rainbow = false
|
|
self.last_milestone = 1
|
|
return self
|
|
end
|
|
|
|
function KobayashiBackground:update(current_ms, bpm)
|
|
self.donbg:update(current_ms)
|
|
self.bg_normal:update(current_ms)
|
|
self.fever:update(current_ms, bpm)
|
|
self.dancer:update(current_ms, bpm)
|
|
self.renda:update(current_ms)
|
|
self.chibi:update(current_ms, bpm)
|
|
end
|
|
|
|
function KobayashiBackground:handle_good(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function KobayashiBackground:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function KobayashiBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
|
|
|
|
function KobayashiBackground:handle_drumroll(player_num) self.renda:add_renda() end
|
|
|
|
function KobayashiBackground:handle_balloon(player_num) self.renda:add_renda() end
|
|
|
|
function KobayashiBackground:handle_gauge(player_num, progress, is_clear, is_rainbow)
|
|
self.donbg:set_clear(is_clear)
|
|
if is_rainbow and not self.is_rainbow then self.fever:start() end
|
|
self.is_clear = is_clear
|
|
self.is_rainbow = is_rainbow
|
|
|
|
local current_milestone
|
|
if is_clear then
|
|
current_milestone = MAX_DANCERS
|
|
else
|
|
current_milestone = math.min(MAX_DANCERS - 1, math.floor(progress * MAX_DANCERS))
|
|
end
|
|
if current_milestone > self.last_milestone then
|
|
for _ = 1, current_milestone - self.last_milestone do self.dancer:add_dancer() end
|
|
self.last_milestone = current_milestone
|
|
elseif current_milestone < self.last_milestone then
|
|
for _ = 1, self.last_milestone - current_milestone do self.dancer:remove_dancer() end
|
|
self.last_milestone = current_milestone
|
|
end
|
|
end
|
|
|
|
function KobayashiBackground:draw_back()
|
|
self.bg_normal:draw()
|
|
if self.is_clear then self.bg_fever:draw() end
|
|
self.donbg:draw()
|
|
self.renda:draw()
|
|
self.dancer:draw()
|
|
self.footer:draw()
|
|
if self.is_rainbow then self.fever:draw() end
|
|
self.chibi:draw()
|
|
end
|
|
|
|
function KobayashiBackground:draw_fore() end
|
|
|
|
function KobayashiBackground:destroy()
|
|
self.donbg:destroy()
|
|
self.bg_normal:destroy()
|
|
self.bg_fever:destroy()
|
|
self.fever:destroy()
|
|
self.dancer:destroy()
|
|
self.footer:destroy()
|
|
self.renda:destroy()
|
|
self.chibi:destroy()
|
|
end
|
|
|
|
return KobayashiBackground
|