200 lines
7.7 KiB
Luau
200 lines
7.7 KiB
Luau
--!strict
|
|
-- Client-only overlays for the local player's rune activations.
|
|
local ArenaMobilityScreen = {}
|
|
|
|
type Streak = {halo: Frame, core: Frame, direction: Vector2, offset: number, speed: number, length: number}
|
|
type Sigil = {root: Frame, scale: UIScale, diamond: UIStroke, stars: {Frame}, side: number, index: number}
|
|
type Spark = {frame: Frame, side: number, offset: number, x: number, lift: number, bend: number, size: number}
|
|
|
|
local gold = Color3.fromRGB(255, 199, 100)
|
|
local coral = Color3.fromRGB(255, 123, 172)
|
|
local violet = Color3.fromRGB(157, 102, 255)
|
|
local lilac = Color3.fromRGB(230, 210, 255)
|
|
local white = Color3.fromRGB(255, 247, 240)
|
|
local streakShape = NumberSequence.new({
|
|
NumberSequenceKeypoint.new(0, 1),
|
|
NumberSequenceKeypoint.new(.32, .62),
|
|
NumberSequenceKeypoint.new(.83, 0),
|
|
NumberSequenceKeypoint.new(1, .2),
|
|
})
|
|
local edgeShape = NumberSequence.new({
|
|
NumberSequenceKeypoint.new(0, 0),
|
|
NumberSequenceKeypoint.new(.34, .59),
|
|
NumberSequenceKeypoint.new(1, 1),
|
|
})
|
|
local jumpDuration = 1.05
|
|
|
|
local function frame(name: string, parent: Instance, color: Color3?): Frame
|
|
local item = Instance.new("Frame")
|
|
item.Name = name
|
|
item.BorderSizePixel = 0
|
|
item.BackgroundTransparency = 1
|
|
item.AnchorPoint = Vector2.new(.5, .5)
|
|
if color then item.BackgroundColor3 = color end
|
|
item.Parent = parent
|
|
return item
|
|
end
|
|
|
|
local function gradient(parent: Frame, transparency: NumberSequence, rotation: number, color: ColorSequence?)
|
|
local effect = Instance.new("UIGradient")
|
|
effect.Transparency = transparency
|
|
effect.Rotation = rotation
|
|
if color then effect.Color = color end
|
|
effect.Parent = parent
|
|
end
|
|
|
|
function ArenaMobilityScreen.new(parent: PlayerGui)
|
|
local gui = Instance.new("ScreenGui")
|
|
gui.Name = "ArenaMobilityScreen"
|
|
gui.ResetOnSpawn = false
|
|
gui.ScreenInsets = Enum.ScreenInsets.None
|
|
gui.DisplayOrder = 8
|
|
gui.Enabled = false
|
|
|
|
local speedLayer = frame("Speed", gui)
|
|
speedLayer.Position = UDim2.fromScale(.5, .5)
|
|
speedLayer.Size = UDim2.fromScale(1, 1)
|
|
local jumpLayer = frame("JumpMagic", gui)
|
|
jumpLayer.Position = speedLayer.Position
|
|
jumpLayer.Size = speedLayer.Size
|
|
local random = Random.new(606)
|
|
|
|
local streaks: {Streak} = {}
|
|
for i = 1, 32 do
|
|
local angle = (i + random:NextNumber(-.35, .35)) * math.pi / 16
|
|
local tint = gold:Lerp(coral, random:NextNumber(0, .76))
|
|
local halo = frame("SpeedStreak", speedLayer, tint)
|
|
local stroke = frame("Core", halo, white)
|
|
stroke.Position = UDim2.fromScale(.5, .5)
|
|
stroke.Size = UDim2.fromScale(1, .32)
|
|
gradient(halo, streakShape, 0)
|
|
gradient(stroke, streakShape, 0, ColorSequence.new(tint, white))
|
|
table.insert(streaks, {
|
|
halo = halo, core = stroke, direction = Vector2.new(math.cos(angle), math.sin(angle)),
|
|
offset = random:NextNumber(), speed = random:NextNumber(.78, 1.50), length = random:NextNumber(.65, 1.46),
|
|
})
|
|
end
|
|
|
|
local glows: {Frame} = {}
|
|
local sigils: {Sigil} = {}
|
|
local sparks: {Spark} = {}
|
|
for _, side in {-1, 1} do
|
|
local glow = frame("SideAura", jumpLayer, violet)
|
|
glow.AnchorPoint = Vector2.new(if side == -1 then 0 else 1, .5)
|
|
glow.Position = UDim2.fromScale(if side == -1 then 0 else 1, .5)
|
|
glow.Size = UDim2.fromScale(.25, 1)
|
|
gradient(glow, edgeShape, if side == -1 then 0 else 180, ColorSequence.new(white, lilac))
|
|
table.insert(glows, glow)
|
|
for i = 1, 6 do
|
|
local root = frame("Sigil", jumpLayer)
|
|
root.Size = UDim2.fromOffset(34, 34)
|
|
local scale = Instance.new("UIScale")
|
|
scale.Parent = root
|
|
local diamond = frame("Diamond", root)
|
|
diamond.Position = UDim2.fromScale(.5, .5)
|
|
diamond.Size = UDim2.fromScale(.44, .44)
|
|
diamond.Rotation = 45
|
|
local outline = Instance.new("UIStroke")
|
|
outline.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
|
|
outline.Color = if i % 2 == 0 then violet else lilac
|
|
outline.Thickness = 1.4
|
|
outline.Parent = diamond
|
|
local stars: {Frame} = {}
|
|
for j = -1, 1 do
|
|
local star = frame("Star", root, if j == 0 then white else lilac)
|
|
star.Position = UDim2.fromScale(.5, .5 + j * .33)
|
|
star.Size = if j == 0 then UDim2.fromOffset(5, 5) else UDim2.fromOffset(3, 3)
|
|
star.Rotation = 45
|
|
table.insert(stars, star)
|
|
end
|
|
table.insert(sigils, {root = root, scale = scale, diamond = outline, stars = stars, side = side, index = i})
|
|
end
|
|
for i = 1, 15 do
|
|
local spark = frame("Spark", jumpLayer, violet:Lerp(lilac, random:NextNumber(.3, 1)))
|
|
table.insert(sparks, {
|
|
frame = spark, side = side, offset = random:NextNumber() * .48, x = random:NextNumber(.033, .24),
|
|
lift = random:NextNumber(.25, .66), bend = random:NextNumber(-.045, .045), size = random:NextNumber(2, 7),
|
|
})
|
|
end
|
|
end
|
|
|
|
gui.Parent = parent
|
|
local boostBegan, boostEnds, jumpBegan = 0, 0, 0
|
|
local function boost(now: number, expiry: number)
|
|
boostBegan, boostEnds = now, expiry
|
|
end
|
|
local function jump(now: number)
|
|
jumpBegan = now
|
|
end
|
|
local function reset()
|
|
boostBegan, boostEnds, jumpBegan = 0, 0, 0
|
|
gui.Enabled = false
|
|
end
|
|
|
|
local function render(now: number, aiming: boolean)
|
|
local boosted = boostEnds > 0 and now < boostEnds + .21
|
|
local airborne = jumpBegan > 0 and now - jumpBegan < jumpDuration
|
|
gui.Enabled = boosted or airborne
|
|
if not gui.Enabled then return end
|
|
local subdued = if aiming then .28 else 1
|
|
local size = gui.AbsoluteSize
|
|
speedLayer.Visible = boosted
|
|
jumpLayer.Visible = airborne
|
|
|
|
if boosted then
|
|
local age = now - boostBegan
|
|
local attack = math.clamp((age + .025) / .16, 0, 1)
|
|
local release = math.clamp((boostEnds + .21 - now) / .33, 0, 1)
|
|
local intensity = attack * release * subdued
|
|
for _, streak in streaks do
|
|
local t = (age * streak.speed + streak.offset) % 1
|
|
local dx, dy = streak.direction.X, streak.direction.Y
|
|
local edge = math.max(math.abs(dx), math.abs(dy))
|
|
local distance = (.67 + .42 * t) / edge
|
|
local length = size.Y * (.027 + .079 * t) * streak.length
|
|
local visibility = math.sin(math.pi * t) ^ .6 * intensity
|
|
streak.halo.Position = UDim2.fromScale(.5 + .5 * dx * distance, .5 + .5 * dy * distance)
|
|
streak.halo.Size = UDim2.fromOffset(length, math.max(3, 5.4 * streak.length))
|
|
streak.halo.Rotation = math.deg(math.atan2(dy * size.Y, dx * size.X))
|
|
streak.halo.BackgroundTransparency = 1 - visibility * .30
|
|
streak.core.BackgroundTransparency = 1 - visibility * .86
|
|
end
|
|
end
|
|
|
|
if airborne then
|
|
local age = now - jumpBegan
|
|
local t = math.clamp(age / jumpDuration, 0, 1)
|
|
local flare = (1 - t) ^ 2 * math.clamp((age + .025) / .09, 0, 1) * subdued
|
|
for _, glow in glows do glow.BackgroundTransparency = 1 - flare * .34 end
|
|
for _, sigil in sigils do
|
|
local lift = (sigil.index - 1) / 5
|
|
local phase = math.clamp((age - lift * .10) / .82, 0, 1)
|
|
local fade = math.sin(phase * math.pi) ^ 1.25 * subdued
|
|
local x = .5 + sigil.side * (.405 - .055 * math.sin(lift * math.pi) + .045 * phase)
|
|
local y = .92 - lift * .49 - .26 * phase
|
|
sigil.root.Position = UDim2.fromScale(x, y)
|
|
sigil.root.Rotation = sigil.side * (25 - lift * 40 + phase * 36)
|
|
sigil.scale.Scale = .75 + .42 * math.sin(math.pi * phase) + lift * .23
|
|
sigil.diamond.Transparency = 1 - fade * .85
|
|
for _, star in sigil.stars do star.BackgroundTransparency = 1 - fade * .96 end
|
|
end
|
|
for _, spark in sparks do
|
|
local p = math.clamp((age - spark.offset) / .50, 0, 1)
|
|
local x = .5 + spark.side * (.5 - spark.x + spark.bend * p)
|
|
spark.frame.Position = UDim2.fromScale(x, .98 - spark.lift * p - spark.offset * .32)
|
|
spark.frame.Rotation = 45 + spark.side * 95 * p
|
|
local size = spark.size * (1 - .48 * p)
|
|
spark.frame.Size = UDim2.fromOffset(size, size)
|
|
spark.frame.BackgroundTransparency = 1 - math.sin(p * math.pi) * .85 * subdued
|
|
end
|
|
end
|
|
end
|
|
|
|
return {
|
|
boost = boost, jump = jump, render = render, reset = reset,
|
|
destroy = function() gui:Destroy() end,
|
|
}
|
|
end
|
|
|
|
return ArenaMobilityScreen
|