213
This commit is contained in:
1 parent
8434f61030
commit
ec69c6c8d7
10 files changed
+2268
-336
No files matched your search
@@ -1045,8 +1045,15 @@ 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")
|
||||
@@ -1060,17 +1067,26 @@ local function setMovementLocked(locked)
|
||||
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 CAST_WINDUP, CAST_FLIGHT = 0.4, 0.55 -- как в GameServer: замах и полёт поплавка
|
||||
local CAM_SETTLE, CAM_RETURN = 0.7, 0.6
|
||||
local UP = Vector3.new(0, 1, 0)
|
||||
local fishCam = nil
|
||||
|
||||
local function easeInOut(a)
|
||||
return a < 0.5 and 4 * a * a * a or 1 - (-2 * a + 2) ^ 3 / 2
|
||||
end
|
||||
@@ -1078,6 +1094,100 @@ 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
|
||||
@@ -1096,62 +1206,80 @@ local function fishCamStep()
|
||||
end
|
||||
return
|
||||
end
|
||||
local t = os.clock() - fc.t0
|
||||
local now = os.clock()
|
||||
local cf, fov
|
||||
if t < CAST_WINDUP then
|
||||
local e = easeOut(t / CAST_WINDUP)
|
||||
cf = fc.origCF:Lerp(fc.windupCF, e)
|
||||
fov = fc.origFov + 14 * e
|
||||
elseif t < CAST_WINDUP + CAST_FLIGHT then
|
||||
if not fc.start then
|
||||
fc.start = (fc.tip and fc.tip.Parent and fc.tip.WorldPosition) or fc.fallbackStart
|
||||
end
|
||||
local a = (t - CAST_WINDUP) / CAST_FLIGHT
|
||||
local p = fc.start:Lerp(fc.target, a) + UP * (math.sin(a * math.pi) * 6) -- та же дуга, что у поплавка
|
||||
local chase = CFrame.lookAt(p - fc.flat * 9 + UP * 3.5, p + fc.flat * 4)
|
||||
local e = easeInOut(a)
|
||||
cf = fc.windupCF:Lerp(chase, e)
|
||||
fov = fc.origFov + 14 - 22 * e
|
||||
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 e = easeOut(math.min(1, (t - CAST_WINDUP - CAST_FLIGHT) / CAM_SETTLE))
|
||||
local now = os.clock()
|
||||
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
|
||||
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
|
||||
cf = fc.landCF:Lerp(fc.restCF + sway, e)
|
||||
fov = fc.origFov - 8 + 8 * e
|
||||
end
|
||||
cam.CFrame = cf
|
||||
cam.FieldOfView = fov
|
||||
end
|
||||
|
||||
local function startFishCam(target)
|
||||
-- начало зарядки: dir — куда полетит поплавок (к центру озера)
|
||||
local function startChargeCam(tool, dir)
|
||||
local cam = workspace.CurrentCamera
|
||||
local char = player.Character
|
||||
local hrp = char and char:FindFirstChild("HumanoidRootPart")
|
||||
if not cam or not hrp or typeof(target) ~= "Vector3" then
|
||||
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
|
||||
if not cam or not hrp then
|
||||
return
|
||||
end
|
||||
local flat = (target - hrp.Position) * Vector3.new(1, 0, 1)
|
||||
flat = flat.Magnitude > 0.1 and flat.Unit or hrp.CFrame.LookVector
|
||||
local tool = char:FindFirstChildOfClass("Tool")
|
||||
local tip = tool and tool:FindFirstChild("Handle") and tool.Handle:FindFirstChild("Tip")
|
||||
fishCam = {
|
||||
t0 = os.clock(), target = target, flat = flat, tip = tip,
|
||||
fallbackStart = hrp.Position + flat * 2 + UP * 4,
|
||||
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,
|
||||
windupCF = CFrame.lookAt(hrp.Position - flat * 13 + UP * 7, hrp.Position:Lerp(target, 0.5)),
|
||||
landCF = CFrame.lookAt(target - flat * 9 + UP * 3.5, target + flat * 4),
|
||||
restCF = CFrame.lookAt(target - flat * 11 + UP * 5.5, target),
|
||||
}
|
||||
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
|
||||
@@ -1164,9 +1292,17 @@ 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()
|
||||
@@ -1195,11 +1331,39 @@ local function placeZone()
|
||||
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 dir = world and 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 == "idle" then
|
||||
setState("casting")
|
||||
remote:FireServer("Cast")
|
||||
elseif state == "waiting" then
|
||||
if state == "waiting" then
|
||||
remote:FireServer("Cancel")
|
||||
setState("idle")
|
||||
elseif state == "bite" then
|
||||
@@ -1233,7 +1397,14 @@ local function hookTool(tool)
|
||||
return
|
||||
end
|
||||
hooked[tool] = true
|
||||
tool.Activated:Connect(onActivate)
|
||||
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")
|
||||
@@ -1263,6 +1434,12 @@ 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
|
||||
@@ -1358,6 +1535,170 @@ task.spawn(function()
|
||||
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 = WHITE, Size = Vector3.new(0.32, 0.06, 1.35), Transparency = 1,
|
||||
Parent = guideFolder,
|
||||
})
|
||||
end
|
||||
chevrons[i] = arms
|
||||
end
|
||||
-- две «палочки» стрелки «>» острием вперёд (по -Z)
|
||||
local ARM_CF = {}
|
||||
for k, s in ipairs({ -1, 1 }) do
|
||||
local center = Vector3.new(s * 0.45, 0, -0.1)
|
||||
ARM_CF[k] = CFrame.lookAt(center, center + Vector3.new(s * 0.9, 0, 1))
|
||||
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
|
||||
|
||||
-- маршрут для текущего шага: точки ломаной (без игрока) и подсказка; nil — линию не показываем
|
||||
local function guideRoute(step, pos, world)
|
||||
local inW1 = world and world.id == "World1"
|
||||
if step == 0 and not world then
|
||||
return { guideMarker("GuideBoard") }, "📋 Прочитай табличку «Как играть»"
|
||||
elseif not world then -- шаги 1–3 из лобби: сначала в портал
|
||||
return { guideMarker("GuidePortal") }, "🌊 Иди в портал «Тихое озеро»"
|
||||
elseif step == 2 and inW1 then
|
||||
return { guideMarker("GuideFishSpot") }, "🎣 Иди на причал, зажми ЛКМ и отпусти — заброс!"
|
||||
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, "💰 Продай рыбу в скупке"
|
||||
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
|
||||
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 = guideRoute(step, pos, world)
|
||||
guideHint.Text = hint or ""
|
||||
guideHint.Visible = hint ~= nil and state == "idle"
|
||||
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
|
||||
local base = CFrame.lookAt(Vector3.new(p.X, y + 0.08, p.Z), Vector3.new(p.X, y + 0.08, p.Z) + dir)
|
||||
-- у игрока и у цели стрелки плавно проявляются и гаснут
|
||||
local fade = math.max(0, 1 - math.min(d - 2, total - 1 - d) / 2.5)
|
||||
local tr = 0.1 + 0.9 * 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)
|
||||
@@ -1365,8 +1706,11 @@ remote.OnClientEvent:Connect(function(action, a, b, c)
|
||||
notify(a, b)
|
||||
elseif action == "Cast" then
|
||||
setState("waiting")
|
||||
startFishCam(a)
|
||||
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
|
||||
@@ -1386,6 +1730,9 @@ remote.OnClientEvent:Connect(function(action, a, b, c)
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user