feat(bunsik): 이웃 가게·손님 방문 멀티플레이, 4개 언어, 설정 창, 마우스 회전, 김밥 해금 효과

- 빈 부지에 NPC 사장님이 운영하는 이웃 가게(크기 제각각), 플레이어가 오면 그 자리를 넘겨줌
- 다른 가게 입구에서 손님으로 앉기: 주인은 2배 값, 손님은 시식 보너스(1분에 한 번)
- 한국어·영어·일본어·중국어(계정 언어 자동 선택), 이름판·메뉴판은 보는 사람 언어로
- 오른쪽 위 언어 버튼을 설정 창으로: 언어, 마우스로 화면 돌리기(PC 기본 켜짐), 효과음
- 메뉴 해금 시 진열대 모형이 생기고 다음 손님이 바로 새 메뉴를 주문
- 통합 테스트 600개 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-12 05:37:46 +09:00
parent c7af87c646
commit 4d861b8fd3
21 changed files with 1464 additions and 135 deletions

View File

@@ -1,5 +1,5 @@
--!strict
-- 화면 UI: 돈, 다음 업그레이드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 언어 전환, 안내 문구, 알림.
-- 화면 UI: 돈, 다음 업그레이드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 설정(언어·마우스 회전·효과음), 안내 문구, 알림.
-- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
@@ -17,6 +17,7 @@ export type HudHandle = {
refresh: () -> (),
notify: (key: string, args: { [string]: any }?) -> (),
setScale: (number) -> (),
menuOpen: () -> boolean, -- 업그레이드·설정 창이 열려 있으면 true(마우스 커서를 풀어 줌)
destroy: () -> (),
}
@@ -250,15 +251,70 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
devButtons[key] = b
end
-- 오른쪽 위: 언어
local langBtn = button(
-- 오른쪽 위: 설정 버튼과 설정 창(언어, 마우스로 화면 돌리기, 효과음)
local settingsBtn = button(
root,
"Lang",
UDim2.fromOffset(120, 44),
"Settings",
UDim2.fromOffset(130, 44),
UDim2.new(1, -10, 0, 6),
Vector2.new(1, 0),
Color3.fromRGB(80, 140, 230)
)
local settings = frame(
root,
"SettingsPanel",
UDim2.fromOffset(520, 330),
UDim2.fromScale(0.5, 0.48),
Vector2.new(0.5, 0.5),
CREAM
)
settings.Visible = false
corner(settings, 20)
stroke(settings, Color3.fromRGB(80, 140, 230), 4)
local settingsTitle = text(settings, "Title", UDim2.new(1, -120, 0, 44), UDim2.fromOffset(16, 10))
settingsTitle.TextXAlignment = Enum.TextXAlignment.Left
local settingsClose = button(
settings,
"Close",
UDim2.fromOffset(90, 42),
UDim2.new(1, -12, 0, 10),
Vector2.new(1, 0),
Color3.fromRGB(220, 80, 70)
)
local function rowLabel(name: string, y: number): TextLabel
local t = text(settings, name, UDim2.new(1, -32, 0, 30), UDim2.fromOffset(16, y))
t.TextXAlignment = Enum.TextXAlignment.Left
return t
end
local langLabel = rowLabel("LangLabel", 64)
-- 언어 버튼: 자동("") + 네 언어
local langChoices = { "" }
for _, l in Locale.LANGS do
table.insert(langChoices, l)
end
local langButtons: { [string]: TextButton } = {}
for i, l in langChoices do
local b = button(
settings,
"Lang_" .. (if l == "" then "auto" else l),
UDim2.fromOffset(92, 44),
UDim2.fromOffset(16 + (i - 1) * 98, 100),
Vector2.zero,
GRAY
)
langButtons[l] = b
end
local mouseLabel = rowLabel("MouseLabel", 160)
local mouseBtn =
button(settings, "MouseLook", UDim2.fromOffset(110, 40), UDim2.new(1, -16, 0, 156), Vector2.new(1, 0), GRAY)
mouseLabel.Size = UDim2.new(1, -150, 0, 30)
local mouseHint =
text(settings, "MouseHint", UDim2.new(1, -32, 0, 22), UDim2.fromOffset(16, 200), Color3.fromRGB(120, 90, 60))
mouseHint.TextXAlignment = Enum.TextXAlignment.Left
local sfxLabel = rowLabel("SfxLabel", 246)
sfxLabel.Size = UDim2.new(1, -150, 0, 30)
local sfxBtn =
button(settings, "Sfx", UDim2.fromOffset(110, 40), UDim2.new(1, -16, 0, 242), Vector2.new(1, 0), GRAY)
local function lang(): string
return attr(state, "Lang", "ko")
@@ -267,7 +323,11 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
return Locale.t(lang(), key, args)
end
local function pname(p: Economy.Purchase): string
return if lang() == "ko" then p.name else p.nameEn
return Locale.itemName(lang(), p.id)
end
local function toggle(b: TextButton, on: boolean)
b.Text = L(if on then "on" else "off")
b.BackgroundColor3 = if on then GREEN else GRAY
end
local pulse: Tween? = nil
@@ -328,9 +388,23 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
end
listBtn.Text = "📋 " .. L("shop")
langBtn.Text = L("language")
settingsBtn.Text = "⚙️ " .. L("settings")
closeBtn.Text = L("close")
settingsTitle.Text = "⚙️ " .. L("settings")
settingsClose.Text = L("close")
langLabel.Text = "🌐 " .. L("language")
local current = attr(state, "LangSetting", "")
for l, b in langButtons do
b.Text = if l == "" then L("langAuto") else Locale.LANG_NAMES[l]
b.BackgroundColor3 = if l == current then Color3.fromRGB(80, 140, 230) else GRAY
end
mouseLabel.Text = "🖱️ " .. L("mouseLook")
mouseHint.Text = L("mouseHint")
toggle(mouseBtn, attr(state, "MouseLook", true) == true)
sfxLabel.Text = "🔊 " .. L("sfx")
toggle(sfxBtn, attr(state, "Sfx", true) == true)
local double = attr(state, "Double", false)
passBtn.Visible = Products.DOUBLE_MONEY_PASS ~= 0
passBtn.Text = if double then "✅ " .. L("doubleOwned") else "💰x2 " .. L("double")
@@ -378,6 +452,16 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
end
local function notify(key: string, args: { [string]: any }?)
-- 서버는 메뉴·업그레이드를 키(menu, item)로 보내고, 이름은 내 언어로 바꿔 씁니다.
if args then
args = table.clone(args)
if typeof(args.menu) == "string" then
args.menuName = Locale.menuName(lang(), args.menu)
end
if typeof(args.item) == "string" then
args.name = Locale.itemName(lang(), args.item)
end
end
local toast =
frame(toasts, "Toast", UDim2.fromOffset(540, 46), UDim2.new(), Vector2.zero, Color3.fromRGB(45, 45, 60))
corner(toast, 12)
@@ -402,6 +486,7 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
conns,
listBtn.Activated:Connect(function()
panel.Visible = not panel.Visible
settings.Visible = false
end)
)
table.insert(
@@ -412,8 +497,35 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
)
table.insert(
conns,
langBtn.Activated:Connect(function()
send("lang", if lang() == "ko" then "en" else "ko")
settingsBtn.Activated:Connect(function()
settings.Visible = not settings.Visible
panel.Visible = false
end)
)
table.insert(
conns,
settingsClose.Activated:Connect(function()
settings.Visible = false
end)
)
for l, b in langButtons do
table.insert(
conns,
b.Activated:Connect(function()
send("lang", l)
end)
)
end
table.insert(
conns,
mouseBtn.Activated:Connect(function()
send("mouseLook", attr(state, "MouseLook", true) ~= true)
end)
)
table.insert(
conns,
sfxBtn.Activated:Connect(function()
send("sfx", attr(state, "Sfx", true) ~= true)
end)
)
table.insert(
@@ -449,6 +561,9 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()
setScale = function(s: number)
scale.Scale = s
end,
menuOpen = function(): boolean
return panel.Visible or settings.Visible
end,
destroy = function()
for _, c in conns do
c:Disconnect()

View File

@@ -1,4 +1,4 @@
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표.
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표, 부지 글자·손님 방문 버튼, 마우스 회전, 효과음 설정.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
@@ -6,6 +6,8 @@ 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
@@ -31,10 +33,17 @@ camera:GetPropertyChangedSignal("ViewportSize"):Connect(rescale)
rescale()
-- 구매·확장 효과음은 내 화면에서만 크게(위치 없이) 들립니다.
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
@@ -42,7 +51,9 @@ 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,
}
@@ -61,5 +72,11 @@ 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)
local UserInputService = game:GetService("UserInputService")
if player:GetAttribute("MouseLook") == true and UserInputService.MouseEnabled and UserInputService.KeyboardEnabled then
hud.notify("mouseHint")
end

View File

@@ -0,0 +1,37 @@
--!strict
-- PC에서 우클릭 없이 마우스만 움직여도 화면이 돌아가게 합니다(마우스를 화면 가운데에 고정).
-- 설정에서 끌 수 있고, Ctrl을 누르고 있거나 업그레이드·설정 창이 열려 있으면 커서를 풀어 버튼을 누를 수 있습니다.
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local MouseLook = {}
-- 지금 마우스를 가운데에 고정할지
function MouseLook.shouldLock(setting: boolean, mouse: boolean, ctrl: boolean, menuOpen: boolean): boolean
return setting and mouse and not ctrl and not menuOpen
end
function MouseLook.start(state: Instance, menuOpen: () -> boolean)
local locked = false
RunService:BindToRenderStep("BunsikMouseLook", Enum.RenderPriority.Camera.Value + 1, function()
local ctrl = UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
or UserInputService:IsKeyDown(Enum.KeyCode.RightControl)
local want = MouseLook.shouldLock(
state:GetAttribute("MouseLook") == true,
UserInputService.MouseEnabled and UserInputService.KeyboardEnabled,
ctrl,
menuOpen()
)
if want then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
locked = true
elseif locked then
-- 우리가 고정했던 것만 풉니다(우클릭 회전 등 기본 동작은 건드리지 않음).
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
locked = false
end
end)
end
return MouseLook

View File

@@ -0,0 +1,120 @@
--!strict
-- 부지 이름판·메뉴판 글자를 보는 사람 언어로 쓰고, 다른 가게 입구에 "손님으로 들어가기" 버튼을 붙입니다.
-- 서버는 부지 모델 속성(OwnerId, OwnerName, Npc, Level)만 바꾸고, 글자는 각 클라이언트가 만듭니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Shared = ReplicatedStorage:WaitForChild("Shared")
local Economy = require(Shared:WaitForChild("Economy"))
local Locale = require(Shared:WaitForChild("Locale"))
local Plots = {}
local function labels(part: Instance): { TextLabel }
local out = {}
for _, gui in part:GetChildren() do
if gui:IsA("SurfaceGui") then
local t = gui:FindFirstChildOfClass("TextLabel")
if t then
table.insert(out, t)
end
end
end
return out
end
-- 이름판 글자: 플레이어 가게, 이웃 가게, 빈 자리
function Plots.nameText(plot: Instance, lang: string): string
local level = plot:GetAttribute("Level")
local tail = if typeof(level) == "number" and level > 0 then ` ⭐Lv.{level}` else ""
local ownerName = plot:GetAttribute("OwnerName")
if typeof(ownerName) == "string" then
return Locale.t(lang, "plotOwner", { name = ownerName }) .. tail
end
local npc = plot:GetAttribute("Npc")
if typeof(npc) == "number" then
local key = `npcShop{npc}`
return Locale.t(lang, key) .. tail
end
return Locale.t(lang, "plotEmpty")
end
-- 메뉴판 글자: 파는 메뉴와 지금 값
function Plots.menuText(plot: Instance, lang: string): string
local level = plot:GetAttribute("Level")
if typeof(level) ~= "number" then
return ""
end
local stats = Economy.statsAt(level)
local lines = {}
for _, key in Economy.MENU_ORDER do
if table.find(stats.menus, key) then
local price = Locale.t(lang, "money", { money = Locale.number(Economy.dishPrice(key, stats, 1)) })
table.insert(lines, `{Economy.MENUS[key].icon} {Locale.menuName(lang, key)} {price}`)
end
end
return table.concat(lines, "\n")
end
-- 부지 하나에 연결합니다. state는 Lang 속성을 가진 인스턴스(실제로는 Player).
function Plots.attach(plot: Model, state: Instance, myId: number, send: (string, any?) -> ()): () -> ()
local base = plot:WaitForChild("Base")
local nameBoard = base:WaitForChild("NameBoard")
local menuBoard = base:WaitForChild("Stall"):WaitForChild("MenuBoard")
local visitPoint = base:WaitForChild("VisitPoint") :: BasePart
local index = tonumber(string.match(plot.Name, "%d+"))
local prompt = Instance.new("ProximityPrompt")
prompt.Name = "VisitPrompt"
prompt.KeyboardKeyCode = Enum.KeyCode.E
prompt.MaxActivationDistance = 12
prompt.RequiresLineOfSight = false
prompt.HoldDuration = 0
prompt.Parent = visitPoint
local function refresh()
local lang = (state:GetAttribute("Lang") :: string?) or "ko"
local nameText = Plots.nameText(plot, lang)
for _, t in labels(nameBoard) do
t.Text = nameText
end
local menuText = Plots.menuText(plot, lang)
for _, t in labels(menuBoard) do
t.Text = menuText
end
local ownerId = plot:GetAttribute("OwnerId")
local open = ownerId ~= nil or plot:GetAttribute("Npc") ~= nil
prompt.Enabled = open and ownerId ~= myId
prompt.ActionText = Locale.t(lang, "visitAction")
prompt.ObjectText = if ownerId ~= nil then Locale.t(lang, "visitor") else Locale.t(lang, "neighbor")
end
local conns = {
plot.AttributeChanged:Connect(refresh),
state:GetAttributeChangedSignal("Lang"):Connect(refresh),
prompt.Triggered:Connect(function()
send("visit", index)
end),
}
refresh()
return function()
for _, c in conns do
c:Disconnect()
end
prompt:Destroy()
end
end
function Plots.start(folder: Instance, state: Instance, myId: number, send: (string, any?) -> ())
local function add(plot: Instance)
if plot:IsA("Model") then
task.spawn(Plots.attach, plot, state, myId, send)
end
end
folder.ChildAdded:Connect(add)
for _, plot in folder:GetChildren() do
add(plot)
end
end
return Plots

View File

@@ -23,6 +23,7 @@ function Stove.attach(stove: BasePart, state: Instance, send: (string, any?) ->
sizzle.SoundId = Sounds.SIZZLE
sizzle.Volume = 0.6
sizzle.Looped = true
sizzle.SoundGroup = game:GetService("SoundService"):FindFirstChild("Sfx") :: SoundGroup?
sizzle.Parent = stove
local function refresh()
@@ -32,8 +33,7 @@ function Stove.attach(stove: BasePart, state: Instance, send: (string, any?) ->
prompt.ObjectText = Locale.t(lang, "stoveObject")
if typeof(menu) == "string" and Economy.MENUS[menu] then
local m = Economy.MENUS[menu]
local name = if lang == "ko" then m.name else m.nameEn
prompt.ActionText = `{m.icon} ` .. Locale.t(lang, "cookAction", { menu = name })
prompt.ActionText = `{m.icon} ` .. Locale.t(lang, "cookAction", { menu = Locale.menuName(lang, menu) })
prompt.Enabled = true
else
prompt.Enabled = false