feat(bunsik): MVP 전체 구현 — 맵, 요리·서빙, 손님 NPC, 업그레이드 20개, 세이브, 결제, 한/영 UI
- Shop.luau: 손님·주문·조리·서빙·구매 순수 로직(lune 단위 테스트, 시뮬레이터 공용) - 서버: World(부지 6칸), PlotBuilder(파트 모형), PlotController, Npc(트윈 이동), Data(ProfileStore), Receipts(결제 1회 = 지급 1회), Game - 클라이언트: Hud(돈·다음 업그레이드·목록·결제·언어·튜토리얼), 내 조리대 전용 버튼, 튜토리얼 화살표, 주인 전용 테스트 버튼 - 2단계 업그레이드 10개 추가, 파이썬 시뮬레이터를 실제 로직 기반 tools/sim.luau로 교체 - tools/cloud.py: 업로드, 원격 Luau 실행, 게임패스·개발자 상품 생성, 서버 인원 설정 - tests/cloud/integration.luau: 로블록스 서버 통합 테스트 514개 통과 - check.sh에 luau-lsp 타입 검사 추가, ProfileStore 고정 버전 포함 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
58
bunsik-tycoon/src/client/Guide.luau
Normal file
58
bunsik-tycoon/src/client/Guide.luau
Normal file
@@ -0,0 +1,58 @@
|
||||
--!strict
|
||||
-- 튜토리얼 화살표: 캐릭터에서 목표(조리대, 손님 자리)까지 빛나는 줄과 위에서 통통 튀는 화살표.
|
||||
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local Guide = {}
|
||||
|
||||
function Guide.start(player: Player)
|
||||
local beam = Instance.new("Beam")
|
||||
beam.Color = ColorSequence.new(Color3.fromRGB(255, 230, 60))
|
||||
beam.Width0 = 0.6
|
||||
beam.Width1 = 0.6
|
||||
beam.FaceCamera = true
|
||||
beam.LightEmission = 1
|
||||
beam.Transparency = NumberSequence.new(0.2)
|
||||
beam.Segments = 1
|
||||
local a0 = Instance.new("Attachment")
|
||||
a0.Name = "GuideFrom"
|
||||
local a1 = Instance.new("Attachment")
|
||||
a1.Name = "GuideTo"
|
||||
beam.Attachment0 = a0
|
||||
beam.Attachment1 = a1
|
||||
|
||||
local arrow = Instance.new("BillboardGui")
|
||||
arrow.Name = "GuideArrow"
|
||||
arrow.Size = UDim2.fromOffset(70, 70)
|
||||
arrow.AlwaysOnTop = true
|
||||
arrow.LightInfluence = 0
|
||||
local label = Instance.new("TextLabel")
|
||||
label.Size = UDim2.fromScale(1, 1)
|
||||
label.BackgroundTransparency = 1
|
||||
label.Text = "⬇️"
|
||||
label.TextScaled = true
|
||||
label.Parent = arrow
|
||||
|
||||
RunService.RenderStepped:Connect(function()
|
||||
local value = player:FindFirstChild("Guide") :: ObjectValue?
|
||||
local target = value and value.Value :: BasePart?
|
||||
local char = player.Character
|
||||
local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart?
|
||||
local tut = player:GetAttribute("Tut")
|
||||
if target and root and (tut == 1 or tut == 2) then
|
||||
a0.Parent = root
|
||||
a1.Parent = target
|
||||
beam.Parent = target
|
||||
arrow.Adornee = target
|
||||
arrow.StudsOffset = Vector3.new(0, 3 + math.abs(math.sin(os.clock() * 4)) * 1.5, 0)
|
||||
arrow.Parent = target
|
||||
else
|
||||
beam.Parent = nil
|
||||
arrow.Parent = nil
|
||||
a0.Parent = nil
|
||||
a1.Parent = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return Guide
|
||||
466
bunsik-tycoon/src/client/Hud.luau
Normal file
466
bunsik-tycoon/src/client/Hud.luau
Normal file
@@ -0,0 +1,466 @@
|
||||
--!strict
|
||||
-- 화면 UI: 돈, 다음 업그레이드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 언어 전환, 안내 문구, 알림.
|
||||
-- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TweenService = game:GetService("TweenService")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Economy = require(Shared:WaitForChild("Economy"))
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
local Products = require(Shared:WaitForChild("Products"))
|
||||
|
||||
local Hud = {}
|
||||
|
||||
export type HudHandle = {
|
||||
gui: ScreenGui,
|
||||
refresh: () -> (),
|
||||
notify: (key: string, args: { [string]: any }?) -> (),
|
||||
setScale: (number) -> (),
|
||||
destroy: () -> (),
|
||||
}
|
||||
|
||||
local ORANGE = Color3.fromRGB(255, 130, 50)
|
||||
local GREEN = Color3.fromRGB(70, 190, 90)
|
||||
local GRAY = Color3.fromRGB(150, 150, 150)
|
||||
local DARK = Color3.fromRGB(45, 35, 35)
|
||||
local CREAM = Color3.fromRGB(255, 248, 235)
|
||||
|
||||
local function corner(parent: Instance, r: number)
|
||||
local c = Instance.new("UICorner")
|
||||
c.CornerRadius = UDim.new(0, r)
|
||||
c.Parent = parent
|
||||
end
|
||||
|
||||
local function stroke(parent: Instance, color: Color3, thickness: number): UIStroke
|
||||
local s = Instance.new("UIStroke")
|
||||
s.Color = color
|
||||
s.Thickness = thickness
|
||||
s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
|
||||
s.Parent = parent
|
||||
return s
|
||||
end
|
||||
|
||||
local function frame(parent: Instance, name: string, size: UDim2, pos: UDim2, anchor: Vector2, color: Color3?): Frame
|
||||
local f = Instance.new("Frame")
|
||||
f.Name = name
|
||||
f.Size = size
|
||||
f.Position = pos
|
||||
f.AnchorPoint = anchor
|
||||
f.BackgroundColor3 = color or CREAM
|
||||
f.BackgroundTransparency = if color then 0 else 1
|
||||
f.BorderSizePixel = 0
|
||||
f.Parent = parent
|
||||
return f
|
||||
end
|
||||
|
||||
local function text(parent: Instance, name: string, size: UDim2, pos: UDim2, color: Color3?): TextLabel
|
||||
local t = Instance.new("TextLabel")
|
||||
t.Name = name
|
||||
t.Size = size
|
||||
t.Position = pos
|
||||
t.BackgroundTransparency = 1
|
||||
t.TextColor3 = color or DARK
|
||||
t.Font = Enum.Font.FredokaOne
|
||||
t.TextScaled = true
|
||||
t.AutoLocalize = false
|
||||
t.Text = ""
|
||||
t.Parent = parent
|
||||
return t
|
||||
end
|
||||
|
||||
local function button(
|
||||
parent: Instance,
|
||||
name: string,
|
||||
size: UDim2,
|
||||
pos: UDim2,
|
||||
anchor: Vector2,
|
||||
color: Color3
|
||||
): TextButton
|
||||
local b = Instance.new("TextButton")
|
||||
b.Name = name
|
||||
b.Size = size
|
||||
b.Position = pos
|
||||
b.AnchorPoint = anchor
|
||||
b.BackgroundColor3 = color
|
||||
b.TextColor3 = Color3.new(1, 1, 1)
|
||||
b.Font = Enum.Font.FredokaOne
|
||||
b.TextScaled = true
|
||||
b.AutoLocalize = false
|
||||
b.AutoButtonColor = true
|
||||
b.Text = ""
|
||||
b.Parent = parent
|
||||
corner(b, 14)
|
||||
stroke(b, Color3.fromRGB(255, 255, 255), 3)
|
||||
local pad = Instance.new("UIPadding")
|
||||
pad.PaddingTop = UDim.new(0.14, 0)
|
||||
pad.PaddingBottom = UDim.new(0.14, 0)
|
||||
pad.PaddingLeft = UDim.new(0, 8)
|
||||
pad.PaddingRight = UDim.new(0, 8)
|
||||
pad.Parent = b
|
||||
return b
|
||||
end
|
||||
|
||||
local function attr(state: Instance, key: string, default: any): any
|
||||
local v = state:GetAttribute(key)
|
||||
if v == nil then
|
||||
return default
|
||||
end
|
||||
return v
|
||||
end
|
||||
|
||||
function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()): HudHandle
|
||||
local gui = Instance.new("ScreenGui")
|
||||
gui.Name = "BunsikHud"
|
||||
gui.ResetOnSpawn = false
|
||||
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
||||
gui.Parent = parent
|
||||
|
||||
local root = frame(gui, "Root", UDim2.fromScale(1, 1), UDim2.fromScale(0, 0), Vector2.zero)
|
||||
local scale = Instance.new("UIScale")
|
||||
scale.Parent = root
|
||||
-- UIScale은 자식 크기를 키우므로, 기준 화면(1100x620) 크기의 루트에 붙이고 가운데에 둡니다.
|
||||
root.Size = UDim2.fromOffset(1100, 620)
|
||||
root.AnchorPoint = Vector2.new(0.5, 0.5)
|
||||
root.Position = UDim2.fromScale(0.5, 0.5)
|
||||
|
||||
-- 돈
|
||||
local money = frame(root, "Money", UDim2.fromOffset(300, 62), UDim2.new(0.5, 0, 0, 6), Vector2.new(0.5, 0), ORANGE)
|
||||
corner(money, 31)
|
||||
stroke(money, Color3.new(1, 1, 1), 4)
|
||||
local moneyText = text(money, "Text", UDim2.new(1, -24, 1, -14), UDim2.fromOffset(12, 7), Color3.new(1, 1, 1))
|
||||
local carry = text(root, "Carry", UDim2.fromOffset(160, 28), UDim2.new(0.5, -80, 0, 72), DARK)
|
||||
|
||||
-- 안내 문구(튜토리얼)
|
||||
local hint = frame(
|
||||
root,
|
||||
"Hint",
|
||||
UDim2.fromOffset(640, 54),
|
||||
UDim2.new(0.5, 0, 0, 104),
|
||||
Vector2.new(0.5, 0),
|
||||
Color3.fromRGB(255, 235, 120)
|
||||
)
|
||||
corner(hint, 14)
|
||||
stroke(hint, ORANGE, 3)
|
||||
local hintText = text(hint, "Text", UDim2.new(1, -20, 1, -10), UDim2.fromOffset(10, 5))
|
||||
|
||||
-- 알림
|
||||
local toasts = frame(root, "Toasts", UDim2.fromOffset(560, 200), UDim2.new(0.5, 0, 0, 166), Vector2.new(0.5, 0))
|
||||
local list = Instance.new("UIListLayout")
|
||||
list.HorizontalAlignment = Enum.HorizontalAlignment.Center
|
||||
list.Padding = UDim.new(0, 6)
|
||||
list.Parent = toasts
|
||||
|
||||
-- 다음 업그레이드 카드(아래 가운데)
|
||||
local card = frame(root, "Next", UDim2.fromOffset(500, 96), UDim2.new(0.5, 0, 1, -8), Vector2.new(0.5, 1), CREAM)
|
||||
corner(card, 18)
|
||||
stroke(card, ORANGE, 4)
|
||||
local cardTitle = text(card, "Title", UDim2.new(1, -170, 0, 40), UDim2.fromOffset(14, 8))
|
||||
cardTitle.TextXAlignment = Enum.TextXAlignment.Left
|
||||
local cardCost =
|
||||
text(card, "Cost", UDim2.new(1, -170, 0, 26), UDim2.fromOffset(14, 48), Color3.fromRGB(120, 90, 60))
|
||||
cardCost.TextXAlignment = Enum.TextXAlignment.Left
|
||||
local barBg = frame(
|
||||
card,
|
||||
"Bar",
|
||||
UDim2.new(1, -170, 0, 10),
|
||||
UDim2.fromOffset(14, 78),
|
||||
Vector2.zero,
|
||||
Color3.fromRGB(230, 220, 200)
|
||||
)
|
||||
corner(barBg, 5)
|
||||
local barFill = frame(barBg, "Fill", UDim2.fromScale(0, 1), UDim2.fromScale(0, 0), Vector2.zero, GREEN)
|
||||
corner(barFill, 5)
|
||||
local buyBtn = button(card, "Buy", UDim2.fromOffset(140, 72), UDim2.new(1, -12, 0.5, 0), Vector2.new(1, 0.5), GREEN)
|
||||
local buyStroke = buyBtn:FindFirstChildOfClass("UIStroke") :: UIStroke
|
||||
|
||||
-- 업그레이드 목록 버튼과 창
|
||||
local listBtn =
|
||||
button(root, "ListButton", UDim2.fromOffset(150, 56), UDim2.new(1, -10, 0.5, -40), Vector2.new(1, 0.5), ORANGE)
|
||||
local panel =
|
||||
frame(root, "Panel", UDim2.fromOffset(520, 430), UDim2.fromScale(0.5, 0.48), Vector2.new(0.5, 0.5), CREAM)
|
||||
panel.Visible = false
|
||||
corner(panel, 20)
|
||||
stroke(panel, ORANGE, 4)
|
||||
local panelTitle = text(panel, "Title", UDim2.new(1, -120, 0, 44), UDim2.fromOffset(16, 10))
|
||||
panelTitle.TextXAlignment = Enum.TextXAlignment.Left
|
||||
local closeBtn = button(
|
||||
panel,
|
||||
"Close",
|
||||
UDim2.fromOffset(90, 42),
|
||||
UDim2.new(1, -12, 0, 10),
|
||||
Vector2.new(1, 0),
|
||||
Color3.fromRGB(220, 80, 70)
|
||||
)
|
||||
local scroll = Instance.new("ScrollingFrame")
|
||||
scroll.Name = "List"
|
||||
scroll.Size = UDim2.new(1, -24, 1, -70)
|
||||
scroll.Position = UDim2.fromOffset(12, 62)
|
||||
scroll.BackgroundTransparency = 1
|
||||
scroll.BorderSizePixel = 0
|
||||
scroll.ScrollBarThickness = 8
|
||||
scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
|
||||
scroll.CanvasSize = UDim2.new()
|
||||
scroll.Parent = panel
|
||||
local rows = Instance.new("UIListLayout")
|
||||
rows.Padding = UDim.new(0, 6)
|
||||
rows.SortOrder = Enum.SortOrder.LayoutOrder
|
||||
rows.Parent = scroll
|
||||
|
||||
-- 왼쪽: 2배 수익, 돈 부스트
|
||||
local passBtn = button(
|
||||
root,
|
||||
"Double",
|
||||
UDim2.fromOffset(170, 64),
|
||||
UDim2.new(0, 10, 0.5, -40),
|
||||
Vector2.new(0, 0.5),
|
||||
Color3.fromRGB(150, 80, 220)
|
||||
)
|
||||
local boostBtn = button(
|
||||
root,
|
||||
"Boost",
|
||||
UDim2.fromOffset(170, 64),
|
||||
UDim2.new(0, 10, 0.5, 34),
|
||||
Vector2.new(0, 0.5),
|
||||
Color3.fromRGB(240, 170, 30)
|
||||
)
|
||||
|
||||
-- 개발자(게임 주인)만 보는 테스트 버튼
|
||||
local dev = frame(
|
||||
root,
|
||||
"Dev",
|
||||
UDim2.fromOffset(170, 150),
|
||||
UDim2.new(0, 10, 0.5, 80),
|
||||
Vector2.new(0, 0),
|
||||
Color3.fromRGB(40, 40, 50)
|
||||
)
|
||||
dev.BackgroundTransparency = 0.3
|
||||
corner(dev, 12)
|
||||
local devTitle = text(dev, "Title", UDim2.new(1, -10, 0, 22), UDim2.fromOffset(5, 4), Color3.new(1, 1, 1))
|
||||
local devButtons: { [string]: TextButton } = {}
|
||||
for i, key in { "devMoney", "devDouble", "devReset" } do
|
||||
local b = button(
|
||||
dev,
|
||||
key,
|
||||
UDim2.new(1, -16, 0, 34),
|
||||
UDim2.fromOffset(8, 30 + (i - 1) * 39),
|
||||
Vector2.zero,
|
||||
Color3.fromRGB(90, 90, 110)
|
||||
)
|
||||
devButtons[key] = b
|
||||
end
|
||||
|
||||
-- 오른쪽 위: 언어
|
||||
local langBtn = button(
|
||||
root,
|
||||
"Lang",
|
||||
UDim2.fromOffset(120, 44),
|
||||
UDim2.new(1, -10, 0, 6),
|
||||
Vector2.new(1, 0),
|
||||
Color3.fromRGB(80, 140, 230)
|
||||
)
|
||||
|
||||
local function lang(): string
|
||||
return attr(state, "Lang", "ko")
|
||||
end
|
||||
local function L(key: string, args: { [string]: any }?): string
|
||||
return Locale.t(lang(), key, args)
|
||||
end
|
||||
local function pname(p: Economy.Purchase): string
|
||||
return if lang() == "ko" then p.name else p.nameEn
|
||||
end
|
||||
|
||||
local pulse: Tween? = nil
|
||||
local listKey = ""
|
||||
|
||||
local function refresh()
|
||||
local m = attr(state, "Money", 0)
|
||||
local bought = attr(state, "Bought", 0)
|
||||
local stats = Economy.statsAt(bought)
|
||||
moneyText.Text = "💰 " .. L("money", { money = Locale.number(m) })
|
||||
local held = attr(state, "Carry", 0)
|
||||
carry.Text = if held > 0 then `🍽️ {held}/{stats.carry}` else ""
|
||||
|
||||
local nextP = Economy.PURCHASES[bought + 1]
|
||||
if nextP then
|
||||
cardTitle.Text = `{L("next")}: {pname(nextP)}`
|
||||
cardCost.Text = L("money", { money = Locale.number(nextP.cost) })
|
||||
barFill.Size = UDim2.fromScale(math.clamp(m / nextP.cost, 0, 1), 1)
|
||||
local can = m >= nextP.cost
|
||||
buyBtn.Text = L("buy")
|
||||
buyBtn.BackgroundColor3 = if can then GREEN else GRAY
|
||||
buyBtn.Visible = true
|
||||
else
|
||||
cardTitle.Text = L("maxed")
|
||||
cardCost.Text = ""
|
||||
barFill.Size = UDim2.fromScale(1, 1)
|
||||
buyBtn.Visible = false
|
||||
end
|
||||
|
||||
-- 튜토리얼 안내
|
||||
local tut = attr(state, "Tut", 0)
|
||||
if tut == 1 or tut == 2 or tut == 3 then
|
||||
hint.Visible = true
|
||||
hintText.Text = L("tut" .. tut)
|
||||
else
|
||||
hint.Visible = false
|
||||
end
|
||||
if tut == 3 and not pulse then
|
||||
buyStroke.Color = Color3.fromRGB(255, 220, 0)
|
||||
local tw = TweenService:Create(
|
||||
buyStroke,
|
||||
TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
|
||||
{ Thickness = 9 }
|
||||
)
|
||||
tw:Play()
|
||||
pulse = tw
|
||||
elseif tut ~= 3 and pulse then
|
||||
pulse:Cancel()
|
||||
pulse = nil
|
||||
buyStroke.Thickness = 3
|
||||
buyStroke.Color = Color3.new(1, 1, 1)
|
||||
end
|
||||
|
||||
dev.Visible = attr(state, "Dev", false) == true
|
||||
devTitle.Text = "🛠 " .. L("devTitle")
|
||||
for key, b in devButtons do
|
||||
b.Text = L(key)
|
||||
end
|
||||
|
||||
listBtn.Text = "📋 " .. L("shop")
|
||||
langBtn.Text = L("language")
|
||||
closeBtn.Text = L("close")
|
||||
|
||||
local double = attr(state, "Double", false)
|
||||
passBtn.Visible = Products.DOUBLE_MONEY_PASS ~= 0
|
||||
passBtn.Text = if double then "✅ " .. L("doubleOwned") else "💰x2 " .. L("double")
|
||||
passBtn.Active = not double
|
||||
passBtn.AutoButtonColor = not double
|
||||
boostBtn.Visible = Products.MONEY_BOOST_PRODUCT ~= 0 and nextP ~= nil
|
||||
boostBtn.Text = "⚡ " .. L("boost") .. "\n+" .. Locale.number(attr(state, "Boost", Economy.BOOST_MIN))
|
||||
|
||||
-- 업그레이드 목록(지금 단계 것만). 산 개수나 언어가 바뀔 때만 다시 그립니다.
|
||||
local key = `{bought}:{lang()}`
|
||||
if key == listKey then
|
||||
return
|
||||
end
|
||||
listKey = key
|
||||
local stage = stats.stage
|
||||
panelTitle.Text = L(if stage >= 2 then "stage2" else "stage1")
|
||||
for _, c in scroll:GetChildren() do
|
||||
if c:IsA("Frame") then
|
||||
c:Destroy()
|
||||
end
|
||||
end
|
||||
local from = if stage >= 2 then 11 else 1
|
||||
local to = if stage >= 2 then #Economy.PURCHASES else 10
|
||||
for i = from, to do
|
||||
local p = Economy.PURCHASES[i]
|
||||
local row =
|
||||
frame(scroll, "Row" .. i, UDim2.new(1, -12, 0, 46), UDim2.new(), Vector2.zero, Color3.new(1, 1, 1))
|
||||
row.LayoutOrder = i
|
||||
corner(row, 10)
|
||||
local done = i <= bought
|
||||
local isNext = i == bought + 1
|
||||
row.BackgroundColor3 = if done
|
||||
then Color3.fromRGB(215, 245, 215)
|
||||
elseif isNext then Color3.fromRGB(255, 240, 200)
|
||||
else Color3.fromRGB(240, 240, 240)
|
||||
local status = if done then "✅" elseif isNext then "👉" else "🔒"
|
||||
local name = text(row, "Name", UDim2.new(0.66, -10, 1, -12), UDim2.fromOffset(10, 6))
|
||||
name.TextXAlignment = Enum.TextXAlignment.Left
|
||||
name.Text = `{status} {pname(p)}`
|
||||
local cost =
|
||||
text(row, "Cost", UDim2.new(0.34, -10, 1, -12), UDim2.new(0.66, 0, 0, 6), Color3.fromRGB(120, 90, 60))
|
||||
cost.TextXAlignment = Enum.TextXAlignment.Right
|
||||
cost.Text = if done then L("bought") else L("money", { money = Locale.number(p.cost) })
|
||||
end
|
||||
end
|
||||
|
||||
local function notify(key: string, args: { [string]: any }?)
|
||||
local toast =
|
||||
frame(toasts, "Toast", UDim2.fromOffset(540, 46), UDim2.new(), Vector2.zero, Color3.fromRGB(45, 45, 60))
|
||||
corner(toast, 12)
|
||||
local t = text(toast, "Text", UDim2.new(1, -20, 1, -10), UDim2.fromOffset(10, 5), Color3.new(1, 1, 1))
|
||||
t.Text = L(key, args)
|
||||
task.delay(2.6, function()
|
||||
TweenService:Create(toast, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play()
|
||||
TweenService:Create(t, TweenInfo.new(0.4), { TextTransparency = 1 }):Play()
|
||||
task.wait(0.45)
|
||||
toast:Destroy()
|
||||
end)
|
||||
end
|
||||
|
||||
local conns: { RBXScriptConnection } = {}
|
||||
table.insert(
|
||||
conns,
|
||||
buyBtn.Activated:Connect(function()
|
||||
send("buy")
|
||||
end)
|
||||
)
|
||||
table.insert(
|
||||
conns,
|
||||
listBtn.Activated:Connect(function()
|
||||
panel.Visible = not panel.Visible
|
||||
end)
|
||||
)
|
||||
table.insert(
|
||||
conns,
|
||||
closeBtn.Activated:Connect(function()
|
||||
panel.Visible = false
|
||||
end)
|
||||
)
|
||||
table.insert(
|
||||
conns,
|
||||
langBtn.Activated:Connect(function()
|
||||
send("lang", if lang() == "ko" then "en" else "ko")
|
||||
end)
|
||||
)
|
||||
table.insert(
|
||||
conns,
|
||||
passBtn.Activated:Connect(function()
|
||||
if not attr(state, "Double", false) then
|
||||
send("pass")
|
||||
end
|
||||
end)
|
||||
)
|
||||
table.insert(
|
||||
conns,
|
||||
boostBtn.Activated:Connect(function()
|
||||
send("boost")
|
||||
end)
|
||||
)
|
||||
local devKinds: { [string]: string } = { devMoney = "dev_money", devDouble = "dev_double", devReset = "dev_reset" }
|
||||
for key, kind in devKinds do
|
||||
table.insert(
|
||||
conns,
|
||||
devButtons[key].Activated:Connect(function()
|
||||
send(kind)
|
||||
end)
|
||||
)
|
||||
end
|
||||
table.insert(conns, state.AttributeChanged:Connect(refresh))
|
||||
refresh()
|
||||
|
||||
return {
|
||||
gui = gui,
|
||||
refresh = refresh,
|
||||
notify = notify,
|
||||
setScale = function(s: number)
|
||||
scale.Scale = s
|
||||
end,
|
||||
destroy = function()
|
||||
for _, c in conns do
|
||||
c:Disconnect()
|
||||
end
|
||||
gui:Destroy()
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 화면 크기에 맞춘 UI 배율(기준 1100x620)
|
||||
function Hud.scaleFor(viewport: Vector2): number
|
||||
return math.clamp(math.min(viewport.X / 1100, viewport.Y / 620), 0.5, 1.4)
|
||||
end
|
||||
|
||||
return Hud
|
||||
@@ -1,3 +1,42 @@
|
||||
-- 클라이언트 진입점: 화면 UI, 내 조리대 버튼, 튜토리얼 화살표.
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
print(`[Bunsik] client ready for {Players.LocalPlayer.Name}`)
|
||||
local Guide = require(script.Parent.Guide)
|
||||
local Hud = require(script.Parent.Hud)
|
||||
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 camera = workspace.CurrentCamera
|
||||
local function rescale()
|
||||
hud.setScale(Hud.scaleFor(camera.ViewportSize))
|
||||
end
|
||||
camera:GetPropertyChangedSignal("ViewportSize"):Connect(rescale)
|
||||
rescale()
|
||||
notifyRemote.OnClientEvent:Connect(function(key, args)
|
||||
if typeof(key) == "string" then
|
||||
hud.notify(key, if typeof(args) == "table" then args else nil)
|
||||
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)
|
||||
|
||||
Guide.start(player)
|
||||
|
||||
60
bunsik-tycoon/src/client/Stove.luau
Normal file
60
bunsik-tycoon/src/client/Stove.luau
Normal file
@@ -0,0 +1,60 @@
|
||||
--!strict
|
||||
-- 내 가게 조리대에만 "요리하기" 버튼(ProximityPrompt)을 만듭니다. 다른 사람 가게에서는 버튼이 안 보입니다.
|
||||
-- 서버가 조리대 속성(CookMenu, CookTime)으로 알려 준 상태를 그대로 보여 주고, 다 누르면 서버에 "cook"을 보냅니다.
|
||||
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Shared = ReplicatedStorage:WaitForChild("Shared")
|
||||
local Economy = require(Shared:WaitForChild("Economy"))
|
||||
local Locale = require(Shared:WaitForChild("Locale"))
|
||||
local Sounds = require(Shared:WaitForChild("Sounds"))
|
||||
|
||||
local Stove = {}
|
||||
|
||||
function Stove.attach(stove: BasePart, state: Instance, send: (string, any?) -> ()): ProximityPrompt
|
||||
local prompt = Instance.new("ProximityPrompt")
|
||||
prompt.Name = "CookPrompt"
|
||||
prompt.KeyboardKeyCode = Enum.KeyCode.E
|
||||
prompt.MaxActivationDistance = 10
|
||||
prompt.RequiresLineOfSight = false
|
||||
prompt.Exclusivity = Enum.ProximityPromptExclusivity.OneGlobally
|
||||
|
||||
local sizzle = Instance.new("Sound")
|
||||
sizzle.SoundId = Sounds.SIZZLE
|
||||
sizzle.Volume = 0.6
|
||||
sizzle.Looped = true
|
||||
sizzle.Parent = stove
|
||||
|
||||
local function refresh()
|
||||
local lang = (state:GetAttribute("Lang") :: string?) or "ko"
|
||||
local menu = stove:GetAttribute("CookMenu")
|
||||
prompt.HoldDuration = (stove:GetAttribute("CookTime") :: number?) or 2.5
|
||||
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.Enabled = true
|
||||
else
|
||||
prompt.Enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
stove.AttributeChanged:Connect(refresh)
|
||||
state:GetAttributeChangedSignal("Lang"):Connect(refresh)
|
||||
prompt.PromptButtonHoldBegan:Connect(function()
|
||||
sizzle:Play()
|
||||
end)
|
||||
prompt.PromptButtonHoldEnded:Connect(function()
|
||||
sizzle:Stop()
|
||||
end)
|
||||
prompt.Triggered:Connect(function()
|
||||
sizzle:Stop()
|
||||
send("cook")
|
||||
end)
|
||||
refresh()
|
||||
prompt.Parent = stove
|
||||
return prompt
|
||||
end
|
||||
|
||||
return Stove
|
||||
Reference in New Issue
Block a user