- Layout 모듈: 안전 영역(상단 바·노치 제외) 크기와 터치 여부로 배율·위치 계산 - 휴대폰: 기준 화면 900x400으로 글자·버튼 크게, 결제 버튼은 왼쪽 위, 사기 버튼은 조이스틱(왼쪽 40%×아래 2/3)과 점프 버튼 자리 사이, 마우스 회전 줄 숨김 - 루트가 화면을 꽉 채우고, 배율을 상단 바 뺀 영역 기준으로 계산(아래 카드 잘림 수정) - 개발자 테스트 버튼을 설정 창 안으로 이동 - 기기 12종 배치 단위 테스트, 배치 미리보기 도구(tools/hud_preview.py) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
3.9 KiB
Lua
104 lines
3.9 KiB
Lua
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표, 부지 글자·손님 방문 버튼, 마우스 회전, 효과음 설정.
|
|
local Players = game:GetService("Players")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
|
|
local SoundService = game:GetService("SoundService")
|
|
|
|
local Guide = require(script.Parent.Guide)
|
|
local Hud = require(script.Parent.Hud)
|
|
local MouseLook = require(script.Parent.MouseLook)
|
|
local Plots = require(script.Parent.Plots)
|
|
local Stove = require(script.Parent.Stove)
|
|
|
|
local player = Players.LocalPlayer
|
|
local remotes = ReplicatedStorage:WaitForChild("Remotes")
|
|
local action = remotes:WaitForChild("Action") :: RemoteEvent
|
|
local notifyRemote = remotes:WaitForChild("Notify") :: RemoteEvent
|
|
|
|
local function send(kind: string, arg: any?)
|
|
action:FireServer(kind, arg)
|
|
end
|
|
|
|
-- 서버가 세이브를 불러오고 부지를 줄 때까지 기다립니다.
|
|
while not player:GetAttribute("Ready") do
|
|
player:GetAttributeChangedSignal("Ready"):Wait()
|
|
end
|
|
|
|
local hud = Hud.build(player:WaitForChild("PlayerGui"), player, send)
|
|
local UserInputService = game:GetService("UserInputService")
|
|
local GuiService = game:GetService("GuiService")
|
|
local camera = workspace.CurrentCamera
|
|
-- 휴대폰·태블릿 배치: 마지막 입력이 터치면 켜고, 마우스·게임패드면 끕니다(키보드 입력은 채팅일 수 있어 무시).
|
|
local touch = UserInputService.TouchEnabled and not UserInputService.MouseEnabled
|
|
local function relayout()
|
|
-- ScreenGui 크기는 상단 바·노치를 뺀 영역입니다. 첫 프레임 전이라 0이면 화면 크기에서 상단 바만 뺍니다.
|
|
local size = hud.gui.AbsoluteSize
|
|
if size.X < 2 or size.Y < 2 then
|
|
size = camera.ViewportSize - Vector2.new(0, GuiService:GetGuiInset().Y)
|
|
end
|
|
hud.setLayout(size, touch)
|
|
end
|
|
UserInputService.LastInputTypeChanged:Connect(function(t)
|
|
local isTouch: boolean? = nil
|
|
if t == Enum.UserInputType.Touch then
|
|
isTouch = true
|
|
elseif t.Name:sub(1, 5) == "Mouse" or t.Name:sub(1, 7) == "Gamepad" then
|
|
isTouch = false
|
|
end
|
|
if isTouch ~= nil and isTouch ~= touch then
|
|
touch = isTouch
|
|
relayout()
|
|
end
|
|
end)
|
|
hud.gui:GetPropertyChangedSignal("AbsoluteSize"):Connect(relayout)
|
|
camera:GetPropertyChangedSignal("ViewportSize"):Connect(relayout)
|
|
relayout()
|
|
-- 구매·확장 효과음은 내 화면에서만 크게(위치 없이) 들립니다.
|
|
local Sounds = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Sounds"))
|
|
local sfxGroup = SoundService:WaitForChild("Sfx") :: SoundGroup
|
|
local function applySfx()
|
|
sfxGroup.Volume = if player:GetAttribute("Sfx") == false then 0 else 1
|
|
end
|
|
player:GetAttributeChangedSignal("Sfx"):Connect(applySfx)
|
|
applySfx()
|
|
local function uiSound(id: string, volume: number): Sound
|
|
local s = Instance.new("Sound")
|
|
s.SoundId = id
|
|
s.Volume = volume
|
|
s.SoundGroup = sfxGroup
|
|
s.Parent = SoundService
|
|
return s
|
|
end
|
|
local buySound = uiSound(Sounds.BUY, 0.7)
|
|
local levelSound = uiSound(Sounds.LEVELUP, 0.8)
|
|
local NOTIFY_SOUND: { [string]: Sound } = {
|
|
purchased = buySound,
|
|
newMenu = buySound,
|
|
boostGot = buySound,
|
|
guestBonus = buySound,
|
|
expanded = levelSound,
|
|
}
|
|
|
|
notifyRemote.OnClientEvent:Connect(function(key, args)
|
|
if typeof(key) == "string" then
|
|
hud.notify(key, if typeof(args) == "table" then args else nil)
|
|
local s = NOTIFY_SOUND[key]
|
|
if s then
|
|
s:Play()
|
|
end
|
|
end
|
|
end)
|
|
|
|
local plotIndex = player:GetAttribute("Plot")
|
|
local world = workspace:WaitForChild("BunsikWorld")
|
|
local plot = world:WaitForChild("Plots"):WaitForChild("Plot" .. tostring(plotIndex))
|
|
local stove = plot:WaitForChild("Base"):WaitForChild("Stall"):WaitForChild("Stove") :: BasePart
|
|
Stove.attach(stove, player, send)
|
|
Plots.start(world:WaitForChild("Plots"), player, player.UserId, send)
|
|
|
|
Guide.start(player)
|
|
MouseLook.start(player, hud.menuOpen)
|
|
if player:GetAttribute("MouseLook") == true and UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then
|
|
hud.notify("mouseHint")
|
|
end
|