Update
This commit is contained in:
1 parent
f316a9bf0c
commit
9fcbd8bc0b
38 files changed
+29208
-4904
No files matched your search
@@ -0,0 +1,336 @@
|
||||
-- Ambience (LocalScript) -> StarterPlayer > StarterPlayerScripts
|
||||
-- Атмосфера у этого игрока: время суток, ночной свет, тучи, дождь/снег, молнии, музыка и звуки окружения,
|
||||
-- плашка «погода и время» на экране. Время и погоду задаёт сервер (WeatherServer) атрибутами workspace.
|
||||
-- Свет локации (Config.Worlds[*].look) ставит FishingClient; здесь всё накладывается поверх:
|
||||
-- свои эффекты цвета живут в камере, поэтому не мешают настройкам локаций.
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local Lighting = game:GetService("Lighting")
|
||||
|
||||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||||
local Audio = require(script.Parent:WaitForChild("Audio"))
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local terrain = workspace.Terrain
|
||||
local rng = Random.new()
|
||||
local WHITE = Color3.new(1, 1, 1)
|
||||
|
||||
local function new(class, props)
|
||||
local o = Instance.new(class)
|
||||
for k, v in pairs(props) do
|
||||
if k ~= "Parent" then
|
||||
o[k] = v
|
||||
end
|
||||
end
|
||||
o.Parent = props.Parent
|
||||
return o
|
||||
end
|
||||
|
||||
local function clockNow()
|
||||
return Config.ClockAt(workspace:GetServerTimeNow(), workspace:GetAttribute("DayStart"))
|
||||
end
|
||||
|
||||
local function currentPlace()
|
||||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
if not hrp then
|
||||
return nil, "Lobby"
|
||||
end
|
||||
local w = Config.WorldAt(hrp.Position)
|
||||
return w, w and w.id or "Lobby"
|
||||
end
|
||||
|
||||
local function currentWeather()
|
||||
return Config.WeatherById(workspace:GetAttribute("Weather"))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- вид погоды
|
||||
|
||||
-- cc — поправка цвета поверх света локации; cover/density/cloud — облака; rain — частиц в секунду
|
||||
local LOOK = {
|
||||
Clear = { cover = 0.4, density = 0.45, cloud = Color3.fromRGB(255, 255, 255), rain = 0,
|
||||
cc = { Brightness = 0, Saturation = 0, Contrast = 0, TintColor = WHITE } },
|
||||
Cloudy = { cover = 0.78, density = 0.6, cloud = Color3.fromRGB(215, 218, 226), rain = 0,
|
||||
cc = { Brightness = -0.03, Saturation = -0.1, Contrast = 0, TintColor = Color3.fromRGB(236, 239, 246) } },
|
||||
Rain = { cover = 0.88, density = 0.75, cloud = Color3.fromRGB(165, 170, 182), rain = 350, rainSound = "rainLight",
|
||||
cc = { Brightness = -0.06, Saturation = -0.18, Contrast = 0.02, TintColor = Color3.fromRGB(214, 224, 240) } },
|
||||
Storm = { cover = 0.96, density = 0.9, cloud = Color3.fromRGB(105, 110, 124), rain = 900, rainSound = "rainHeavy", lightning = true,
|
||||
cc = { Brightness = -0.12, Saturation = -0.3, Contrast = 0.06, TintColor = Color3.fromRGB(190, 200, 226) } },
|
||||
Fog = { cover = 0.6, density = 0.5, cloud = Color3.fromRGB(232, 232, 238), rain = 0,
|
||||
cc = { Brightness = 0.02, Saturation = -0.22, Contrast = -0.05, TintColor = Color3.fromRGB(234, 238, 242) } },
|
||||
}
|
||||
|
||||
-- эффекты в камере: действуют только у этого игрока и не путаются с эффектами Lighting
|
||||
local camera = workspace.CurrentCamera
|
||||
local weatherCC = new("ColorCorrectionEffect", { Name = "WeatherCC", Parent = camera })
|
||||
local nightCC = new("ColorCorrectionEffect", { Name = "NightCC", Parent = camera })
|
||||
workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
|
||||
camera = workspace.CurrentCamera
|
||||
weatherCC.Parent = camera
|
||||
nightCC.Parent = camera
|
||||
end)
|
||||
|
||||
local clouds = terrain:FindFirstChildOfClass("Clouds") or new("Clouds", { Parent = terrain })
|
||||
|
||||
-- дождь (а во фьорде — снег) сыплется из невидимой плиты над камерой
|
||||
local rainPart = new("Part", {
|
||||
Name = "RainFX", Anchored = true, CanCollide = false, CanQuery = false, CanTouch = false,
|
||||
Transparency = 1, Size = Vector3.new(110, 1, 110), Parent = workspace,
|
||||
})
|
||||
local rain = new("ParticleEmitter", {
|
||||
Texture = "rbxasset://textures/SelfView/whiteRect.png",
|
||||
Rate = 0, Lifetime = NumberRange.new(1.1, 1.4), Speed = NumberRange.new(55, 70),
|
||||
EmissionDirection = Enum.NormalId.Bottom, SpreadAngle = Vector2.new(4, 4),
|
||||
Orientation = Enum.ParticleOrientation.VelocityParallel,
|
||||
Size = NumberSequence.new(0.07), Squash = NumberSequence.new(2.5),
|
||||
Color = ColorSequence.new(Color3.fromRGB(200, 215, 235)), Transparency = NumberSequence.new(0.45),
|
||||
LightInfluence = 1,
|
||||
Parent = rainPart,
|
||||
})
|
||||
|
||||
local function rainStyle(snowy)
|
||||
if snowy then
|
||||
rain.Speed = NumberRange.new(6, 10)
|
||||
rain.Lifetime = NumberRange.new(5, 7)
|
||||
rain.Size = NumberSequence.new(0.22)
|
||||
rain.Squash = NumberSequence.new(0)
|
||||
rain.SpreadAngle = Vector2.new(25, 25)
|
||||
rain.Orientation = Enum.ParticleOrientation.FacingCamera
|
||||
rain.Color = ColorSequence.new(WHITE)
|
||||
rain.Transparency = NumberSequence.new(0.1)
|
||||
else
|
||||
rain.Speed = NumberRange.new(55, 70)
|
||||
rain.Lifetime = NumberRange.new(1.1, 1.4)
|
||||
rain.Size = NumberSequence.new(0.07)
|
||||
rain.Squash = NumberSequence.new(2.5)
|
||||
rain.SpreadAngle = Vector2.new(4, 4)
|
||||
rain.Orientation = Enum.ParticleOrientation.VelocityParallel
|
||||
rain.Color = ColorSequence.new(Color3.fromRGB(200, 215, 235))
|
||||
rain.Transparency = NumberSequence.new(0.45)
|
||||
end
|
||||
end
|
||||
|
||||
local appliedWeather, appliedPlace = nil, nil
|
||||
local function applyWeather(instant)
|
||||
local w = currentWeather()
|
||||
local _, placeId = currentPlace()
|
||||
if appliedWeather == w.id and appliedPlace == placeId and not instant then
|
||||
return
|
||||
end
|
||||
appliedWeather, appliedPlace = w.id, placeId
|
||||
local look = LOOK[w.id] or LOOK.Clear
|
||||
local info = TweenInfo.new(instant and 0 or 6)
|
||||
TweenService:Create(weatherCC, info, look.cc):Play()
|
||||
TweenService:Create(clouds, info, { Cover = look.cover, Density = look.density }):Play() -- цвет туч ставит главный цикл (с учётом ночи)
|
||||
local snowy = placeId == "World3"
|
||||
rainStyle(snowy)
|
||||
rain.Rate = snowy and look.rain * 0.35 or look.rain
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- молнии
|
||||
|
||||
task.spawn(function()
|
||||
while true do
|
||||
task.wait(rng:NextNumber(6, 16))
|
||||
local w = currentWeather()
|
||||
local _, placeId = currentPlace()
|
||||
if LOOK[w.id] and LOOK[w.id].lightning and placeId ~= "World3" then
|
||||
-- двойная вспышка, гром приходит чуть позже (молния далеко)
|
||||
local base = weatherCC.Brightness
|
||||
for _ = 1, 2 do
|
||||
weatherCC.Brightness = base + 0.45
|
||||
task.wait(0.06)
|
||||
weatherCC.Brightness = base
|
||||
task.wait(0.09)
|
||||
end
|
||||
local far = rng:NextNumber()
|
||||
task.delay(0.2 + far * 1.4, function()
|
||||
local list = Config.Sounds.thunder
|
||||
Audio.playId(list[rng:NextInteger(1, #list)], 0.9 - far * 0.5, "ambient")
|
||||
end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- музыка
|
||||
|
||||
local tracks = {}
|
||||
local function track(name)
|
||||
if not tracks[name] then
|
||||
tracks[name] = Audio.loop(name, "music")
|
||||
end
|
||||
return tracks[name]
|
||||
end
|
||||
|
||||
local currentTrack = nil
|
||||
local function musicFor(placeId, night)
|
||||
if night and placeId ~= "World2" then
|
||||
return "musicNight"
|
||||
end
|
||||
if placeId == "Lobby" then
|
||||
return (math.floor(workspace:GetServerTimeNow() / 600) % 2 == 0) and "musicLobby" or "musicLobby2"
|
||||
elseif placeId == "World1" then
|
||||
return (math.floor(workspace:GetServerTimeNow() / 600) % 2 == 0) and "musicLake" or "musicLake2"
|
||||
elseif placeId == "World3" then
|
||||
return "musicNight"
|
||||
end
|
||||
return "musicLake2"
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- звуки окружения
|
||||
|
||||
local ambient = {}
|
||||
for _, name in ipairs({ "birdsLake", "birdsPark", "birdsJungle", "crickets", "lakeWater", "wind", "rainLight", "rainHeavy" }) do
|
||||
ambient[name] = Audio.loop(name, "ambient")
|
||||
end
|
||||
|
||||
-- какие петли и насколько громко звучат сейчас
|
||||
local function ambientMix(placeId, night, w)
|
||||
local mix = {}
|
||||
local day = not night
|
||||
mix.birdsLake = (day and placeId == "World1") and 1 or 0
|
||||
mix.birdsPark = (day and placeId == "Lobby") and 1 or 0
|
||||
mix.birdsJungle = (day and placeId == "World2") and 1 or 0
|
||||
mix.crickets = (night and placeId ~= "World3") and 1 or 0
|
||||
mix.lakeWater = (placeId == "World1" or placeId == "World2") and 1 or 0
|
||||
local wind = 1
|
||||
if placeId == "World3" then
|
||||
wind = 2.5
|
||||
end
|
||||
if w.id == "Storm" then
|
||||
wind *= 2
|
||||
end
|
||||
mix.wind = wind
|
||||
local wet = placeId ~= "World3"
|
||||
mix.rainLight = (wet and w.id == "Rain") and 1 or 0
|
||||
mix.rainHeavy = (wet and w.id == "Storm") and 1 or 0
|
||||
-- в дождь птицы прячутся
|
||||
if w.id == "Rain" or w.id == "Storm" then
|
||||
mix.birdsLake, mix.birdsPark, mix.birdsJungle = 0, 0, 0
|
||||
end
|
||||
return mix
|
||||
end
|
||||
|
||||
-- треск у каждого костра на карте (звук в самом костре: слышно только рядом)
|
||||
task.spawn(function()
|
||||
local map = workspace:WaitForChild("FishingMap", 60)
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
task.wait(3)
|
||||
local def = Config.Sounds.fire
|
||||
for _, d in ipairs(map:GetDescendants()) do
|
||||
if d:IsA("Fire") and d.Parent and d.Parent:IsA("BasePart") then
|
||||
new("Sound", {
|
||||
Name = "FireCrackle", SoundId = def.id, Volume = def.volume, Looped = true, Playing = true,
|
||||
RollOffMode = Enum.RollOffMode.InverseTapered, RollOffMinDistance = 6, RollOffMaxDistance = def.roll or 30,
|
||||
SoundGroup = Audio.groups.ambient, Parent = d.Parent,
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- плашка «погода и время»
|
||||
|
||||
-- в стиле интерфейса (UiTheme): тёмное дерево с золотой рамкой; масштаб — как у основного интерфейса
|
||||
local Theme = require(script.Parent:WaitForChild("UiTheme"))
|
||||
local hud = new("ScreenGui", { Name = "WeatherHud", ResetOnSpawn = false, IgnoreGuiInset = false, Parent = player:WaitForChild("PlayerGui") })
|
||||
local pill = new("Frame", {
|
||||
Size = UDim2.fromOffset(230, 48), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 74),
|
||||
BackgroundColor3 = Theme.C.woodDark, BackgroundTransparency = 0.08, Parent = Theme.followScale(hud),
|
||||
})
|
||||
new("UICorner", { CornerRadius = UDim.new(0, 8), Parent = pill })
|
||||
local pillStroke = new("UIStroke", { Color = Theme.C.goldDark, Thickness = 2, Transparency = 0, Parent = pill })
|
||||
local line1 = new("TextLabel", {
|
||||
Size = UDim2.new(1, -16, 0, 24), Position = UDim2.fromOffset(10, 3), BackgroundTransparency = 1,
|
||||
FontFace = Theme.TITLE_FACE, TextSize = 16, TextColor3 = Theme.C.parchment, TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Text = "", Parent = pill,
|
||||
})
|
||||
local line2 = new("TextLabel", {
|
||||
Size = UDim2.new(1, -16, 0, 16), Position = UDim2.fromOffset(10, 27), BackgroundTransparency = 1,
|
||||
FontFace = Theme.BODY2_FACE, TextSize = 12, TextColor3 = Color3.fromRGB(170, 215, 140), TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Text = "", Parent = pill,
|
||||
})
|
||||
|
||||
local function weatherName(w, placeId)
|
||||
return (w.names and w.names[placeId]) or w.name
|
||||
end
|
||||
|
||||
local lastShownWeather = nil
|
||||
local function refreshPill(clock, night, w, placeId)
|
||||
local h = math.floor(clock)
|
||||
local m = math.floor((clock - h) * 60)
|
||||
line1.Text = ("%s %s · %s %02d:%02d"):format(w.icon, weatherName(w, placeId), night and "🌙" or "☀", h, m)
|
||||
local bonus = {}
|
||||
if w.desc then
|
||||
table.insert(bonus, w.desc)
|
||||
end
|
||||
if night then
|
||||
table.insert(bonus, ("Ночь: удача +%d%%"):format(math.floor(Config.DayNight.nightLuck * 100 + 0.5)))
|
||||
end
|
||||
line2.Text = #bonus > 0 and table.concat(bonus, " · ") or "Спокойная погода"
|
||||
if lastShownWeather ~= w.id then
|
||||
-- погода сменилась: плашка вспыхивает
|
||||
if lastShownWeather ~= nil then
|
||||
pillStroke.Color = Color3.fromRGB(255, 220, 120)
|
||||
pillStroke.Transparency = 0
|
||||
TweenService:Create(pillStroke, TweenInfo.new(2.5), { Color = Theme.C.goldDark, Transparency = 0 }):Play()
|
||||
end
|
||||
lastShownWeather = w.id
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- главный цикл
|
||||
|
||||
-- часы двигаются каждый кадр (плавно), остальное проверяется раз в полсекунды
|
||||
RunService.RenderStepped:Connect(function()
|
||||
if Config.DayNight.enabled then
|
||||
Lighting.ClockTime = clockNow()
|
||||
end
|
||||
if camera then
|
||||
rainPart.CFrame = CFrame.new(camera.CFrame.Position + Vector3.new(0, 35, 0))
|
||||
end
|
||||
end)
|
||||
|
||||
workspace:GetAttributeChangedSignal("Weather"):Connect(function()
|
||||
applyWeather(false)
|
||||
end)
|
||||
applyWeather(true)
|
||||
|
||||
task.spawn(function()
|
||||
while true do
|
||||
local clock = clockNow()
|
||||
local nightness = Config.DayNight.enabled and Config.Nightness(clock) or 0
|
||||
local night = nightness >= 0.5
|
||||
local w = currentWeather()
|
||||
local _, placeId = currentPlace()
|
||||
|
||||
-- ночь: темнее, холоднее, менее насыщенно
|
||||
nightCC.Brightness = -0.1 * nightness
|
||||
nightCC.Saturation = -0.18 * nightness
|
||||
nightCC.TintColor = WHITE:Lerp(Color3.fromRGB(165, 185, 255), nightness)
|
||||
clouds.Color = (LOOK[w.id] or LOOK.Clear).cloud:Lerp(Color3.fromRGB(40, 45, 60), nightness * 0.8)
|
||||
|
||||
applyWeather(false) -- смена локации меняет дождь на снег и обратно
|
||||
|
||||
-- музыка: плавная смена трека, в грозу тише
|
||||
local want = musicFor(placeId, night)
|
||||
local duck = (w.id == "Storm") and 0.5 or 1
|
||||
if currentTrack ~= want then
|
||||
if currentTrack then
|
||||
Audio.fade(track(currentTrack), 0, 3)
|
||||
end
|
||||
currentTrack = want
|
||||
end
|
||||
Audio.fade(track(want), duck, 3)
|
||||
|
||||
for name, factor in pairs(ambientMix(placeId, night, w)) do
|
||||
Audio.fade(ambient[name], factor, 3)
|
||||
end
|
||||
|
||||
refreshPill(clock, night, w, placeId)
|
||||
task.wait(0.5)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,128 @@
|
||||
-- Audio (ModuleScript) -> StarterPlayer > StarterPlayerScripts
|
||||
-- Звуки у этого игрока. Три группы громкости: музыка, эффекты и окружение (окружение — по громкости эффектов).
|
||||
-- Громкость берётся из атрибутов игрока VolMusic / VolSfx (их выставляет и сохраняет сервер).
|
||||
-- Audio.play(name) — разовый звук из Config.Sounds
|
||||
-- Audio.loop(name, group) — петля (молчит, пока не вызвать Audio.fade)
|
||||
-- Audio.fade(sound, factor) — плавно к громкости «базовая × factor» (0 — тишина, звук ставится на паузу)
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local SoundService = game:GetService("SoundService")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||||
local player = Players.LocalPlayer
|
||||
local rng = Random.new()
|
||||
|
||||
local Audio = {}
|
||||
|
||||
local function group(name)
|
||||
local g = SoundService:FindFirstChild(name)
|
||||
if not g then
|
||||
g = Instance.new("SoundGroup")
|
||||
g.Name = name
|
||||
g.Parent = SoundService
|
||||
end
|
||||
return g
|
||||
end
|
||||
Audio.groups = {
|
||||
music = group("MusicGroup"),
|
||||
sfx = group("SfxGroup"),
|
||||
ambient = group("AmbientGroup"),
|
||||
}
|
||||
|
||||
local function applyVolumes()
|
||||
local music = player:GetAttribute("VolMusic") or Config.DefaultVolume.music
|
||||
local sfx = player:GetAttribute("VolSfx") or Config.DefaultVolume.sfx
|
||||
Audio.groups.music.Volume = music
|
||||
Audio.groups.sfx.Volume = sfx
|
||||
Audio.groups.ambient.Volume = sfx
|
||||
end
|
||||
applyVolumes()
|
||||
player:GetAttributeChangedSignal("VolMusic"):Connect(applyVolumes)
|
||||
player:GetAttributeChangedSignal("VolSfx"):Connect(applyVolumes)
|
||||
|
||||
function Audio.play(name, volumeMult)
|
||||
local def = Config.Sounds[name]
|
||||
if not def or not def.id then
|
||||
return nil
|
||||
end
|
||||
local s = Instance.new("Sound")
|
||||
s.SoundId = def.id
|
||||
s.Volume = (def.volume or 0.5) * (volumeMult or 1)
|
||||
if def.pitch then
|
||||
s.PlaybackSpeed = rng:NextNumber(def.pitch[1], def.pitch[2])
|
||||
end
|
||||
s.SoundGroup = Audio.groups.sfx
|
||||
s.Parent = SoundService
|
||||
s:Play()
|
||||
s.Ended:Connect(function()
|
||||
s:Destroy()
|
||||
end)
|
||||
task.delay(30, function()
|
||||
if s.Parent then
|
||||
s:Destroy()
|
||||
end
|
||||
end)
|
||||
return s
|
||||
end
|
||||
|
||||
-- разовый звук по прямому id (например, случайный раскат грома из списка)
|
||||
function Audio.playId(id, volume, groupName)
|
||||
local s = Instance.new("Sound")
|
||||
s.SoundId = id
|
||||
s.Volume = volume or 0.5
|
||||
s.SoundGroup = Audio.groups[groupName or "sfx"]
|
||||
s.Parent = SoundService
|
||||
s:Play()
|
||||
s.Ended:Connect(function()
|
||||
s:Destroy()
|
||||
end)
|
||||
return s
|
||||
end
|
||||
|
||||
function Audio.loop(name, groupName)
|
||||
local def = Config.Sounds[name]
|
||||
if not def then
|
||||
return nil
|
||||
end
|
||||
local s = Instance.new("Sound")
|
||||
s.Name = name
|
||||
s.SoundId = def.id
|
||||
s.Looped = true
|
||||
s.Volume = 0
|
||||
s.SoundGroup = Audio.groups[groupName or "ambient"]
|
||||
s:SetAttribute("BaseVolume", def.volume or 0.5)
|
||||
s.Parent = SoundService
|
||||
return s
|
||||
end
|
||||
|
||||
local fades = {}
|
||||
function Audio.fade(s, factor, time)
|
||||
if not s then
|
||||
return
|
||||
end
|
||||
local target = (s:GetAttribute("BaseVolume") or 0.5) * (factor or 0)
|
||||
if fades[s] and fades[s].target == target then
|
||||
return
|
||||
end
|
||||
if fades[s] then
|
||||
fades[s].tween:Cancel()
|
||||
end
|
||||
if target > 0 and not s.IsPlaying then
|
||||
s:Resume()
|
||||
if not s.IsPlaying then
|
||||
s:Play()
|
||||
end
|
||||
end
|
||||
local tw = TweenService:Create(s, TweenInfo.new(time or 2), { Volume = target })
|
||||
fades[s] = { tween = tw, target = target }
|
||||
tw.Completed:Connect(function(state)
|
||||
if state == Enum.PlaybackState.Completed and target <= 0.001 then
|
||||
s:Pause()
|
||||
end
|
||||
end)
|
||||
tw:Play()
|
||||
end
|
||||
|
||||
return Audio
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,412 @@
|
||||
-- GuildClient (LocalScript) -> StarterPlayer > StarterPlayerScripts
|
||||
-- Окно гильдии рыбаков (ранг и испытание, заказы, наживка, ловушки), строка жемчуга и печатей в HUD,
|
||||
-- кнопки наживки и автоловли, церемония нового ранга. Стиль и помощники — из FishingClient (Theme.kit).
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
|
||||
local Theme = require(script.Parent:WaitForChild("UiTheme"))
|
||||
local Audio = require(script.Parent:WaitForChild("Audio"))
|
||||
local remote = ReplicatedStorage:WaitForChild("GameEvent")
|
||||
|
||||
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, BODY2 = K.TITLE, K.BODY2
|
||||
local RANKS = Config.Guild.ranks
|
||||
local CENTER, RIGHT = Enum.TextXAlignment.Center, Enum.TextXAlignment.Right
|
||||
local WHITE = Color3.new(1, 1, 1)
|
||||
|
||||
local state = nil -- последнее состояние гильдии от сервера
|
||||
|
||||
local function rankOf(idx)
|
||||
return RANKS[math.clamp(idx or 1, 1, #RANKS)]
|
||||
end
|
||||
|
||||
-- щит ранга: ромб цвета ранга с буквой
|
||||
local function shield(parent, size, idx, props)
|
||||
local r = rankOf(idx)
|
||||
local f = new("Frame", { Size = UDim2.fromOffset(size, size), Rotation = 45, BackgroundColor3 = r.color, Parent = parent },
|
||||
{ corner(math.floor(size / 6)), stroke(C.gold, math.max(2, size / 14), 0), gradient(WHITE, Color3.fromRGB(150, 150, 150), 45) })
|
||||
for k, v in pairs(props or {}) do
|
||||
f[k] = v
|
||||
end
|
||||
text({ Size = UDim2.fromScale(1, 1), Rotation = -45, Font = TITLE, TextScaled = true, TextXAlignment = CENTER, Text = r.id,
|
||||
TextColor3 = WHITE, TextStrokeColor3 = C.ink, TextStrokeTransparency = 0.2, Parent = f })
|
||||
return f
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- окно гильдии
|
||||
|
||||
local win = K.makeWindow("⚔ Гильдия рыбаков", C.crimson, {
|
||||
{ id = "rank", label = "⚔ Ранг" },
|
||||
{ id = "orders", label = "📜 Заказы" },
|
||||
{ id = "bait", label = "🐛 Наживка" },
|
||||
{ id = "traps", label = "🧺 Ловушки" },
|
||||
})
|
||||
local lists = {
|
||||
rank = K.scrollArea(win.pages.rank),
|
||||
orders = K.scrollArea(win.pages.orders),
|
||||
bait = K.scrollArea(win.pages.bait),
|
||||
traps = K.scrollArea(win.pages.traps),
|
||||
}
|
||||
|
||||
-- деревянная карточка-строка
|
||||
local function card(parent, order, height, strokeColor)
|
||||
return new("Frame", { Size = UDim2.new(1, -4, 0, height), BackgroundColor3 = WHITE, LayoutOrder = order, Parent = parent },
|
||||
{ corner(8), stroke(strokeColor or C.goldDark, 2, 0), gradient(C.woodLight, C.wood, 90) })
|
||||
end
|
||||
|
||||
local function rewardText(o)
|
||||
return ("+%d %s +%s %s%s"):format(o.seals, Theme.SEAL, fmt(o.coins), Theme.SILVER, (o.pearls or 0) > 0 and (" +" .. o.pearls .. " " .. Theme.PEARL) or "")
|
||||
end
|
||||
|
||||
local function renderRank(list)
|
||||
local idx = player:GetAttribute("RankIdx") or 1
|
||||
local r = rankOf(idx)
|
||||
local seals = player:GetAttribute("Seals") or 0
|
||||
local nextR = RANKS[idx + 1]
|
||||
|
||||
-- шапка: щит, звание, печати
|
||||
local head = card(list, 0, 120, C.gold)
|
||||
shield(head, 64, idx, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(62, 60) })
|
||||
text({ Size = UDim2.new(1, -140, 0, 30), Position = UDim2.fromOffset(122, 10), Font = TITLE, TextSize = 24, TextColor3 = r.color:Lerp(WHITE, 0.35),
|
||||
Text = ("Ранг %s — %s"):format(r.id, r.name), Parent = head })
|
||||
text({ Size = UDim2.new(1, -140, 0, 22), Position = UDim2.fromOffset(122, 42), Font = BODY2, TextSize = 15, TextColor3 = C.muted, RichText = true,
|
||||
Text = ("%s Печати: <b>%s</b>%s %s Жемчуг: <b>%s</b>"):format(Theme.SEAL, fmt(seals), nextR and (" / " .. fmt(nextR.seals)) or "", Theme.PEARL, fmt(player:GetAttribute("Pearls") or 0)),
|
||||
Parent = head })
|
||||
if nextR then
|
||||
K.progressBar(head, UDim2.fromOffset(122, 74), UDim2.new(1, -140, 0, 14), (seals - r.seals) / math.max(1, nextR.seals - r.seals), C.gold)
|
||||
text({ Size = UDim2.new(1, -140, 0, 18), Position = UDim2.fromOffset(122, 92), Font = BODY2, TextSize = 13, TextColor3 = C.muted,
|
||||
Text = "Печати дают только заказы гильдии и испытания", Parent = head })
|
||||
end
|
||||
|
||||
-- испытание на следующий ранг
|
||||
local t = state and state.trial
|
||||
if t and nextR then
|
||||
local box = card(list, 1, 96, t.ready and C.goldBright or C.goldDark)
|
||||
text({ Size = UDim2.new(1, -220, 0, 26), Position = UDim2.fromOffset(16, 10), Font = TITLE, TextSize = 19, TextColor3 = C.goldBright,
|
||||
Text = ("⚔ Испытание на ранг %s"):format(nextR.id), Parent = box })
|
||||
text({ Size = UDim2.new(1, -220, 0, 40), Position = UDim2.fromOffset(16, 38), Font = BODY2, TextSize = 15, TextWrapped = true, RichText = true,
|
||||
TextYAlignment = Enum.TextYAlignment.Top,
|
||||
Text = t.text .. (t.active and (" <font color=\"" .. Theme.HEX.gold .. "\">" .. t.progress .. " / " .. t.goal .. "</font>") or "")
|
||||
.. (t.ready and "" or ("\n<font color=\"" .. Theme.HEX.muted .. "\">Сначала накопи " .. fmt(nextR.seals) .. " печатей</font>")),
|
||||
Parent = box })
|
||||
local label, color, active
|
||||
if not t.ready then
|
||||
label, color, active = "🔒 " .. fmt(nextR.seals) .. " " .. Theme.SEAL, C.grey, false
|
||||
elseif t.active and nextR.trial.kind == "deliver" then
|
||||
label, color, active = "🐟 Сдать рыбу", C.green, true
|
||||
elseif t.active then
|
||||
label, color, active = "Идёт…", C.grey, false
|
||||
else
|
||||
label, color, active = "⚔ Взять", C.crimson, true
|
||||
end
|
||||
btn({ Size = UDim2.fromOffset(180, 50), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -14, 0.5, 0), BackgroundColor3 = color,
|
||||
AutoButtonColor = active, Text = label, TextSize = 18, Parent = box }, active and function()
|
||||
remote:FireServer("TakeTrial")
|
||||
end or nil)
|
||||
end
|
||||
|
||||
-- лестница рангов
|
||||
for i, rr in ipairs(RANKS) do
|
||||
local here = i == idx
|
||||
local row = card(list, 10 + i, 58, here and C.gold or nil)
|
||||
if i > idx then
|
||||
row.BackgroundTransparency = 0.35
|
||||
end
|
||||
shield(row, 30, i, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(34, 29) })
|
||||
text({ Size = UDim2.fromOffset(230, 24), Position = UDim2.fromOffset(64, 6), Font = TITLE, TextSize = 17,
|
||||
TextColor3 = i <= idx and C.text or C.muted, Text = ("%s — %s"):format(rr.id, rr.name), Parent = row })
|
||||
text({ Size = UDim2.new(1, -200, 0, 20), Position = UDim2.fromOffset(64, 31), Font = BODY2, TextSize = 13, TextColor3 = C.muted,
|
||||
TextTruncate = Enum.TextTruncate.AtEnd, Text = rr.unlocks, Parent = row })
|
||||
text({ Size = UDim2.fromOffset(120, 24), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -14, 0, 17), Font = TITLE, TextSize = 16,
|
||||
TextXAlignment = RIGHT, TextColor3 = i <= idx and C.green:Lerp(WHITE, 0.4) or C.gold,
|
||||
Text = i <= idx and "✓" or (fmt(rr.seals) .. " " .. Theme.SEAL), Parent = row })
|
||||
end
|
||||
end
|
||||
|
||||
local function renderOrders(list)
|
||||
if not state then
|
||||
return
|
||||
end
|
||||
local left = (state.ordersEnd or 0) - workspace:GetServerTimeNow()
|
||||
local h = math.floor(math.max(0, left) / 3600)
|
||||
local m = math.floor(math.max(0, left) % 3600 / 60)
|
||||
text({ Size = UDim2.new(1, -4, 0, 26), LayoutOrder = 0, Font = BODY2, TextSize = 15, TextColor3 = C.muted, RichText = true,
|
||||
Text = ("Личные заказы гильдии. Новые через <b>%d ч %02d мин</b>. Рыбу сдают у доски заказов в лобби."):format(h, m), Parent = list })
|
||||
for i, o in ipairs(state.orders) do
|
||||
local row = card(list, i, 92, o.done and C.green or nil)
|
||||
text({ Size = UDim2.new(1, -230, 0, 26), Position = UDim2.fromOffset(16, 8), Font = TITLE, TextSize = 18,
|
||||
TextColor3 = o.done and C.muted or C.text, TextTruncate = Enum.TextTruncate.AtEnd, Text = (o.done and "✅ " or "📜 ") .. o.text, Parent = row })
|
||||
text({ Size = UDim2.new(1, -230, 0, 20), Position = UDim2.fromOffset(16, 36), Font = BODY2, TextSize = 14, TextColor3 = C.gold,
|
||||
Text = rewardText(o), Parent = row })
|
||||
K.progressBar(row, UDim2.fromOffset(16, 64), UDim2.new(1, -310, 0, 12), o.progress / math.max(1, o.count), o.done and C.green or C.gold)
|
||||
text({ Size = UDim2.fromOffset(70, 18), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -224, 0, 61), Font = TITLE, TextSize = 14,
|
||||
TextXAlignment = RIGHT, Text = ("%d / %d"):format(o.progress, o.count), Parent = row })
|
||||
if not o.done then
|
||||
if o.deliver then
|
||||
btn({ Size = UDim2.fromOffset(120, 40), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -86, 0, 10), BackgroundColor3 = C.green,
|
||||
Text = "🐟 Сдать", TextSize = 17, Parent = row }, function()
|
||||
remote:FireServer("DeliverOrder", i)
|
||||
end)
|
||||
end
|
||||
btn({ Size = UDim2.fromOffset(66, 40), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 10), BackgroundColor3 = C.woodLight,
|
||||
Text = "🎲 " .. Config.Orders.rerollPearls .. Theme.PEARL, TextSize = 14, Parent = row }, function()
|
||||
remote:FireServer("RerollOrder", i)
|
||||
end)
|
||||
end
|
||||
end
|
||||
text({ Size = UDim2.new(1, -4, 0, 24), LayoutOrder = 99, Font = BODY2, TextSize = 13, TextColor3 = C.muted,
|
||||
Text = ("🎲 — заменить заказ другим за %d %s"):format(Config.Orders.rerollPearls, Theme.PEARL), Parent = list })
|
||||
end
|
||||
|
||||
local function renderBait(list)
|
||||
local idx = player:GetAttribute("RankIdx") or 1
|
||||
local coins = player:GetAttribute("Coins") or 0
|
||||
local pearls = player:GetAttribute("Pearls") or 0
|
||||
local counts = state and state.baits or {}
|
||||
local equipped = player:GetAttribute("Bait")
|
||||
text({ Size = UDim2.new(1, -4, 0, 26), LayoutOrder = 0, Font = BODY2, TextSize = 15, TextColor3 = C.muted,
|
||||
Text = "Один слот наживки: 1 штука тратится на каждый заброс.", Parent = list })
|
||||
for i, b in ipairs(Config.Baits) do
|
||||
local have = counts[b.id] or 0
|
||||
local locked = b.rank and idx < b.rank
|
||||
local pearl = b.currency == "pearls"
|
||||
local row = card(list, i, 84, equipped == b.id and C.goldBright or nil)
|
||||
text({ Size = UDim2.fromOffset(60, 60), Position = UDim2.fromOffset(10, 12), TextSize = 40, TextXAlignment = CENTER, Text = b.icon, Parent = row })
|
||||
text({ Size = UDim2.new(1, -330, 0, 26), Position = UDim2.fromOffset(78, 10), Font = TITLE, TextSize = 18,
|
||||
Text = b.name .. (have > 0 and (" ×" .. have) or ""), Parent = row })
|
||||
text({ Size = UDim2.new(1, -330, 0, 36), Position = UDim2.fromOffset(78, 38), Font = BODY2, TextSize = 14, TextColor3 = C.muted, TextWrapped = true,
|
||||
TextYAlignment = Enum.TextYAlignment.Top, Text = b.desc, Parent = row })
|
||||
local can = (pearl and pearls >= b.price) or (not pearl and coins >= b.price)
|
||||
btn({
|
||||
Size = UDim2.fromOffset(130, 42), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -12, 0.5, 0),
|
||||
BackgroundColor3 = locked and C.grey or (can and C.green or C.woodLight), AutoButtonColor = not locked,
|
||||
Text = locked and ("🔒 Ранг " .. RANKS[b.rank].id) or (("%s %d · ×%d"):format(pearl and Theme.PEARL or Theme.SILVER, b.price, b.pack)), TextSize = 15, Parent = row,
|
||||
}, (not locked) and function()
|
||||
remote:FireServer("BuyBait", b.id)
|
||||
end or nil)
|
||||
if have > 0 then
|
||||
local on = equipped == b.id
|
||||
btn({
|
||||
Size = UDim2.fromOffset(100, 42), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -150, 0.5, 0),
|
||||
BackgroundColor3 = on and C.gold or C.blue, TextColor3 = on and C.ink or C.text, Text = on and "✓ В слоте" or "Взять", TextSize = 15, Parent = row,
|
||||
}, function()
|
||||
remote:FireServer("EquipBait", on and "" or b.id)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function renderTraps(list)
|
||||
if not state then
|
||||
return
|
||||
end
|
||||
if (state.trapSlots or 0) == 0 then
|
||||
local box = card(list, 0, 90)
|
||||
text({ Size = UDim2.new(1, -32, 1, 0), Position = UDim2.fromOffset(16, 0), Font = TITLE, TextSize = 18, TextWrapped = true, TextColor3 = C.muted,
|
||||
Text = "🔒 Ловушки-вентери открываются с ранга D.\nКаждая сама ловит рыбу «Тихого озера», даже когда ты не в игре.", Parent = box })
|
||||
return
|
||||
end
|
||||
text({ Size = UDim2.new(1, -4, 0, 26), LayoutOrder = 0, Font = BODY2, TextSize = 15, TextColor3 = C.muted,
|
||||
Text = ("Каждая ловушка: 1 рыба за %d мин, не больше %d. Работает и офлайн."):format(state.trapEvery / 60, state.trapMax), Parent = list })
|
||||
local total = 0
|
||||
for i = 1, state.trapSlots do
|
||||
local n = state.traps[i] or 0
|
||||
total += n
|
||||
local row = card(list, i, 64, n >= state.trapMax and C.goldBright or nil)
|
||||
text({ Size = UDim2.new(1, -40, 0, 26), Position = UDim2.fromOffset(16, 6), Font = TITLE, TextSize = 18,
|
||||
Text = ("🧺 Ловушка %d: %d / %d рыб%s"):format(i, n, state.trapMax, n >= state.trapMax and " · полная!" or ""), Parent = row })
|
||||
K.progressBar(row, UDim2.fromOffset(16, 38), UDim2.new(1, -32, 0, 12), n / state.trapMax, C.gold)
|
||||
end
|
||||
local b = btn({
|
||||
Size = UDim2.fromOffset(260, 52), BackgroundColor3 = total > 0 and C.green or C.grey, AutoButtonColor = total > 0,
|
||||
Text = ("🧺 Забрать улов (%d)"):format(total), TextSize = 19, LayoutOrder = 50, Parent = list,
|
||||
}, total > 0 and function()
|
||||
remote:FireServer("CollectTraps")
|
||||
end or nil)
|
||||
b.AnchorPoint = Vector2.new(0, 0)
|
||||
end
|
||||
|
||||
win.render = function(tab)
|
||||
local list = lists[tab]
|
||||
if not list then
|
||||
return
|
||||
end
|
||||
K.clear(list)
|
||||
if tab == "rank" then
|
||||
renderRank(list)
|
||||
elseif tab == "orders" then
|
||||
renderOrders(list)
|
||||
elseif tab == "bait" then
|
||||
renderBait(list)
|
||||
elseif tab == "traps" then
|
||||
renderTraps(list)
|
||||
end
|
||||
end
|
||||
|
||||
local function openGuild(tab)
|
||||
remote:FireServer("GuildState")
|
||||
win.open(tab)
|
||||
end
|
||||
|
||||
K.sideButton(7, "⚔", "Гильдия", "G", C.crimson, function()
|
||||
if win.isOpen() then
|
||||
win.close()
|
||||
else
|
||||
openGuild()
|
||||
end
|
||||
end)
|
||||
UserInputService.InputBegan:Connect(function(input, processed)
|
||||
if not processed and input.KeyCode == Enum.KeyCode.G then
|
||||
if win.isOpen() then
|
||||
win.close()
|
||||
else
|
||||
openGuild()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---------------------------------------------------------------- HUD: жемчуг, печати, ранг, отдых
|
||||
|
||||
local hud = K.hud
|
||||
hud.Parent.Size = UDim2.fromOffset(290, 198)
|
||||
local guildLine = text({ Size = UDim2.new(1, 0, 0, 20), Position = UDim2.fromOffset(0, 149), TextSize = 14, Font = BODY2, RichText = true, Text = "", Parent = hud })
|
||||
-- отдых: строка видна, только пока есть двойной опыт
|
||||
local restText = text({ Size = UDim2.new(1, 0, 0, 18), Position = UDim2.fromOffset(0, 169), Font = BODY2, TextSize = 13, TextColor3 = Color3.fromRGB(170, 215, 255), Text = "", Parent = hud })
|
||||
local restPlate = restText
|
||||
|
||||
local function refreshHud()
|
||||
local idx = player:GetAttribute("RankIdx") or 1
|
||||
local r = rankOf(idx)
|
||||
local nextSeals = player:GetAttribute("SealsNext")
|
||||
guildLine.Text = ("<font color=\"#%s\"><b>⚔ %s</b></font> %s %s%s %s %s"):format(r.color:Lerp(WHITE, 0.3):ToHex(), r.id,
|
||||
Theme.SEAL, fmt(player:GetAttribute("Seals") or 0), nextSeals and ("/" .. fmt(nextSeals)) or "", Theme.PEARL, fmt(player:GetAttribute("Pearls") or 0))
|
||||
local rest = player:GetAttribute("RestLeft") or 0
|
||||
restPlate.Visible = rest > 0
|
||||
restText.Text = ("🛌 Отдых: опыт ×2 ещё %d мин"):format(math.ceil(rest / 60))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- наживка и автоловля (правый низ, над кнопкой прыжка на телефоне)
|
||||
|
||||
local bar = new("Frame", {
|
||||
Size = UDim2.fromOffset(250, 56), AnchorPoint = Vector2.new(1, 1), Position = UDim2.new(1, -12, 1, -12), BackgroundTransparency = 1, Parent = K.screen,
|
||||
}, { new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, HorizontalAlignment = Enum.HorizontalAlignment.Right, Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }) })
|
||||
local baitBtn = btn({ Size = UDim2.fromOffset(110, 52), BackgroundColor3 = C.woodLight, Text = "", TextSize = 16, LayoutOrder = 1, Parent = bar }, function()
|
||||
openGuild("bait")
|
||||
end)
|
||||
local autoBtn = btn({ Size = UDim2.fromOffset(130, 52), BackgroundColor3 = C.woodLight, Text = "", TextSize = 15, LayoutOrder = 2, Visible = false, Parent = bar }, function()
|
||||
remote:FireServer("AutoFish", not player:GetAttribute("AutoFish"))
|
||||
end)
|
||||
Theme.onLayout(function(compact)
|
||||
-- на телефоне — внизу, левее кнопки прыжка (над ней — панель целей)
|
||||
bar.Position = compact and UDim2.new(1, -140, 1, -8) or UDim2.new(1, -12, 1, -12)
|
||||
end)
|
||||
|
||||
local function refreshBar()
|
||||
local id = player:GetAttribute("Bait")
|
||||
local b = id and Config.Find(Config.Baits, id)
|
||||
baitBtn.Text = b and ("%s ×%d"):format(b.icon, player:GetAttribute("BaitCount") or 0) or "🐛 Наживка"
|
||||
baitBtn.BackgroundColor3 = b and C.woodLight or C.wood
|
||||
local idx = player:GetAttribute("RankIdx") or 1
|
||||
autoBtn.Visible = rankOf(idx).auto == true
|
||||
local on = player:GetAttribute("AutoFish") == true
|
||||
autoBtn.Text = on and "🎣 Авто: ВКЛ" or "🎣 Автоловля"
|
||||
autoBtn.BackgroundColor3 = on and C.green or C.woodLight
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- церемония нового ранга
|
||||
|
||||
local ceremonyGui = new("ScreenGui", { Name = "RankCeremony", ResetOnSpawn = false, IgnoreGuiInset = true, DisplayOrder = 40, Enabled = false, Parent = player:WaitForChild("PlayerGui") })
|
||||
local function ceremony(letter, name, unlocks, pearls)
|
||||
ceremonyGui.Enabled = true
|
||||
local root = Theme.followScale(ceremonyGui)
|
||||
local dim = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.45, Parent = root })
|
||||
local _, idx = Config.RankById(letter)
|
||||
local panel = new("Frame", {
|
||||
Size = UDim2.fromOffset(520, 300), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), BackgroundColor3 = WHITE, Parent = root,
|
||||
}, { corner(12), stroke(C.goldDark, 4, 0), Theme.woodGradient(C.wood, C.woodDark) })
|
||||
Theme.innerBorder(panel, 7, 8, C.gold, 0.2)
|
||||
Theme.rivets(panel, 12, 8)
|
||||
text({ Size = UDim2.new(1, 0, 0, 34), Position = UDim2.fromOffset(0, 16), Font = TITLE, TextSize = 26, TextXAlignment = CENTER, TextColor3 = C.goldBright,
|
||||
TextStrokeColor3 = C.ink, TextStrokeTransparency = 0.2, Text = "⚔ НОВЫЙ РАНГ ГИЛЬДИИ ⚔", Parent = panel })
|
||||
local sh = shield(panel, 96, idx, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(260, 118) })
|
||||
text({ Size = UDim2.new(1, -40, 0, 30), Position = UDim2.fromOffset(20, 180), Font = TITLE, TextSize = 24, TextXAlignment = CENTER,
|
||||
Text = ("%s — «%s»"):format(letter, name), Parent = panel })
|
||||
text({ Size = UDim2.new(1, -40, 0, 40), Position = UDim2.fromOffset(20, 212), Font = BODY2, TextSize = 15, TextXAlignment = CENTER, TextWrapped = true,
|
||||
TextColor3 = C.muted, Text = "Открыто: " .. unlocks, Parent = panel })
|
||||
text({ Size = UDim2.new(1, -40, 0, 26), Position = UDim2.fromOffset(20, 256), Font = TITLE, TextSize = 19, TextXAlignment = CENTER,
|
||||
TextColor3 = C.pearl, Text = ("+%d %s"):format(pearls or 0, Theme.PEARL), Parent = panel })
|
||||
K.popIn(panel, 0.3)
|
||||
TweenService:Create(sh, TweenInfo.new(1.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Rotation = 405 }):Play()
|
||||
Audio.play("fanfare")
|
||||
-- конфетти
|
||||
local colors = { C.goldBright, C.crimson, C.forest, C.parchment, Color3.fromRGB(120, 200, 255) }
|
||||
for i = 1, 70 do
|
||||
local p = new("Frame", {
|
||||
Size = UDim2.fromOffset(math.random(6, 12), math.random(10, 18)), Position = UDim2.new(math.random(), 0, 0, -30),
|
||||
Rotation = math.random(0, 360), BackgroundColor3 = colors[(i % #colors) + 1], BorderSizePixel = 0, Parent = root,
|
||||
})
|
||||
local t = math.random(18, 34) / 10
|
||||
TweenService:Create(p, TweenInfo.new(t, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
|
||||
Position = UDim2.new(p.Position.X.Scale + (math.random() - 0.5) * 0.2, 0, 1.1, 0), Rotation = p.Rotation + math.random(-360, 360),
|
||||
}):Play()
|
||||
end
|
||||
task.delay(5, function()
|
||||
TweenService:Create(dim, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play()
|
||||
task.wait(0.4)
|
||||
root:Destroy()
|
||||
ceremonyGui.Enabled = false
|
||||
end)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- события
|
||||
|
||||
remote.OnClientEvent:Connect(function(action, a, b, c, d)
|
||||
if action == "Guild" then
|
||||
state = a
|
||||
win.refresh()
|
||||
elseif action == "OpenGuild" then
|
||||
openGuild(a)
|
||||
elseif action == "RankUp" then
|
||||
win.close()
|
||||
ceremony(a, b, c, d)
|
||||
elseif action == "OrderDone" then
|
||||
Audio.play("quest")
|
||||
end
|
||||
end)
|
||||
|
||||
player.AttributeChanged:Connect(function(name)
|
||||
if name == "Seals" or name == "Pearls" or name == "RankIdx" or name == "SealsNext" or name == "RestLeft" then
|
||||
refreshHud()
|
||||
end
|
||||
if name == "Bait" or name == "BaitCount" or name == "AutoFish" or name == "RankIdx" then
|
||||
refreshBar()
|
||||
end
|
||||
if (name == "Coins" or name == "Pearls" or name == "Bait") and win.isOpen() and win.current == "bait" then
|
||||
win.refresh()
|
||||
end
|
||||
end)
|
||||
refreshHud()
|
||||
refreshBar()
|
||||
|
||||
-- таймер заказов и ловушки тикают, пока окно открыто
|
||||
task.spawn(function()
|
||||
while true do
|
||||
task.wait(30)
|
||||
if win.isOpen() and (win.current == "orders" or win.current == "traps") then
|
||||
remote:FireServer("GuildState")
|
||||
end
|
||||
end
|
||||
end)
|
||||
remote:FireServer("GuildState")
|
||||
@@ -0,0 +1,184 @@
|
||||
-- UiTheme (ModuleScript) -> StarterPlayer > StarterPlayerScripts
|
||||
-- Общий стиль интерфейса «средневековая гильдия»: палитра, шрифты с кириллицей,
|
||||
-- украшения окон (золотая рамка, заклёпки, багровая лента) и масштаб под размер экрана.
|
||||
|
||||
local UserInputService = game:GetService("UserInputService")
|
||||
|
||||
local Theme = {}
|
||||
|
||||
---------------------------------------------------------------- палитра
|
||||
-- старые ключи (bg, panel, blue…) оставлены, чтобы весь интерфейс перекрасился сразу
|
||||
|
||||
local C = {
|
||||
woodDark = Color3.fromRGB(40, 28, 20),
|
||||
wood = Color3.fromRGB(66, 46, 30),
|
||||
woodLight = Color3.fromRGB(98, 70, 44),
|
||||
parchment = Color3.fromRGB(236, 220, 180),
|
||||
ink = Color3.fromRGB(52, 36, 24),
|
||||
gold = Color3.fromRGB(218, 172, 92),
|
||||
goldBright = Color3.fromRGB(255, 214, 120),
|
||||
goldDark = Color3.fromRGB(140, 102, 52),
|
||||
crimson = Color3.fromRGB(150, 40, 35),
|
||||
forest = Color3.fromRGB(64, 112, 62),
|
||||
silver = Color3.fromRGB(214, 220, 228),
|
||||
pearl = Color3.fromRGB(235, 225, 245),
|
||||
}
|
||||
C.bg = C.woodDark
|
||||
C.panel = C.wood
|
||||
C.panel2 = C.woodLight
|
||||
C.green = C.forest
|
||||
C.red = C.crimson
|
||||
C.blue = Color3.fromRGB(70, 92, 112) -- «сталь»: телепорт, надеть
|
||||
C.purple = Color3.fromRGB(110, 62, 118)
|
||||
C.grey = Color3.fromRGB(84, 72, 60)
|
||||
C.text = C.parchment
|
||||
C.muted = Color3.fromRGB(192, 172, 136)
|
||||
C.line = C.goldDark
|
||||
C.dark = Color3.fromRGB(24, 16, 11) -- подложка полосок прогресса
|
||||
Theme.C = C
|
||||
|
||||
-- цвета для RichText
|
||||
Theme.HEX = {
|
||||
gold = "#FFD678",
|
||||
muted = "#C0AC88",
|
||||
green = "#9BE08C",
|
||||
red = "#FF8A7A",
|
||||
silver = "#DCE2EA",
|
||||
}
|
||||
|
||||
---------------------------------------------------------------- значки валют
|
||||
-- 🪙 в Roblox не рисуется (квадратик), поэтому серебро — светлый кружок
|
||||
Theme.SILVER = "⚪"
|
||||
Theme.PEARL = "🦪"
|
||||
Theme.SEAL = "📜"
|
||||
|
||||
---------------------------------------------------------------- шрифты
|
||||
-- проверено в Studio: у Merriweather и Nunito есть кириллица (у FredokaOne и Gotham — нет)
|
||||
|
||||
local function family(name, weight)
|
||||
return Font.new("rbxasset://fonts/families/" .. name .. ".json", weight)
|
||||
end
|
||||
Theme.TITLE_FACE = family("Merriweather", Enum.FontWeight.Heavy)
|
||||
Theme.BODY_FACE = family("Nunito", Enum.FontWeight.ExtraBold)
|
||||
Theme.BODY2_FACE = family("Nunito", Enum.FontWeight.Bold)
|
||||
Theme.HINT_FACE = family("Nunito", Enum.FontWeight.Heavy)
|
||||
-- старые Enum.Font в коде подменяются на эти шрифты
|
||||
Theme.FACES = {
|
||||
[Enum.Font.FredokaOne] = Theme.TITLE_FACE,
|
||||
[Enum.Font.GothamBold] = Theme.BODY_FACE,
|
||||
[Enum.Font.GothamMedium] = Theme.BODY2_FACE,
|
||||
[Enum.Font.GothamBlack] = Theme.TITLE_FACE,
|
||||
}
|
||||
|
||||
---------------------------------------------------------------- украшения
|
||||
|
||||
local function make(class, props)
|
||||
local o = Instance.new(class)
|
||||
for k, v in pairs(props) do
|
||||
if k ~= "Parent" then
|
||||
o[k] = v
|
||||
end
|
||||
end
|
||||
o.Parent = props.Parent
|
||||
return o
|
||||
end
|
||||
|
||||
-- ромбики-заклёпки по углам
|
||||
function Theme.rivets(frame, size, inset, color)
|
||||
size = size or 10
|
||||
inset = inset or 6
|
||||
for _, a in ipairs({ Vector2.new(0, 0), Vector2.new(1, 0), Vector2.new(0, 1), Vector2.new(1, 1) }) do
|
||||
local r = make("Frame", {
|
||||
Name = "Rivet", Size = UDim2.fromOffset(size, size), AnchorPoint = Vector2.new(0.5, 0.5), Rotation = 45,
|
||||
Position = UDim2.new(a.X, a.X == 0 and inset or -inset, a.Y, a.Y == 0 and inset or -inset),
|
||||
BackgroundColor3 = color or C.gold, BorderSizePixel = 0, ZIndex = 6, Parent = frame,
|
||||
})
|
||||
make("UIStroke", { Color = C.ink, Thickness = 1.5, Parent = r })
|
||||
end
|
||||
end
|
||||
|
||||
-- рамка в 2 слоя: снаружи тёмное золото (UIStroke у самого окна), внутри — светлая тонкая линия
|
||||
function Theme.innerBorder(frame, inset, radius, color, transparency)
|
||||
inset = inset or 5
|
||||
local b = make("Frame", {
|
||||
Name = "InnerBorder", Size = UDim2.new(1, -inset * 2, 1, -inset * 2), Position = UDim2.fromOffset(inset, inset),
|
||||
BackgroundTransparency = 1, ZIndex = 1, Parent = frame,
|
||||
})
|
||||
make("UICorner", { CornerRadius = UDim.new(0, radius or 8), Parent = b })
|
||||
make("UIStroke", { Color = color or C.gold, Thickness = 1.5, Transparency = transparency or 0.25, Parent = b })
|
||||
return b
|
||||
end
|
||||
|
||||
-- деревянная панель: тёплый градиент сверху вниз
|
||||
function Theme.woodGradient(top, bottom)
|
||||
return make("UIGradient", { Color = ColorSequence.new(top or C.wood, bottom or C.woodDark), Rotation = 90 })
|
||||
end
|
||||
|
||||
---------------------------------------------------------------- масштаб под экран
|
||||
-- Весь интерфейс лежит в «холсте» Root: он во столько же раз больше экрана, во сколько уменьшен
|
||||
-- UIScale. Поэтому вёрстка в пикселях одинакова на любом экране, а на телефоне всё меньше и плотнее.
|
||||
-- compact — узкий/сенсорный экран: другая раскладка (сетка кнопок, окна на весь экран).
|
||||
|
||||
local BASE = Vector2.new(1280, 720)
|
||||
local BASE_COMPACT = Vector2.new(780, 430)
|
||||
local listeners = {}
|
||||
Theme.compact = false
|
||||
Theme.scale = 1
|
||||
|
||||
local function isCompact(size)
|
||||
return size.X < 900 or UserInputService.TouchEnabled
|
||||
end
|
||||
|
||||
function Theme.onLayout(fn)
|
||||
table.insert(listeners, fn)
|
||||
fn(Theme.compact, Theme.scale)
|
||||
end
|
||||
|
||||
function Theme.scaleRoot(screenGui, name)
|
||||
local root = make("Frame", { Name = name or "Root", BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), Parent = screenGui })
|
||||
local uiScale = make("UIScale", { Parent = root })
|
||||
local function update()
|
||||
local size = screenGui.AbsoluteSize
|
||||
if size.X < 2 or size.Y < 2 then
|
||||
return
|
||||
end
|
||||
local compact = isCompact(size)
|
||||
local base = compact and BASE_COMPACT or BASE
|
||||
local s = math.clamp(math.min(size.X / base.X, size.Y / base.Y), 0.45, 1)
|
||||
uiScale.Scale = s
|
||||
root.Size = UDim2.fromScale(1 / s, 1 / s)
|
||||
if compact ~= Theme.compact or s ~= Theme.scale then
|
||||
Theme.compact, Theme.scale = compact, s
|
||||
for _, fn in ipairs(listeners) do
|
||||
task.spawn(fn, compact, s)
|
||||
end
|
||||
end
|
||||
end
|
||||
screenGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(update)
|
||||
update()
|
||||
return root
|
||||
end
|
||||
|
||||
-- второй ScreenGui (погода и т.п.) — тот же масштаб, но без своей раскладки
|
||||
function Theme.followScale(screenGui)
|
||||
local root = make("Frame", { Name = "Root", BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), Parent = screenGui })
|
||||
local uiScale = make("UIScale", { Parent = root })
|
||||
local function apply(_, s)
|
||||
uiScale.Scale = s
|
||||
root.Size = UDim2.fromScale(1 / s, 1 / s)
|
||||
end
|
||||
local function update()
|
||||
local size = screenGui.AbsoluteSize
|
||||
if size.X < 2 or size.Y < 2 then
|
||||
return
|
||||
end
|
||||
local compact = isCompact(size)
|
||||
local base = compact and BASE_COMPACT or BASE
|
||||
apply(compact, math.clamp(math.min(size.X / base.X, size.Y / base.Y), 0.45, 1))
|
||||
end
|
||||
screenGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(update)
|
||||
update()
|
||||
return root
|
||||
end
|
||||
|
||||
return Theme
|
||||
Reference in new issue
Block a user