1805 lines
77 KiB
Lua
1805 lines
77 KiB
Lua
-- FishingClient (LocalScript) -> StarterPlayer > StarterPlayerScripts
|
||
-- Интерфейс: HUD, сумка, коллекция с наградами, миры, задания, ежедневная награда,
|
||
-- магазин, улучшения, удача, донат, событие, мини-игра, атмосфера миров.
|
||
|
||
local Players = game:GetService("Players")
|
||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||
local RunService = game:GetService("RunService")
|
||
local TweenService = game:GetService("TweenService")
|
||
local UserInputService = game:GetService("UserInputService")
|
||
local MarketplaceService = game:GetService("MarketplaceService")
|
||
local Lighting = game:GetService("Lighting")
|
||
|
||
local player = Players.LocalPlayer
|
||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||
local Models = require(ReplicatedStorage:WaitForChild("GameModels"))
|
||
local remote = ReplicatedStorage:WaitForChild("GameEvent")
|
||
|
||
---------------------------------------------------------------- стиль
|
||
|
||
local C = {
|
||
bg = Color3.fromRGB(18, 24, 40),
|
||
panel = Color3.fromRGB(30, 38, 62),
|
||
panel2 = Color3.fromRGB(44, 56, 90),
|
||
gold = Color3.fromRGB(255, 200, 70),
|
||
green = Color3.fromRGB(60, 190, 95),
|
||
blue = Color3.fromRGB(60, 135, 230),
|
||
red = Color3.fromRGB(215, 65, 65),
|
||
purple = Color3.fromRGB(150, 90, 220),
|
||
grey = Color3.fromRGB(75, 82, 102),
|
||
text = Color3.new(1, 1, 1),
|
||
muted = Color3.fromRGB(170, 180, 205),
|
||
line = Color3.fromRGB(90, 110, 165),
|
||
}
|
||
local TITLE = Enum.Font.FredokaOne
|
||
local BODY = Enum.Font.GothamBold
|
||
local BODY2 = Enum.Font.GothamMedium
|
||
local WHITE, BLACK = Color3.new(1, 1, 1), Color3.new(0, 0, 0)
|
||
local DING = "rbxasset://sounds/electronicpingshort.wav"
|
||
|
||
---------------------------------------------------------------- помощники UI
|
||
|
||
local function new(class, props, children)
|
||
local obj = Instance.new(class)
|
||
local parent
|
||
for k, v in pairs(props or {}) do
|
||
if k == "Parent" then
|
||
parent = v
|
||
else
|
||
obj[k] = v
|
||
end
|
||
end
|
||
for _, c in ipairs(children or {}) do
|
||
c.Parent = obj
|
||
end
|
||
if parent then
|
||
obj.Parent = parent
|
||
end
|
||
return obj
|
||
end
|
||
local function corner(r)
|
||
return new("UICorner", { CornerRadius = UDim.new(0, r or 10) })
|
||
end
|
||
local function stroke(color, th, tr)
|
||
return new("UIStroke", { Color = color, Thickness = th or 2, Transparency = tr or 0, ApplyStrokeMode = Enum.ApplyStrokeMode.Border })
|
||
end
|
||
local function gradient(a, b, rot)
|
||
return new("UIGradient", { Color = ColorSequence.new(a, b), Rotation = rot or 90 })
|
||
end
|
||
local function text(props)
|
||
local d = {
|
||
BackgroundTransparency = 1, Font = BODY, TextColor3 = C.text, TextSize = 16,
|
||
TextXAlignment = Enum.TextXAlignment.Left, TextYAlignment = Enum.TextYAlignment.Center,
|
||
}
|
||
for k, v in pairs(props) do
|
||
d[k] = v
|
||
end
|
||
return new("TextLabel", d)
|
||
end
|
||
local function btn(props, onClick)
|
||
local d = { AutoButtonColor = true, Font = TITLE, TextColor3 = C.text, TextSize = 18, BackgroundColor3 = C.blue, Text = "" }
|
||
for k, v in pairs(props) do
|
||
d[k] = v
|
||
end
|
||
local b = new("TextButton", d, { corner(10), new("UIGradient", { Color = ColorSequence.new(WHITE, Color3.fromRGB(195, 195, 195)), Rotation = 90 }) })
|
||
if onClick then
|
||
b.MouseButton1Click:Connect(onClick)
|
||
end
|
||
return b
|
||
end
|
||
local function clear(container)
|
||
for _, c in ipairs(container:GetChildren()) do
|
||
if c:IsA("GuiObject") then
|
||
c:Destroy()
|
||
end
|
||
end
|
||
end
|
||
local function fmt(n)
|
||
local s = tostring(math.floor(n))
|
||
local out = s:reverse():gsub("(%d%d%d)", "%1 "):reverse()
|
||
return (out:gsub("^ ", ""))
|
||
end
|
||
local function stars(n)
|
||
return string.rep("★", n) .. string.rep("☆", Config.RodUpgrade.maxLevel - n)
|
||
end
|
||
local function hex(c)
|
||
return "#" .. c:ToHex()
|
||
end
|
||
local function timeStr(sec)
|
||
sec = math.max(0, math.floor(sec))
|
||
return ("%d:%02d"):format(math.floor(sec / 60), sec % 60)
|
||
end
|
||
local function attrSet(name)
|
||
local set = {}
|
||
for id in string.gmatch(player:GetAttribute(name) or "", "[^,]+") do
|
||
set[id] = true
|
||
end
|
||
return set
|
||
end
|
||
local function rodLevels()
|
||
local t = {}
|
||
for id, lv in string.gmatch(player:GetAttribute("RodLevels") or "", "([^,:]+):(%d+)") do
|
||
t[id] = tonumber(lv)
|
||
end
|
||
return t
|
||
end
|
||
local function playUiSound(id, vol)
|
||
local s = Instance.new("Sound")
|
||
s.SoundId = id
|
||
s.Volume = vol or 0.5
|
||
s.Parent = workspace.CurrentCamera
|
||
s:Play()
|
||
game:GetService("Debris"):AddItem(s, 3)
|
||
end
|
||
|
||
local function viewport(parent, model, dir, zoom)
|
||
local vf = new("ViewportFrame", {
|
||
Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1,
|
||
Ambient = Color3.fromRGB(175, 175, 185), LightColor = WHITE, LightDirection = Vector3.new(-0.4, -1, -0.6),
|
||
Parent = parent,
|
||
})
|
||
model.Parent = vf
|
||
local cf, size = model:GetBoundingBox()
|
||
local cam = Instance.new("Camera")
|
||
cam.FieldOfView = 30
|
||
local dist = (size.Magnitude / 2) / math.tan(math.rad(15)) * (zoom or 0.9)
|
||
cam.CFrame = CFrame.lookAt(cf.Position + dir.Unit * dist, cf.Position)
|
||
cam.Parent = vf
|
||
vf.CurrentCamera = cam
|
||
return vf
|
||
end
|
||
local FISH_VIEW = Vector3.new(0.12, 0.15, 1)
|
||
local ROD_VIEW = Vector3.new(1, 0.1, 0.05)
|
||
local BAG_VIEW = Vector3.new(0.6, 0.25, 1)
|
||
|
||
local function silhouette(model)
|
||
for _, p in ipairs(model:GetDescendants()) do
|
||
if p:IsA("BasePart") then
|
||
p.Color = Color3.fromRGB(10, 12, 20)
|
||
p.Material = Enum.Material.SmoothPlastic
|
||
elseif p:IsA("ParticleEmitter") or p:IsA("PointLight") then
|
||
p:Destroy()
|
||
end
|
||
end
|
||
return model
|
||
end
|
||
|
||
---------------------------------------------------------------- корень
|
||
|
||
local gui = new("ScreenGui", {
|
||
Name = "FishingUI", ResetOnSpawn = false, IgnoreGuiInset = false,
|
||
ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = player:WaitForChild("PlayerGui"),
|
||
})
|
||
|
||
---------------------------------------------------------------- HUD
|
||
|
||
local hud = new("Frame", {
|
||
Size = UDim2.fromOffset(290, 172), Position = UDim2.fromOffset(12, 10), BackgroundColor3 = WHITE, Parent = gui,
|
||
}, { corner(16), stroke(C.line, 2, 0.35), gradient(C.panel2, C.bg, 90),
|
||
new("UIPadding", { PaddingLeft = UDim.new(0, 14), PaddingRight = UDim.new(0, 14), PaddingTop = UDim.new(0, 10) }) })
|
||
local coinsText = text({ Size = UDim2.new(1, 0, 0, 32), Font = TITLE, TextSize = 30, TextColor3 = C.gold, Text = "💰 0", TextStrokeTransparency = 0.6, Parent = hud })
|
||
local lvlBadge = new("Frame", { Size = UDim2.fromOffset(36, 36), Position = UDim2.fromOffset(0, 38), BackgroundColor3 = WHITE, Parent = hud },
|
||
{ corner(18), gradient(Color3.fromRGB(255, 225, 110), Color3.fromRGB(235, 145, 30), 90), stroke(Color3.fromRGB(120, 70, 10), 2, 0.2) })
|
||
local lvlText = text({ Size = UDim2.fromScale(1, 1), Font = TITLE, TextSize = 19, TextXAlignment = Enum.TextXAlignment.Center, TextColor3 = Color3.fromRGB(70, 40, 0), Text = "1", Parent = lvlBadge })
|
||
local xpBack = new("Frame", { Size = UDim2.new(1, -46, 0, 18), Position = UDim2.fromOffset(46, 47), BackgroundColor3 = Color3.fromRGB(14, 18, 30), Parent = hud }, { corner(9) })
|
||
local xpFill = new("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = WHITE, Parent = xpBack }, { corner(9), gradient(Color3.fromRGB(110, 225, 255), Color3.fromRGB(60, 110, 255), 0) })
|
||
local xpText = text({ Size = UDim2.fromScale(1, 1), TextSize = 12, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 2, Text = "", TextStrokeTransparency = 0.5, Parent = xpBack })
|
||
local luckText = text({ Size = UDim2.new(1, 0, 0, 22), Position = UDim2.fromOffset(0, 82), TextSize = 16, RichText = true, TextColor3 = Color3.fromRGB(130, 255, 150), Text = "", Parent = hud })
|
||
local bagText = text({ Size = UDim2.new(1, 0, 0, 20), Position = UDim2.fromOffset(0, 106), TextSize = 14, Font = BODY2, Text = "", Parent = hud })
|
||
local rodText = text({ Size = UDim2.new(1, 0, 0, 20), Position = UDim2.fromOffset(0, 128), TextSize = 14, Font = BODY2, TextColor3 = C.muted, RichText = true, Text = "", Parent = hud })
|
||
|
||
-- баннер события (справа сверху)
|
||
local eventBanner = new("Frame", {
|
||
Size = UDim2.fromOffset(280, 58), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 10),
|
||
BackgroundColor3 = WHITE, Visible = false, Parent = gui,
|
||
}, { corner(14), stroke(C.gold, 2, 0.1), gradient(Color3.fromRGB(90, 60, 20), C.bg, 90) })
|
||
local eventTitle = text({ Size = UDim2.new(1, -20, 0, 26), Position = UDim2.fromOffset(12, 4), Font = TITLE, TextSize = 19, TextColor3 = C.gold, Text = "", Parent = eventBanner })
|
||
local eventDesc = text({ Size = UDim2.new(1, -20, 0, 20), Position = UDim2.fromOffset(12, 30), Font = BODY2, TextSize = 13, TextColor3 = C.text, Text = "", Parent = eventBanner })
|
||
|
||
-- кнопки слева
|
||
local side = new("Frame", {
|
||
Size = UDim2.fromOffset(70, 380), AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0, 12, 0.5, 60),
|
||
BackgroundTransparency = 1, Parent = gui,
|
||
}, { new("UIListLayout", { Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }) })
|
||
|
||
local sideDots = {}
|
||
local function sideButton(order, icon, label, key, color, onClick)
|
||
local b = btn({ Size = UDim2.fromOffset(68, 68), BackgroundColor3 = color, LayoutOrder = order, Parent = side }, onClick)
|
||
stroke(color:Lerp(BLACK, 0.45), 3).Parent = b
|
||
text({ Size = UDim2.new(1, 0, 0, 36), Position = UDim2.fromOffset(0, 3), TextSize = 28, TextXAlignment = Enum.TextXAlignment.Center, Text = icon, Parent = b })
|
||
text({ Size = UDim2.new(1, 0, 0, 18), Position = UDim2.fromOffset(0, 44), Font = TITLE, TextSize = 13, TextXAlignment = Enum.TextXAlignment.Center, Text = label, TextStrokeTransparency = 0.5, Parent = b })
|
||
if key and not UserInputService.TouchEnabled then
|
||
local tag = new("Frame", { Size = UDim2.fromOffset(20, 20), Position = UDim2.new(1, -14, 0, -6), BackgroundColor3 = C.bg, Parent = b }, { corner(6), stroke(C.gold, 1.5) })
|
||
text({ Size = UDim2.fromScale(1, 1), Font = TITLE, TextSize = 12, TextXAlignment = Enum.TextXAlignment.Center, TextColor3 = C.gold, Text = key, Parent = tag })
|
||
end
|
||
local dot = new("Frame", { Size = UDim2.fromOffset(16, 16), Position = UDim2.new(0, -5, 0, -5), BackgroundColor3 = C.red, Visible = false, ZIndex = 3, Parent = b }, { corner(8), stroke(WHITE, 2) })
|
||
sideDots[label] = dot
|
||
return b
|
||
end
|
||
|
||
---------------------------------------------------------------- уведомления
|
||
|
||
local toasts = new("Frame", {
|
||
Size = UDim2.new(0, 560, 0, 200), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 8),
|
||
BackgroundTransparency = 1, Parent = gui,
|
||
}, { new("UIListLayout", { Padding = UDim.new(0, 6), HorizontalAlignment = Enum.HorizontalAlignment.Center, SortOrder = Enum.SortOrder.LayoutOrder }) })
|
||
local toastOrder = 0
|
||
local toastTimers = {}
|
||
|
||
local function notify(msg, color)
|
||
-- такое же сообщение уже на экране — не дублируем, а продлеваем его
|
||
for _, c in ipairs(toasts:GetChildren()) do
|
||
if c:IsA("Frame") and c:GetAttribute("Msg") == msg then
|
||
toastTimers[c] = (toastTimers[c] or 0) + 1
|
||
local my = toastTimers[c]
|
||
task.delay(3.2, function()
|
||
if c.Parent and toastTimers[c] == my then
|
||
c:Destroy()
|
||
end
|
||
end)
|
||
return
|
||
end
|
||
end
|
||
toastOrder += 1
|
||
local items = {}
|
||
for _, c in ipairs(toasts:GetChildren()) do
|
||
if c:IsA("Frame") then
|
||
table.insert(items, c)
|
||
end
|
||
end
|
||
if #items >= 3 then
|
||
items[1]:Destroy()
|
||
end
|
||
local t = new("Frame", {
|
||
Size = UDim2.new(0, 0, 0, 38), AutomaticSize = Enum.AutomaticSize.X, BackgroundColor3 = C.bg,
|
||
BackgroundTransparency = 0.15, LayoutOrder = toastOrder, Parent = toasts,
|
||
}, { corner(12), stroke(color or WHITE, 2, 0.2), new("UIPadding", { PaddingLeft = UDim.new(0, 16), PaddingRight = UDim.new(0, 16) }) })
|
||
local l = text({ Size = UDim2.new(0, 0, 1, 0), AutomaticSize = Enum.AutomaticSize.X, Font = TITLE, TextSize = 19, TextColor3 = color or WHITE, Text = msg, Parent = t })
|
||
t:SetAttribute("Msg", msg)
|
||
toastTimers[t] = 0
|
||
task.delay(3.2, function()
|
||
if t.Parent and toastTimers[t] == 0 then
|
||
TweenService:Create(t, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play()
|
||
TweenService:Create(l, TweenInfo.new(0.4), { TextTransparency = 1 }):Play()
|
||
task.wait(0.45)
|
||
t:Destroy()
|
||
end
|
||
end)
|
||
end
|
||
|
||
-- карточка пойманной рыбы
|
||
local catchCard = new("Frame", {
|
||
Size = UDim2.fromOffset(400, 128), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, -220),
|
||
BackgroundColor3 = WHITE, Visible = false, Parent = gui,
|
||
}, { corner(18) })
|
||
local catchStroke = stroke(WHITE, 3)
|
||
catchStroke.Parent = catchCard
|
||
local catchGrad = gradient(C.panel2, C.bg, 90)
|
||
catchGrad.Parent = catchCard
|
||
local catchView = new("Frame", { Size = UDim2.fromOffset(130, 108), Position = UDim2.fromOffset(10, 10), BackgroundColor3 = C.bg, BackgroundTransparency = 0.3, Parent = catchCard }, { corner(14) })
|
||
local catchHeader = text({ Size = UDim2.new(1, -160, 0, 20), Position = UDim2.fromOffset(152, 10), Font = TITLE, TextSize = 15, TextColor3 = C.muted, Text = "", Parent = catchCard })
|
||
local catchName = text({ Size = UDim2.new(1, -160, 0, 30), Position = UDim2.fromOffset(152, 30), Font = TITLE, TextSize = 26, Text = "", TextStrokeTransparency = 0.6, Parent = catchCard })
|
||
local catchInfo = text({ Size = UDim2.new(1, -160, 0, 20), Position = UDim2.fromOffset(152, 64), TextSize = 15, RichText = true, Text = "", Parent = catchCard })
|
||
local catchValue = text({ Size = UDim2.new(1, -160, 0, 26), Position = UDim2.fromOffset(152, 90), Font = TITLE, TextSize = 21, TextColor3 = C.gold, Text = "", Parent = catchCard })
|
||
local catchToken = 0
|
||
|
||
local function showCatch(fish, extra)
|
||
catchToken += 1
|
||
local my = catchToken
|
||
local r = Config.Rarities[fish.rarity]
|
||
local mut = fish.mutation and Config.Find(Config.Mutations, fish.mutation)
|
||
clear(catchView)
|
||
viewport(catchView, Models.buildFish(fish.id, fish.mutation, 1, true), FISH_VIEW, 0.75)
|
||
catchStroke.Color = mut and mut.color or r.color
|
||
catchGrad.Color = ColorSequence.new(r.color:Lerp(C.bg, 0.55), C.bg)
|
||
catchHeader.Text = extra and extra.new and "🆕 НОВЫЙ ВИД! Опыт x2" or (extra and extra.record and "🏆 НОВЫЙ РЕКОРД!" or "ПОЙМАНА РЫБА")
|
||
catchHeader.TextColor3 = (extra and (extra.new or extra.record)) and C.gold or C.muted
|
||
catchName.Text = fish.name
|
||
catchName.TextColor3 = r.color
|
||
catchInfo.Text = ("<font color=\"%s\">%s</font>%s · %.2f кг"):format(
|
||
hex(r.color), r.name, mut and (" · <font color=\"" .. hex(mut.color) .. "\">" .. mut.name .. " x" .. mut.mult .. "</font>") or "", fish.weight)
|
||
catchValue.Text = ("💰 %s ⭐ +%d XP"):format(fmt(fish.value), fish.xp * ((extra and extra.new) and 2 or 1))
|
||
catchCard.Visible = true
|
||
TweenService:Create(catchCard, TweenInfo.new(0.45, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Position = UDim2.new(0.5, 0, 0, 120) }):Play()
|
||
task.delay(3.4, function()
|
||
if my == catchToken then
|
||
local tw = TweenService:Create(catchCard, TweenInfo.new(0.35, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { Position = UDim2.new(0.5, 0, 0, -220) })
|
||
tw:Play()
|
||
tw.Completed:Wait()
|
||
if my == catchToken then
|
||
catchCard.Visible = false
|
||
end
|
||
end
|
||
end)
|
||
end
|
||
|
||
local function floatText(msg, color)
|
||
local l = text({
|
||
Size = UDim2.fromOffset(400, 60), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.42),
|
||
Font = TITLE, TextSize = 46, TextXAlignment = Enum.TextXAlignment.Center, TextColor3 = color,
|
||
TextStrokeTransparency = 0.2, Text = msg, Parent = gui,
|
||
})
|
||
TweenService:Create(l, TweenInfo.new(1.4, Enum.EasingStyle.Quad), { Position = UDim2.fromScale(0.5, 0.3), TextTransparency = 1, TextStrokeTransparency = 1 }):Play()
|
||
task.delay(1.5, function()
|
||
l:Destroy()
|
||
end)
|
||
end
|
||
|
||
---------------------------------------------------------------- статус и мини-игра
|
||
|
||
local statusLabel = text({
|
||
Size = UDim2.fromOffset(460, 34), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -110),
|
||
Font = TITLE, TextSize = 22, TextXAlignment = Enum.TextXAlignment.Center, TextStrokeTransparency = 0.3,
|
||
Text = "🎣 Ждём поклёвку… (клик — смотать)", Visible = false, Parent = gui,
|
||
})
|
||
local mgFrame = new("Frame", {
|
||
Size = UDim2.fromOffset(480, 124), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -100),
|
||
BackgroundColor3 = WHITE, Visible = false, Parent = gui,
|
||
}, { corner(16), stroke(C.gold, 2.5, 0.1), gradient(C.panel2, C.bg, 90) })
|
||
text({
|
||
Size = UDim2.new(1, 0, 0, 30), Position = UDim2.fromOffset(0, 6), Font = TITLE, TextSize = 24,
|
||
TextXAlignment = Enum.TextXAlignment.Center, TextColor3 = C.gold, TextStrokeTransparency = 0.5,
|
||
Text = "❗ КЛЮЁТ! Кликай, когда метка в зелёной зоне", Parent = mgFrame,
|
||
})
|
||
local bar = new("Frame", { Size = UDim2.new(1, -30, 0, 36), Position = UDim2.fromOffset(15, 42), BackgroundColor3 = Color3.fromRGB(22, 28, 46), ClipsDescendants = true, Parent = mgFrame }, { corner(9), stroke(BLACK, 1.5, 0.4) })
|
||
local zoneF = new("Frame", { Size = UDim2.fromScale(0.25, 1), BackgroundColor3 = WHITE, BorderSizePixel = 0, Parent = bar }, { gradient(Color3.fromRGB(130, 245, 150), Color3.fromRGB(35, 165, 75), 90) })
|
||
local markerF = new("Frame", { Size = UDim2.new(0, 8, 1, 4), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0, 0.5), BackgroundColor3 = WHITE, ZIndex = 3, Parent = bar }, { corner(4), stroke(BLACK, 2) })
|
||
local pipsText = text({ Size = UDim2.new(0.5, -15, 0, 24), Position = UDim2.fromOffset(15, 84), Font = TITLE, TextSize = 19, RichText = true, Text = "", Parent = mgFrame })
|
||
local missText = text({ Size = UDim2.new(0.5, -15, 0, 24), Position = UDim2.new(0.5, 0, 0, 84), Font = TITLE, TextSize = 19, TextXAlignment = Enum.TextXAlignment.Right, RichText = true, Text = "", Parent = mgFrame })
|
||
local timeBar = new("Frame", { Size = UDim2.new(1, -30, 0, 5), Position = UDim2.fromOffset(15, 112), BackgroundColor3 = C.gold, BorderSizePixel = 0, Parent = mgFrame }, { corner(3) })
|
||
|
||
---------------------------------------------------------------- окна
|
||
|
||
local openWindow = nil
|
||
|
||
local function makeWindow(title, accent, tabs)
|
||
local w = { pages = {}, tabButtons = {}, current = nil }
|
||
local frame = new("Frame", {
|
||
Size = UDim2.fromScale(0.92, 0.82), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.53),
|
||
BackgroundColor3 = WHITE, Visible = false, Parent = gui,
|
||
}, { corner(20), stroke(accent, 3, 0.05), gradient(C.panel, C.bg, 90), new("UISizeConstraint", { MaxSize = Vector2.new(760, 540) }) })
|
||
local scale = new("UIScale", { Parent = frame })
|
||
local header = new("Frame", { Size = UDim2.new(1, 0, 0, 56), BackgroundColor3 = WHITE, Parent = frame }, { corner(20), gradient(accent, accent:Lerp(BLACK, 0.35), 90) })
|
||
new("Frame", { Size = UDim2.new(1, 0, 0, 20), Position = UDim2.new(0, 0, 1, -20), BackgroundColor3 = accent:Lerp(BLACK, 0.3), BorderSizePixel = 0, Parent = header })
|
||
text({ Size = UDim2.new(1, -80, 1, 0), Position = UDim2.fromOffset(20, 0), Font = TITLE, TextSize = 30, Text = title, TextStrokeTransparency = 0.5, ZIndex = 2, Parent = header })
|
||
btn({ Size = UDim2.fromOffset(42, 42), Position = UDim2.new(1, -52, 0, 7), BackgroundColor3 = C.red, Text = "✕", TextSize = 22, ZIndex = 3, Parent = header }, function()
|
||
w.close()
|
||
end)
|
||
local hasTabs = #tabs > 1
|
||
local tabBar = new("Frame", { Size = UDim2.new(1, -28, 0, 42), Position = UDim2.fromOffset(14, 66), BackgroundTransparency = 1, Visible = hasTabs, Parent = frame },
|
||
{ new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }) })
|
||
local top = hasTabs and 116 or 68
|
||
local body = new("Frame", { Size = UDim2.new(1, -28, 1, -(top + 12)), Position = UDim2.fromOffset(14, top), BackgroundTransparency = 1, Parent = frame })
|
||
w.frame = frame
|
||
|
||
function w.setTab(id)
|
||
w.current = id
|
||
for k, page in pairs(w.pages) do
|
||
page.Visible = (k == id)
|
||
end
|
||
for k, b in pairs(w.tabButtons) do
|
||
b.BackgroundColor3 = (k == id) and accent or C.panel2
|
||
end
|
||
if w.render then
|
||
w.render(id)
|
||
end
|
||
end
|
||
for i, t in ipairs(tabs) do
|
||
w.pages[t.id] = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1, Visible = false, Parent = body })
|
||
w.tabButtons[t.id] = btn({ Size = UDim2.new(1 / #tabs, -8, 1, 0), Text = t.label, TextSize = 18, BackgroundColor3 = C.panel2, LayoutOrder = i, Parent = tabBar }, function()
|
||
w.setTab(t.id)
|
||
end)
|
||
end
|
||
function w.open(tab)
|
||
if openWindow and openWindow ~= w then
|
||
openWindow.close()
|
||
end
|
||
openWindow = w
|
||
frame.Visible = true
|
||
scale.Scale = 0.85
|
||
TweenService:Create(scale, TweenInfo.new(0.25, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }):Play()
|
||
w.setTab(tab or w.current or tabs[1].id)
|
||
end
|
||
function w.close()
|
||
frame.Visible = false
|
||
if openWindow == w then
|
||
openWindow = nil
|
||
end
|
||
end
|
||
function w.isOpen()
|
||
return frame.Visible
|
||
end
|
||
function w.toggle(tab)
|
||
if frame.Visible and (tab == nil or w.current == tab) then
|
||
w.close()
|
||
else
|
||
w.open(tab)
|
||
end
|
||
end
|
||
function w.refresh()
|
||
if frame.Visible and w.render then
|
||
w.render(w.current)
|
||
end
|
||
end
|
||
return w
|
||
end
|
||
|
||
local function scrollArea(parent, cell, topOffset)
|
||
local sf = new("ScrollingFrame", {
|
||
Size = UDim2.new(1, 0, 1, -(topOffset or 0)), Position = UDim2.fromOffset(0, topOffset or 0),
|
||
BackgroundTransparency = 1, BorderSizePixel = 0, ScrollBarThickness = 6, ScrollBarImageColor3 = C.muted,
|
||
AutomaticCanvasSize = Enum.AutomaticSize.Y, CanvasSize = UDim2.new(), Parent = parent,
|
||
}, { new("UIPadding", { PaddingRight = UDim.new(0, 10), PaddingTop = UDim.new(0, 4), PaddingLeft = UDim.new(0, 2), PaddingBottom = UDim.new(0, 8) }) })
|
||
if cell then
|
||
new("UIGridLayout", { CellSize = cell, CellPadding = UDim2.fromOffset(10, 10), SortOrder = Enum.SortOrder.LayoutOrder, Parent = sf })
|
||
else
|
||
new("UIListLayout", { Padding = UDim.new(0, 10), SortOrder = Enum.SortOrder.LayoutOrder, Parent = sf })
|
||
end
|
||
return sf
|
||
end
|
||
|
||
local function itemRow(parent, order, o)
|
||
local row = new("Frame", { Size = UDim2.new(1, -4, 0, 100), BackgroundColor3 = WHITE, LayoutOrder = order, Parent = parent },
|
||
{ corner(14), stroke(o.strokeColor or C.line, 2, o.strokeColor and 0 or 0.45), gradient(C.panel2, C.panel, 90) })
|
||
local view = new("Frame", { Size = UDim2.fromOffset(124, 84), Position = UDim2.fromOffset(8, 8), BackgroundColor3 = o.iconBg or C.bg, Parent = row }, { corner(10) })
|
||
if o.model then
|
||
viewport(view, o.model, o.dir, o.zoom)
|
||
elseif o.icon then
|
||
text({ Size = UDim2.fromScale(1, 1), TextSize = 48, TextXAlignment = Enum.TextXAlignment.Center, Text = o.icon, Parent = view })
|
||
end
|
||
text({ Size = UDim2.new(1, -300, 0, 28), Position = UDim2.fromOffset(144, 8), Font = TITLE, TextSize = 22, Text = o.title, TextColor3 = o.titleColor or C.text, RichText = true, TextTruncate = Enum.TextTruncate.AtEnd, Parent = row })
|
||
text({
|
||
Size = UDim2.new(1, -300, 0, 56), Position = UDim2.fromOffset(144, 38), Font = BODY2, TextSize = 14, TextColor3 = C.muted,
|
||
RichText = true, TextWrapped = true, TextYAlignment = Enum.TextYAlignment.Top, Text = o.lines, Parent = row,
|
||
})
|
||
btn({
|
||
Size = UDim2.fromOffset(140, 50), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0),
|
||
Text = o.buttonText, BackgroundColor3 = o.buttonColor, AutoButtonColor = o.active, TextSize = 19, Parent = row,
|
||
}, o.active and o.onClick or nil)
|
||
return row
|
||
end
|
||
|
||
local function progressBar(parent, pos, size, frac, color)
|
||
local back = new("Frame", { Size = size, Position = pos, BackgroundColor3 = Color3.fromRGB(14, 18, 30), Parent = parent }, { corner(7) })
|
||
new("Frame", { Size = UDim2.fromScale(math.clamp(frac, 0, 1), 1), BackgroundColor3 = color, Parent = back }, { corner(7) })
|
||
return back
|
||
end
|
||
|
||
---------------------------------------------------------------- данные с сервера
|
||
|
||
local inventory, discovered, claimed = {}, {}, {}
|
||
local quests, daily = {}, { available = false, streak = 0, nextStreak = 1 }
|
||
|
||
---------------------------------------------------------------- магазин
|
||
|
||
local shopWin = makeWindow("🎣 Магазин Михалыча", Color3.fromRGB(215, 120, 40), {
|
||
{ id = "rods", label = "🎣 Удочки" },
|
||
{ id = "upgrade", label = "✨ Улучшение" },
|
||
{ id = "bags", label = "🎒 Сумки" },
|
||
{ id = "luck", label = "🍀 Удача" },
|
||
})
|
||
local shopLists = {
|
||
rods = scrollArea(shopWin.pages.rods),
|
||
upgrade = scrollArea(shopWin.pages.upgrade),
|
||
bags = scrollArea(shopWin.pages.bags),
|
||
luck = scrollArea(shopWin.pages.luck),
|
||
}
|
||
|
||
local function statLine(s)
|
||
return ("🍀 Удача <b>+%d%%</b> ⏱ Клёв <b>x%.2f</b> 🎯 Зона <b>%d%%</b>"):format(math.floor(s.luck * 100 + 0.5), s.speed, math.floor(s.zone * 100 + 0.5))
|
||
end
|
||
local function buyButton(price, level, myLevel, coins)
|
||
if myLevel < level then
|
||
return "🔒 Ур. " .. level, C.grey, false
|
||
end
|
||
return "💰 " .. fmt(price), coins >= price and C.green or Color3.fromRGB(150, 95, 60), true
|
||
end
|
||
|
||
shopWin.render = function(tab)
|
||
local list = shopLists[tab]
|
||
if not list then
|
||
return
|
||
end
|
||
clear(list)
|
||
local myLevel = player:GetAttribute("Level") or 1
|
||
local coins = player:GetAttribute("Coins") or 0
|
||
local levels = rodLevels()
|
||
|
||
if tab == "rods" then
|
||
local owned = attrSet("OwnedRods")
|
||
for i, rod in ipairs(Config.Rods) do
|
||
local lv = levels[rod.id] or 0
|
||
local equipped = player:GetAttribute("Rod") == rod.id
|
||
local bText, bColor, active
|
||
if equipped then
|
||
bText, bColor, active = "Надето ✓", C.grey, false
|
||
elseif owned[rod.id] then
|
||
bText, bColor, active = "Надеть", C.blue, true
|
||
else
|
||
bText, bColor, active = buyButton(rod.price, rod.level, myLevel, coins)
|
||
end
|
||
itemRow(list, i, {
|
||
model = Models.buildRod(rod.id, lv, true), dir = ROD_VIEW, zoom = 0.6,
|
||
title = rod.name .. (owned[rod.id] and (" <font color=\"#FFD45A\">" .. stars(lv) .. "</font>") or ""),
|
||
lines = statLine(Config.RodStats(rod.id, lv)) .. "\n" .. (owned[rod.id] and "Куплена" or ("Нужен уровень " .. rod.level)),
|
||
strokeColor = equipped and C.gold or nil,
|
||
buttonText = bText, buttonColor = bColor, active = active,
|
||
onClick = function()
|
||
remote:FireServer("Buy", "Rod", rod.id)
|
||
end,
|
||
})
|
||
end
|
||
elseif tab == "upgrade" then
|
||
text({
|
||
Size = UDim2.new(1, -4, 0, 40), LayoutOrder = 0, TextSize = 14, Font = BODY2, TextColor3 = C.muted, TextWrapped = true,
|
||
Text = "Каждое улучшение даёт +" .. math.floor(Config.RodUpgrade.luckPerLevel * 100) .. "% удачи, ускоряет клёв и расширяет зелёную зону. Максимум — " .. stars(Config.RodUpgrade.maxLevel),
|
||
Parent = list,
|
||
})
|
||
local owned = attrSet("OwnedRods")
|
||
local order = 0
|
||
for _, rod in ipairs(Config.Rods) do
|
||
if owned[rod.id] then
|
||
order += 1
|
||
local lv = levels[rod.id] or 0
|
||
local now = Config.RodStats(rod.id, lv)
|
||
local maxed = lv >= Config.RodUpgrade.maxLevel
|
||
local lines
|
||
if maxed then
|
||
lines = statLine(now) .. "\n<font color=\"#FFD45A\">Максимальное улучшение!</font>"
|
||
else
|
||
local nxt = Config.RodStats(rod.id, lv + 1)
|
||
lines = ("🍀 +%d%% → <font color=\"#7CFF9A\"><b>+%d%%</b></font> ⏱ x%.2f → <font color=\"#7CFF9A\"><b>x%.2f</b></font>\n🎯 %d%% → <font color=\"#7CFF9A\"><b>%d%%</b></font>"):format(
|
||
math.floor(now.luck * 100 + 0.5), math.floor(nxt.luck * 100 + 0.5), now.speed, nxt.speed,
|
||
math.floor(now.zone * 100 + 0.5), math.floor(nxt.zone * 100 + 0.5))
|
||
end
|
||
local cost = Config.UpgradeCost(rod, lv)
|
||
itemRow(list, order, {
|
||
model = Models.buildRod(rod.id, lv, true), dir = ROD_VIEW, zoom = 0.6,
|
||
title = rod.name .. " <font color=\"#FFD45A\">" .. stars(lv) .. "</font>",
|
||
lines = lines,
|
||
strokeColor = player:GetAttribute("Rod") == rod.id and C.gold or nil,
|
||
buttonText = maxed and "MAX ★" or ("✨ " .. fmt(cost)),
|
||
buttonColor = maxed and C.grey or (coins >= cost and Color3.fromRGB(190, 120, 255) or Color3.fromRGB(110, 80, 140)),
|
||
active = not maxed,
|
||
onClick = function()
|
||
remote:FireServer("Buy", "Upgrade", rod.id)
|
||
end,
|
||
})
|
||
end
|
||
end
|
||
elseif tab == "bags" then
|
||
local owned = attrSet("OwnedBags")
|
||
local bonus = attrSet("Passes").BigBag and 100 or 0
|
||
for i, bag in ipairs(Config.Bags) do
|
||
local equipped = player:GetAttribute("Bag") == bag.id
|
||
local bText, bColor, active
|
||
if equipped then
|
||
bText, bColor, active = "Надето ✓", C.grey, false
|
||
elseif owned[bag.id] then
|
||
bText, bColor, active = "Надеть", C.blue, true
|
||
else
|
||
bText, bColor, active = buyButton(bag.price, bag.level, myLevel, coins)
|
||
end
|
||
itemRow(list, i, {
|
||
model = Models.buildBag(bag.id, true), dir = BAG_VIEW, zoom = 0.8,
|
||
title = bag.name,
|
||
lines = ("🎒 Вмещает <b>%d</b> рыб%s\n%s"):format(bag.capacity + bonus, bonus > 0 and " (с пропуском)" or "", owned[bag.id] and "Куплена" or ("Нужен уровень " .. bag.level)),
|
||
strokeColor = equipped and C.gold or nil,
|
||
buttonText = bText, buttonColor = bColor, active = active,
|
||
onClick = function()
|
||
remote:FireServer("Buy", "Bag", bag.id)
|
||
end,
|
||
})
|
||
end
|
||
elseif tab == "luck" then
|
||
local lv = levels[player:GetAttribute("Rod") or "Basic"] or 0
|
||
local rod = Config.Find(Config.Rods, player:GetAttribute("Rod") or "Basic") or Config.Rods[1]
|
||
local boost = player:GetAttribute("BoostBonus") or 0
|
||
local total = player:GetAttribute("Luck") or 100
|
||
local ps = attrSet("Passes")
|
||
local evId = workspace:GetAttribute("Event")
|
||
local event = evId and Config.Find(Config.Events, evId)
|
||
local mutLine = {}
|
||
for _, m in ipairs(Config.Mutations) do
|
||
table.insert(mutLine, ("<font color=\"%s\">%s %.1f%%</font>"):format(hex(m.color), m.name, math.min(100, m.chance * total / 100 * ((event and event.mutation) or 1) * 100)))
|
||
end
|
||
local lines = {
|
||
("<font size=\"24\" face=\"FredokaOne\" color=\"#7CFF9A\">🍀 Твоя удача: %d%%</font>"):format(total),
|
||
("Базовая 100%% · 🎣 Удочка +%d%% · ✨ Улучшения +%d%%"):format(math.floor(rod.luck * 100 + 0.5), math.floor(lv * Config.RodUpgrade.luckPerLevel * 100 + 0.5)),
|
||
("⭐ Уровень +%d%% · 🏆 Мастерство миров +%d%%"):format(math.floor(((player:GetAttribute("Level") or 1) - 1) * Config.LuckPerPlayerLevel * 100 + 0.5), math.floor((player:GetAttribute("Mastery") or 0) * Config.MasteryLuck * 100 + 0.5)),
|
||
("🧪 Зелье +%d%%%s · 👑 Пропуска +%d%%%s"):format(math.floor(boost * 100 + 0.5), boost > 0 and (" (" .. timeStr(player:GetAttribute("BoostLeft") or 0) .. ")") or "",
|
||
(ps.VIP and 25 or 0) + (ps.LuckyCharm and 50 or 0), (event and event.luck) and (" · 🎉 Событие +" .. event.luck * 100 .. "%") or ""),
|
||
"Шанс мутаций: " .. table.concat(mutLine, " · "),
|
||
}
|
||
local info = new("Frame", { Size = UDim2.new(1, -4, 0, 160), BackgroundColor3 = WHITE, LayoutOrder = 0, Parent = list },
|
||
{ corner(14), stroke(Color3.fromRGB(90, 220, 120), 2, 0.2), gradient(Color3.fromRGB(35, 70, 55), C.panel, 90), new("UIPadding", { PaddingLeft = UDim.new(0, 16), PaddingTop = UDim.new(0, 10), PaddingRight = UDim.new(0, 16) }) })
|
||
text({ Size = UDim2.fromScale(1, 1), TextSize = 15, RichText = true, TextYAlignment = Enum.TextYAlignment.Top, TextWrapped = true, Text = table.concat(lines, "\n"), Parent = info })
|
||
for i, p in ipairs(Config.Potions) do
|
||
local bText, bColor, active = buyButton(p.price, p.level or 1, myLevel, coins)
|
||
itemRow(list, i, {
|
||
icon = "🧪", iconBg = p.color:Lerp(C.bg, 0.6),
|
||
title = p.name, titleColor = p.color,
|
||
lines = ("Удача <b>+%d%%</b> на <b>%d мин</b>.\nРедкая рыба и мутации попадаются чаще!"):format(p.bonus * 100, p.duration / 60),
|
||
buttonText = bText, buttonColor = bColor, active = active,
|
||
onClick = function()
|
||
remote:FireServer("Buy", "Potion", p.id)
|
||
end,
|
||
})
|
||
end
|
||
end
|
||
end
|
||
|
||
---------------------------------------------------------------- сумка и коллекция
|
||
|
||
local bagWin = makeWindow("🎒 Сумка", Color3.fromRGB(60, 140, 220), {
|
||
{ id = "fish", label = "🐟 Улов" },
|
||
{ id = "dex", label = "📖 Коллекция" },
|
||
})
|
||
|
||
local fishHeader = new("Frame", { Size = UDim2.new(1, 0, 0, 50), BackgroundColor3 = WHITE, Parent = bagWin.pages.fish }, { corner(12), gradient(C.panel2, C.panel, 90) })
|
||
local fishSummary = text({ Size = UDim2.new(1, -200, 1, 0), Position = UDim2.fromOffset(14, 0), Font = TITLE, TextSize = 19, RichText = true, Text = "", Parent = fishHeader })
|
||
btn({ Size = UDim2.fromOffset(170, 38), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -8, 0.5, 0), BackgroundColor3 = C.green, Text = "💰 Продать всё", TextSize = 18, Parent = fishHeader }, function()
|
||
remote:FireServer("SellAll")
|
||
end)
|
||
local fishGrid = scrollArea(bagWin.pages.fish, UDim2.fromOffset(132, 176), 60)
|
||
|
||
local dexWorld = "World1"
|
||
local dexTabs = new("Frame", { Size = UDim2.new(1, 0, 0, 38), BackgroundTransparency = 1, Parent = bagWin.pages.dex },
|
||
{ new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 8) }) })
|
||
local dexList = scrollArea(bagWin.pages.dex, nil, 46)
|
||
local dexTabButtons = {}
|
||
|
||
local function fishCard(parent, order, rarityColor, strokeColor)
|
||
return new("Frame", { BackgroundColor3 = WHITE, LayoutOrder = order, Parent = parent },
|
||
{ corner(14), stroke(strokeColor or rarityColor, 2.5, 0.05), gradient(rarityColor:Lerp(C.bg, 0.55), C.panel, 90) })
|
||
end
|
||
|
||
local function rewardButton(parent, state, label, onClick)
|
||
local color = (state == "ready") and C.green or C.grey
|
||
return btn({
|
||
Size = UDim2.fromOffset(150, 34), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -8, 0.5, 0),
|
||
BackgroundColor3 = color, AutoButtonColor = state == "ready", Text = label, TextSize = 16, Parent = parent,
|
||
}, state == "ready" and onClick or nil)
|
||
end
|
||
|
||
local function renderDex()
|
||
clear(dexList)
|
||
for id, b in pairs(dexTabButtons) do
|
||
b.BackgroundColor3 = (id == dexWorld) and C.purple or C.panel2
|
||
end
|
||
local world = Config.Find(Config.Worlds, dexWorld)
|
||
local all = Config.Zones[dexWorld].fish
|
||
local found = 0
|
||
for _, f in ipairs(all) do
|
||
if discovered[f.id] then
|
||
found += 1
|
||
end
|
||
end
|
||
|
||
-- мастерство мира
|
||
local head = new("Frame", { Size = UDim2.new(1, -4, 0, 56), BackgroundColor3 = WHITE, LayoutOrder = 0, Parent = dexList },
|
||
{ corner(12), stroke(C.gold, 2, 0.3), gradient(Color3.fromRGB(70, 55, 20), C.panel, 90) })
|
||
text({
|
||
Size = UDim2.new(1, -180, 1, 0), Position = UDim2.fromOffset(14, 0), Font = TITLE, TextSize = 17, RichText = true, TextWrapped = true,
|
||
Text = ("%s %s — <font color=\"#FFD45A\">%d / %d</font>\n<font size=\"13\" color=\"#AAB4CD\">Собери всех: +%s 💰 и +%d%% удачи навсегда</font>"):format(
|
||
world.icon, world.name, found, #all, fmt(Config.MasteryCoins * world.mult), math.floor(Config.MasteryLuck * 100 + 0.5)),
|
||
Parent = head,
|
||
})
|
||
local mKey = dexWorld .. ":Master"
|
||
rewardButton(head, claimed[mKey] and "done" or (found == #all and "ready" or "locked"),
|
||
claimed[mKey] and "Получено ✓" or (found == #all and "🏆 Забрать" or "🔒 Не собрано"), function()
|
||
remote:FireServer("ClaimCollection", dexWorld, "Master")
|
||
end)
|
||
|
||
for ri, rarity in ipairs(Config.RarityOrder) do
|
||
local group = {}
|
||
for _, f in ipairs(all) do
|
||
if f.rarity == rarity then
|
||
table.insert(group, f)
|
||
end
|
||
end
|
||
if #group > 0 then
|
||
local r = Config.Rarities[rarity]
|
||
local have = 0
|
||
for _, f in ipairs(group) do
|
||
if discovered[f.id] then
|
||
have += 1
|
||
end
|
||
end
|
||
local section = new("Frame", { Size = UDim2.new(1, -4, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, BackgroundTransparency = 1, LayoutOrder = ri, Parent = dexList },
|
||
{ new("UIListLayout", { Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder }) })
|
||
local hdr = new("Frame", { Size = UDim2.new(1, 0, 0, 44), BackgroundColor3 = WHITE, LayoutOrder = 0, Parent = section },
|
||
{ corner(10), gradient(r.color:Lerp(C.bg, 0.5), C.panel, 0) })
|
||
local reward = Config.CollectionRewards[rarity]
|
||
text({
|
||
Size = UDim2.new(1, -180, 1, 0), Position = UDim2.fromOffset(12, 0), Font = TITLE, TextSize = 17, RichText = true,
|
||
Text = ("<font color=\"%s\">%s</font> %d/%d <font size=\"13\" color=\"#AAB4CD\">+%s 💰 +%s XP</font>"):format(
|
||
hex(r.color), r.name, have, #group, fmt(reward.coins * world.mult), fmt(reward.xp * world.mult)),
|
||
Parent = hdr,
|
||
})
|
||
local key = dexWorld .. ":" .. rarity
|
||
rewardButton(hdr, claimed[key] and "done" or (have == #group and "ready" or "locked"),
|
||
claimed[key] and "Получено ✓" or (have == #group and "🎁 Забрать" or ("🔒 " .. have .. "/" .. #group)), function()
|
||
remote:FireServer("ClaimCollection", dexWorld, rarity)
|
||
end)
|
||
local grid = new("Frame", { Size = UDim2.new(1, 0, 0, 0), AutomaticSize = Enum.AutomaticSize.Y, BackgroundTransparency = 1, LayoutOrder = 1, Parent = section },
|
||
{ new("UIGridLayout", { CellSize = UDim2.fromOffset(124, 150), CellPadding = UDim2.fromOffset(8, 8), SortOrder = Enum.SortOrder.LayoutOrder }) })
|
||
for i, f in ipairs(group) do
|
||
local rec = discovered[f.id]
|
||
local card = fishCard(grid, i, rec and r.color or C.grey)
|
||
local view = new("Frame", { Size = UDim2.new(1, -12, 0, 76), Position = UDim2.fromOffset(6, 6), BackgroundTransparency = 1, Parent = card })
|
||
local model = Models.buildFish(f.id, nil, 1, true)
|
||
viewport(view, rec and model or silhouette(model), FISH_VIEW, 0.72)
|
||
text({ Size = UDim2.new(1, -10, 0, 20), Position = UDim2.fromOffset(6, 84), Font = TITLE, TextSize = 15, TextColor3 = rec and r.color or C.muted, Text = rec and f.name or "???", TextTruncate = Enum.TextTruncate.AtEnd, Parent = card })
|
||
text({
|
||
Size = UDim2.new(1, -10, 0, 40), Position = UDim2.fromOffset(6, 104), Font = BODY2, TextSize = 12, TextColor3 = C.muted, TextWrapped = true,
|
||
TextYAlignment = Enum.TextYAlignment.Top,
|
||
Text = rec and ("Поймано: %d\nРекорд: %.2f кг"):format(rec.count, rec.best) or "Ещё не поймана", Parent = card,
|
||
})
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
for i, w in ipairs(Config.Worlds) do
|
||
if not w.soon then
|
||
dexTabButtons[w.id] = btn({ Size = UDim2.new(0, 170, 1, 0), Text = w.icon .. " " .. w.name, TextSize = 15, BackgroundColor3 = C.panel2, LayoutOrder = i, Parent = dexTabs }, function()
|
||
dexWorld = w.id
|
||
renderDex()
|
||
end)
|
||
end
|
||
end
|
||
|
||
bagWin.render = function(tab)
|
||
if tab == "fish" then
|
||
clear(fishGrid)
|
||
local total = 0
|
||
for _, it in ipairs(inventory) do
|
||
total += it.value
|
||
end
|
||
fishSummary.Text = ("🐟 %d / %d · <font color=\"#FFD45A\">💰 ≈%s</font>"):format(#inventory, player:GetAttribute("BagCap") or 0, fmt(player:GetAttribute("BagValue") or total))
|
||
if #inventory == 0 then
|
||
text({ Size = UDim2.fromOffset(400, 60), Font = TITLE, TextSize = 20, TextColor3 = C.muted, TextWrapped = true, Text = "Сумка пуста. Иди к воде и поймай рыбу! 🎣", Parent = fishGrid })
|
||
return
|
||
end
|
||
local sorted = table.clone(inventory)
|
||
table.sort(sorted, function(a, b)
|
||
return a.value > b.value
|
||
end)
|
||
for i, it in ipairs(sorted) do
|
||
local r = Config.Rarities[it.rarity] or Config.Rarities.Common
|
||
local mut = it.mutation and Config.Find(Config.Mutations, it.mutation)
|
||
local card = fishCard(fishGrid, i, r.color, mut and mut.color)
|
||
local view = new("Frame", { Size = UDim2.new(1, -12, 0, 84), Position = UDim2.fromOffset(6, 6), BackgroundTransparency = 1, Parent = card })
|
||
viewport(view, Models.buildFish(it.id, it.mutation, 1, true), FISH_VIEW, 0.72)
|
||
if mut then
|
||
local tag = new("Frame", { Size = UDim2.fromOffset(0, 20), AutomaticSize = Enum.AutomaticSize.X, Position = UDim2.fromOffset(6, 6), BackgroundColor3 = mut.color, ZIndex = 3, Parent = card },
|
||
{ corner(6), new("UIPadding", { PaddingLeft = UDim.new(0, 6), PaddingRight = UDim.new(0, 6) }) })
|
||
text({ Size = UDim2.new(0, 0, 1, 0), AutomaticSize = Enum.AutomaticSize.X, Font = TITLE, TextSize = 13, TextColor3 = C.bg, Text = mut.name, ZIndex = 4, Parent = tag })
|
||
end
|
||
text({ Size = UDim2.new(1, -10, 0, 20), Position = UDim2.fromOffset(6, 92), Font = TITLE, TextSize = 16, TextColor3 = r.color, Text = it.name, TextTruncate = Enum.TextTruncate.AtEnd, Parent = card })
|
||
text({ Size = UDim2.new(1, -10, 0, 16), Position = UDim2.fromOffset(6, 112), Font = BODY2, TextSize = 13, TextColor3 = C.muted, Text = ("%.2f кг · %s"):format(it.weight, r.name), Parent = card })
|
||
btn({ Size = UDim2.new(1, -12, 0, 32), Position = UDim2.fromOffset(6, 136), BackgroundColor3 = C.green, Text = "💰 " .. fmt(it.value), TextSize = 17, Parent = card }, function()
|
||
remote:FireServer("SellOne", it.uid)
|
||
end)
|
||
end
|
||
elseif tab == "dex" then
|
||
renderDex()
|
||
end
|
||
end
|
||
|
||
---------------------------------------------------------------- миры
|
||
|
||
local worldsWin = makeWindow("🌍 Миры", Color3.fromRGB(40, 160, 200), { { id = "list", label = "Миры" } })
|
||
local worldsList = scrollArea(worldsWin.pages.list)
|
||
|
||
local function currentWorld()
|
||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||
return hrp and Config.WorldAt(hrp.Position)
|
||
end
|
||
|
||
worldsWin.render = function()
|
||
clear(worldsList)
|
||
local myLevel = player:GetAttribute("Level") or 1
|
||
local here = currentWorld()
|
||
itemRow(worldsList, 0, {
|
||
icon = "🏠", iconBg = Color3.fromRGB(90, 70, 30),
|
||
title = "Лобби", titleColor = C.gold,
|
||
lines = "Магазин удочек, скупка, донат-лавки и ежедневный сундук.",
|
||
buttonText = here == nil and "Вы здесь" or "🌀 Телепорт", buttonColor = here == nil and C.grey or C.blue, active = here ~= nil,
|
||
onClick = function()
|
||
remote:FireServer("Teleport", "Lobby")
|
||
worldsWin.close()
|
||
end,
|
||
})
|
||
for i, w in ipairs(Config.Worlds) do
|
||
local zone = Config.Zones[w.id]
|
||
local total, found = 0, 0
|
||
if zone then
|
||
for _, f in ipairs(zone.fish) do
|
||
total += 1
|
||
if discovered[f.id] then
|
||
found += 1
|
||
end
|
||
end
|
||
end
|
||
local bText, bColor, active
|
||
if w.soon then
|
||
bText, bColor, active = "Скоро…", C.grey, false
|
||
elseif myLevel < w.level then
|
||
bText, bColor, active = "🔒 Ур. " .. w.level, C.grey, false
|
||
elseif here and here.id == w.id then
|
||
bText, bColor, active = "Вы здесь", C.grey, false
|
||
else
|
||
bText, bColor, active = "🌀 Телепорт", C.blue, true
|
||
end
|
||
itemRow(worldsList, i, {
|
||
icon = w.icon, iconBg = w.color:Lerp(C.bg, 0.6),
|
||
title = w.name, titleColor = w.color,
|
||
lines = w.desc .. "\n" .. (w.soon and "В разработке" or ("Уровень: %d · Рыб поймано: %d / %d · Награды x%d"):format(w.level, found, total, w.mult)),
|
||
strokeColor = (here and here.id == w.id) and C.gold or nil,
|
||
buttonText = bText, buttonColor = bColor, active = active,
|
||
onClick = function()
|
||
remote:FireServer("Teleport", w.id)
|
||
worldsWin.close()
|
||
end,
|
||
})
|
||
end
|
||
end
|
||
|
||
---------------------------------------------------------------- задания и ежедневная награда
|
||
|
||
local questWin = makeWindow("📜 Задания", Color3.fromRGB(200, 140, 40), {
|
||
{ id = "quests", label = "📜 Задания" },
|
||
{ id = "daily", label = "🎁 Ежедневно" },
|
||
})
|
||
local questList = scrollArea(questWin.pages.quests)
|
||
local dailyPage = questWin.pages.daily
|
||
|
||
local function questText(q)
|
||
local t = Config.Quests[1]
|
||
for _, def in ipairs(Config.Quests) do
|
||
if def.kind == q.kind then
|
||
t = def
|
||
end
|
||
end
|
||
return string.find(t.text, "%%d") and t.text:format(q.goal) or t.text
|
||
end
|
||
|
||
questWin.render = function(tab)
|
||
if tab == "quests" then
|
||
clear(questList)
|
||
text({ Size = UDim2.new(1, -4, 0, 30), LayoutOrder = 0, Font = BODY2, TextSize = 14, TextColor3 = C.muted, Text = "Выполняй задания — после награды появится новое.", Parent = questList })
|
||
for i, q in ipairs(quests) do
|
||
local done = q.progress >= q.goal
|
||
local row = new("Frame", { Size = UDim2.new(1, -4, 0, 92), BackgroundColor3 = WHITE, LayoutOrder = i, Parent = questList },
|
||
{ corner(14), stroke(done and C.green or C.line, 2, done and 0 or 0.45), gradient(C.panel2, C.panel, 90) })
|
||
text({ Size = UDim2.new(1, -190, 0, 28), Position = UDim2.fromOffset(16, 8), Font = TITLE, TextSize = 19, Text = questText(q), TextTruncate = Enum.TextTruncate.AtEnd, Parent = row })
|
||
progressBar(row, UDim2.fromOffset(16, 42), UDim2.new(1, -200, 0, 14), q.progress / q.goal, done and C.green or C.gold)
|
||
text({ Size = UDim2.new(1, -190, 0, 20), Position = UDim2.fromOffset(16, 62), Font = BODY2, TextSize = 13, TextColor3 = C.muted, RichText = true,
|
||
Text = ("%s / %s · <font color=\"#FFD45A\">+%s 💰 +%s XP</font>"):format(fmt(q.progress), fmt(q.goal), fmt(q.coins), fmt(q.xp)), Parent = row })
|
||
btn({
|
||
Size = UDim2.fromOffset(150, 46), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0),
|
||
BackgroundColor3 = done and C.green or C.grey, AutoButtonColor = done, Text = done and "🎁 Забрать" or "В процессе", TextSize = 18, Parent = row,
|
||
}, done and function()
|
||
remote:FireServer("ClaimQuest", i)
|
||
end or nil)
|
||
end
|
||
elseif tab == "daily" then
|
||
clear(dailyPage)
|
||
local myLevel = player:GetAttribute("Level") or 1
|
||
text({
|
||
Size = UDim2.new(1, 0, 0, 30), Font = TITLE, TextSize = 20, RichText = true,
|
||
Text = ("🔥 Серия: <font color=\"#FFD45A\">%d</font> дн. Заходи каждый день — награда растёт!"):format(daily.streak), Parent = dailyPage,
|
||
})
|
||
local row = new("Frame", { Size = UDim2.new(1, 0, 0, 150), Position = UDim2.fromOffset(0, 40), BackgroundTransparency = 1, Parent = dailyPage },
|
||
{ new("UIGridLayout", { CellSize = UDim2.new(1 / 7, -8, 1, 0), CellPadding = UDim2.fromOffset(8, 0) }) })
|
||
for d, r in ipairs(Config.DailyRewards) do
|
||
local isNext = d == daily.nextStreak and daily.available
|
||
local passed = d <= daily.streak and not (daily.available and daily.nextStreak == 1)
|
||
local cell = new("Frame", { BackgroundColor3 = WHITE, Parent = row },
|
||
{ corner(12), stroke(isNext and C.gold or C.line, isNext and 3 or 2, isNext and 0 or 0.4), gradient(isNext and Color3.fromRGB(90, 70, 20) or C.panel2, C.panel, 90) })
|
||
text({ Size = UDim2.new(1, 0, 0, 24), Position = UDim2.fromOffset(0, 6), Font = TITLE, TextSize = 15, TextXAlignment = Enum.TextXAlignment.Center, Text = "День " .. d, Parent = cell })
|
||
text({ Size = UDim2.new(1, 0, 0, 44), Position = UDim2.fromOffset(0, 32), TextSize = 32, TextXAlignment = Enum.TextXAlignment.Center, Text = passed and "✅" or (r.potion and "🧪" or "💰"), Parent = cell })
|
||
text({
|
||
Size = UDim2.new(1, -6, 0, 50), Position = UDim2.fromOffset(3, 80), Font = BODY2, TextSize = 12, TextXAlignment = Enum.TextXAlignment.Center, TextWrapped = true, TextColor3 = C.gold,
|
||
Text = fmt(r.coins * (1 + (myLevel - 1) * 0.2)) .. " 💰" .. (r.potion and "\n+ зелье" or ""), Parent = cell,
|
||
})
|
||
end
|
||
btn({
|
||
Size = UDim2.fromOffset(260, 54), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 210),
|
||
BackgroundColor3 = daily.available and C.green or C.grey, AutoButtonColor = daily.available,
|
||
Text = daily.available and "🎁 Забрать награду" or "Приходи завтра!", TextSize = 22, Parent = dailyPage,
|
||
}, daily.available and function()
|
||
remote:FireServer("ClaimDaily")
|
||
end or nil)
|
||
end
|
||
end
|
||
|
||
---------------------------------------------------------------- донат
|
||
|
||
local robuxWin = makeWindow("💎 Премиум", Color3.fromRGB(150, 80, 210), {
|
||
{ id = "passes", label = "👑 Пропуска" },
|
||
{ id = "products", label = "🪙 Наборы" },
|
||
})
|
||
local robuxLists = { passes = scrollArea(robuxWin.pages.passes), products = scrollArea(robuxWin.pages.products) }
|
||
|
||
robuxWin.render = function(tab)
|
||
local list = robuxLists[tab]
|
||
clear(list)
|
||
local owned = attrSet("Passes")
|
||
local items = tab == "passes" and Config.GamePasses or Config.Products
|
||
for i, it in ipairs(items) do
|
||
local has = tab == "passes" and owned[it.key]
|
||
itemRow(list, i, {
|
||
icon = it.icon, iconBg = Color3.fromRGB(70, 40, 100),
|
||
title = it.name, titleColor = C.gold,
|
||
lines = it.desc .. (tab == "passes" and "\nДействует навсегда" or ""),
|
||
strokeColor = has and C.gold or nil,
|
||
buttonText = has and "Куплено ✓" or ("R$ " .. it.robux), buttonColor = has and C.grey or C.green, active = not has,
|
||
onClick = function()
|
||
if not it.id or it.id == 0 then
|
||
notify("Товар ещё не настроен: впиши его ID в FishConfig", Color3.fromRGB(255, 200, 120))
|
||
return
|
||
end
|
||
if tab == "passes" then
|
||
MarketplaceService:PromptGamePassPurchase(player, it.id)
|
||
else
|
||
MarketplaceService:PromptProductPurchase(player, it.id)
|
||
end
|
||
end,
|
||
})
|
||
end
|
||
end
|
||
|
||
---------------------------------------------------------------- боковые кнопки
|
||
|
||
sideButton(1, "🎒", "Сумка", "B", Color3.fromRGB(60, 140, 220), function()
|
||
bagWin.toggle("fish")
|
||
end)
|
||
sideButton(2, "📖", "Рыбы", "C", Color3.fromRGB(150, 90, 220), function()
|
||
bagWin.toggle("dex")
|
||
end)
|
||
sideButton(3, "🌍", "Миры", "M", Color3.fromRGB(40, 160, 200), function()
|
||
worldsWin.toggle()
|
||
end)
|
||
sideButton(4, "📜", "Задания", "Q", Color3.fromRGB(210, 150, 40), function()
|
||
questWin.toggle()
|
||
end)
|
||
sideButton(5, "💎", "Донат", nil, Color3.fromRGB(150, 80, 210), function()
|
||
robuxWin.toggle()
|
||
end)
|
||
|
||
local function refreshDots()
|
||
local q = false
|
||
for _, quest in ipairs(quests) do
|
||
if quest.progress >= quest.goal then
|
||
q = true
|
||
end
|
||
end
|
||
sideDots["Задания"].Visible = q or daily.available
|
||
local c = false
|
||
for _, w in ipairs(Config.Worlds) do
|
||
local zone = Config.Zones[w.id]
|
||
if zone then
|
||
for _, rarity in ipairs(Config.RarityOrder) do
|
||
local any, all = false, true
|
||
for _, f in ipairs(zone.fish) do
|
||
if f.rarity == rarity then
|
||
any = true
|
||
if not discovered[f.id] then
|
||
all = false
|
||
end
|
||
end
|
||
end
|
||
if any and all and not claimed[w.id .. ":" .. rarity] then
|
||
c = true
|
||
end
|
||
end
|
||
end
|
||
end
|
||
sideDots["Рыбы"].Visible = c
|
||
end
|
||
|
||
---------------------------------------------------------------- HUD: обновление
|
||
|
||
local function refreshHud()
|
||
local xp = player:GetAttribute("XP") or 0
|
||
local need = player:GetAttribute("XPNeed") or 100
|
||
coinsText.Text = "💰 " .. fmt(player:GetAttribute("Coins") or 0)
|
||
lvlText.Text = tostring(player:GetAttribute("Level") or 1)
|
||
xpText.Text = ("%d / %d XP"):format(xp, need)
|
||
TweenService:Create(xpFill, TweenInfo.new(0.3), { Size = UDim2.fromScale(math.clamp(xp / need, 0, 1), 1) }):Play()
|
||
local boost = player:GetAttribute("BoostBonus") or 0
|
||
luckText.Text = ("🍀 Удача <b>%d%%</b>%s"):format(player:GetAttribute("Luck") or 100,
|
||
boost > 0 and (" <font color=\"#FFD45A\">🧪 +%d%% %s</font>"):format(boost * 100, timeStr(player:GetAttribute("BoostLeft") or 0)) or "")
|
||
local count, cap = player:GetAttribute("BagCount") or 0, player:GetAttribute("BagCap") or 10
|
||
bagText.Text = ("🎒 %d / %d · ≈ %s 💰"):format(count, cap, fmt(player:GetAttribute("BagValue") or 0))
|
||
bagText.TextColor3 = count >= cap and Color3.fromRGB(255, 120, 120) or C.text
|
||
local rod = Config.Find(Config.Rods, player:GetAttribute("Rod") or "Basic")
|
||
rodText.Text = ("🎣 %s <font color=\"#FFD45A\">%s</font>"):format(rod and rod.name or "", stars(player:GetAttribute("RodLevel") or 0))
|
||
end
|
||
|
||
local pending = false
|
||
player.AttributeChanged:Connect(function(name)
|
||
refreshHud()
|
||
if name == "BoostLeft" and not (shopWin.isOpen() and shopWin.current == "luck") then
|
||
return
|
||
end
|
||
if not pending then
|
||
pending = true
|
||
task.defer(function()
|
||
pending = false
|
||
shopWin.refresh()
|
||
robuxWin.refresh()
|
||
if worldsWin.isOpen() then
|
||
worldsWin.refresh()
|
||
end
|
||
end)
|
||
end
|
||
end)
|
||
refreshHud()
|
||
|
||
---------------------------------------------------------------- рыбалка
|
||
|
||
local state = "idle"
|
||
local mg = { pos = 0, dir = 1, speed = 1, zoneStart = 0.4, zoneWidth = 0.25, hits = 0, need = 1, misses = 0, maxMisses = 2, deadline = 0, timeout = 10 }
|
||
|
||
-- с начала зарядки и до конца рыбалки персонажем не управляем: не ходит, не прыгает, не поворачивается
|
||
local ContextActionService = game:GetService("ContextActionService")
|
||
local MOVE_KEYS = {
|
||
Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D, Enum.KeyCode.Space,
|
||
Enum.KeyCode.Up, Enum.KeyCode.Down, Enum.KeyCode.Left, Enum.KeyCode.Right,
|
||
Enum.KeyCode.Thumbstick1, Enum.KeyCode.ButtonA,
|
||
}
|
||
local controls
|
||
local movementLocked = false
|
||
local function setMovementLocked(locked)
|
||
if not controls then
|
||
local pm = player:FindFirstChild("PlayerScripts") and player.PlayerScripts:FindFirstChild("PlayerModule")
|
||
local ok, mod = pcall(require, pm)
|
||
controls = ok and mod and mod:GetControls() or nil
|
||
end
|
||
if controls then
|
||
if locked then
|
||
controls:Disable()
|
||
else
|
||
controls:Enable()
|
||
end
|
||
end
|
||
if locked ~= movementLocked then
|
||
movementLocked = locked
|
||
if locked then
|
||
ContextActionService:BindActionAtPriority("FishingLock", function()
|
||
return Enum.ContextActionResult.Sink
|
||
end, false, Enum.ContextActionPriority.High.Value + 100, table.unpack(MOVE_KEYS))
|
||
else
|
||
ContextActionService:UnbindAction("FishingLock")
|
||
end
|
||
end
|
||
local hum = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
|
||
if hum then
|
||
hum.AutoRotate = not locked
|
||
hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, not locked)
|
||
if locked then
|
||
hum:Move(Vector3.zero)
|
||
end
|
||
end
|
||
end
|
||
|
||
local function easeInOut(a)
|
||
return a < 0.5 and 4 * a * a * a or 1 - (-2 * a + 2) ^ 3 / 2
|
||
end
|
||
local function easeOut(a)
|
||
return 1 - (1 - a) ^ 3
|
||
end
|
||
|
||
---------------------------------------------------------------- заброс: зарядка, шкала силы, наклон удочки
|
||
-- держишь ЛКМ — сила растёт, удочка уходит назад; отпустил — бросок на дальность по силе
|
||
|
||
local REST_ANGLE, BACK_ANGLE = 30, 110 -- удочка в покое (как в GameServer) и в полном замахе
|
||
local function gripCF(angle)
|
||
return (CFrame.Angles(math.rad(angle), 0, 0) * CFrame.new(0, 0, -0.3)):Inverse()
|
||
end
|
||
|
||
local charge = nil -- { t0, tool }
|
||
local castTool = nil -- удочка последнего броска: вернуть её в покой, если бросок не удался
|
||
local function chargePower()
|
||
return charge and math.min(1, (os.clock() - charge.t0) / Config.CastChargeTime) or 0
|
||
end
|
||
local function inPerfect(v)
|
||
return v >= Config.CastPerfect[1] and v <= Config.CastPerfect[2]
|
||
end
|
||
|
||
-- шкала-дуга справа от персонажа: внизу слабый бросок, вверху сильный, зелёная зона — бонус удачи
|
||
local GAUGE_R, GAUGE_DEG, GAUGE_N = 190, 110, 32
|
||
local gauge = new("Frame", {
|
||
Size = UDim2.fromOffset(150, 280), AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0.57, 0, 0.48, 0),
|
||
BackgroundTransparency = 1, Visible = false, Parent = gui,
|
||
})
|
||
local GAUGE_C = Vector2.new(110 - GAUGE_R, 140) -- центр окружности левее рамки: дуга выгнута вправо
|
||
local function arcPoint(v, r)
|
||
local th = math.rad(-GAUGE_DEG / 2 + GAUGE_DEG * v)
|
||
return GAUGE_C + Vector2.new(math.cos(th) * r, -math.sin(th) * r), -math.deg(th)
|
||
end
|
||
do
|
||
local segLen = 2 * math.pi * GAUGE_R * (GAUGE_DEG / 360) / GAUGE_N
|
||
for _, layer in ipairs({ { 46, 4, BLACK }, { 34, 1 } }) do -- чёрная обводка, потом цветные секции
|
||
for i = 0, GAUGE_N - 1 do
|
||
local v = (i + 0.5) / GAUGE_N
|
||
local pos, rot = arcPoint(v, GAUGE_R)
|
||
local color = layer[3]
|
||
or ((v < 0.12 or v > 0.94) and C.red)
|
||
or (inPerfect(v) and Color3.fromRGB(110, 235, 60))
|
||
or Color3.fromRGB(40, 70, 95)
|
||
new("Frame", {
|
||
Size = UDim2.fromOffset(layer[1], segLen + layer[2]), AnchorPoint = Vector2.new(0.5, 0.5),
|
||
Position = UDim2.fromOffset(pos.X, pos.Y), Rotation = rot, BorderSizePixel = 0,
|
||
BackgroundColor3 = color, Parent = gauge,
|
||
})
|
||
end
|
||
end
|
||
end
|
||
local needle = new("Frame", {
|
||
Size = UDim2.fromOffset(64, 8), AnchorPoint = Vector2.new(0.5, 0.5), BackgroundColor3 = WHITE,
|
||
BorderSizePixel = 0, ZIndex = 3, Parent = gauge,
|
||
}, { corner(4), stroke(BLACK, 2) })
|
||
local multLabel = text({
|
||
Size = UDim2.fromOffset(110, 40), AnchorPoint = Vector2.new(0.5, 1), Font = TITLE, TextSize = 34,
|
||
Text = "×" .. Config.CastPerfectLuck, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 4,
|
||
Visible = false, Parent = gauge,
|
||
})
|
||
new("UIStroke", { Color = BLACK, Thickness = 3, Parent = multLabel })
|
||
do
|
||
local top = arcPoint(1, GAUGE_R)
|
||
multLabel.Position = UDim2.fromOffset(top.X + 10, top.Y - 18)
|
||
end
|
||
|
||
local function updateCharge()
|
||
local p = chargePower()
|
||
local pos, rot = arcPoint(p, GAUGE_R)
|
||
needle.Position = UDim2.fromOffset(pos.X, pos.Y)
|
||
needle.Rotation = rot
|
||
local good = inPerfect(p)
|
||
multLabel.Visible = good
|
||
needle.BackgroundColor3 = good and Color3.fromRGB(190, 255, 150) or WHITE
|
||
if charge.tool and charge.tool.Parent then
|
||
charge.tool.Grip = gripCF(REST_ANGLE + (BACK_ANGLE - REST_ANGLE) * easeOut(p))
|
||
end
|
||
end
|
||
|
||
---------------------------------------------------------------- камера при забросе
|
||
-- зарядка: камера уходит в сторону от персонажа и отъезжает тем дальше, чем сильнее замах;
|
||
-- бросок: камера сбоку разгоняется за поплавком; потом сверху-сбоку держит в кадре игрока и поплавок
|
||
|
||
local CAM_IN, CAM_SETTLE, CAM_RETURN = 0.35, 0.8, 0.6
|
||
local UP = Vector3.new(0, 1, 0)
|
||
local fishCam = nil
|
||
|
||
local function sideCF(fc, p)
|
||
return CFrame.lookAt(fc.hrp + fc.r * (9 + 3 * p) - fc.f * (3 + 2 * p) + UP * (3 + 1.5 * p), fc.hrp + fc.f * 6 + UP)
|
||
end
|
||
local function chaseCF(fc, p)
|
||
return CFrame.lookAt(p + fc.r * 9 - fc.f * 5 + UP * 3, p + fc.f * 3)
|
||
end
|
||
local function restCF(fc)
|
||
local d = ((fc.target - fc.hrp) * Vector3.new(1, 0, 1)).Magnitude
|
||
local mid = fc.hrp:Lerp(fc.target, 0.5)
|
||
return CFrame.lookAt(mid + fc.r * (8 + d * 0.55) - fc.f * 4 + UP * (6 + d * 0.25), fc.hrp:Lerp(fc.target, 0.6))
|
||
end
|
||
|
||
local function fishCamStep()
|
||
local fc = fishCam
|
||
local cam = workspace.CurrentCamera
|
||
if not fc or not cam then
|
||
return
|
||
end
|
||
if fc.returning then
|
||
local a = math.min(1, (os.clock() - fc.returning) / CAM_RETURN)
|
||
local e = easeInOut(a)
|
||
cam.CFrame = fc.leaveCF:Lerp(fc.origCF, e)
|
||
cam.FieldOfView = fc.leaveFov + (fc.origFov - fc.leaveFov) * e
|
||
if a >= 1 then
|
||
RunService:UnbindFromRenderStep("FishCam")
|
||
cam.CameraType = Enum.CameraType.Custom
|
||
fishCam = nil
|
||
end
|
||
return
|
||
end
|
||
local now = os.clock()
|
||
local cf, fov
|
||
if not fc.castT0 then
|
||
-- зарядка: плавно уходим в вид сбоку; чем сильнее замах, тем дальше камера и шире обзор
|
||
-- после отпускания ЛКМ, пока ждём ответ сервера, держим набранную силу
|
||
local p = charge and chargePower() or (fc.power or 0)
|
||
fc.power = p
|
||
local e = easeOut(math.min(1, (now - fc.t0) / CAM_IN))
|
||
cf = fc.origCF:Lerp(sideCF(fc, p), e)
|
||
fov = fc.origFov + 12 * p * e
|
||
else
|
||
local th = fc.throw
|
||
local t = now - fc.castT0
|
||
local lunge = fc.fromCF + fc.f * 1.5
|
||
if t < th.windup then
|
||
-- рывок удочки вперёд: камера подаётся следом
|
||
local e = easeOut(t / th.windup)
|
||
cf = fc.fromCF:Lerp(lunge, e)
|
||
fov = fc.fromFov + 4 * e
|
||
elseif t < th.windup + th.flight then
|
||
if not fc.start then
|
||
fc.start = (fc.tip and fc.tip.Parent and fc.tip.WorldPosition) or (fc.hrp + fc.f * 2 + UP * 4)
|
||
end
|
||
local a = (t - th.windup) / th.flight
|
||
local p = fc.start:Lerp(fc.target, a) + UP * (math.sin(a * math.pi) * th.arc) -- та же дуга, что у поплавка
|
||
local e = easeInOut(a)
|
||
cf = lunge:Lerp(chaseCF(fc, p), e)
|
||
fov = (fc.fromFov + 4) + ((fc.origFov - 6) - (fc.fromFov + 4)) * e
|
||
else
|
||
local e = easeOut(math.min(1, (t - th.windup - th.flight) / CAM_SETTLE))
|
||
local sway = Vector3.new(math.sin(now * 0.7) * 0.5, math.sin(now * 1.1) * 0.25, 0)
|
||
if state == "bite" then
|
||
sway += Vector3.new(math.random() - 0.5, math.random() - 0.5, 0) * 0.15
|
||
end
|
||
cf = chaseCF(fc, fc.target):Lerp(restCF(fc) + sway, e)
|
||
fov = fc.origFov - 6 + 6 * e
|
||
end
|
||
end
|
||
cam.CFrame = cf
|
||
cam.FieldOfView = fov
|
||
end
|
||
|
||
-- начало зарядки: dir — куда полетит поплавок (к центру озера)
|
||
local function startChargeCam(tool, dir)
|
||
local cam = workspace.CurrentCamera
|
||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||
if not cam or not hrp then
|
||
return
|
||
end
|
||
fishCam = {
|
||
t0 = os.clock(), hrp = hrp.Position, f = dir, r = dir:Cross(UP),
|
||
tip = tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip"),
|
||
-- если камера ещё возвращалась с прошлого заброса, возвращаться будем туда же
|
||
origCF = fishCam and fishCam.origCF or cam.CFrame,
|
||
origFov = fishCam and fishCam.origFov or cam.FieldOfView,
|
||
}
|
||
cam.CameraType = Enum.CameraType.Scriptable
|
||
RunService:UnbindFromRenderStep("FishCam")
|
||
RunService:BindToRenderStep("FishCam", Enum.RenderPriority.Camera.Value + 1, fishCamStep)
|
||
end
|
||
|
||
-- сервер принял бросок: target — куда упадёт поплавок, throw — тайминги и высота дуги
|
||
local function startCastCam(target, throw)
|
||
local cam = workspace.CurrentCamera
|
||
if not fishCam or fishCam.returning or not cam or typeof(target) ~= "Vector3" or type(throw) ~= "table" then
|
||
return
|
||
end
|
||
fishCam.castT0 = os.clock()
|
||
fishCam.target = target
|
||
fishCam.throw = throw
|
||
fishCam.fromCF = cam.CFrame
|
||
fishCam.fromFov = cam.FieldOfView
|
||
end
|
||
|
||
local function stopFishCam()
|
||
local cam = workspace.CurrentCamera
|
||
if not fishCam or fishCam.returning or not cam then
|
||
return
|
||
end
|
||
fishCam.returning = os.clock()
|
||
fishCam.leaveCF = cam.CFrame
|
||
fishCam.leaveFov = cam.FieldOfView
|
||
end
|
||
|
||
local reelToken
|
||
local function setState(s)
|
||
if s ~= "charging" and charge then
|
||
-- зарядку прервали (убрал удочку и т.п.): удочку обратно в покой
|
||
if charge.tool.Parent then
|
||
charge.tool.Grip = gripCF(REST_ANGLE)
|
||
end
|
||
charge = nil
|
||
end
|
||
state = s
|
||
statusLabel.Visible = (s == "waiting")
|
||
mgFrame.Visible = (s == "bite")
|
||
gauge.Visible = (s == "charging")
|
||
setMovementLocked(s ~= "idle")
|
||
if s == "idle" then
|
||
stopFishCam()
|
||
elseif s == "reeling" then
|
||
-- на случай, если сервер не ответит на вытаскивание: не оставляем игрока замороженным
|
||
local token = {}
|
||
reelToken = token
|
||
task.delay(4, function()
|
||
if state == "reeling" and reelToken == token then
|
||
setState("idle")
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
local function updatePips()
|
||
pipsText.Text = "🎯 " .. string.rep("<font color=\"#7CFF9A\">●</font>", mg.hits) .. string.rep("<font color=\"#5A6480\">●</font>", mg.need - mg.hits)
|
||
missText.Text = string.rep("<font color=\"#5A6480\">✖</font>", mg.misses) .. string.rep("❤️", mg.maxMisses - mg.misses)
|
||
end
|
||
local function flash(color)
|
||
bar.BackgroundColor3 = color
|
||
TweenService:Create(bar, TweenInfo.new(0.35), { BackgroundColor3 = Color3.fromRGB(22, 28, 46) }):Play()
|
||
end
|
||
local function placeZone()
|
||
mg.zoneStart = math.random() * (1 - mg.zoneWidth)
|
||
zoneF.Size = UDim2.fromScale(mg.zoneWidth, 1)
|
||
zoneF.Position = UDim2.fromScale(mg.zoneStart, 0)
|
||
end
|
||
|
||
-- ЛКМ зажата: персонаж разворачивается к центру озера, начинается зарядка
|
||
local function startCharge(tool)
|
||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||
if not hrp then
|
||
return
|
||
end
|
||
local world = Config.WorldAt(hrp.Position)
|
||
-- из воды и издалека не заряжаем вовсе: сразу подсказка
|
||
local can = Config.CanCastFrom(world, hrp.Position, player.Character:FindFirstChildOfClass("Humanoid"))
|
||
if can ~= true then
|
||
notify(can, Color3.fromRGB(255, 200, 120))
|
||
return
|
||
end
|
||
local dir = Config.CastDirection(world, hrp.Position)
|
||
if not dir then
|
||
dir = hrp.CFrame.LookVector * Vector3.new(1, 0, 1)
|
||
dir = dir.Magnitude > 0.01 and dir.Unit or Vector3.new(0, 0, -1)
|
||
end
|
||
hrp.CFrame = CFrame.lookAt(hrp.Position, hrp.Position + dir)
|
||
charge = { t0 = os.clock(), tool = tool }
|
||
setState("charging")
|
||
startChargeCam(tool, dir)
|
||
updateCharge()
|
||
end
|
||
|
||
-- ЛКМ отпущена: бросок с набранной силой
|
||
local function releaseCast()
|
||
if state ~= "charging" or not charge then
|
||
return
|
||
end
|
||
local power = chargePower()
|
||
castTool = charge.tool
|
||
charge = nil -- удочку не возвращаем: сервер сам сделает рывок вперёд
|
||
setState("casting")
|
||
remote:FireServer("Cast", power)
|
||
end
|
||
|
||
local function onActivate()
|
||
if state == "waiting" then
|
||
remote:FireServer("Cancel")
|
||
setState("idle")
|
||
elseif state == "bite" then
|
||
local inZone = mg.pos >= mg.zoneStart and mg.pos <= mg.zoneStart + mg.zoneWidth
|
||
if inZone then
|
||
mg.hits += 1
|
||
flash(Color3.fromRGB(60, 160, 80))
|
||
if mg.hits >= mg.need then
|
||
setState("reeling")
|
||
remote:FireServer("Catch", true, mg.misses)
|
||
return
|
||
end
|
||
mg.speed *= 1.12
|
||
placeZone()
|
||
else
|
||
mg.misses += 1
|
||
flash(Color3.fromRGB(170, 50, 50))
|
||
if mg.misses >= mg.maxMisses then
|
||
setState("reeling")
|
||
remote:FireServer("Catch", false, mg.misses)
|
||
return
|
||
end
|
||
end
|
||
updatePips()
|
||
end
|
||
end
|
||
|
||
local hooked = setmetatable({}, { __mode = "k" })
|
||
local function hookTool(tool)
|
||
if hooked[tool] or not tool:IsA("Tool") or not tool:GetAttribute("IsRod") then
|
||
return
|
||
end
|
||
hooked[tool] = true
|
||
tool.Activated:Connect(function()
|
||
if state == "idle" then
|
||
startCharge(tool)
|
||
else
|
||
onActivate()
|
||
end
|
||
end)
|
||
tool.Deactivated:Connect(releaseCast)
|
||
tool.Unequipped:Connect(function()
|
||
if state == "waiting" or state == "bite" or state == "casting" then
|
||
remote:FireServer("Cancel")
|
||
end
|
||
setState("idle")
|
||
end)
|
||
end
|
||
local function watch(container)
|
||
for _, c in ipairs(container:GetChildren()) do
|
||
hookTool(c)
|
||
end
|
||
container.ChildAdded:Connect(hookTool)
|
||
end
|
||
player.ChildAdded:Connect(function(c)
|
||
if c:IsA("Backpack") then
|
||
watch(c)
|
||
end
|
||
end)
|
||
if player:FindFirstChild("Backpack") then
|
||
watch(player.Backpack)
|
||
end
|
||
player.CharacterAdded:Connect(function(char)
|
||
setState("idle")
|
||
watch(char)
|
||
end)
|
||
if player.Character then
|
||
watch(player.Character)
|
||
end
|
||
|
||
RunService.RenderStepped:Connect(function()
|
||
if state == "charging" and charge then
|
||
updateCharge()
|
||
end
|
||
end)
|
||
|
||
RunService.RenderStepped:Connect(function(dt)
|
||
if state ~= "bite" then
|
||
return
|
||
end
|
||
mg.pos += mg.dir * mg.speed * dt
|
||
if mg.pos >= 1 then
|
||
mg.pos, mg.dir = 1, -1
|
||
elseif mg.pos <= 0 then
|
||
mg.pos, mg.dir = 0, 1
|
||
end
|
||
markerF.Position = UDim2.fromScale(mg.pos, 0.5)
|
||
local left = math.max(0, mg.deadline - os.clock())
|
||
timeBar.Size = UDim2.new(left / mg.timeout, -30 * left / mg.timeout, 0, 5)
|
||
if left <= 0 then
|
||
setState("reeling")
|
||
remote:FireServer("Catch", false, mg.misses)
|
||
end
|
||
end)
|
||
|
||
UserInputService.InputBegan:Connect(function(input, processed)
|
||
if processed then
|
||
return
|
||
end
|
||
local k = input.KeyCode
|
||
if k == Enum.KeyCode.B then
|
||
bagWin.toggle("fish")
|
||
elseif k == Enum.KeyCode.C then
|
||
bagWin.toggle("dex")
|
||
elseif k == Enum.KeyCode.M then
|
||
worldsWin.toggle()
|
||
elseif k == Enum.KeyCode.Q then
|
||
questWin.toggle()
|
||
end
|
||
end)
|
||
|
||
---------------------------------------------------------------- атмосфера миров (только у этого игрока)
|
||
|
||
local snowPart = new("Part", {
|
||
Name = "SnowFX", Anchored = true, CanCollide = false, CanQuery = false, CanTouch = false,
|
||
Transparency = 1, Size = Vector3.new(90, 1, 90), Parent = workspace,
|
||
})
|
||
local snow = new("ParticleEmitter", {
|
||
Rate = 0, Lifetime = NumberRange.new(5, 7), Speed = NumberRange.new(4, 7),
|
||
EmissionDirection = Enum.NormalId.Bottom, SpreadAngle = Vector2.new(15, 15),
|
||
Size = NumberSequence.new(0.25), Color = ColorSequence.new(WHITE), LightEmission = 0.3,
|
||
Parent = snowPart,
|
||
})
|
||
local lastWorldId = "none"
|
||
local terrain = workspace.Terrain
|
||
local defaultWater = Color3.fromRGB(10, 55, 70)
|
||
|
||
local function applyAmbience(world)
|
||
local clock = (world and world.clock) or 14.5
|
||
TweenService:Create(Lighting, TweenInfo.new(2), { ClockTime = clock }):Play()
|
||
terrain.WaterColor = (world and world.water) or defaultWater
|
||
local atm = Lighting:FindFirstChildOfClass("Atmosphere")
|
||
if atm then
|
||
local frost = world and world.id == "World3"
|
||
TweenService:Create(atm, TweenInfo.new(2), {
|
||
Density = frost and 0.38 or 0.25,
|
||
Color = frost and Color3.fromRGB(170, 200, 235) or Color3.fromRGB(200, 215, 232),
|
||
}):Play()
|
||
end
|
||
snow.Rate = (world and world.id == "World3") and 140 or 0
|
||
end
|
||
|
||
task.spawn(function()
|
||
while true do
|
||
local w = currentWorld()
|
||
local id = w and w.id or "lobby"
|
||
if id ~= lastWorldId then
|
||
lastWorldId = id
|
||
applyAmbience(w)
|
||
if w then
|
||
notify(w.icon .. " " .. w.name, w.color)
|
||
end
|
||
end
|
||
local cam = workspace.CurrentCamera
|
||
if cam then
|
||
snowPart.CFrame = CFrame.new(cam.CFrame.Position + Vector3.new(0, 25, 0))
|
||
end
|
||
-- баннер события
|
||
local evId = workspace:GetAttribute("Event")
|
||
local event = evId and Config.Find(Config.Events, evId)
|
||
if event then
|
||
eventBanner.Visible = true
|
||
eventTitle.Text = event.name .. " " .. timeStr((workspace:GetAttribute("EventEnds") or 0) - workspace:GetServerTimeNow())
|
||
eventDesc.Text = event.desc
|
||
else
|
||
eventBanner.Visible = false
|
||
end
|
||
task.wait(0.5)
|
||
end
|
||
end)
|
||
|
||
---------------------------------------------------------------- обучение: линия-подсказка
|
||
-- белые «стрелки» бегут по земле от игрока к цели текущего шага (см. Config.TutorialDone)
|
||
|
||
local GUIDE_N, GUIDE_GAP, GUIDE_SPEED = 32, 3, 7 -- сколько стрелок, шаг между ними, скорость бега
|
||
local W1 = Config.Worlds[1].center
|
||
local guideStep = 0 -- шаг, отправленный на сервер (атрибут Tutorial может прийти чуть позже)
|
||
|
||
local guideHint = text({
|
||
Size = UDim2.fromOffset(560, 42), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 64),
|
||
BackgroundTransparency = 0.2, BackgroundColor3 = C.bg, Font = TITLE, TextSize = 20,
|
||
TextXAlignment = Enum.TextXAlignment.Center, Visible = false, Parent = gui,
|
||
}, nil)
|
||
corner(12).Parent = guideHint
|
||
stroke(C.gold, 2).Parent = guideHint
|
||
|
||
local guideFolder = new("Folder", { Name = "TutorialGuide", Parent = workspace })
|
||
local chevrons = {}
|
||
for i = 1, GUIDE_N do
|
||
local arms = {}
|
||
for k = 1, 2 do
|
||
arms[k] = new("Part", {
|
||
Anchored = true, CanCollide = false, CanQuery = false, CanTouch = false, CastShadow = false,
|
||
Material = Enum.Material.Neon, Color = Color3.fromRGB(70, 195, 255), Size = Vector3.new(0.5, 0.5, 2), Transparency = 1,
|
||
Parent = guideFolder,
|
||
})
|
||
end
|
||
chevrons[i] = arms
|
||
end
|
||
-- два объёмных бруска стрелки «>» острием вперёд (по -Z)
|
||
local GUIDE_HEIGHT = 2.2 -- стрелки висят в воздухе над землёй
|
||
local ARM_CF = {}
|
||
for k, s in ipairs({ -1, 1 }) do
|
||
local center = Vector3.new(s * 0.65, 0, -0.15)
|
||
ARM_CF[k] = CFrame.lookAt(center, center + Vector3.new(s * 1.3, 0, 1.5))
|
||
end
|
||
local function hideChevrons(from)
|
||
for i = from, GUIDE_N do
|
||
chevrons[i][1].Transparency = 1
|
||
chevrons[i][2].Transparency = 1
|
||
end
|
||
end
|
||
|
||
local guideRay = RaycastParams.new()
|
||
guideRay.FilterType = Enum.RaycastFilterType.Exclude
|
||
guideRay.RespectCanCollide = true
|
||
guideRay.IgnoreWater = false
|
||
|
||
local function tutorialStep()
|
||
return math.max(player:GetAttribute("Tutorial") or 0, guideStep)
|
||
end
|
||
local function advanceTutorial(step)
|
||
if step > tutorialStep() then
|
||
guideStep = step
|
||
remote:FireServer("Tutorial", step)
|
||
if step >= Config.TutorialDone then
|
||
notify("🎓 Обучение пройдено! Дальше — сам: лови, улучшай удочку, открывай миры", C.gold)
|
||
end
|
||
end
|
||
end
|
||
|
||
local function guideMarker(name)
|
||
local map = workspace:FindFirstChild("FishingMap")
|
||
local m = map and map:FindFirstChild(name)
|
||
return m and m.Position
|
||
end
|
||
|
||
-- объект цели подсвечивается голубым (атрибут GuideTarget ставит MapBuilder)
|
||
local guideHighlight = new("Highlight", {
|
||
FillColor = Color3.fromRGB(70, 195, 255), OutlineColor = Color3.fromRGB(170, 235, 255),
|
||
DepthMode = Enum.HighlightDepthMode.AlwaysOnTop, Enabled = false, Parent = guideFolder,
|
||
})
|
||
local guideObjects, guideScanAt = {}, {}
|
||
local function guideObject(key)
|
||
local obj = guideObjects[key]
|
||
if obj and obj.Parent then
|
||
return obj
|
||
end
|
||
-- карта большая: если объекта нет (ещё не загрузился), ищем заново не чаще раза в 2 секунды
|
||
if guideScanAt[key] and os.clock() - guideScanAt[key] < 2 then
|
||
return nil
|
||
end
|
||
guideScanAt[key] = os.clock()
|
||
local map = workspace:FindFirstChild("FishingMap")
|
||
if not map then
|
||
return nil
|
||
end
|
||
for _, d in ipairs(map:GetDescendants()) do
|
||
if d:GetAttribute("GuideTarget") == key then
|
||
guideObjects[key] = d
|
||
return d
|
||
end
|
||
end
|
||
return nil
|
||
end
|
||
|
||
-- маршрут для текущего шага: точки ломаной (без игрока), подсказка и что подсветить; nil — линию не показываем
|
||
local function guideRoute(step, pos, world)
|
||
local inW1 = world and world.id == "World1"
|
||
if step == 0 and not world then
|
||
return { guideMarker("GuideBoard") }, "📋 Прочитай табличку «Как играть»", "Board"
|
||
elseif not world then -- шаги 1–3 из лобби: сначала в портал
|
||
return { guideMarker("GuidePortal") }, "🌊 Иди в портал «Тихое озеро»", "Portal"
|
||
elseif step == 2 and inW1 then
|
||
return { guideMarker("GuideFishSpot") }, "🎣 Иди на причал, зажми ЛКМ и отпусти — заброс!", "Pier"
|
||
elseif step == 3 and inW1 then
|
||
local route = {}
|
||
local rel = pos - W1
|
||
if math.abs(rel.X) < 6 and rel.Z < 80 then
|
||
table.insert(route, W1 + Vector3.new(0, 4.5, 84)) -- сначала сойти с причала
|
||
end
|
||
table.insert(route, guideMarker("GuideSell"))
|
||
return route, "💰 Продай рыбу в скупке", "Sell"
|
||
end
|
||
return nil
|
||
end
|
||
|
||
RunService.RenderStepped:Connect(function()
|
||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||
local step = tutorialStep()
|
||
-- пока сервер не прислал шаг (данные ещё грузятся), ничего не показываем
|
||
if not hrp or player:GetAttribute("Tutorial") == nil or step >= Config.TutorialDone then
|
||
guideHint.Visible = false
|
||
guideHighlight.Enabled = false
|
||
hideChevrons(1)
|
||
return
|
||
end
|
||
local pos = hrp.Position
|
||
local world = Config.WorldAt(pos)
|
||
|
||
-- переходы между шагами
|
||
if step <= 1 and world and world.id == "World1" then
|
||
advanceTutorial(2)
|
||
elseif step == 0 then
|
||
local board = guideMarker("GuideBoard")
|
||
if board and (board - pos).Magnitude < 9 then
|
||
advanceTutorial(1)
|
||
end
|
||
elseif step == 2 and (player:GetAttribute("TotalCaught") or 0) > 0 then
|
||
advanceTutorial(3)
|
||
end
|
||
step = tutorialStep()
|
||
|
||
local route, hint, key = guideRoute(step, pos, world)
|
||
guideHint.Text = hint or ""
|
||
guideHint.Visible = hint ~= nil and state == "idle"
|
||
local target = (key and state == "idle") and guideObject(key) or nil
|
||
guideHighlight.Adornee = target or nil
|
||
guideHighlight.Enabled = target ~= nil
|
||
if target then
|
||
local pulse = (math.sin(os.clock() * 4) + 1) / 2 -- мягкое мигание
|
||
guideHighlight.FillTransparency = 0.45 + 0.3 * pulse
|
||
guideHighlight.OutlineTransparency = 0.3 * pulse
|
||
end
|
||
if not route or #route == 0 or state ~= "idle" then
|
||
hideChevrons(1)
|
||
return
|
||
end
|
||
|
||
-- ломаная от ног игрока через точки маршрута
|
||
local pts = { pos - Vector3.new(0, 3, 0) }
|
||
for _, p in ipairs(route) do
|
||
table.insert(pts, p)
|
||
end
|
||
local lens, total = {}, 0
|
||
for i = 2, #pts do
|
||
local d = ((pts[i] - pts[i - 1]) * Vector3.new(1, 0, 1)).Magnitude
|
||
lens[i] = math.max(d, 0.001)
|
||
total += d
|
||
end
|
||
if total < 4 then
|
||
hideChevrons(1) -- уже на месте
|
||
return
|
||
end
|
||
|
||
guideRay.FilterDescendantsInstances = { player.Character, guideFolder }
|
||
local phase = (os.clock() * GUIDE_SPEED) % GUIDE_GAP
|
||
local seg, segStart = 2, 0
|
||
for i = 1, GUIDE_N do
|
||
local d = 2 + phase + (i - 1) * GUIDE_GAP
|
||
if d > total - 1 then
|
||
hideChevrons(i)
|
||
break
|
||
end
|
||
while seg < #pts and d > segStart + lens[seg] do
|
||
segStart += lens[seg]
|
||
seg += 1
|
||
end
|
||
local a, b = pts[seg - 1], pts[seg]
|
||
local p = a:Lerp(b, (d - segStart) / lens[seg])
|
||
local dir = (b - a) * Vector3.new(1, 0, 1)
|
||
local hit = workspace:Raycast(p + Vector3.new(0, 4, 0), Vector3.new(0, -12, 0), guideRay)
|
||
-- висят в воздухе и слегка покачиваются волной
|
||
local y = (hit and hit.Position.Y or p.Y) + GUIDE_HEIGHT + math.sin(os.clock() * 4 - d * 0.5) * 0.25
|
||
local base = CFrame.lookAt(Vector3.new(p.X, y, p.Z), Vector3.new(p.X, y, p.Z) + dir)
|
||
-- у игрока и у цели стрелки плавно проявляются и гаснут
|
||
local fade = math.max(0, 1 - math.min(d - 2, total - 1 - d) / 2.5)
|
||
local tr = 0.05 + 0.95 * fade
|
||
for k = 1, 2 do
|
||
chevrons[i][k].CFrame = base * ARM_CF[k]
|
||
chevrons[i][k].Transparency = tr
|
||
end
|
||
end
|
||
end)
|
||
|
||
---------------------------------------------------------------- события от сервера
|
||
|
||
remote.OnClientEvent:Connect(function(action, a, b, c)
|
||
if action == "Notify" then
|
||
notify(a, b)
|
||
elseif action == "Cast" then
|
||
setState("waiting")
|
||
startCastCam(a, b)
|
||
elseif action == "CastFail" or action == "Cancel" or action == "Escaped" then
|
||
if action == "CastFail" and castTool and castTool.Parent then
|
||
castTool.Grip = gripCF(REST_ANGLE) -- сервер удочку не трогал, а у нас она в замахе
|
||
end
|
||
setState("idle")
|
||
elseif action == "Bite" then
|
||
mg.speed = a.speed
|
||
mg.zoneWidth = a.zoneWidth
|
||
mg.need = a.hits
|
||
mg.hits = 0
|
||
mg.misses = 0
|
||
mg.maxMisses = a.misses
|
||
mg.timeout = a.timeout
|
||
mg.deadline = os.clock() + a.timeout
|
||
mg.pos, mg.dir = 0, 1
|
||
placeZone()
|
||
updatePips()
|
||
setState("bite")
|
||
elseif action == "Caught" then
|
||
setState("idle")
|
||
showCatch(a, b)
|
||
playUiSound(DING, 0.5)
|
||
elseif action == "Sold" then
|
||
if tutorialStep() == 3 then
|
||
advanceTutorial(Config.TutorialDone)
|
||
end
|
||
floatText("+" .. fmt(a) .. " 💰", C.gold)
|
||
notify(("Продано рыб: %d → +%s 💰"):format(b, fmt(a)), Color3.fromRGB(120, 255, 140))
|
||
elseif action == "Inventory" then
|
||
inventory = a or {}
|
||
discovered = b or {}
|
||
claimed = c or {}
|
||
bagWin.refresh()
|
||
refreshDots()
|
||
elseif action == "Quests" then
|
||
quests = a or {}
|
||
daily = b or daily
|
||
questWin.refresh()
|
||
refreshDots()
|
||
elseif action == "OpenShop" then
|
||
shopWin.open("rods")
|
||
elseif action == "OpenQuests" then
|
||
questWin.open("daily")
|
||
elseif action == "OpenRobux" then
|
||
robuxWin.open(a)
|
||
end
|
||
end)
|
||
|
||
remote:FireServer("RequestInventory")
|