233 lines
10 KiB
Luau
233 lines
10 KiB
Luau
--!strict
|
|
local Players = game:GetService("Players")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local RunService = game:GetService("RunService")
|
|
local Input = game:GetService("UserInputService")
|
|
local TweenService = game:GetService("TweenService")
|
|
local UI = require(ReplicatedStorage:WaitForChild("HunterUI") :: ModuleScript)
|
|
local Rules = require(ReplicatedStorage:WaitForChild("MatchRules") :: ModuleScript)
|
|
local Sounds = require(ReplicatedStorage:WaitForChild("SniperEffects") :: ModuleScript)
|
|
local Siege = require(ReplicatedStorage:WaitForChild("CitadelAssaultConfig") :: ModuleScript)
|
|
local Hunter = ReplicatedStorage:WaitForChild("Hunter")
|
|
local Profiles = require(Hunter:WaitForChild("ModeProfiles") :: ModuleScript)
|
|
local Config = require(Hunter:WaitForChild("RoundConfig") :: ModuleScript)
|
|
local Strings = require(Hunter:WaitForChild("Strings") :: ModuleScript)
|
|
local match = ReplicatedStorage:WaitForChild("ArenaRound"):WaitForChild("Procedural")
|
|
local player = Players.LocalPlayer
|
|
local playerGui = player:WaitForChild("PlayerGui")
|
|
|
|
local gui = Instance.new("ScreenGui")
|
|
gui.Name = "RoundPresentation"
|
|
gui.ResetOnSpawn = false
|
|
gui.IgnoreGuiInset = true
|
|
gui.DisplayOrder = 24
|
|
gui.Parent = playerGui
|
|
|
|
local vignette = Instance.new("CanvasGroup")
|
|
vignette.Name = "FinalPushVignette"
|
|
vignette.Size = UDim2.fromScale(1, 1)
|
|
vignette.BackgroundTransparency = 1
|
|
vignette.Visible = false
|
|
vignette.Parent = gui
|
|
local edges = {
|
|
{0, 0, 1, .2, 90}, {0, .8, 1, .2, 270},
|
|
{0, 0, .14, 1, 0}, {.86, 0, .14, 1, 180},
|
|
}
|
|
for _, side in edges do
|
|
local edge = Instance.new("Frame")
|
|
edge.Position = UDim2.fromScale(side[1], side[2])
|
|
edge.Size = UDim2.fromScale(side[3], side[4])
|
|
edge.BorderSizePixel = 0
|
|
edge.BackgroundColor3 = Color3.fromRGB(255, 60, 70)
|
|
edge.Parent = vignette
|
|
local gradient = Instance.new("UIGradient", edge)
|
|
gradient.Rotation = side[5]
|
|
gradient.Transparency = NumberSequence.new(.38, 1)
|
|
end
|
|
|
|
local swapShade = Instance.new("Frame")
|
|
swapShade.Name = "RoleSwapShade"
|
|
swapShade.Size = UDim2.fromScale(1, 1)
|
|
swapShade.BackgroundColor3 = UI.Panel
|
|
swapShade.BackgroundTransparency = 1
|
|
swapShade.Visible = false
|
|
swapShade.Parent = gui
|
|
|
|
local card = Instance.new("CanvasGroup")
|
|
card.Name = "Briefing"
|
|
card.AnchorPoint = Vector2.new(.5, .5)
|
|
card.Position = UDim2.fromScale(.5, .5)
|
|
card.Size = UDim2.new(.85, 0, 0, 260)
|
|
card.BackgroundTransparency = 1
|
|
card.Visible = false
|
|
card.Parent = gui
|
|
local max = Instance.new("UISizeConstraint", card)
|
|
max.MaxSize = Vector2.new(520, 260)
|
|
local plate = UI.plate(card, "Plate", UDim2.new(), UDim2.fromScale(1, 1), UI.Blue)
|
|
local contour = UI.contour(plate, UI.Blue)
|
|
UI.label(plate, "Mode", Strings.round.mode, UDim2.fromOffset(12, 12), UDim2.new(1, -24, 0, 19), 14, UI.Muted)
|
|
local title = UI.label(plate, "Title", "", UDim2.fromOffset(12, 31), UDim2.new(1, -24, 0, 40), 34, UI.Blue)
|
|
title.FontFace = UI.Display
|
|
local goal = UI.label(plate, "Goal", "", UDim2.fromOffset(18, 70), UDim2.new(1, -36, 0, 35), 18, UI.Ink)
|
|
goal.TextWrapped = true
|
|
local rules: {TextLabel} = {}
|
|
for i = 1, 3 do
|
|
local line = UI.label(plate, "Rule" .. i, "", UDim2.fromOffset(25, 108 + (i - 1) * 23), UDim2.new(1, -50, 0, 23), 15, UI.Ink)
|
|
line.TextXAlignment = Enum.TextXAlignment.Left
|
|
table.insert(rules, line)
|
|
end
|
|
local role = UI.label(plate, "Role", "", UDim2.fromOffset(18, 182), UDim2.new(1, -36, 0, 24), 17, UI.Gold)
|
|
local tutorial = UI.label(plate, "Tutorial", "", UDim2.fromOffset(18, 207), UDim2.new(1, -36, 0, 31), 14, UI.Muted)
|
|
tutorial.TextWrapped = true
|
|
local track = UI.element("ProgressBar", plate, UDim2.fromScale(.07, .94), UDim2.new(.86, 0, 0, 4))
|
|
local fill = track:WaitForChild("Fill") :: Frame
|
|
|
|
local banner = UI.plate(gui, "RoundBanner", UDim2.fromScale(.5, .28), UDim2.new(.82, 0, 0, 78), UI.Gold)
|
|
banner.AnchorPoint = Vector2.new(.5, .5)
|
|
Instance.new("UISizeConstraint", banner).MaxSize = Vector2.new(500, 78)
|
|
local bannerTitle = UI.label(banner, "Title", "", UDim2.fromOffset(0, 6), UDim2.new(1, 0, 0, 36), 27, UI.Gold)
|
|
bannerTitle.FontFace = UI.Display
|
|
local bannerDetail = UI.label(banner, "Detail", "", UDim2.fromOffset(12, 43), UDim2.new(1, -24, 0, 25), 16, UI.Ink)
|
|
local respawn = UI.label(gui, "Respawn", "", UDim2.fromScale(.5, .63), UDim2.new(.85, 0, 0, 42), 27, UI.Ink)
|
|
respawn.AnchorPoint = Vector2.new(.5, .5)
|
|
respawn.FontFace = UI.Display
|
|
UI.edge(respawn, UI.Panel, 0)
|
|
banner.Visible, respawn.Visible = false, false
|
|
|
|
local seen: {[string]: boolean} = {}
|
|
local oldStage: string? = nil
|
|
local wasInArena = false
|
|
local briefUntil, bannerUntil = 0, 0
|
|
local lastTick = -1
|
|
local barTween: Tween? = nil
|
|
local slide: Tween? = nil
|
|
local fade: Tween? = nil
|
|
local pulse: Tween? = nil
|
|
local swapTween: Tween? = nil
|
|
local shakeUntil = 0
|
|
|
|
local function showBriefing(id: string, now: number, untilAt: number, short: boolean)
|
|
local profile = Profiles[id]
|
|
if not profile then return end
|
|
local side = player:GetAttribute("ArenaTeam")
|
|
local tone = if side == "Orange" then UI.Orange else UI.Blue
|
|
title.TextColor3 = tone
|
|
title.Text = Rules.get(id).title
|
|
goal.Text = profile.goal
|
|
contour:SetAttribute("Accent", tone)
|
|
UI.tintPlate(plate, tone)
|
|
for i, line in rules do
|
|
line.Visible = not short
|
|
line.Text = "✓ " .. profile.rules[i]
|
|
end
|
|
local attacker = match:FindFirstChild("CitadelMatchState")
|
|
local attackerSide = attacker and attacker:GetAttribute("Attacker") or Siege.FIRST_ATTACKER
|
|
role.Position = UDim2.fromOffset(18, if short then 122 else 182)
|
|
role.Text = if id == "Siege" then (if side == attackerSide then Strings.round.attack else Strings.round.defend) else Strings.team(side)
|
|
tutorial.Visible = not short and not seen[id]
|
|
tutorial.Text = Strings.round.tutorial[id] or ""
|
|
if not short then seen[id] = true end
|
|
card.Size = UDim2.new(.85, 0, 0, if short then 168 else 260)
|
|
briefUntil = untilAt
|
|
card.Position, card.GroupTransparency, card.Visible = UDim2.fromScale(.5, .54), 1, true
|
|
if barTween then barTween:Cancel() end
|
|
if slide then slide:Cancel() end
|
|
if fade then fade:Cancel() end
|
|
local entrance = TweenInfo.new(.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
|
|
slide = TweenService:Create(card, entrance, {Position = UDim2.fromScale(.5, .5)})
|
|
fade = TweenService:Create(card, entrance, {GroupTransparency = 0})
|
|
local duration = math.max(.05, if short then Config.lateBriefingSeconds else profile.briefingSeconds)
|
|
fill.Size = UDim2.fromScale(math.clamp((untilAt - now) / duration, 0, 1), 1)
|
|
barTween = TweenService:Create(fill, TweenInfo.new(math.max(.05, untilAt - now), Enum.EasingStyle.Linear), {Size = UDim2.fromScale(0, 1)})
|
|
slide:Play()
|
|
fade:Play()
|
|
barTween:Play()
|
|
end
|
|
|
|
local function showBanner(heading: string, detail: string, untilAt: number)
|
|
bannerTitle.Text, bannerDetail.Text = heading, detail
|
|
bannerUntil = untilAt
|
|
banner.Visible = true
|
|
end
|
|
|
|
local function update()
|
|
local now = workspace:GetServerTimeNow()
|
|
local inArena = player:GetAttribute("InArena") == true
|
|
local stage = match:GetAttribute("RoundStage") :: string?
|
|
local id = Rules.get(match:GetAttribute("Ruleset")).id
|
|
local final = inArena and stage == "FinalPush"
|
|
local swapping = inArena and stage == "RoleSwap"
|
|
if swapping ~= swapShade.Visible then
|
|
swapShade.Visible = swapping
|
|
if swapTween then swapTween:Cancel(); swapTween = nil end
|
|
if swapping then
|
|
swapShade.BackgroundTransparency = 1
|
|
swapTween = TweenService:Create(swapShade, TweenInfo.new(.22), {BackgroundTransparency = .28})
|
|
swapTween:Play()
|
|
end
|
|
end
|
|
if final ~= vignette.Visible then
|
|
vignette.Visible = final
|
|
if pulse then pulse:Cancel(); pulse = nil end
|
|
if final then
|
|
vignette.GroupTransparency = .46
|
|
pulse = TweenService:Create(vignette, TweenInfo.new(.9, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
|
|
{GroupTransparency = .75})
|
|
pulse:Play()
|
|
end
|
|
end
|
|
if inArena and (stage ~= oldStage or not wasInArena) then
|
|
card.Visible = false
|
|
banner.Visible = false
|
|
lastTick = -1
|
|
if stage == "Briefing" then
|
|
local limit = match:GetAttribute("StageEndsAt")
|
|
if typeof(limit) == "number" and limit > now then showBriefing(id, now, limit, false) end
|
|
elseif stage == "RoleSwap" then
|
|
local limit = match:GetAttribute("StageEndsAt")
|
|
if typeof(limit) == "number" then showBanner(Strings.round.swap, "", limit) end
|
|
elseif stage == "Live" or stage == "FinalPush" then
|
|
if final then
|
|
showBanner(Strings.round.final, Strings.round.finalPush[id] or "", now + Config.finalBannerSeconds)
|
|
elseif oldStage == "Countdown" and wasInArena then
|
|
showBanner(Strings.round.fight, "", now + Config.startBannerSeconds)
|
|
Sounds.sound("RoundStart")
|
|
if Config.CameraShake and not Input.TouchEnabled then shakeUntil = os.clock() + .22 end
|
|
elseif not wasInArena then
|
|
showBriefing(id, now, now + Config.lateBriefingSeconds, true)
|
|
end
|
|
end
|
|
end
|
|
card.Visible = card.Visible and inArena and now < briefUntil
|
|
banner.Visible = banner.Visible and inArena and now < bannerUntil
|
|
local shieldAt = player:GetAttribute("RoundRespawnAt")
|
|
local left = if typeof(shieldAt) == "number" then math.ceil(shieldAt - now) else 0
|
|
respawn.Visible = inArena and left > 0
|
|
if respawn.Visible then respawn.Text = string.format(Strings.round.respawn, left) end
|
|
if final then
|
|
local endsAt = match:GetAttribute("EndsAt")
|
|
local seconds = if typeof(endsAt) == "number" then math.ceil(endsAt - now) else 0
|
|
if seconds > 0 and seconds <= Config.finalTickSeconds and seconds ~= lastTick then
|
|
lastTick = seconds
|
|
Sounds.sound("Tick")
|
|
end
|
|
end
|
|
oldStage, wasInArena = stage, inArena
|
|
end
|
|
|
|
local connection = RunService.Heartbeat:Connect(update)
|
|
local shakeName = "HunterRoundStartShake"
|
|
if Config.CameraShake and not Input.TouchEnabled then
|
|
RunService:BindToRenderStep(shakeName, Enum.RenderPriority.Camera.Value + 1, function()
|
|
local camera = workspace.CurrentCamera
|
|
local left = shakeUntil - os.clock()
|
|
if camera and left > 0 then camera.CFrame *= CFrame.Angles(math.sin(left * 85) * left * .027, 0, 0) end
|
|
end)
|
|
end
|
|
script.Destroying:Once(function()
|
|
connection:Disconnect()
|
|
if Config.CameraShake and not Input.TouchEnabled then RunService:UnbindFromRenderStep(shakeName) end
|
|
for _, tween in {barTween, slide, fade, pulse, swapTween} do if tween then tween:Cancel() end end
|
|
gui:Destroy()
|
|
end)
|