Дома на Острове 2: код из Studio перенесён в src и соединён с GameServer/FishingClient
This commit is contained in:
1 parent
a9bc4207cb
commit
0fe8bd35a0
8 files changed
+2032
-4
No files matched your search
@@ -2552,7 +2552,7 @@ local function teleportLoading(targetId, delay)
|
||||
loadingGui:SetAttribute("Ready", false)
|
||||
loadingGui:SetAttribute("StartAt", now)
|
||||
loadingGui:SetAttribute("MinUntil", now + Config.Loading.teleport)
|
||||
loadingGui:SetAttribute("Title", placeTitle(target))
|
||||
loadingGui:SetAttribute("Title", targetId == "Home" and "🏠 Мой дом" or placeTitle(target))
|
||||
loadingGui:SetAttribute("Visible", true)
|
||||
end
|
||||
task.spawn(function()
|
||||
@@ -2562,7 +2562,18 @@ local function teleportLoading(targetId, delay)
|
||||
repeat
|
||||
task.wait()
|
||||
w = currentWorld()
|
||||
until (w and w.id or "Lobby") == targetId or os.clock() > deadline or token ~= teleportToken
|
||||
local arrived
|
||||
if targetId == "Home" then
|
||||
-- остров «Мой дом» не мир из Config: ждём, пока персонаж окажется рядом с его спавном
|
||||
local island = workspace:FindFirstChild("Island2")
|
||||
local spawnPart = island and island:FindFirstChild("HomeSpawn")
|
||||
local char = Players.LocalPlayer.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
arrived = spawnPart ~= nil and hrp ~= nil and (hrp.Position - spawnPart.Position).Magnitude < 300
|
||||
else
|
||||
arrived = (w and w.id or "Lobby") == targetId
|
||||
end
|
||||
until arrived or os.clock() > deadline or token ~= teleportToken
|
||||
if token ~= teleportToken then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -0,0 +1,689 @@
|
||||
-- HouseClient (LocalScript) -> StarterPlayer > StarterPlayerScripts
|
||||
-- Остров «Мой дом», клиент:
|
||||
-- • окно «Мой дом» (уровень дома, улучшение) — у таблички участка ("OpenHouse");
|
||||
-- • окно «Компьютер» — категории HouseCosmetics строками с шансами, кнопки крутки ("OpenHouseComputer");
|
||||
-- • открытие как в кейсах: на весь экран, по ленте на каждую крутку, линия со стрелками по центру,
|
||||
-- «Катиться быстрее» и автоматическое вращение ("HouseSpinResult");
|
||||
-- • та же лента на экране компьютера в доме — видна всем игрокам ("HouseScreenSpin").
|
||||
-- Стиль окон — Theme.kit из FishingClient.
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local RunService = game:GetService("RunService")
|
||||
local Lighting = game:GetService("Lighting")
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local HC = require(ReplicatedStorage:WaitForChild("HouseConfig"))
|
||||
local COS = require(ReplicatedStorage:WaitForChild("HouseCosmetics"))
|
||||
local Theme = require(script.Parent:WaitForChild("UiTheme"))
|
||||
local remote = ReplicatedStorage:WaitForChild("GameEvent")
|
||||
local okAudio, Audio = pcall(function()
|
||||
return require(script.Parent:WaitForChild("Audio", 5))
|
||||
end)
|
||||
|
||||
while not Theme.kit do
|
||||
task.wait(0.1)
|
||||
end
|
||||
local K = Theme.kit
|
||||
local C = Theme.C
|
||||
local new, text, btn, corner, stroke, gradient = K.new, K.text, K.btn, K.corner, K.stroke, K.gradient
|
||||
local fmt = K.fmt
|
||||
local TITLE = K.TITLE
|
||||
local CENTER = Enum.TextXAlignment.Center
|
||||
local RIGHT = Enum.TextXAlignment.Right
|
||||
local WHITE = Color3.new(1, 1, 1)
|
||||
local GREEN = Color3.fromRGB(70, 140, 70)
|
||||
|
||||
local function sound(name)
|
||||
if okAudio and Audio then
|
||||
pcall(Audio.play, name)
|
||||
end
|
||||
end
|
||||
|
||||
-- своя кнопка «закрыть» в правом верхнем углу (рисованная печать окна не всегда загружается)
|
||||
local function closeButton(parent, onClick, z)
|
||||
local b = btn({ Name = "CloseX", Size = UDim2.fromOffset(42, 42), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 10), BackgroundColor3 = C.crimson,
|
||||
Text = "✕", TextSize = 24, TextColor3 = C.goldBright, ZIndex = z or 60, Parent = parent }, onClick)
|
||||
if Theme.unskin then
|
||||
Theme.unskin(b)
|
||||
end
|
||||
local c = b:FindFirstChildOfClass("UICorner")
|
||||
if c then
|
||||
c.CornerRadius = UDim.new(1, 0)
|
||||
end
|
||||
Theme.pressFx(b)
|
||||
return b
|
||||
end
|
||||
|
||||
local function card(list, order, height, strokeColor)
|
||||
return new("Frame", { Size = UDim2.new(1, -4, 0, height), BackgroundColor3 = WHITE, LayoutOrder = order, Parent = list },
|
||||
{ corner(8), stroke(strokeColor or C.goldDark, 2, 0), gradient(C.woodLight, C.wood, 90) })
|
||||
end
|
||||
|
||||
local function clearList(list)
|
||||
for _, c in ipairs(list:GetChildren()) do
|
||||
if c:IsA("GuiObject") then
|
||||
c:Destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- образец предмета: цветной квадрат или шар (кусты), у радужных — градиент
|
||||
local function swatch(parent, cat, it, props)
|
||||
local r = COS.Rarities[it.rarity]
|
||||
local sw = new("Frame", props)
|
||||
sw.BackgroundColor3 = it.color
|
||||
corner(cat.id == "bush" and it.shape == "Ball" and 999 or 6).Parent = sw
|
||||
stroke(r.color, 2, 0).Parent = sw
|
||||
if it.rainbow then
|
||||
new("UIGradient", { Color = ColorSequence.new({
|
||||
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 90, 90)), ColorSequenceKeypoint.new(0.33, Color3.fromRGB(255, 230, 90)),
|
||||
ColorSequenceKeypoint.new(0.66, Color3.fromRGB(90, 220, 255)), ColorSequenceKeypoint.new(1, Color3.fromRGB(220, 110, 255)),
|
||||
}), Parent = sw })
|
||||
end
|
||||
sw.Parent = props.Parent
|
||||
return sw
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- окно «Мой дом»: уровень и улучшение
|
||||
|
||||
local win = K.makeWindow("🏠 Мой дом", GREEN, { { id = "house", label = "🏠 Дом" } })
|
||||
local list = K.scrollArea(win.pages.house)
|
||||
closeButton(win.frame, function()
|
||||
win.close()
|
||||
end)
|
||||
|
||||
local function render()
|
||||
clearList(list)
|
||||
local lvl = player:GetAttribute("HouseLevel") or 0
|
||||
local coins = player:GetAttribute("Coins") or 0
|
||||
local plot = player:GetAttribute("HousePlot")
|
||||
|
||||
local head = card(list, 1, 96, C.gold)
|
||||
text({ Size = UDim2.new(1, -24, 0, 30), Position = UDim2.fromOffset(12, 8), Font = TITLE, TextSize = 24, TextColor3 = C.goldBright,
|
||||
Text = ("Ур. %d · %s"):format(lvl, HC.name(lvl)), Parent = head })
|
||||
text({ Size = UDim2.new(1, -24, 0, 20), Position = UDim2.fromOffset(12, 38), TextSize = 15, TextColor3 = C.muted,
|
||||
Text = plot and ("Участок №" .. plot .. " на острове") or "Участок выдаётся на острове «Мой дом»", Parent = head })
|
||||
text({ Size = UDim2.new(0, 220, 0, 20), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 38), TextSize = 15, TextXAlignment = RIGHT,
|
||||
TextColor3 = C.silver, Text = ("%s %s"):format(fmt(coins), Theme.SILVER), Parent = head })
|
||||
local bar = new("Frame", { Size = UDim2.new(1, -24, 0, 14), Position = UDim2.fromOffset(12, 68), BackgroundColor3 = C.dark, Parent = head },
|
||||
{ corner(7), stroke(C.goldDark, 1.5, 0) })
|
||||
new("Frame", { Size = UDim2.fromScale(lvl / HC.MaxLevel, 1), BackgroundColor3 = Color3.fromRGB(110, 200, 110), BorderSizePixel = 0, Parent = bar }, { corner(7) })
|
||||
text({ Size = UDim2.fromScale(1, 1), TextSize = 12, TextXAlignment = CENTER, Font = TITLE, Text = lvl .. " / " .. HC.MaxLevel,
|
||||
TextStrokeTransparency = 0.4, TextStrokeColor3 = C.ink, Parent = bar })
|
||||
|
||||
if lvl < HC.MaxLevel then
|
||||
local nextLv = lvl + 1
|
||||
local cost = HC.cost(nextLv)
|
||||
local can = coins >= cost and plot ~= nil
|
||||
local up = card(list, 2, 74, Color3.fromRGB(110, 200, 110))
|
||||
text({ Size = UDim2.new(1, -230, 0, 26), Position = UDim2.fromOffset(12, 10), Font = TITLE, TextSize = 20, TextColor3 = C.text,
|
||||
Text = ("Следующий: ур. %d · %s"):format(nextLv, HC.name(nextLv)), Parent = up })
|
||||
text({ Size = UDim2.new(1, -230, 0, 22), Position = UDim2.fromOffset(12, 40), TextSize = 16, TextColor3 = can and C.silver or Color3.fromRGB(255, 138, 122),
|
||||
Text = ("Цена: %s %s"):format(fmt(cost), Theme.SILVER), Parent = up })
|
||||
local b = btn({ Size = UDim2.fromOffset(200, 48), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0),
|
||||
BackgroundColor3 = can and GREEN or C.grey, Text = can and "Улучшить" or (plot and "Мало серебра" or "Нет участка"), TextSize = 20, Parent = up }, function()
|
||||
remote:FireServer("HouseUpgrade")
|
||||
end)
|
||||
b.AutoButtonColor = can
|
||||
Theme.pressFx(b)
|
||||
else
|
||||
local done = card(list, 2, 52, C.goldBright)
|
||||
text({ Size = UDim2.fromScale(1, 1), Font = TITLE, TextSize = 20, TextXAlignment = CENTER, TextColor3 = C.goldBright,
|
||||
Text = "👑 Максимальный уровень дома!", Parent = done })
|
||||
end
|
||||
|
||||
for i = 1, HC.MaxLevel do
|
||||
local owned = i <= lvl
|
||||
local isNext = i == lvl + 1
|
||||
local row = card(list, 10 + i, 40, owned and Color3.fromRGB(110, 200, 110) or (isNext and C.gold or C.goldDark))
|
||||
if not owned and not isNext then
|
||||
row.BackgroundTransparency = 0.35
|
||||
end
|
||||
text({ Size = UDim2.new(0, 46, 1, 0), Position = UDim2.fromOffset(10, 0), Font = TITLE, TextSize = 18,
|
||||
TextColor3 = owned and Color3.fromRGB(160, 240, 160) or C.goldBright, Text = owned and "✔" or tostring(i), Parent = row })
|
||||
text({ Size = UDim2.new(1, -260, 1, 0), Position = UDim2.fromOffset(50, 0), TextSize = 17, TextColor3 = owned and C.text or C.muted,
|
||||
Text = ("Ур. %d · %s"):format(i, HC.name(i)), Parent = row })
|
||||
text({ Size = UDim2.new(0, 220, 1, 0), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 0), TextSize = 16, TextXAlignment = RIGHT,
|
||||
TextColor3 = owned and Color3.fromRGB(160, 240, 160) or C.silver, Text = owned and "куплено" or (fmt(HC.cost(i)) .. " " .. Theme.SILVER), Parent = row })
|
||||
end
|
||||
end
|
||||
win.render = render
|
||||
|
||||
---------------------------------------------------------------- окно «Компьютер»: категории строками с шансами
|
||||
-- Нажать на полученный предмет — надеть (ещё раз — вернуть стандарт).
|
||||
|
||||
local cos = { owned = {}, equip = {} } -- последнее состояние от сервера
|
||||
local lastSpin = {} -- [категория] = { [id] = сколько выпало в последней крутке }
|
||||
local spinning = false -- идёт открытие: строки не перерисовываем, повторно не крутим
|
||||
|
||||
local pcWin = K.makeWindow("💻 Компьютер", Color3.fromRGB(70, 200, 120), { { id = "spin", label = "🎲 Улучшения" } })
|
||||
local pcList = K.scrollArea(pcWin.pages.spin)
|
||||
closeButton(pcWin.frame, function()
|
||||
pcWin.close()
|
||||
end)
|
||||
|
||||
local function ownedSet(catId)
|
||||
local set = {}
|
||||
for _, id in ipairs(cos.owned[catId] or {}) do
|
||||
set[id] = true
|
||||
end
|
||||
return set
|
||||
end
|
||||
|
||||
local function requestSpin(catId, n)
|
||||
if spinning then
|
||||
return
|
||||
end
|
||||
local cat = COS.category(catId)
|
||||
if (player:GetAttribute("Coins") or 0) < cat.cost * n then
|
||||
K.notify("Не хватает серебра", Color3.fromRGB(255, 120, 120))
|
||||
return
|
||||
end
|
||||
spinning = true -- снимется, когда закроется открытие (или сервер не ответит)
|
||||
remote:FireServer("HouseSpin", catId, n)
|
||||
task.delay(3, function()
|
||||
if spinning and not (player.PlayerGui:FindFirstChild("HouseSpinGui") and player.PlayerGui.HouseSpinGui.Enabled) then
|
||||
spinning = false
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function renderPc()
|
||||
clearList(pcList)
|
||||
local coins = player:GetAttribute("Coins") or 0
|
||||
text({ Size = UDim2.new(1, -4, 0, 24), LayoutOrder = 0, TextSize = 15, TextColor3 = C.muted, Parent = pcList,
|
||||
Text = ("Твоё серебро: %s %s · повтор возвращает %d%% цены · нажми на свой предмет, чтобы надеть"):format(fmt(coins), Theme.SILVER, COS.DuplicateRefund * 100) })
|
||||
for ci, cat in ipairs(COS.Categories) do
|
||||
local owned = ownedSet(cat.id)
|
||||
local equipped = cos.equip[cat.id]
|
||||
local row = new("Frame", { Size = UDim2.new(1, -4, 0, 196), BackgroundColor3 = WHITE, LayoutOrder = ci, Parent = pcList },
|
||||
{ corner(8), stroke(C.goldDark, 2, 0), gradient(C.woodLight, C.wood, 90) })
|
||||
local have = 0
|
||||
for _ in pairs(owned) do
|
||||
have += 1
|
||||
end
|
||||
local btnW = 118
|
||||
local btnsW = #COS.SpinCounts * (btnW + 8)
|
||||
text({ Size = UDim2.new(1, -(btnsW + 24), 0, 30), Position = UDim2.fromOffset(12, 8), Font = TITLE, TextSize = 21, TextColor3 = C.goldBright,
|
||||
Text = ("%s %s"):format(cat.icon, cat.name), Parent = row })
|
||||
text({ Size = UDim2.new(1, -(btnsW + 24), 0, 18), Position = UDim2.fromOffset(12, 36), TextSize = 14, TextColor3 = C.muted, TextTruncate = Enum.TextTruncate.AtEnd,
|
||||
Text = ("Собрано %d / %d · надето: %s"):format(have, #cat.items, equipped and cat.byId[equipped] and cat.byId[equipped].name or "стандарт"), Parent = row })
|
||||
for bi, n in ipairs(COS.SpinCounts) do
|
||||
local cost = cat.cost * n
|
||||
local can = coins >= cost
|
||||
local b = btn({ Size = UDim2.fromOffset(btnW, 44), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12 - (#COS.SpinCounts - bi) * (btnW + 8), 0, 8),
|
||||
BackgroundColor3 = can and GREEN or C.grey, TextSize = 14, TextWrapped = true,
|
||||
Text = ("Открыть %d\n%s %s"):format(n, fmt(cost), Theme.SILVER), Parent = row }, function()
|
||||
requestSpin(cat.id, n)
|
||||
end)
|
||||
b.AutoButtonColor = can
|
||||
Theme.pressFx(b)
|
||||
end
|
||||
local tiles = new("Frame", { Size = UDim2.new(1, -24, 0, 126), Position = UDim2.fromOffset(12, 60), BackgroundTransparency = 1, Parent = row }, {
|
||||
new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder }),
|
||||
})
|
||||
local n = #cat.items
|
||||
for ii, it in ipairs(cat.items) do
|
||||
local r = COS.Rarities[it.rarity]
|
||||
local has = owned[it.id] == true
|
||||
local on = equipped == it.id
|
||||
local tile = new("TextButton", { Size = UDim2.new(1 / n, -6 + 6 / n, 1, 0), BackgroundColor3 = C.dark, BackgroundTransparency = has and 0.1 or 0.45,
|
||||
AutoButtonColor = has, Text = "", LayoutOrder = ii, Parent = tiles }, { corner(8), stroke(on and C.goldBright or r.color, on and 3.5 or 2, has and 0 or 0.35) })
|
||||
local sw = swatch(tile, cat, it, { Size = UDim2.fromOffset(46, 46), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 8),
|
||||
BackgroundTransparency = has and 0 or 0.4, Parent = tile })
|
||||
if not has then
|
||||
text({ Size = UDim2.fromScale(1, 1), TextXAlignment = CENTER, TextSize = 22, Font = TITLE, Text = "?", TextColor3 = WHITE, TextStrokeTransparency = 0.3, TextStrokeColor3 = C.ink, Parent = sw })
|
||||
end
|
||||
text({ Size = UDim2.new(1, -8, 0, 30), Position = UDim2.fromOffset(4, 56), TextSize = 12, TextWrapped = true, TextXAlignment = CENTER,
|
||||
TextColor3 = has and C.text or C.muted, Text = it.name, Parent = tile })
|
||||
text({ Size = UDim2.new(1, -8, 0, 22), Position = UDim2.fromOffset(4, 86), Font = TITLE, TextSize = 18, TextXAlignment = CENTER,
|
||||
TextColor3 = r.color, TextStrokeColor3 = C.ink, TextStrokeTransparency = 0.3, Text = COS.chanceText(it.chance), Parent = tile })
|
||||
text({ Size = UDim2.new(1, -8, 0, 14), Position = UDim2.fromOffset(4, 108), TextSize = 11, TextXAlignment = CENTER,
|
||||
TextColor3 = on and C.goldBright or (has and Color3.fromRGB(160, 240, 160) or C.muted),
|
||||
Text = on and "Надето" or (has and "есть" or r.name), Parent = tile })
|
||||
local got = lastSpin[cat.id] and lastSpin[cat.id][it.id]
|
||||
if got then
|
||||
text({ Size = UDim2.fromOffset(40, 18), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -4, 0, 4), BackgroundTransparency = 0, BackgroundColor3 = Color3.fromRGB(70, 160, 70),
|
||||
TextSize = 12, Font = TITLE, TextXAlignment = CENTER, Text = "+" .. got, Parent = tile })
|
||||
end
|
||||
if has then
|
||||
tile.MouseButton1Click:Connect(function()
|
||||
remote:FireServer("HouseEquip", cat.id, (not on) and it.id or nil)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
pcWin.render = function()
|
||||
if not spinning then
|
||||
renderPc()
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- плитка ленты (как в кейсах): тёмная карточка, цветная полоса редкости снизу
|
||||
|
||||
local function reelTile(parent, cat, it, w, h, x, y, z, small)
|
||||
local r = COS.Rarities[it.rarity]
|
||||
-- привязка по центру: UIScale увеличивает выпавший лот симметрично, линия остаётся по его центру
|
||||
local t = new("Frame", { Name = "Tile", Size = UDim2.fromOffset(w, h), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(x + w / 2, y + h / 2),
|
||||
BackgroundColor3 = WHITE, BorderSizePixel = 0, ZIndex = z, Parent = parent })
|
||||
local g = new("UIGradient", { Color = ColorSequence.new(Color3.fromRGB(44, 44, 52), Color3.fromRGB(16, 16, 20)), Rotation = 90, Parent = t })
|
||||
local st = new("UIStroke", { Color = Color3.fromRGB(70, 70, 82), Thickness = small and 1 or 1.5, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = t })
|
||||
new("Frame", { Name = "RarityBar", Size = UDim2.new(1, 0, 0, small and 3 or 4), AnchorPoint = Vector2.new(0, 1), Position = UDim2.fromScale(0, 1), BackgroundColor3 = r.color,
|
||||
BorderSizePixel = 0, ZIndex = z + 2, Parent = t })
|
||||
local s = math.floor(h * 0.48)
|
||||
swatch(t, cat, it, { Size = UDim2.fromOffset(s, s), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, math.floor(h * 0.1)), ZIndex = z + 1, Parent = t })
|
||||
new("TextLabel", { Size = UDim2.new(1, -8, 0, math.floor(h * 0.2)), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -(small and 4 or 6)), BackgroundTransparency = 1,
|
||||
Font = K.BODY, TextScaled = true, TextColor3 = Color3.fromRGB(225, 225, 230), Text = it.name, ZIndex = z + 1, Parent = t })
|
||||
return t, g, st
|
||||
end
|
||||
|
||||
-- выпавшая плитка: светлая «подсветка», рамка редкости, увеличение
|
||||
local function highlight(tile, g, st, it)
|
||||
local r = COS.Rarities[it.rarity]
|
||||
g.Color = ColorSequence.new({
|
||||
ColorSequenceKeypoint.new(0, Color3.fromRGB(150, 185, 215)),
|
||||
ColorSequenceKeypoint.new(0.45, Color3.fromRGB(60, 86, 112)),
|
||||
ColorSequenceKeypoint.new(1, Color3.fromRGB(18, 22, 30)),
|
||||
})
|
||||
st.Color = Color3.fromRGB(235, 235, 240)
|
||||
st.Thickness = 2.5
|
||||
tile.RarityBar.BackgroundColor3 = r.color
|
||||
tile.ZIndex += 5
|
||||
for _, d in ipairs(tile:GetDescendants()) do
|
||||
if d:IsA("GuiObject") then
|
||||
d.ZIndex += 5
|
||||
end
|
||||
end
|
||||
local sc = new("UIScale", { Parent = tile })
|
||||
TweenService:Create(sc, TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1.14 }):Play()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- открытие на весь экран
|
||||
|
||||
local settings = { fast = false, auto = false }
|
||||
local spinGui = new("ScreenGui", { Name = "HouseSpinGui", IgnoreGuiInset = true, ResetOnSpawn = false, DisplayOrder = 60, Enabled = false,
|
||||
ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = player:WaitForChild("PlayerGui") })
|
||||
local blur = Lighting:FindFirstChild("HouseSpinBlur") or new("BlurEffect", { Name = "HouseSpinBlur", Size = 0, Enabled = false, Parent = Lighting })
|
||||
local shade = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.fromRGB(6, 6, 8), BackgroundTransparency = 0.25, Active = true, Parent = spinGui })
|
||||
new("UIGradient", { Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 0.25), NumberSequenceKeypoint.new(0.5, 0.05), NumberSequenceKeypoint.new(1, 0.25) }), Parent = shade })
|
||||
local spinTitle = text({ Size = UDim2.new(1, 0, 0, 44), Position = UDim2.new(0, 0, 0, 92), Font = TITLE, TextSize = 32, TextXAlignment = CENTER, TextColor3 = WHITE,
|
||||
TextStrokeTransparency = 0.4, TextStrokeColor3 = Color3.new(0, 0, 0), Text = "", ZIndex = 5, Parent = spinGui })
|
||||
|
||||
-- верхние кнопки: автовращение (жёлтая), «Катиться быстрее» (зелёная), закрыть
|
||||
local function flatButton(props, color)
|
||||
local b = new("TextButton", props)
|
||||
b.BackgroundColor3 = color
|
||||
b.AutoButtonColor = true
|
||||
b.Font = Enum.Font.FredokaOne
|
||||
if Theme.FACES and Theme.FACES[TITLE] then
|
||||
b.FontFace = Theme.FACES[TITLE]
|
||||
end
|
||||
b.TextColor3 = WHITE
|
||||
b.TextStrokeTransparency = 0.2
|
||||
b.TextStrokeColor3 = Color3.fromRGB(20, 20, 20)
|
||||
corner(6).Parent = b
|
||||
new("UIStroke", { Color = Color3.fromRGB(255, 255, 255), Transparency = 0.6, Thickness = 2, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = b })
|
||||
new("UIGradient", { Color = ColorSequence.new(Color3.fromRGB(255, 255, 255), Color3.fromRGB(200, 200, 200)), Rotation = 90, Parent = b })
|
||||
b.MouseButton1Click:Connect(function()
|
||||
sound("click")
|
||||
end)
|
||||
return b
|
||||
end
|
||||
local autoBtn = flatButton({ Size = UDim2.fromOffset(250, 52), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.33, 0, 0, 24), TextSize = 18, TextWrapped = true, ZIndex = 6, Parent = spinGui },
|
||||
Color3.fromRGB(245, 190, 30))
|
||||
local fastBtn = flatButton({ Size = UDim2.fromOffset(240, 58), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -86, 0, 22), TextSize = 22, ZIndex = 6, Parent = spinGui },
|
||||
Color3.fromRGB(60, 190, 70))
|
||||
local function paintToggles()
|
||||
autoBtn.Text = "Автоматическое вращение: " .. (settings.auto and "включено" or "выключено")
|
||||
autoBtn.BackgroundColor3 = settings.auto and Color3.fromRGB(255, 150, 30) or Color3.fromRGB(245, 190, 30)
|
||||
fastBtn.Text = settings.fast and "Быстро: включено" or "Катиться быстрее"
|
||||
fastBtn.BackgroundColor3 = settings.fast and Color3.fromRGB(40, 150, 60) or Color3.fromRGB(60, 190, 70)
|
||||
end
|
||||
paintToggles()
|
||||
autoBtn.MouseButton1Click:Connect(function()
|
||||
settings.auto = not settings.auto
|
||||
paintToggles()
|
||||
end)
|
||||
fastBtn.MouseButton1Click:Connect(function()
|
||||
settings.fast = not settings.fast
|
||||
paintToggles()
|
||||
end)
|
||||
|
||||
-- область лент, линия по центру и стрелки
|
||||
local reelArea = new("Frame", { Size = UDim2.new(1, -120, 0.62, 0), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.52), BackgroundTransparency = 1, Parent = spinGui })
|
||||
local rowsHolder = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1, Parent = reelArea })
|
||||
local centerLine = new("Frame", { Size = UDim2.new(0, 3, 1, 0), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.fromScale(0.5, 0), BackgroundColor3 = Color3.fromRGB(12, 12, 12),
|
||||
BorderSizePixel = 0, ZIndex = 30, Parent = reelArea })
|
||||
local arrowTop = text({ Size = UDim2.fromOffset(70, 60), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 0, 0), Font = Enum.Font.GothamBold, TextSize = 64,
|
||||
TextXAlignment = CENTER, TextColor3 = WHITE, TextStrokeTransparency = 0, TextStrokeColor3 = Color3.fromRGB(20, 20, 20), Text = "▼", ZIndex = 31, Parent = reelArea })
|
||||
local arrowBottom = text({ Size = UDim2.fromOffset(70, 60), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 1, 0), Font = Enum.Font.GothamBold, TextSize = 64,
|
||||
TextXAlignment = CENTER, TextColor3 = WHITE, TextStrokeTransparency = 0, TextStrokeColor3 = Color3.fromRGB(20, 20, 20), Text = "▲", ZIndex = 31, Parent = reelArea })
|
||||
|
||||
local resultText = text({ Size = UDim2.new(1, -40, 0, 34), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -86), Font = TITLE, TextSize = 26, TextXAlignment = CENTER,
|
||||
TextColor3 = WHITE, TextStrokeTransparency = 0.4, TextStrokeColor3 = Color3.new(0, 0, 0), Text = "", ZIndex = 5, Parent = spinGui })
|
||||
local bottomBar = new("Frame", { Size = UDim2.new(1, 0, 0, 56), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -22), BackgroundTransparency = 1, ZIndex = 5, Parent = spinGui }, {
|
||||
new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, HorizontalAlignment = Enum.HorizontalAlignment.Center, Padding = UDim.new(0, 14), SortOrder = Enum.SortOrder.LayoutOrder }),
|
||||
})
|
||||
local skipBtn = flatButton({ Size = UDim2.fromOffset(200, 52), TextSize = 22, Text = "Пропустить", LayoutOrder = 1, ZIndex = 6, Parent = bottomBar }, Color3.fromRGB(90, 90, 100))
|
||||
local takeBtn = flatButton({ Size = UDim2.fromOffset(200, 52), TextSize = 22, Text = "Забрать", LayoutOrder = 2, ZIndex = 6, Parent = bottomBar }, Color3.fromRGB(60, 190, 70))
|
||||
local againBtn = flatButton({ Size = UDim2.fromOffset(220, 52), TextSize = 22, Text = "Ещё", LayoutOrder = 3, ZIndex = 6, Parent = bottomBar }, Color3.fromRGB(70, 110, 200))
|
||||
|
||||
local current = nil -- текущее открытие: { catId, results, refund, state, rows, finished, token }
|
||||
local spinToken = 0
|
||||
|
||||
local function setBlur(on)
|
||||
blur.Enabled = true
|
||||
TweenService:Create(blur, TweenInfo.new(0.25), { Size = on and 18 or 0 }):Play()
|
||||
if not on then
|
||||
task.delay(0.3, function()
|
||||
if not spinGui.Enabled then
|
||||
blur.Enabled = false
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function closeSpin()
|
||||
spinToken += 1
|
||||
spinGui.Enabled = false
|
||||
setBlur(false)
|
||||
spinning = false
|
||||
if current then
|
||||
cos = current.state or cos
|
||||
lastSpin = {}
|
||||
local counts = {}
|
||||
for _, x in ipairs(current.results) do
|
||||
counts[x.id] = (counts[x.id] or 0) + 1
|
||||
end
|
||||
lastSpin[current.catId] = counts
|
||||
if not current.revealed then
|
||||
remote:FireServer("HouseReveal")
|
||||
end
|
||||
current = nil
|
||||
end
|
||||
pcWin.refresh()
|
||||
end
|
||||
closeButton(spinGui, function()
|
||||
if current and not current.finished then
|
||||
current.skip()
|
||||
end
|
||||
closeSpin()
|
||||
end, 40)
|
||||
|
||||
-- все ленты остановились: итог, кнопки, автовращение
|
||||
local function onAllStopped(cur)
|
||||
cur.finished = true
|
||||
cur.revealed = true
|
||||
remote:FireServer("HouseReveal")
|
||||
local cat = COS.category(cur.catId)
|
||||
local newCount = 0
|
||||
for _, x in ipairs(cur.results) do
|
||||
if x.new then
|
||||
newCount += 1
|
||||
end
|
||||
end
|
||||
if #cur.results == 1 then
|
||||
local it = cat.byId[cur.results[1].id]
|
||||
local r = COS.Rarities[it.rarity]
|
||||
resultText.Text = ("%s · %s%s"):format(it.name, r.name, cur.results[1].new and " · НОВИНКА!" or (" · повтор, +" .. fmt(cur.refund) .. " " .. Theme.SILVER))
|
||||
resultText.TextColor3 = r.color
|
||||
else
|
||||
resultText.Text = ("Новых: %d · за повторы +%s %s"):format(newCount, fmt(cur.refund), Theme.SILVER)
|
||||
resultText.TextColor3 = newCount > 0 and C.goldBright or WHITE
|
||||
end
|
||||
sound("open")
|
||||
skipBtn.Visible = false
|
||||
takeBtn.Visible = true
|
||||
againBtn.Visible = true
|
||||
againBtn.Text = ("Ещё %d · %s %s"):format(#cur.results, fmt(cat.cost * #cur.results), Theme.SILVER)
|
||||
-- автовращение: через мгновение ещё раз, пока хватает серебра
|
||||
if settings.auto then
|
||||
local token = spinToken
|
||||
task.delay(settings.fast and 0.8 or 1.5, function()
|
||||
if token ~= spinToken or not settings.auto or not current or not current.finished then
|
||||
return
|
||||
end
|
||||
if (player:GetAttribute("Coins") or 0) < cat.cost * #cur.results then
|
||||
settings.auto = false
|
||||
paintToggles()
|
||||
resultText.Text = "Автовращение остановлено: не хватает серебра"
|
||||
return
|
||||
end
|
||||
local catId, n = cur.catId, #cur.results
|
||||
closeSpin()
|
||||
requestSpin(catId, n)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
takeBtn.MouseButton1Click:Connect(closeSpin)
|
||||
againBtn.MouseButton1Click:Connect(function()
|
||||
if current then
|
||||
local catId, n = current.catId, #current.results
|
||||
closeSpin()
|
||||
requestSpin(catId, n)
|
||||
end
|
||||
end)
|
||||
skipBtn.MouseButton1Click:Connect(function()
|
||||
if current and not current.finished then
|
||||
current.skip()
|
||||
end
|
||||
end)
|
||||
|
||||
local reelRng = Random.new()
|
||||
|
||||
local function playSpin(catId, results, refund, state)
|
||||
local cat = COS.category(catId)
|
||||
if not cat or #results == 0 then
|
||||
cos = state or cos
|
||||
spinning = false
|
||||
return
|
||||
end
|
||||
spinning = true
|
||||
spinToken += 1
|
||||
local token = spinToken
|
||||
for _, c in ipairs(rowsHolder:GetChildren()) do
|
||||
c:Destroy()
|
||||
end
|
||||
local cur = { catId = catId, results = results, refund = refund, state = state, finished = false, revealed = false }
|
||||
current = cur
|
||||
spinTitle.Text = ("%s %s%s"):format(cat.icon, cat.name, #results > 1 and (" ×" .. #results) or "")
|
||||
resultText.Text = ""
|
||||
skipBtn.Visible = true
|
||||
takeBtn.Visible = false
|
||||
againBtn.Visible = false
|
||||
spinGui.Enabled = true
|
||||
setBlur(true)
|
||||
sound("open")
|
||||
RunService.Heartbeat:Wait()
|
||||
|
||||
-- размеры: строки делят высоту области, плитки — полтора высоты строки.
|
||||
-- Размер области считаем от экрана: AbsoluteSize только что включённого ScreenGui ещё не пересчитан.
|
||||
local vpSize = workspace.CurrentCamera.ViewportSize
|
||||
local area = Vector2.new(vpSize.X - 120, vpSize.Y * 0.62)
|
||||
local rows = #results
|
||||
local gap = rows > 3 and 8 or 40
|
||||
local rowH = math.min(170, (area.Y - gap * (rows - 1)) / rows)
|
||||
local tileH = math.floor(rowH * 0.84)
|
||||
local tileW = math.floor(tileH * 1.5)
|
||||
local step = tileW + math.max(4, math.floor(tileW * 0.04))
|
||||
local total = rows * rowH + (rows - 1) * gap
|
||||
local y0 = (area.Y - total) / 2
|
||||
centerLine.Size = UDim2.new(0, 3, 0, total + 20)
|
||||
centerLine.Position = UDim2.new(0.5, 0, 0, y0 - 10)
|
||||
arrowTop.Position = UDim2.new(0.5, 0, 0, y0 - 6)
|
||||
arrowBottom.Position = UDim2.new(0.5, 0, 0, y0 + total + 6)
|
||||
arrowTop.TextSize = math.clamp(rowH * 0.5, 34, 64)
|
||||
arrowBottom.TextSize = arrowTop.TextSize
|
||||
|
||||
local N, TI = 54, 47
|
||||
local baseTime = settings.fast and 1.5 or 4.6
|
||||
local stagger = settings.fast and 0.06 or 0.22
|
||||
local reels = {}
|
||||
local stopped = 0
|
||||
for k, res in ipairs(results) do
|
||||
local row = new("Frame", { Size = UDim2.new(1, 0, 0, rowH), Position = UDim2.fromOffset(0, y0 + (k - 1) * (rowH + gap)), BackgroundTransparency = 1,
|
||||
ClipsDescendants = true, Parent = rowsHolder })
|
||||
local strip = new("Frame", { Size = UDim2.fromOffset(step * N, rowH), BackgroundTransparency = 1, Parent = row })
|
||||
local win1 = cat.byId[res.id]
|
||||
local tiles = {}
|
||||
for j = 1, N do
|
||||
local it = (j == TI) and win1 or COS.roll(catId, reelRng)
|
||||
local t, g, st = reelTile(strip, cat, it, tileW, tileH, (j - 1) * step, (rowH - tileH) / 2, 2, rows > 3)
|
||||
tiles[j] = { t = t, g = g, st = st, it = it }
|
||||
end
|
||||
-- позиция ленты отсчитывается от центра строки (Scale 0.5) — выпавшая плитка всегда под линией
|
||||
local finalX = -((TI - 1) * step + tileW / 2) -- линия ровно по центру выпавшего лота
|
||||
strip.Position = UDim2.new(0.5, -tileW * 2, 0, 0)
|
||||
local tw = TweenService:Create(strip, TweenInfo.new(baseTime + (k - 1) * stagger, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { Position = UDim2.new(0.5, finalX, 0, 0) })
|
||||
local reel = { strip = strip, tween = tw, finalX = finalX, tiles = tiles, done = false }
|
||||
reels[k] = reel
|
||||
local function stop()
|
||||
if reel.done or token ~= spinToken then
|
||||
return
|
||||
end
|
||||
reel.done = true
|
||||
tw:Cancel()
|
||||
strip.Position = UDim2.new(0.5, finalX, 0, 0)
|
||||
local w = tiles[TI]
|
||||
highlight(w.t, w.g, w.st, w.it)
|
||||
stopped += 1
|
||||
if stopped == #results then
|
||||
onAllStopped(cur)
|
||||
end
|
||||
end
|
||||
reel.stop = stop
|
||||
tw.Completed:Connect(stop)
|
||||
tw:Play()
|
||||
end
|
||||
-- щелчок, когда под линией проходит новая плитка (по первой ленте)
|
||||
local lastIdx = -1
|
||||
local conn
|
||||
conn = RunService.RenderStepped:Connect(function()
|
||||
if token ~= spinToken or reels[1].done then
|
||||
conn:Disconnect()
|
||||
return
|
||||
end
|
||||
local idx = math.floor(-reels[1].strip.Position.X.Offset / step)
|
||||
if idx ~= lastIdx then
|
||||
lastIdx = idx
|
||||
sound("click")
|
||||
end
|
||||
end)
|
||||
cur.skip = function()
|
||||
for _, r in ipairs(reels) do
|
||||
r.stop()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- лента на экране компьютера в доме (видна всем)
|
||||
|
||||
local SCREEN_PPS = 110 -- пикселей на стад: экран 2.9 × 1.7 → ~320 × 187
|
||||
|
||||
local function screenSpin(plot, catId, targetId)
|
||||
local cat = COS.category(catId)
|
||||
local isl = workspace:FindFirstChild("Island2")
|
||||
local f = cat and isl and isl:FindFirstChild("Houses") and isl.Houses:FindFirstChild("Plot_" .. tostring(plot))
|
||||
local screen = f and f:FindFirstChild("ComputerScreen", true)
|
||||
if not screen or not cat.byId[targetId] then
|
||||
return
|
||||
end
|
||||
local old = screen:FindFirstChild("ReelGui")
|
||||
if old then
|
||||
old:Destroy()
|
||||
end
|
||||
local home = nil
|
||||
for _, g in ipairs(screen:GetChildren()) do
|
||||
if g:IsA("SurfaceGui") and g.Name ~= "ReelGui" then
|
||||
home = g
|
||||
g.Enabled = false
|
||||
end
|
||||
end
|
||||
local sg = new("SurfaceGui", { Name = "ReelGui", Face = Enum.NormalId.Front, SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud, PixelsPerStud = SCREEN_PPS,
|
||||
LightInfluence = 0, ZIndexBehavior = Enum.ZIndexBehavior.Sibling, Parent = screen })
|
||||
local W, H = screen.Size.X * SCREEN_PPS, screen.Size.Y * SCREEN_PPS
|
||||
local bg = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.fromRGB(14, 14, 18), BorderSizePixel = 0, Parent = sg })
|
||||
new("TextLabel", { Size = UDim2.new(1, 0, 0, H * 0.16), Position = UDim2.fromOffset(0, H * 0.02), BackgroundTransparency = 1, Font = Enum.Font.GothamBold, TextScaled = true,
|
||||
TextColor3 = WHITE, Text = cat.icon .. " " .. cat.name, Parent = bg })
|
||||
local rowH = H * 0.62
|
||||
local row = new("Frame", { Size = UDim2.new(1, 0, 0, rowH), Position = UDim2.fromOffset(0, H * 0.2), BackgroundTransparency = 1, ClipsDescendants = true, Parent = bg })
|
||||
local tileH = math.floor(rowH * 0.86)
|
||||
local tileW = math.floor(tileH * 1.3)
|
||||
local step = tileW + 4
|
||||
local N, TI = 34, 28
|
||||
local strip = new("Frame", { Size = UDim2.fromOffset(step * N, rowH), BackgroundTransparency = 1, Parent = row })
|
||||
local winTile
|
||||
for j = 1, N do
|
||||
local it = (j == TI) and cat.byId[targetId] or COS.roll(catId, reelRng)
|
||||
local t, g, st = reelTile(strip, cat, it, tileW, tileH, (j - 1) * step, (rowH - tileH) / 2, 2, true)
|
||||
if j == TI then
|
||||
winTile = { t = t, g = g, st = st, it = it }
|
||||
end
|
||||
end
|
||||
new("Frame", { Size = UDim2.new(0, 2, 0, rowH + 10), AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, H * 0.2 - 5), BackgroundColor3 = WHITE, BorderSizePixel = 0, ZIndex = 20, Parent = bg })
|
||||
local label = new("TextLabel", { Size = UDim2.new(1, -10, 0, H * 0.14), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, -2), BackgroundTransparency = 1,
|
||||
Font = Enum.Font.GothamBold, TextScaled = true, TextColor3 = Color3.fromRGB(200, 200, 210), Text = "Крутим…", Parent = bg })
|
||||
local finalX = -((TI - 1) * step + tileW / 2)
|
||||
strip.Position = UDim2.new(0.5, -tileW * 2, 0, 0)
|
||||
local tw = TweenService:Create(strip, TweenInfo.new(4, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { Position = UDim2.new(0.5, finalX, 0, 0) })
|
||||
tw.Completed:Connect(function()
|
||||
if not sg.Parent then
|
||||
return
|
||||
end
|
||||
highlight(winTile.t, winTile.g, winTile.st, winTile.it)
|
||||
local r = COS.Rarities[winTile.it.rarity]
|
||||
label.Text = winTile.it.name
|
||||
label.TextColor3 = r.color
|
||||
task.delay(4, function()
|
||||
if sg.Parent then
|
||||
sg:Destroy()
|
||||
if home and home.Parent then
|
||||
home.Enabled = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
tw:Play()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- события от сервера
|
||||
|
||||
pcWin.frame:GetPropertyChangedSignal("Visible"):Connect(function()
|
||||
if not pcWin.frame.Visible and spinGui.Enabled and current and current.finished then
|
||||
closeSpin()
|
||||
end
|
||||
end)
|
||||
|
||||
remote.OnClientEvent:Connect(function(action, a, b, c, d)
|
||||
if action == "OpenHouse" then
|
||||
win.open("house")
|
||||
task.defer(function()
|
||||
list.CanvasPosition = Vector2.zero
|
||||
end)
|
||||
elseif action == "OpenHouseComputer" then
|
||||
cos = a
|
||||
lastSpin = {}
|
||||
pcWin.open("spin")
|
||||
task.defer(function()
|
||||
pcList.CanvasPosition = Vector2.zero
|
||||
end)
|
||||
elseif action == "HouseCos" then
|
||||
cos = a
|
||||
pcWin.refresh()
|
||||
elseif action == "HouseSpinResult" then
|
||||
playSpin(a, b, c or 0, d)
|
||||
elseif action == "HouseScreenSpin" then
|
||||
screenSpin(a, b, c)
|
||||
end
|
||||
end)
|
||||
|
||||
for _, attr in ipairs({ "HouseLevel", "Coins", "HousePlot" }) do
|
||||
player:GetAttributeChangedSignal(attr):Connect(function()
|
||||
win.refresh()
|
||||
pcWin.refresh()
|
||||
end)
|
||||
end
|
||||
Reference in new issue
Block a user