diff --git a/bunsik-tycoon/ECONOMY.md b/bunsik-tycoon/ECONOMY.md index 8989d17..63e1485 100644 --- a/bunsik-tycoon/ECONOMY.md +++ b/bunsik-tycoon/ECONOMY.md @@ -1,7 +1,7 @@ # 분식집 타이쿤 — 경제 수치표 목표: 첫 구매는 10초 안에, 그 뒤로는 40~90초마다 하나씩 사고, 10분 무렵 "실내 분식집 확장"(2단계)에 닿게 합니다. 2단계는 구매 간격 1.5~2.5분입니다. -숫자의 원본은 `src/shared/Economy.luau`입니다. 표의 시각은 시뮬레이터 `tools/sim.luau`가 **실제 게임 로직(`src/shared/Shop.luau`)**을 봇으로 돌려서 낸 값입니다(2026-10-12, 예전 파이썬 시뮬레이터는 게임 코드와 따로 놀 수 있어서 지웠습니다). +숫자의 원본은 `src/shared/Economy.luau`입니다. 표의 시각은 시뮬레이터 `tools/sim.luau`가 **실제 게임 로직(`src/shared/Shop.luau`)**을 봇으로 돌려서 낸 값입니다(2026-10-13 요리 창 반영, 예전 파이썬 시뮬레이터는 게임 코드와 따로 놀 수 있어서 지웠습니다). ``` lune run tools/sim.luau # 기본 @@ -16,7 +16,7 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) | 처음 테이블 수 | 1 | 동시에 앉을 수 있는 손님 수 | | 손님 간격 | 6초 | 빈자리가 없으면 그냥 지나감. 접속하자마자 첫 손님 | | 손님 입장 | 2.5초 | 입구에서 자리까지 걷는 시간(NPC 이동 시간과 같음) | -| 조리 시간 | 2.5초 | 조리대에서 버튼을 누르고 있는 시간 | +| 조리(화구 수준) | 2.5 | 요리 창의 누르는 횟수·시간 기준. 화구 Lv1 1.5, Lv2 1이면 같은 비율로 줄어듦(`src/shared/Recipes.luau`). 시뮬레이터는 아이가 쉬지 않고 했을 때 한 접시 4.6~5.3초(메뉴 고르기·완성 연출 포함)로 봄 | | 왕복 시간 | 약 5초 | 조리대 → 테이블 → 조리대(시뮬레이터 가정. 게임 속 걷기 속도는 20) | | 식사 시간 | 6초 | 다 먹으면 자리가 빔. 돈은 접시를 놓는 순간 들어옴 | | 한 번에 드는 접시 | 1 | 쟁반 2, 큰 쟁반 3 | @@ -26,13 +26,14 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) | 메뉴 | 한 접시 | 해금 | |---|---|---| -| 떡볶이 🌶️ | 10 | 처음부터 | -| 김밥 🍙 | 20 | 구매 2번 | -| 순대 🌭 | 35 | 구매 6번 | +| 떡볶이 🌶️ | 15 | 처음부터 | +| 김밥 🍙 | 25 | 구매 2번 | +| 순대 🌭 | 40 | 구매 6번 | | 어묵 🍢 | 50 | 구매 13번(2단계) | | 튀김 🍤 | 70 | 구매 17번(2단계) | -손님은 해금된 메뉴를 돌아가며 주문합니다. 양념 비법은 모든 메뉴 가격에 배율을 곱하고 소수점은 버립니다(순대 35 × 1.5 = 52). +손님은 해금된 메뉴를 돌아가며 주문합니다. 양념 비법은 모든 메뉴 가격에 배율을 곱하고 소수점은 버립니다(김밥 25 × 1.5 = 37). +2026-10-13: 버튼을 꾹 누르던 조리를 메뉴별 요리 창(2~3단계)으로 바꾸면서 한 접시에 손이 더 가므로 1단계 메뉴 값을 10·20·35 → 15·25·40으로 올렸습니다. 확장 시점이 예전(9:39)과 비슷하게 9:47입니다. ## 구매 순서와 시점 @@ -40,28 +41,28 @@ lune run tests/Sim.spec.luau # 목표 범위 자동 검사(check.sh에 포함) | # | 구매 | 비용 | 효과 | 도달 시각 | 2배 게임패스 | |---|---|---|---|---|---| -| 1 | 테이블 2 | 10 | 테이블 1 → 2 | 0:05 | 0:05 | -| 2 | 김밥 해금 | 40 | 메뉴 추가(20) | 0:37 | 0:21 | -| 3 | 간판 Lv1 | 70 | 손님 간격 6 → 5초 | 1:18 | 0:37 | -| 4 | 화구 Lv1 | 90 | 조리 2.5 → 1.5초 | 2:05 | 0:59 | -| 5 | 테이블 3 | 120 | 테이블 2 → 3 | 3:05 | 1:26 | -| 6 | 순대 해금 | 160 | 메뉴 추가(35) | 4:19 | 2:07 | -| 7 | 양념 비법 Lv1 | 240 | 모든 메뉴 가격 1.5배 | 5:37 | 2:48 | -| 8 | 알바생 고용 | 360 | 알바생이 카운터에 접시를 만들어 둠, 플레이어는 나르기만 | 6:49 | 3:29 | -| 9 | 테이블 4 | 480 | 테이블 3 → 4, 손님 간격 5 → 4초 | 8:04 | 4:05 | -| 10 | 실내 분식집 확장 | 600 | 2단계: 건물, 새 업그레이드 줄 | 9:39 | 4:55 | -| 11 | 쟁반 | 700 | 접시 2개 들기 | 11:29 | 5:46 | -| 12 | 테이블 5 | 800 | 테이블 5 | 13:06 | 6:31 | -| 13 | 어묵 해금 | 950 | 메뉴 추가(50) | 15:06 | 7:31 | -| 14 | 간판 Lv2 | 1,150 | 손님 간격 4 → 3초 | 16:51 | 8:26 | -| 15 | 테이블 6 | 1,400 | 테이블 6 | 18:34 | 9:21 | -| 16 | 화구 Lv2 | 1,700 | 조리 1.5 → 1초 | 20:34 | 10:16 | -| 17 | 튀김 해금 | 2,000 | 메뉴 추가(70) | 22:59 | 11:26 | -| 18 | 양념 비법 Lv2 | 2,500 | 가격 배율 2배 | 25:20 | 12:36 | -| 19 | 큰 쟁반 | 3,000 | 접시 3개 들기 | 27:30 | 13:36 | -| 20 | 테이블 7·8 | 3,600 | 테이블 8, 손님 간격 2.5초 | 30:00 | 14:51 | +| 1 | 테이블 2 | 10 | 테이블 1 → 2 | 0:09 | 0:09 | +| 2 | 김밥 해금 | 40 | 메뉴 추가(25) | 0:43 | 0:21 | +| 3 | 간판 Lv1 | 70 | 손님 간격 6 → 5초 | 1:28 | 0:43 | +| 4 | 화구 Lv1 | 90 | 요리 창 누르는 양 60%(2.5 → 1.5) | 2:14 | 1:06 | +| 5 | 테이블 3 | 120 | 테이블 2 → 3 | 3:13 | 1:35 | +| 6 | 순대 해금 | 160 | 메뉴 추가(40) | 4:32 | 2:15 | +| 7 | 양념 비법 Lv1 | 240 | 모든 메뉴 가격 1.5배 | 6:00 | 3:05 | +| 8 | 알바생 고용 | 360 | 알바생이 카운터에 접시를 만들어 둠, 플레이어는 나르기만 | 7:27 | 3:54 | +| 9 | 테이블 4 | 480 | 테이블 3 → 4, 손님 간격 5 → 4초 | 8:27 | 4:25 | +| 10 | 실내 분식집 확장 | 600 | 2단계: 건물, 새 업그레이드 줄 | 9:47 | 5:05 | +| 11 | 쟁반 | 700 | 접시 2개 들기 | 11:12 | 5:50 | +| 12 | 테이블 5 | 800 | 테이블 5 | 12:32 | 6:27 | +| 13 | 어묵 해금 | 950 | 메뉴 추가(50) | 14:07 | 7:12 | +| 14 | 간판 Lv2 | 1,150 | 손님 간격 4 → 3초 | 15:42 | 8:02 | +| 15 | 테이블 6 | 1,400 | 테이블 6 | 17:13 | 8:47 | +| 16 | 화구 Lv2 | 1,700 | 요리 창 누르는 양 40%(1.5 → 1) | 18:57 | 9:37 | +| 17 | 튀김 해금 | 2,000 | 메뉴 추가(70) | 21:07 | 10:42 | +| 18 | 양념 비법 Lv2 | 2,500 | 가격 배율 2배 | 23:17 | 11:47 | +| 19 | 큰 쟁반 | 3,000 | 접시 3개 들기 | 25:16 | 12:47 | +| 20 | 테이블 7·8 | 3,600 | 테이블 8, 손님 간격 2.5초 | 27:32 | 13:47 | -1단계 구매 간격은 5초 → 32초 → 41초 → … → 95초, 2단계는 97~150초입니다. 비용은 한 단계에 약 1.2~1.3배씩 오릅니다. +1단계 구매 간격은 9초 → 34초 → 45초 → … → 88초, 2단계는 80~136초입니다. 비용은 한 단계에 약 1.2~1.3배씩 오릅니다. 20개를 다 사면 "2호점은 다음 업데이트에서 열려요"가 나옵니다. 오프라인 수익과 체인점(리버스)은 2차 업데이트입니다. ## 게임패스·상품과의 관계 diff --git a/bunsik-tycoon/PLAYTEST.md b/bunsik-tycoon/PLAYTEST.md index 5209daa..e41edec 100644 --- a/bunsik-tycoon/PLAYTEST.md +++ b/bunsik-tycoon/PLAYTEST.md @@ -8,35 +8,40 @@ ## 해 볼 것 (15~20분) -1. 튜토리얼: 노란 줄과 ⬇️ 화살표를 따라 조리대로 가서 버튼을 꾹 누르고(PC는 E 키), 접시를 손님 자리로 가져갑니다. 손님 근처에 가면 접시가 자동으로 놓입니다. -2. 돈이 생기면 아래 가운데 "다음 업그레이드" 카드의 초록 [사기] 버튼으로 삽니다. 살 수 있을 때는 버튼이 반짝이고, 오른쪽 주황 [업그레이드] 버튼에 빨간 `!` 배지가 붙습니다. [업그레이드] 버튼을 누르면 전체 목록이 열리고, 다음에 살 줄로 자동으로 내려갑니다(그 줄에서도 바로 살 수 있음). -3. 8번째 구매(알바생)부터는 알바생이 카운터(조리대 오른쪽)에 접시를 만들어 둡니다. 카운터 근처에 가면 접시를 자동으로 집습니다. -4. 10번째 구매(실내 분식집 확장)를 하면 건물이 생기고 2단계 업그레이드 10개가 열립니다. -5. 오른쪽 위 파란 톱니바퀴 [설정] 버튼을 눌러 봅니다. +1. 튜토리얼: 노란 줄과 화살표를 따라 조리대로 가서 [요리하기] 버튼(PC는 E 키)을 누릅니다. 요리 창이 열립니다. + - 손님이 주문한 메뉴 카드(손님 얼굴과 x1 표시, 통통 튀는 카드)를 누릅니다. + - 위쪽 글과 손가락 그림대로 합니다: 톡톡 누르기, 꾹 누르고 있기, 좌우로 문지르기. 창 안 어디를 눌러도 됩니다. PC는 마우스를 움직이기만 해도 문질러지고, E·스페이스 키로 톡톡·꾹도 됩니다. + - "완성!"이 뜨면 접시를 손님 자리로 가져갑니다. 손님 근처에 가면 접시가 자동으로 놓이고, 손님 말풍선이 하트로 바뀝니다. +2. 돈이 생기면 아래 가운데 막대의 [사기] 버튼으로 삽니다. 살 수 있을 때는 버튼이 초록색으로 바뀌어 둥실거리고, 분홍 [상점] 버튼에 빨간 `!`가 붙습니다. [상점]을 누르면 지금 단계 업그레이드 10개가 카드로 한 화면에 다 보입니다(다음 것은 노란 테두리, 그 카드에서도 바로 살 수 있음). +3. 메뉴마다 조리 과정이 다릅니다. 김밥(구매 2번)·순대(6번)를 사면 각각 해 봅니다. 화구 Lv1(4번)을 사면 누르는 횟수가 줄어듭니다. +4. 8번째 구매(알바생)부터는 알바생이 카운터(조리대 오른쪽)에 접시를 만들어 둡니다. 카운터 근처에 가면 접시를 자동으로 집습니다. 직접 요리해도 됩니다. +5. 10번째 구매(실내 분식집 확장)를 하면 건물이 생기고 2단계 업그레이드 10개가 열립니다. +6. 오른쪽 위 파란 톱니바퀴 [설정] 버튼을 눌러 봅니다. - 언어: 자동(계정 언어)·한국어·English·日本語·中文 중에서 고릅니다. 이름판·메뉴판·버튼 글자가 모두 바뀝니다. - - 마우스로 화면 돌리기(PC, 기본 켜짐): 우클릭 없이 마우스만 움직여도 화면이 돕니다. 버튼을 누를 땐 Ctrl을 누르고 있거나, 업그레이드·설정 창을 열면 커서가 나옵니다. + - 마우스로 화면 돌리기(PC, 기본 켜짐): 우클릭 없이 마우스만 움직여도 화면이 돕니다. 버튼을 누를 땐 Ctrl을 누르고 있거나, 상점·설정·요리 창을 열면 커서가 나옵니다. - 효과음 켜기/끄기. -6. 김밥 해금을 사면: 포장마차 왼쪽에 김밥 진열대(김발·김밥 접시)가 반짝이며 생기고, 1초쯤 뒤 오는 손님이 김밥을 주문합니다. 메뉴판에도 김밥이 추가됩니다. -7. 옆 가게: 다른 부지에는 이웃 가게(NPC 사장님이 운영, 크기가 제각각)가 열려 있습니다. 다른 플레이어가 들어오면 그 자리는 그 사람 가게로 바뀝니다. +7. 김밥 해금을 사면: 포장마차 왼쪽에 김밥 진열대(김발·김밥 접시)가 반짝이며 생기고, 1초쯤 뒤 오는 손님이 김밥을 주문합니다. 메뉴판에도 김밥이 추가됩니다. +8. 옆 가게: 다른 부지에는 이웃 가게(NPC 사장님이 운영, 크기가 제각각)가 열려 있습니다. 다른 플레이어가 들어오면 그 자리는 그 사람 가게로 바뀝니다. - 다른 가게 입구(이름판 아래)에서 E(휴대폰은 버튼)를 누르면 손님으로 빈자리에 앉습니다. 음식이 나오면 처음 한 번은 시식 보너스(접시 값)를 내 가게 돈으로 받습니다(1분에 한 번). 점프하면 일어납니다. - 내 가게에 다른 플레이어가 손님으로 오면 알림이 뜨고, 그 손님 접시는 2배 값을 받습니다. -8. 나갔다가 다시 들어와서 돈·업그레이드·설정이 그대로인지 봅니다. +9. 나갔다가 다시 들어와서 돈·업그레이드·설정이 그대로인지 봅니다. ## 휴대폰에서 해 볼 것 휴대폰·태블릿은 화면을 가로로 두고 합니다. 화면을 터치하면 휴대폰 배치로 바뀝니다. -- 왼쪽 위: 보라 [2배 수익], 노랑 [돈 부스트]. 왼쪽 아래 조이스틱 자리와 겹치지 않게 위로 올렸습니다. -- 오른쪽 위: 파랑 [설정], 주황 [업그레이드]. 오른쪽 아래 점프 버튼 자리는 비워 두었습니다. -- 아래: 다음 업그레이드 카드. [사기] 버튼은 조이스틱과 점프 버튼 사이에 옵니다. +- 왼쪽 위: 분홍 [상점], 보라 [2배 돈], 주황 [부스트]가 한 줄로. 왼쪽 아래 조이스틱 자리와 겹치지 않게 위로 올렸습니다. +- 가운데 위: 돈. 오른쪽 위: 파랑 톱니바퀴(설정). 오른쪽 아래 점프 버튼 자리는 비워 두었습니다. +- 아래: 다음 업그레이드 막대. [사기] 버튼은 조이스틱과 점프 버튼 사이에 옵니다. 막대 바로 위에 손에 든 음식 그림이 보입니다. +- 요리 창은 화면을 거의 다 채웁니다. 문지르기를 할 때 캐릭터가 움직이지 않는지 봐 주세요. - 설정 창에는 마우스 회전 줄이 없습니다(휴대폰에는 필요 없음). - 조이스틱으로 걸을 때 버튼이 눌리지 않는지, 글자가 너무 작지 않은지 봐 주세요. -## 새 화면 UI에서 봐 줄 것 +## 새 화면 UI에서 봐 줄 것(2026-10-13 처음부터 다시 디자인) -- 버튼을 누르면 쏙 들어갔다 나오는지, PC에서 마우스를 올리면 살짝 커지는지 -- 돈을 벌면 돈 표시가 통 튀고 아래에 초록 `+돈` 글자가 떠오르는지 -- 업그레이드·설정 창이 튀어나오듯 열리고 뒤 화면이 어두워지는지 -- 아이콘(동전, 메뉴 음식, 테이블 등)이 깨지거나 빈 네모로 나오지 않는지 +- 늘 보이는 것은 돈, 버튼 묶음(상점·2배 돈·부스트), 설정, 다음 업그레이드 막대, 손에 든 음식뿐입니다. 덜 어지러운지 +- 색(분홍·노랑·민트·하늘·보라 사탕색)과 둥근 모양이 아이들 취향에 맞는지 +- 요리 창 그림(팬·도마·찜기·냄비·튀김기, 마스코트 떡이)과 재료가 쌓이는 모습이 자연스러운지 +- 아이콘·그림이 깨지거나 빈 네모로 나오지 않는지 - 글자가 버튼 밖으로 넘치거나 너무 작은 곳이 없는지(영어·일본어·중국어도) ## 개발자 테스트 버튼(주인 계정에만 보임) diff --git a/bunsik-tycoon/SPEC.md b/bunsik-tycoon/SPEC.md index cb91bf1..d55948b 100644 --- a/bunsik-tycoon/SPEC.md +++ b/bunsik-tycoon/SPEC.md @@ -91,15 +91,22 @@ - 소셜(MVP): 남의 가게에 걸어 들어가 구경할 수 있고, 친구와 같은 서버에서 놉니다. - 소셜(2차): 친구 가게의 손님이 되어 주문하기, 친구를 직원으로 고용하기. -### B. 요리 조작: 누르고 있기 + 들고 가서 내려놓기 -1. 조리대에 다가가면 "떡볶이 만들기" 버튼이 뜹니다(로블록스 기본 ProximityPrompt). PC는 E키, 모바일은 화면 터치. -2. 버튼을 2.5초 누르고 있으면 완성됩니다. 게이지가 차고, 지글지글 조리음이 납니다(쇼츠용 ASMR 포인트). -3. 완성된 접시를 손에 들고 주문한 손님 테이블에 가면 자동으로 놓입니다. -4. 손님이 먹고 돈을 내면 동전이 튀어나오고 "+10" 숫자가 뜹니다. -- 타이밍 맞추기는 넣지 않습니다. 어린 아이가 실패하면 바로 그만두기 때문입니다. -- 손님 머리 위 말풍선에 메뉴 그림을 띄워서 글을 못 읽어도 알 수 있게 합니다. -- 처음 접속하면 화살표가 조리대 → 손님 순서로 안내합니다. 첫 서빙까지 30초 안이 목표입니다. -- "화구" 업그레이드로 누르는 시간이 짧아지고, "알바생"을 고용하면 조리가 자동이 됩니다. +### B. 요리 조작: 요리 창(메뉴 고르기 → 메뉴별 조리 과정 → 완성) + 들고 가서 내려놓기 +2026-10-13 사용자 요청으로 "버튼 꾹 누르기"에서 바꿨습니다. 코드는 `src/shared/Recipes.luau`(과정·진행 상태), `src/client/Kitchen.luau`(화면). +1. 조리대에 다가가 버튼(PC는 E키, 휴대폰은 터치)을 누르면 요리 창이 열립니다. 창이 열린 동안은 캐릭터가 움직이지 않습니다. +2. 메뉴 고르기: 해금된 메뉴 카드에 손님 얼굴과 주문 수(x2)가 붙고 통통 튑니다. 주문이 없는 메뉴는 흐리게, 안 산 메뉴는 자물쇠입니다. + - 주문 없는 메뉴는 고를 수 없습니다. 아무도 안 시킨 접시를 들고 갇히는 일을 막기 위해서입니다(서버도 같은 규칙으로 검사). +3. 조리: 메뉴마다 2~3단계이고, 단계마다 조작이 다릅니다. 창 안 어디를 눌러도 되고 실패는 없습니다. + - 떡볶이(팬): 떡 넣기(톡톡) → 양념 붓기(꾹) → 젓기(문지르기) + - 김밥(도마): 재료 올리기(톡톡) → 말기(문지르기) → 썰기(톡톡) + - 순대(찜기): 넣기(톡톡) → 찌기(꾹) → 썰기(톡톡) + - 어묵(냄비): 꼬치에 끼우기(톡톡) → 국물에 담그기(꾹) + - 튀김(튀김기): 튀김옷(문지르기) → 튀기기(꾹) → 건지기(톡톡) + - 단계 표시는 글 대신 도구 그림 동그라미 1-2-3, 손가락 그림이 할 동작(톡톡·꾹·좌우로 문지르기)을 보여 줍니다. 누를 때마다 재료가 쌓이고 효과음이 납니다. +4. 완성: 접시가 튀어나오고 마스코트 떡이가 기뻐합니다. 주문이 남고 손에 자리가 있으면 바로 다음 메뉴 고르기, 아니면 창이 닫힙니다. +5. 완성된 접시를 손에 들고 주문한 손님 테이블에 가면 자동으로 놓입니다. 손님 머리 위 말풍선은 음식 그림이고, 받으면 하트로 바뀝니다. +- 다른 게임과 비교해 정한 것: Papa's 시리즈·Cooking Mama처럼 단계마다 다른 짧은 동작을 쓰되, 어린아이가 실패하면 그만두므로 태우기·시간 제한은 넣지 않았습니다(Restaurant Tycoon 2도 실패 없음). 한 접시 4~6초로 짧게 하고, 반복이 지루해지지 않게 "화구" 업그레이드가 누르는 양을 60%·40%로 줄이고 "알바생"이 자동으로 만들어 줍니다. +- 한 접시에 손이 더 가므로 1단계 메뉴 값을 올렸습니다(`ECONOMY.md`). ### C. 경제 수치 - 첫 10분 표: `ECONOMY.md`. 첫 구매 0:05, 10번째 구매(실내 확장) 9:39. diff --git a/bunsik-tycoon/art/kitchen.png b/bunsik-tycoon/art/kitchen.png new file mode 100644 index 0000000..3fcbe2a Binary files /dev/null and b/bunsik-tycoon/art/kitchen.png differ diff --git a/bunsik-tycoon/art/ui_icons.png b/bunsik-tycoon/art/ui_icons.png index 19ca6b4..839c365 100644 Binary files a/bunsik-tycoon/art/ui_icons.png and b/bunsik-tycoon/art/ui_icons.png differ diff --git a/bunsik-tycoon/sfx/pop.ogg b/bunsik-tycoon/sfx/pop.ogg new file mode 100644 index 0000000..14d7728 Binary files /dev/null and b/bunsik-tycoon/sfx/pop.ogg differ diff --git a/bunsik-tycoon/src/client/Guide.luau b/bunsik-tycoon/src/client/Guide.luau index 90c42ad..ae4bc8e 100644 --- a/bunsik-tycoon/src/client/Guide.luau +++ b/bunsik-tycoon/src/client/Guide.luau @@ -1,8 +1,11 @@ --!strict -- 튜토리얼 화살표: 캐릭터에서 목표(조리대, 손님 자리)까지 빛나는 줄과 위에서 통통 튀는 화살표. +local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") +local Icons = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Icons")) + local Guide = {} function Guide.start(player: Player) @@ -26,11 +29,10 @@ function Guide.start(player: Player) arrow.Size = UDim2.fromOffset(70, 70) arrow.AlwaysOnTop = true arrow.LightInfluence = 0 - local label = Instance.new("TextLabel") + local label = Instance.new("ImageLabel") label.Size = UDim2.fromScale(1, 1) label.BackgroundTransparency = 1 - label.Text = "⬇️" - label.TextScaled = true + Icons.apply(label, "arrowDown") label.Parent = arrow RunService.RenderStepped:Connect(function() diff --git a/bunsik-tycoon/src/client/Hud.luau b/bunsik-tycoon/src/client/Hud.luau index a2f98a7..acd9465 100644 --- a/bunsik-tycoon/src/client/Hud.luau +++ b/bunsik-tycoon/src/client/Hud.luau @@ -1,6 +1,6 @@ --!strict --- 화면 UI: 돈, 다음 업그레이드 카드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 설정(언어·마우스 회전·효과음·개발자 테스트), --- 안내 문구, 알림. 모양은 Theme(굵은 테두리, 그러데이션, 입체 버튼, 아이콘), 배치는 Layout 모듈이 정합니다. +-- 화면 UI: 돈, 손에 든 접시, 다음 업그레이드 막대, 상점·2배 수익·돈 부스트 버튼, 설정, 튜토리얼 말풍선, 알림, +-- 그리고 창 세 개(업그레이드 상점, 설정, 요리). 모양은 Theme("사탕" 스타일), 배치는 Layout, 요리 창은 Kitchen 모듈. -- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다. local ReplicatedStorage = game:GetService("ReplicatedStorage") @@ -10,6 +10,7 @@ local Shared = ReplicatedStorage:WaitForChild("Shared") local Economy = require(Shared:WaitForChild("Economy")) local Locale = require(Shared:WaitForChild("Locale")) local Products = require(Shared:WaitForChild("Products")) +local Kitchen = require(script.Parent:WaitForChild("Kitchen")) local Layout = require(script.Parent:WaitForChild("Layout")) local Theme = require(script.Parent:WaitForChild("Theme")) @@ -22,13 +23,12 @@ export type HudHandle = { -- UI가 쓸 수 있는 화면 크기(픽셀, 상단 바 제외)와 터치 화면 여부로 배치를 다시 잡습니다. setLayout: (size: Vector2, touch: boolean) -> (), layout: () -> Layout.Result, - open: (which: string?) -> (), -- "shop", "settings", nil(닫기) - menuOpen: () -> boolean, -- 업그레이드·설정 창이 열려 있으면 true(마우스 커서를 풀어 줌) + open: (which: string?) -> (), -- "shop", "settings", "kitchen", nil(닫기) + menuOpen: () -> boolean, -- 창이 열려 있으면 true(마우스 커서를 풀어 줌) + kitchen: Kitchen.KitchenHandle, destroy: () -> (), } -local INK = Theme.INK - -- 업그레이드 id → 아이콘 local function itemIcon(id: string): string local menu = id:match("^Unlock(%a+)$") @@ -49,16 +49,21 @@ local function itemIcon(id: string): string end return "star" end +Hud.itemIcon = itemIcon -- 알림 종류별 아이콘과 색 local TOAST_STYLE: { [string]: { icon: string, color: Color3 } } = { - purchased = { icon = "check", color = Color3.fromRGB(70, 190, 70) }, - newMenu = { icon = "star", color = Color3.fromRGB(255, 140, 40) }, - expanded = { icon = "store", color = Color3.fromRGB(240, 170, 20) }, - boostGot = { icon = "bolt", color = Color3.fromRGB(240, 170, 20) }, - guestBonus = { icon = "coin", color = Color3.fromRGB(70, 190, 70) }, - guestArrived = { icon = "chef", color = Color3.fromRGB(60, 150, 240) }, - devResetDone = { icon = "wrench", color = Color3.fromRGB(110, 110, 130) }, + purchased = { icon = "check", color = Theme.MINT }, + newMenu = { icon = "star", color = Theme.ORANGE }, + expanded = { icon = "store", color = Theme.YELLOW }, + boostGot = { icon = "bolt", color = Theme.YELLOW }, + guestBonus = { icon = "coin", color = Theme.MINT }, + guestArrived = { icon = "customer", color = Theme.SKY }, + guestSeated = { icon = "customer", color = Theme.SKY }, + guestAte = { icon = "heart", color = Theme.PINK }, + notEnough = { icon = "coin", color = Theme.GRAY }, + tutDone = { icon = "mascot", color = Theme.PINK }, + devResetDone = { icon = "wrench", color = Theme.GRAY }, } local function attr(state: Instance, key: string, default: any): any @@ -74,122 +79,19 @@ local function at(o: GuiObject, x: number, y: number, w: number, h: number) o.Size = UDim2.fromOffset(w, h) end --- 네모 아이콘 버튼: 큰 아이콘 위, 이름은 아래 테두리에 걸쳐 놓입니다. -local function squareButton(parent: Instance, name: string, color: Color3, icon: string): (Theme.Button, TextLabel) - local b = Theme.button(parent, name, color, 18) - local ic = Theme.icon(b.face, "Icon", icon) - ic.AnchorPoint = Vector2.new(0.5, 0) - ic.Position = UDim2.fromScale(0.5, 0.03) - ic.Size = UDim2.fromScale(0.74, 0.7) - ic.ZIndex = 4 - local label = Theme.text(b.button, "Label", false, 2.5) - label.AnchorPoint = Vector2.new(0.5, 1) - label.Position = UDim2.new(0.5, 0, 1, -2) - label.Size = UDim2.fromScale(1.08, 0.32) - label.ZIndex = 5 - return b, label -end - --- 창 틀: 뒤에 비스듬한 판, 크림색 본문, 왼쪽 위 이름표 리본, 오른쪽 위 빨간 X 버튼. -local function panelShell(parent: Instance, name: string, color: Color3): (Frame, Frame, TextLabel, Theme.Button) - local p = Theme.frame(parent, name) - p.Visible = false - p.ZIndex = 20 - local scale = Instance.new("UIScale") - scale.Parent = p - local back = Theme.frame(p, "Back", Theme.darken(color, 0.1)) - back.Position = UDim2.fromOffset(10, 30) - back.Size = UDim2.new(1, -20, 1, -36) - back.Rotation = 2.5 - Theme.corner(back, 24) - Theme.stroke(back, INK, 4) - local body = Theme.frame(p, "Body", Theme.WHITE) - body.Position = UDim2.fromOffset(0, 24) - body.Size = UDim2.new(1, 0, 1, -24) - body.ZIndex = 2 - Theme.corner(body, 24) - Theme.stroke(body, INK, 4) - Theme.gradient(body, Color3.fromRGB(255, 252, 244), Color3.fromRGB(255, 236, 205)) - -- 본문 위쪽 색 띠 - local band = Theme.frame(body, "Band", color) - band.Size = UDim2.new(1, 0, 0, 44) - band.ZIndex = 2 - Theme.corner(band, 24) - Theme.gradient(band, Theme.lighten(color, 0.15), color) - local bandFill = Theme.frame(band, "Fill", color) - bandFill.Position = UDim2.fromOffset(0, 24) - bandFill.Size = UDim2.new(1, 0, 0, 20) - bandFill.BorderSizePixel = 0 - bandFill.ZIndex = 2 - bandFill.BackgroundColor3 = color - - local ribbon = Theme.frame(p, "Ribbon", Theme.WHITE) - ribbon.Position = UDim2.fromOffset(18, 2) - ribbon.Size = UDim2.fromOffset(250, 50) - ribbon.Rotation = -2 - ribbon.ZIndex = 4 - Theme.corner(ribbon, 14) - Theme.stroke(ribbon, INK, 4) - Theme.gradient(ribbon, Theme.lighten(color, 0.25), Theme.darken(color, 0.1)) - local title = Theme.text(ribbon, "Title", false, 3) - title.Position = UDim2.fromOffset(14, 6) - title.Size = UDim2.new(1, -28, 1, -12) - title.ZIndex = 5 - - local close = Theme.button(p, "Close", Theme.RED, 14, 3.5) - close.button.AnchorPoint = Vector2.new(0.5, 0.5) - close.button.Rotation = 6 - close.button.ZIndex = 6 - local x = Theme.icon(close.face, "X", "close") - x.Size = UDim2.fromScale(0.62, 0.62) - x.AnchorPoint = Vector2.new(0.5, 0.5) - x.Position = UDim2.fromScale(0.5, 0.5) - x.ZIndex = 4 - return p, body, title, close -end - -local function popIn(o: GuiObject) - local s = o:FindFirstChildOfClass("UIScale") - if s then - s.Scale = 0.6 - TweenService:Create(s, TweenInfo.new(0.32, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }) - :Play() - end -end - --- 켜기/끄기 버튼(설정 창) -local function toggleButton(parent: Instance, name: string): (Theme.Button, TextLabel) - local b = Theme.button(parent, name, Theme.GREEN, 14) - local label = Theme.text(b.face, "Label", false, 2.5) - label.Size = UDim2.new(1, -16, 0.7, 0) - label.Position = UDim2.fromScale(0.5, 0.5) - label.AnchorPoint = Vector2.new(0.5, 0.5) - label.ZIndex = 4 - return b, label -end - -local function textButton(parent: Instance, name: string, color: Color3, radius: number): (Theme.Button, TextLabel) - local b = Theme.button(parent, name, color, radius) - local label = Theme.text(b.face, "Label", false, 2.5) - label.Size = UDim2.new(1, -14, 0.66, 0) - label.Position = UDim2.fromScale(0.5, 0.5) - label.AnchorPoint = Vector2.new(0.5, 0.5) - label.ZIndex = 4 - return b, label -end - +-- 설정 창 한 줄(아이콘 + 이름) local function settingRow(parent: Instance, name: string, icon: string): (Frame, TextLabel) local row = Theme.frame(parent, name) row.ZIndex = 3 local ic = Theme.icon(row, "Icon", icon) - ic.Size = UDim2.fromOffset(36, 36) + ic.Size = UDim2.fromOffset(40, 40) ic.Position = UDim2.fromScale(0, 0.5) ic.AnchorPoint = Vector2.new(0, 0.5) ic.ZIndex = 4 - local t = Theme.text(row, "Text", true) - t.Position = UDim2.new(0, 44, 0.5, 0) + local t = Theme.text(row, "Text") + t.Position = UDim2.new(0, 50, 0.5, 0) t.AnchorPoint = Vector2.new(0, 0.5) - t.Size = UDim2.new(1, -44, 0, 30) + t.Size = UDim2.new(1, -50, 0, 30) t.TextXAlignment = Enum.TextXAlignment.Left t.ZIndex = 4 return row, t @@ -203,9 +105,16 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () gui.Parent = parent local tweens: { Tween } = {} - local function loop(t: Tween) - t:Play() + local function keep(t: Tween): Tween table.insert(tweens, t) + return t + end + + 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 -- 루트는 기준 단위(화면 픽셀 / 배율) 크기로 만들고 UIScale로 키워 화면을 꽉 채웁니다. @@ -214,257 +123,198 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local scale = Instance.new("UIScale") scale.Parent = root - -- 돈: 금색 알약 + 왼쪽에 튀어나온 동전 + -- 돈: 노란 알약 + 왼쪽에 튀어나온 동전, 숫자는 둥근 글꼴 local money = Theme.frame(root, "Money") local moneyScale = Instance.new("UIScale") moneyScale.Parent = money - local pill = Theme.frame(money, "Pill", Theme.WHITE) + local pill = Theme.frame(money, "Pill", Theme.YELLOW) pill.AnchorPoint = Vector2.new(0, 0.5) - pill.Position = UDim2.new(0, 30, 0.5, 0) - pill.Size = UDim2.new(1, -30, 0, 50) - Theme.corner(pill, 1, 1) - Theme.stroke(pill, INK, 4) - Theme.gradient(pill, Color3.fromRGB(255, 226, 90), Color3.fromRGB(255, 160, 30)) + pill.Position = UDim2.new(0, 26, 0.5, 0) + pill.Size = UDim2.new(1, -26, 0, 46) + Theme.round(pill) + Theme.stroke(pill, Theme.edge(Theme.YELLOW), 3.5) + Theme.gradient(pill, Color3.fromRGB(255, 232, 120), Theme.YELLOW) local pillGloss = Theme.frame(pill, "Gloss", Theme.WHITE) - pillGloss.BackgroundTransparency = 0.65 - pillGloss.Position = UDim2.fromOffset(36, 5) - pillGloss.Size = UDim2.new(1, -60, 0, 12) - Theme.corner(pillGloss, 1, 1) - local moneyText = Theme.text(pill, "Text", false, 3) - moneyText.Position = UDim2.fromOffset(40, 6) - moneyText.Size = UDim2.new(1, -56, 1, -12) + pillGloss.BackgroundTransparency = 0.55 + pillGloss.Position = UDim2.fromOffset(40, 5) + pillGloss.Size = UDim2.new(1, -64, 0, 10) + Theme.round(pillGloss) + local moneyText = Theme.text(pill, "Text", Theme.edge(Theme.YELLOW), true) + moneyText.Position = UDim2.fromOffset(40, 5) + moneyText.Size = UDim2.new(1, -56, 1, -10) moneyText.ZIndex = 2 local coin = Theme.icon(money, "Coin", "coin") - coin.Size = UDim2.fromOffset(66, 66) - coin.Position = UDim2.new(0, -2, 0.5, 0) + coin.Size = UDim2.fromOffset(62, 62) + coin.Position = UDim2.new(0, -4, 0.5, 0) coin.AnchorPoint = Vector2.new(0, 0.5) - coin.Rotation = -10 coin.ZIndex = 3 - loop( + + -- 손에 든 접시: 든 만큼 음식 그림, 빈 칸은 점선 동그라미 + local carry = Theme.frame(root, "Carry", Theme.WHITE) + carry.BackgroundTransparency = 0.1 + Theme.round(carry) + Theme.stroke(carry, Theme.LINE, 3) + local carryList = Instance.new("UIListLayout") + carryList.FillDirection = Enum.FillDirection.Horizontal + carryList.HorizontalAlignment = Enum.HorizontalAlignment.Center + carryList.VerticalAlignment = Enum.VerticalAlignment.Center + carryList.Padding = UDim.new(0, 6) + carryList.SortOrder = Enum.SortOrder.LayoutOrder + carryList.Parent = carry + local carrySlots: { ImageLabel } = {} + for i = 1, 3 do + local slot = Theme.icon(carry, "Slot" .. i, "plate") + slot.Size = UDim2.fromOffset(36, 36) + slot.LayoutOrder = i + slot.BackgroundColor3 = Theme.CREAM + Theme.round(slot) + carrySlots[i] = slot + end + + -- 튜토리얼 말풍선: 마스코트 떡이가 말해 줍니다. + local hint = Theme.frame(root, "Hint") + local bubble = Theme.frame(hint, "Bubble", Theme.WHITE) + bubble.Position = UDim2.fromOffset(44, 0) + bubble.Size = UDim2.new(1, -44, 1, 0) + Theme.corner(bubble, 22) + Theme.stroke(bubble, Theme.PINK, 4) + local hintText = Theme.text(bubble, "Text") + hintText.Position = UDim2.fromOffset(46, 8) + hintText.Size = UDim2.new(1, -60, 1, -16) + local mascot = Theme.icon(hint, "Mascot", "mascot") + mascot.Size = UDim2.fromOffset(84, 84) + mascot.AnchorPoint = Vector2.new(0, 0.5) + mascot.Position = UDim2.fromScale(0, 0.5) + mascot.ZIndex = 3 + keep( TweenService:Create( - coin, - TweenInfo.new(1.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), + mascot, + TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), { Rotation = 8 } ) - ) + ):Play() - -- 들고 있는 접시 - local carry = Theme.frame(root, "Carry", Theme.NAVY) - carry.BackgroundTransparency = 0.25 - Theme.corner(carry, 1, 1) - Theme.stroke(carry, INK, 2.5) - local plateIcon = Theme.icon(carry, "Icon", "plate") - plateIcon.Size = UDim2.fromOffset(34, 34) - plateIcon.Position = UDim2.new(0, -4, 0.5, 0) - plateIcon.AnchorPoint = Vector2.new(0, 0.5) - local carryText = Theme.text(carry, "Text", false, 2) - carryText.Position = UDim2.fromOffset(32, 3) - carryText.Size = UDim2.new(1, -40, 1, -6) - - -- 안내 문구(튜토리얼) - local hint = Theme.frame(root, "Hint", Theme.WHITE) - Theme.corner(hint, 16) - Theme.stroke(hint, INK, 4) - Theme.gradient(hint, Color3.fromRGB(255, 244, 150), Color3.fromRGB(255, 205, 60)) - local hintIcon = Theme.icon(hint, "Icon", "arrowDown") - hintIcon.Size = UDim2.fromOffset(46, 46) - hintIcon.AnchorPoint = Vector2.new(0, 0.5) - hintIcon.Position = UDim2.new(0, 8, 0.5, 0) - loop( - TweenService:Create( - hintIcon, - TweenInfo.new(0.45, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), - { Position = UDim2.new(0, 8, 0.5, 6) } - ) - ) - local hintText = Theme.text(hint, "Text", true) - hintText.Position = UDim2.fromOffset(60, 7) - hintText.Size = UDim2.new(1, -72, 1, -14) - - -- 알림 + -- 알림(새 알림이 위에, 최대 3개) local toasts = Theme.frame(root, "Toasts") local list = Instance.new("UIListLayout") list.HorizontalAlignment = Enum.HorizontalAlignment.Center - list.Padding = UDim.new(0, 8) + list.Padding = UDim.new(0, 6) list.SortOrder = Enum.SortOrder.LayoutOrder list.Parent = toasts - -- 다음 업그레이드 카드(아래): 이름표, 아이콘 상자, 이름, 진행 막대, [사기] + -- 다음 업그레이드 막대(아래): 아이콘 동그라미, 이름, 진행 막대, [사기] local card = Theme.frame(root, "Next") local cardBody = Theme.frame(card, "Body", Theme.WHITE) - cardBody.Position = UDim2.fromOffset(0, 16) - cardBody.Size = UDim2.new(1, 0, 1, -16) - Theme.corner(cardBody, 20) - Theme.stroke(cardBody, INK, 4) - Theme.gradient(cardBody, Color3.fromRGB(255, 252, 244), Color3.fromRGB(255, 232, 196)) - local tab = Theme.frame(card, "Tab", Theme.WHITE) - tab.Position = UDim2.fromOffset(16, 0) - tab.Size = UDim2.fromOffset(190, 30) - tab.ZIndex = 3 - Theme.corner(tab, 10) - Theme.stroke(tab, INK, 3) - Theme.gradient(tab, Color3.fromRGB(255, 130, 90), Color3.fromRGB(230, 60, 40)) - local tabText = Theme.text(tab, "Text", false, 2) - tabText.Position = UDim2.fromOffset(10, 4) - tabText.Size = UDim2.new(1, -20, 1, -8) - tabText.ZIndex = 4 - local iconBox = Theme.frame(cardBody, "IconBox", Theme.WHITE) + cardBody.Size = UDim2.fromScale(1, 1) + Theme.corner(cardBody, 26) + local cardStroke = Theme.stroke(cardBody, Theme.edge(Theme.PINK), 4) + local iconBox = Theme.frame(cardBody, "IconBox", Theme.PINK) iconBox.AnchorPoint = Vector2.new(0, 0.5) - iconBox.Position = UDim2.new(0, 12, 0.5, 4) - iconBox.Size = UDim2.fromOffset(68, 68) - Theme.corner(iconBox, 16) - Theme.stroke(iconBox, INK, 3) - Theme.gradient(iconBox, Color3.fromRGB(255, 255, 255), Color3.fromRGB(255, 214, 160)) + iconBox.Position = UDim2.new(0, 10, 0.5, 0) + iconBox.Size = UDim2.fromOffset(64, 64) + Theme.round(iconBox) + Theme.gradient(iconBox, Color3.fromRGB(255, 236, 242), Color3.fromRGB(255, 205, 220)) + Theme.stroke(iconBox, Theme.lighten(Theme.PINK, 0.3), 3) local itemImg = Theme.icon(iconBox, "Icon", "table") - itemImg.Size = UDim2.fromScale(0.86, 0.86) - itemImg.AnchorPoint = Vector2.new(0.5, 0.5) - itemImg.Position = UDim2.fromScale(0.5, 0.5) - local cardTitle = Theme.text(cardBody, "Title", true) + Theme.place(itemImg, 0.5, 0.5, 0.86, 0.86) + local cardTitle = Theme.text(cardBody, "Title") cardTitle.TextXAlignment = Enum.TextXAlignment.Left - cardTitle.Position = UDim2.fromOffset(92, 14) - cardTitle.Size = UDim2.new(1, -258, 0, 34) - local bar = Theme.frame(cardBody, "Bar", Color3.fromRGB(110, 70, 45)) - bar.Position = UDim2.fromOffset(92, 54) - bar.Size = UDim2.new(1, -258, 0, 28) - Theme.corner(bar, 1, 1) - Theme.stroke(bar, INK, 3) - local barFill = Theme.frame(bar, "Fill", Theme.WHITE) + cardTitle.Position = UDim2.fromOffset(84, 10) + cardTitle.Size = UDim2.new(1, -236, 0, 30) + local bar = Theme.frame(cardBody, "Bar", Color3.fromRGB(240, 228, 236)) + bar.Position = UDim2.fromOffset(84, 46) + bar.Size = UDim2.new(1, -236, 0, 26) + Theme.round(bar) + Theme.stroke(bar, Theme.LINE, 2) + local barFill = Theme.frame(bar, "Fill", Theme.MINT) barFill.Size = UDim2.fromScale(0, 1) - Theme.corner(barFill, 1, 1) - Theme.gradient(barFill, Color3.fromRGB(160, 245, 90), Color3.fromRGB(60, 185, 40)) - local cardCost = Theme.text(bar, "Cost", false, 2.2) - cardCost.Position = UDim2.fromOffset(8, 3) - cardCost.Size = UDim2.new(1, -16, 1, -6) + Theme.round(barFill) + Theme.gradient(barFill, Color3.fromRGB(120, 235, 170), Theme.MINT) + local cardCost = Theme.text(bar, "Cost", Theme.edge(Theme.MINT), true) + cardCost.Position = UDim2.fromOffset(8, 2) + cardCost.Size = UDim2.new(1, -16, 1, -4) cardCost.ZIndex = 3 - local buy, buyLabel = textButton(card, "Buy", Theme.GREEN, 18) + local buy, buyLabel = Theme.textButton(card, "Buy", Theme.MINT, 22) buy.button.AnchorPoint = Vector2.new(0.5, 0.5) buy.button.ZIndex = 3 - local buyShine = Theme.shine(buy.face, 18, 1.8) - table.insert(tweens, buyShine) - local buyGlow = Theme.icon(buy.button, "Glow", "glow") - buyGlow.Size = UDim2.fromScale(1.7, 2.2) - buyGlow.AnchorPoint = Vector2.new(0.5, 0.5) - buyGlow.Position = UDim2.fromScale(0.5, 0.5) - buyGlow.ImageColor3 = Color3.fromRGB(255, 240, 120) - buyGlow.ZIndex = 0 - loop( - TweenService:Create( - buyGlow, - TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), - { ImageTransparency = 0.6 } - ) - ) local pointer = Theme.icon(card, "Pointer", "hand") - pointer.Size = UDim2.fromOffset(54, 54) + pointer.Size = UDim2.fromOffset(56, 56) pointer.AnchorPoint = Vector2.new(0.5, 1) pointer.Rotation = 180 pointer.ZIndex = 8 pointer.Visible = false - -- 네모 아이콘 버튼들 - local listBtn, listLabel = squareButton(root, "ListButton", Theme.ORANGE, "scroll") + -- 버튼 묶음: 상점, 2배 수익, 돈 부스트 / 설정(아이콘만) + local listBtn, listLabel = Theme.iconButton(root, "ListButton", Theme.PINK, "cart") local listBadge, listBadgeText = Theme.badge(listBtn.button, "Badge") listBadgeText.Text = "!" - loop( - TweenService:Create( - listBadge, - TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), - { Rotation = 12 } - ) - ) - local settingsBtn, settingsLabel = squareButton(root, "Settings", Theme.BLUE, "gear") - - local function premium(name: string, color: Color3, icon: string): (Theme.Button, TextLabel, ImageLabel) - local b, label = squareButton(root, name, color, icon) - local rays = Theme.icon(b.button, "Rays", "rays") - rays.Size = UDim2.fromScale(1.45, 1.45) - rays.AnchorPoint = Vector2.new(0.5, 0.5) - rays.Position = UDim2.fromScale(0.5, 0.5) - rays.ImageColor3 = Color3.fromRGB(255, 236, 140) - rays.ImageTransparency = 0.15 - rays.ZIndex = 0 - loop( - TweenService:Create( - rays, - TweenInfo.new(9, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1), - { Rotation = 360 } - ) - ) - table.insert(tweens, Theme.shine(b.face, 18, 2.6)) - return b, label, rays - end - local passBtn, passLabel, passRays = premium("Double", Theme.PURPLE, "moneyBag") - local x2 = Theme.text(passBtn.face, "X2", false, 3) + local settingsBtn = Theme.button(root, "Settings", Theme.SKY, 20) + local gear = Theme.icon(settingsBtn.face, "Icon", "gear") + Theme.place(gear, 0.5, 0.5, 0.72, 0.72) + gear.ZIndex = 4 + local passBtn, passLabel = Theme.iconButton(root, "Double", Theme.LAVENDER, "moneyBag") + local x2 = Theme.text(passBtn.button, "X2", Theme.edge(Theme.LAVENDER), true) x2.Text = "x2" - x2.TextColor3 = Color3.fromRGB(255, 230, 60) + x2.TextColor3 = Color3.fromRGB(255, 236, 90) x2.AnchorPoint = Vector2.new(1, 0) - x2.Position = UDim2.new(1, -2, 0, 2) - x2.Size = UDim2.fromScale(0.5, 0.36) - x2.Rotation = 12 + x2.Position = UDim2.new(1, 4, 0, -6) + x2.Size = UDim2.fromScale(0.5, 0.34) x2.ZIndex = 6 local passCheck = Theme.icon(passBtn.button, "Owned", "check") - passCheck.Size = UDim2.fromScale(0.42, 0.42) + passCheck.Size = UDim2.fromScale(0.4, 0.4) passCheck.AnchorPoint = Vector2.new(0.5, 0.5) - passCheck.Position = UDim2.new(1, -8, 0, 8) + passCheck.Position = UDim2.new(1, -6, 0, 6) passCheck.ZIndex = 8 - local boostBtn, boostLabel = premium("Boost", Theme.YELLOW, "bolt") - local boostTag = Theme.frame(boostBtn.button, "Tag", Theme.WHITE) + local boostBtn, boostLabel = Theme.iconButton(root, "Boost", Theme.ORANGE, "bolt") + local boostTag = Theme.frame(boostBtn.button, "Tag", Theme.MINT) boostTag.AnchorPoint = Vector2.new(0.5, 0.5) - boostTag.Position = UDim2.new(0.5, 0, 0, 13) - boostTag.Size = UDim2.new(0.8, 0, 0, 24) - boostTag.Rotation = -6 + boostTag.Position = UDim2.new(0.5, 0, 0, 2) + boostTag.Size = UDim2.new(0.9, 0, 0, 22) boostTag.ZIndex = 8 - Theme.corner(boostTag, 1, 1) - Theme.stroke(boostTag, INK, 2.5) - Theme.gradient(boostTag, Color3.fromRGB(150, 245, 90), Color3.fromRGB(60, 185, 40)) - local boostAmount = Theme.text(boostTag, "Text", false, 2) + Theme.round(boostTag) + Theme.stroke(boostTag, Theme.edge(Theme.MINT), 2.5) + local boostAmount = Theme.text(boostTag, "Text", Theme.edge(Theme.MINT), true) boostAmount.Position = UDim2.fromOffset(6, 2) boostAmount.Size = UDim2.new(1, -12, 1, -4) boostAmount.ZIndex = 9 - -- 창 뒤 어둡게 - local dim = Theme.frame(root, "Dim", Color3.new(0, 0, 0)) - dim.BackgroundTransparency = 0.55 + -- 창 뒤 어둡게(누르면 창 닫힘) + local dim = Instance.new("TextButton") + dim.Name = "Dim" + dim.Text = "" + dim.AutoButtonColor = false + dim.BorderSizePixel = 0 + dim.BackgroundColor3 = Color3.fromRGB(40, 20, 50) + dim.BackgroundTransparency = 0.5 dim.Size = UDim2.fromScale(1, 1) dim.Visible = false dim.ZIndex = 10 + dim.Parent = root - -- 업그레이드 목록 창 - local panel, panelBody, panelTitle, closeBtn = panelShell(root, "Panel", Color3.fromRGB(255, 120, 50)) - local stageText = Theme.text(panelBody, "Stage", false, 2.5) - stageText.Position = UDim2.fromOffset(280, 8) - stageText.Size = UDim2.new(1, -350, 0, 30) - stageText.TextXAlignment = Enum.TextXAlignment.Right + -- 업그레이드 상점 창: 지금 단계 10개를 카드 5x2로 + local shopPanel = Theme.panel(root, "Panel", Theme.PINK) + local panel = shopPanel.frame + local stageTag = Theme.frame(shopPanel.body, "StageTag", Theme.WHITE) + stageTag.ZIndex = 3 + stageTag.AnchorPoint = Vector2.new(0, 0.5) + stageTag.Position = UDim2.fromOffset(16, Layout.HEADER_H / 2) + stageTag.Size = UDim2.fromOffset(150, 30) + stageTag.BackgroundTransparency = 0.15 + Theme.round(stageTag) + local stageText = Theme.text(stageTag, "Text") + stageText.Position = UDim2.fromOffset(10, 4) + stageText.Size = UDim2.new(1, -20, 1, -8) stageText.ZIndex = 4 - local scroll = Instance.new("ScrollingFrame") - scroll.Name = "List" - scroll.Position = UDim2.fromOffset(14, 56) - scroll.Size = UDim2.new(1, -24, 1, -68) - scroll.BackgroundTransparency = 1 - scroll.BorderSizePixel = 0 - scroll.ScrollBarThickness = 8 - scroll.ScrollBarImageColor3 = INK - scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y - scroll.CanvasSize = UDim2.new() - scroll.ZIndex = 3 - scroll.Parent = panelBody - local rows = Instance.new("UIListLayout") - rows.Padding = UDim.new(0, 8) - rows.SortOrder = Enum.SortOrder.LayoutOrder - rows.HorizontalAlignment = Enum.HorizontalAlignment.Center - rows.Parent = scroll - local rowPad = Instance.new("UIPadding") - rowPad.PaddingTop = UDim.new(0, 6) - rowPad.PaddingBottom = UDim.new(0, 8) - rowPad.Parent = scroll + local cards = Theme.frame(shopPanel.body, "Cards") + cards.Size = UDim2.fromScale(1, 1) + cards.ZIndex = 3 -- 설정 창(언어, 마우스로 화면 돌리기, 효과음, 개발자 테스트) - local settings, _settingsBody, settingsTitle, settingsClose = - panelShell(root, "SettingsPanel", Color3.fromRGB(60, 160, 245)) + local setPanel = Theme.panel(root, "SettingsPanel", Theme.SKY) + local settings = setPanel.frame local langRow, langLabel = settingRow(settings, "LangRow", "globe") langRow.ZIndex = 3 - at(langRow, 18, 68, 300, 32) - -- 언어 버튼: 자동("") + 네 언어 + at(langRow, 22, 66, 300, 40) local langChoices = { "" } for _, l in Locale.LANGS do table.insert(langChoices, l) @@ -472,27 +322,26 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local langButtons: { [string]: Theme.Button } = {} local langLabels: { [string]: TextLabel } = {} for _, l in langChoices do - local b, t = textButton(settings, "Lang_" .. (if l == "" then "auto" else l), Theme.GRAY, 14) + local b, t = Theme.textButton(settings, "Lang_" .. (if l == "" then "auto" else l), Theme.GRAY, 16) b.button.ZIndex = 3 langButtons[l] = b langLabels[l] = t end local mouseRow, mouseLabel = settingRow(settings, "MouseRow", "mouse") - local mouseBtn, mouseValue = toggleButton(settings, "MouseLook") + local mouseBtn, mouseValue = Theme.textButton(settings, "MouseLook", Theme.MINT) mouseBtn.button.ZIndex = 3 - local mouseHint = Theme.text(settings, "MouseHint", true) - mouseHint.TextColor3 = Theme.BROWN + local mouseHint = Theme.text(settings, "MouseHint") + mouseHint.TextColor3 = Theme.SOFT mouseHint.TextXAlignment = Enum.TextXAlignment.Left mouseHint.ZIndex = 3 local sfxRow, sfxLabel = settingRow(settings, "SfxRow", "speaker") - local sfxBtn, sfxValue = toggleButton(settings, "Sfx") + local sfxBtn, sfxValue = Theme.textButton(settings, "Sfx", Theme.MINT) sfxBtn.button.ZIndex = 3 - -- 개발자(게임 주인)만 보는 테스트 버튼 줄 local devRow, devTitle = settingRow(settings, "DevLabel", "wrench") local devButtons: { [string]: Theme.Button } = {} local devLabels: { [string]: TextLabel } = {} for _, key in { "devMoney", "devDouble", "devReset" } do - local b, t = textButton(settings, key, Color3.fromRGB(110, 115, 140), 12) + local b, t = Theme.textButton(settings, key, Color3.fromRGB(130, 120, 160), 16) b.button.ZIndex = 3 devButtons[key] = b devLabels[key] = t @@ -501,6 +350,9 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () o.ZIndex = 3 end + -- 요리 창 + local kitchen = Kitchen.build(root, state, send) + -- 화면 크기에 맞춰 배치합니다(Layout 모듈). 버튼은 가운데 기준이라 누르면 제자리에서 작아집니다. local function place(o: GuiObject, r: Layout.Rect) o.AnchorPoint = Vector2.new(0.5, 0.5) @@ -510,6 +362,8 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local screen = Vector2.new(1100, 620) local touch = false local layoutNow: Layout.Result + local buyBob: Tween? = nil + local lastCan = false local function relayout() local dev = attr(state, "Dev", false) == true local lay = Layout.compute(screen.X, screen.Y, touch, dev) @@ -528,20 +382,27 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () place(boostBtn.button, lay.boost) place(panel, lay.panel) place(settings, lay.settingsPanel) - -- [사기] 버튼은 카드 안 좌표로 + kitchen.setLayout(lay) + -- [사기] 버튼은 막대 안 좌표로 local b = lay.buy + if buyBob then + buyBob:Cancel() + buyBob = nil + end buy.button.Position = UDim2.fromOffset(b.x - lay.card.x + b.w / 2, b.y - lay.card.y + b.h / 2) buy.button.Size = UDim2.fromOffset(b.w, b.h) + -- 살 수 있을 때만 [사기] 버튼이 둥실거림(늘 보이는 것 중 움직이는 것은 이것 하나) + if lastCan then + buyBob = keep(Theme.bob(buy.button, 4, 0.8)) + end pointer.Position = UDim2.fromOffset(b.x - lay.card.x + b.w / 2, b.y - lay.card.y - 2) local r = lay.rows - local closeK = r.closeH + 4 - at(closeBtn.button, 0, 0, closeK, closeK) - closeBtn.button.Position = UDim2.new(1, -closeK / 2 - 4, 0, closeK / 2 + 2) - at(settingsClose.button, 0, 0, closeK, closeK) - settingsClose.button.Position = UDim2.new(1, -closeK / 2 - 4, 0, closeK / 2 + 2) + for _, c in { shopPanel.close, setPanel.close } do + c.button.Size = UDim2.fromOffset(r.closeH, r.closeH) + end local i = 0 for _, l in langChoices do - at(langButtons[l].button, 18 + i * 102, 104, 94, r.langButtonH) + at(langButtons[l].button, 22 + i * 104, 106, 96, r.langButtonH) i += 1 end local mouseY = r.mouseY @@ -549,62 +410,56 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () mouseBtn.button.Visible = mouseY ~= nil mouseHint.Visible = mouseY ~= nil if mouseY then - at(mouseRow, 18, mouseY, 360, r.toggleH) - at(mouseBtn.button, 0, 0, 116, r.toggleH) - mouseBtn.button.Position = UDim2.new(1, -134, 0, mouseY) - at(mouseHint, 62, mouseY + r.toggleH + 6, 440, 24) + at(mouseRow, 22, mouseY, 360, r.toggleH) + at(mouseBtn.button, 0, 0, 120, r.toggleH) + mouseBtn.button.Position = UDim2.new(1, -142, 0, mouseY) + at(mouseHint, 72, mouseY + r.toggleH + 6, 440, 24) end - at(sfxRow, 18, r.sfxY, 360, r.toggleH) - at(sfxBtn.button, 0, 0, 116, r.toggleH) - sfxBtn.button.Position = UDim2.new(1, -134, 0, r.sfxY) + at(sfxRow, 22, r.sfxY, 360, r.toggleH) + at(sfxBtn.button, 0, 0, 120, r.toggleH) + sfxBtn.button.Position = UDim2.new(1, -142, 0, r.sfxY) local devY = r.devY devRow.Visible = devY ~= nil if devY then - at(devRow, 18, devY, 360, 34) + at(devRow, 22, devY, 360, 36) end local j = 0 for _, key in { "devMoney", "devDouble", "devReset" } do local db = devButtons[key].button db.Visible = devY ~= nil if devY then - at(db, 18 + j * 170, devY + 38, 160, r.devButtonH) + at(db, 22 + j * 174, devY + 40, 164, r.devButtonH) end j += 1 end end relayout() - 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 Locale.itemName(lang(), p.id) end local function toggle(b: Theme.Button, label: TextLabel, on: boolean) label.Text = L(if on then "on" else "off") - b.setColor(if on then Theme.GREEN else Theme.GRAY) + b.setColor(if on then Theme.MINT else Theme.GRAY) end - local listKey = "" + local cardsKey = "" local lastMoney: number? = nil - -- 돈이 늘면 "+N원"이 떠오르고 돈 알약이 통 튑니다. + -- 돈이 늘면 "+N"이 떠오르고 돈 알약이 통 튑니다. local function moneyPop(gain: number) moneyScale.Scale = 1.12 TweenService:Create(moneyScale, TweenInfo.new(0.35, Enum.EasingStyle.Back), { Scale = 1 }):Play() - local f = Theme.text(root, "Gain", false, 2.5) - f.Text = "+" .. L("money", { money = Locale.number(gain) }) - f.TextColor3 = Color3.fromRGB(150, 255, 110) + local f = Theme.text(root, "Gain", Theme.edge(Theme.MINT), true) + f.Text = "+" .. Locale.number(gain) + f.TextColor3 = Color3.fromRGB(150, 255, 170) local m = layoutNow.money f.AnchorPoint = Vector2.new(0.5, 0) - f.Size = UDim2.fromOffset(200, 34) - f.Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h + 2) + f.Size = UDim2.fromOffset(160, 34) + f.Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h - 4) f.ZIndex = 9 TweenService:Create(f, TweenInfo.new(0.9, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { - Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h + 34), + Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h + 26), TextTransparency = 1, }):Play() local st = f:FindFirstChildOfClass("UIStroke") @@ -616,32 +471,123 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () end) end + -- 상점 카드 한 장 + local function shopCard(i: number, p: Economy.Purchase, bought: number, can: boolean, g: Layout.Grid) + local done = i <= bought + local isNext = i == bought + 1 + local k = (i - 1) % 10 + local col, row = k % g.cols, k // g.cols + local holder = Theme.frame(cards, "Row" .. i) + holder.ZIndex = 3 + at(holder, g.pad + col * (g.cardW + g.gap), g.top + row * (g.cardH + g.gap), g.cardW, g.cardH) + local c = Theme.frame(holder, "Card", Theme.WHITE) + c.Size = UDim2.fromScale(1, 1) + c.ZIndex = 3 + Theme.corner(c, 20) + local tint = if done then Theme.MINT elseif isNext then Theme.YELLOW else Theme.GRAY + Theme.stroke(c, if isNext then Theme.edge(Theme.YELLOW) else Theme.lighten(tint, 0.35), if isNext then 4 else 3) + Theme.gradient(c, Theme.WHITE, Theme.lighten(tint, if done then 0.75 elseif isNext then 0.6 else 0.7)) + local img = Theme.icon(c, "Icon", itemIcon(p.id)) + Theme.place(img, 0.5, 0.3, 0.62, 0.42) + img.ZIndex = 4 + local name = Theme.text(c, "Name") + name.AnchorPoint = Vector2.new(0.5, 0.5) + name.Position = UDim2.fromScale(0.5, 0.6) + name.Size = UDim2.new(1, -12, 0.2, 0) + name.ZIndex = 4 + name.Text = pname(p) + if done then + local ok = Theme.icon(c, "Done", "check") + ok.Size = UDim2.fromOffset(40, 40) + ok.AnchorPoint = Vector2.new(0.5, 0.5) + ok.Position = UDim2.new(1, -12, 0, 12) + ok.ZIndex = 5 + local t = Theme.text(c, "Cost", Theme.edge(Theme.MINT)) + t.TextColor3 = Theme.WHITE + t.AnchorPoint = Vector2.new(0.5, 0.5) + t.Position = UDim2.fromScale(0.5, 0.85) + t.Size = UDim2.fromScale(0.8, 0.16) + t.ZIndex = 4 + t.Text = L("bought") + elseif isNext then + local rb, rl = Theme.textButton(holder, "BuyRow", if can then Theme.MINT else Theme.GRAY, 16) + rb.button.AnchorPoint = Vector2.new(0.5, 1) + rb.button.Position = UDim2.new(0.5, 0, 1, -8) + rb.button.Size = UDim2.new(1, -16, 0.26, 0) + rb.button.ZIndex = 5 + rl.FontFace = Theme.NUM + rl.Text = Locale.number(p.cost) + local coinIc = Theme.icon(rb.face, "Coin", "coin") + coinIc.AnchorPoint = Vector2.new(0, 0.5) + coinIc.Position = UDim2.new(0, 2, 0.5, 0) + coinIc.Size = UDim2.fromScale(0.3, 1.1) + coinIc.ZIndex = 5 + rl.Position = UDim2.new(0.5, 10, 0.5, 0) + rl.Size = UDim2.new(1, -40, 0.62, 0) + rb.button.Activated:Connect(function() + send("buy") + end) + if can then + keep(Theme.bob(holder, 5, 0.9)) + end + else + img.ImageTransparency = 0.5 + local lockImg = Theme.icon(c, "Lock", "lock") + lockImg.Size = UDim2.fromOffset(36, 36) + lockImg.AnchorPoint = Vector2.new(0.5, 0.5) + lockImg.Position = UDim2.fromScale(0.68, 0.4) + lockImg.ZIndex = 5 + local t = Theme.text(c, "Cost", nil, true) + t.TextColor3 = Theme.SOFT + t.AnchorPoint = Vector2.new(0.5, 0.5) + t.Position = UDim2.fromScale(0.5, 0.85) + t.Size = UDim2.fromScale(0.8, 0.15) + t.ZIndex = 4 + t.Text = Locale.number(p.cost) + end + end + 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) }) + moneyText.Text = Locale.number(m) if lastMoney and m > lastMoney then moneyPop(m - lastMoney) end lastMoney = m - local held = attr(state, "Carry", 0) + + -- 손에 든 접시 + local handStr = attr(state, "Hand", "") :: string + local hand = if handStr == "" then {} else string.split(handStr, ",") + local held = attr(state, "Carry", #hand) carry.Visible = held > 0 - carryText.Text = `{held}/{stats.carry}` + for i, slot in carrySlots do + slot.Visible = i <= stats.carry + local menu = hand[i] + if menu and Economy.MENUS[menu] then + Theme.setIcon(slot, menu) + slot.ImageTransparency = 0 + slot.BackgroundTransparency = 1 + else + Theme.setIcon(slot, "plate") + slot.ImageTransparency = if i <= held then 0 else 0.75 + slot.BackgroundTransparency = if i <= held then 1 else 0 + end + end + carry.Size = UDim2.fromOffset(stats.carry * 42 + 20, layoutNow.carry.h) local nextP = Economy.PURCHASES[bought + 1] local can = false - tabText.Text = L("nextUp") if nextP then cardTitle.Text = pname(nextP) - cardCost.Text = `{Locale.number(math.min(m, nextP.cost))} / ` - .. L("money", { money = Locale.number(nextP.cost) }) + cardCost.Text = `{Locale.number(math.min(m, nextP.cost))} / {Locale.number(nextP.cost)}` barFill.Size = UDim2.fromScale(math.clamp(m / nextP.cost, 0, 1), 1) barFill.Visible = m > 0 Theme.setIcon(itemImg, itemIcon(nextP.id)) can = m >= nextP.cost buyLabel.Text = L("buy") - buy.setColor(if can then Theme.GREEN else Theme.GRAY) + buy.setColor(if can then Theme.MINT else Theme.GRAY) buy.button.Visible = true else cardTitle.Text = L("maxed") @@ -651,9 +597,11 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () Theme.setIcon(itemImg, "star") buy.button.Visible = false end - local shine = buy.face:FindFirstChild("Shine") :: Frame - shine.Visible = can - buyGlow.Visible = can + cardStroke.Color = if can then Theme.edge(Theme.MINT) else Theme.edge(Theme.PINK) + if can ~= lastCan then + lastCan = can + relayout() + end listBadge.Visible = can -- 튜토리얼 안내 @@ -674,15 +622,14 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () t.Text = L(key) end - listLabel.Text = L("shop") - settingsLabel.Text = L("settings") - panelTitle.Text = L("shop") - settingsTitle.Text = L("settings") + listLabel.Text = L("btnShop") + shopPanel.title.Text = L("shop") + setPanel.title.Text = L("settings") langLabel.Text = L("language") local current = attr(state, "LangSetting", "") for l, b in langButtons do langLabels[l].Text = if l == "" then L("langAuto") else Locale.LANG_NAMES[l] - b.setColor(if l == current then Theme.BLUE else Theme.GRAY) + b.setColor(if l == current then Theme.SKY else Theme.GRAY) end mouseLabel.Text = L("mouseLook") mouseHint.Text = L("mouseHint") @@ -692,106 +639,32 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local double = attr(state, "Double", false) passBtn.button.Visible = Products.DOUBLE_MONEY_PASS ~= 0 - passLabel.Text = if double then L("doubleOn") else L("double") + passLabel.Text = if double then L("doubleOn") else L("btnDouble") passCheck.Visible = double x2.Visible = not double - passRays.Visible = not double passBtn.button.Active = not double boostBtn.button.Visible = Products.MONEY_BOOST_PRODUCT ~= 0 and nextP ~= nil - boostLabel.Text = L("boost") + boostLabel.Text = L("btnBoost") boostAmount.Text = "+" .. Locale.number(attr(state, "Boost", Economy.BOOST_MIN)) - -- 업그레이드 목록(지금 단계 것만). 산 개수, 언어, 살 수 있는지가 바뀔 때만 다시 그립니다. - local key = `{bought}:{lang()}:{can}` - if key == listKey then + kitchen.refresh() + + -- 상점 카드(지금 단계 것만). 산 개수, 언어, 살 수 있는지, 배치가 바뀔 때만 다시 그립니다. + local g = layoutNow.grid + local key = `{bought}:{lang()}:{can}:{g.cardW}:{g.cardH}` + if key == cardsKey then return end - listKey = key + cardsKey = key local stage = stats.stage stageText.Text = L(if stage >= 2 then "stage2" else "stage1") - for _, c in scroll:GetChildren() do - if c:IsA("Frame") then - c:Destroy() - end + for _, c in cards:GetChildren() do + c:Destroy() end local from = if stage >= 2 then 11 else 1 local to = if stage >= 2 then #Economy.PURCHASES else 10 - local rowH = if layoutNow.touch then 64 else 58 for i = from, to do - local p = Economy.PURCHASES[i] - local done = i <= bought - local isNext = i == bought + 1 - local row = Theme.frame(scroll, "Row" .. i, Theme.WHITE) - row.Size = UDim2.new(1, -16, 0, rowH) - row.LayoutOrder = i - row.ZIndex = 3 - Theme.corner(row, 14) - Theme.stroke(row, INK, if isNext then 3.5 else 2.5) - if done then - Theme.gradient(row, Color3.fromRGB(232, 255, 220), Color3.fromRGB(190, 240, 170)) - elseif isNext then - Theme.gradient(row, Color3.fromRGB(255, 248, 190), Color3.fromRGB(255, 210, 100)) - else - Theme.gradient(row, Color3.fromRGB(245, 240, 232), Color3.fromRGB(222, 214, 202)) - end - local box = Theme.frame(row, "IconBox", Theme.WHITE) - box.AnchorPoint = Vector2.new(0, 0.5) - box.Position = UDim2.new(0, 8, 0.5, 0) - box.Size = UDim2.fromOffset(rowH - 14, rowH - 14) - box.ZIndex = 3 - Theme.corner(box, 10) - Theme.stroke(box, INK, 2) - local img = Theme.icon(box, "Icon", itemIcon(p.id)) - img.Size = UDim2.fromScale(0.9, 0.9) - img.AnchorPoint = Vector2.new(0.5, 0.5) - img.Position = UDim2.fromScale(0.5, 0.5) - img.ZIndex = 4 - if not done and not isNext then - img.ImageTransparency = 0.45 - local lockImg = Theme.icon(box, "Lock", "lock") - lockImg.Size = UDim2.fromScale(0.5, 0.5) - lockImg.Position = UDim2.fromScale(0.55, 0.55) - lockImg.ZIndex = 5 - end - local name = Theme.text(row, "Name", true) - name.TextXAlignment = Enum.TextXAlignment.Left - name.Position = UDim2.new(0, rowH + 4, 0.18, 0) - name.Size = UDim2.new(1, -(rowH + 4) - 150, 0.64, 0) - name.ZIndex = 4 - name.Text = `{i}. {pname(p)}` - if done then - local ok = Theme.icon(row, "Done", "check") - ok.Size = UDim2.fromOffset(34, 34) - ok.AnchorPoint = Vector2.new(1, 0.5) - ok.Position = UDim2.new(1, -96, 0.5, 0) - ok.ZIndex = 4 - local t = Theme.text(row, "Cost", false, 2) - t.TextColor3 = Color3.fromRGB(120, 230, 90) - t.AnchorPoint = Vector2.new(1, 0.5) - t.Position = UDim2.new(1, -12, 0.5, 0) - t.Size = UDim2.new(0, 80, 0.5, 0) - t.ZIndex = 4 - t.Text = L("bought") - elseif isNext then - local rb, rl = textButton(row, "BuyRow", if can then Theme.GREEN else Theme.GRAY, 12) - rb.button.AnchorPoint = Vector2.new(1, 0.5) - rb.button.Position = UDim2.new(1, -8, 0.5, 2) - rb.button.Size = UDim2.new(0, 134, 1, -12) - rb.button.ZIndex = 4 - rl.Text = L("money", { money = Locale.number(p.cost) }) - rb.button.Activated:Connect(function() - send("buy") - end) - else - local t = Theme.text(row, "Cost", true) - t.TextColor3 = Color3.fromRGB(130, 110, 95) - t.TextXAlignment = Enum.TextXAlignment.Right - t.AnchorPoint = Vector2.new(1, 0.5) - t.Position = UDim2.new(1, -16, 0.5, 0) - t.Size = UDim2.new(0, 120, 0.46, 0) - t.ZIndex = 4 - t.Text = L("money", { money = Locale.number(p.cost) }) - end + shopCard(i, Economy.PURCHASES[i], bought, can, g) end end @@ -807,62 +680,78 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () args.name = Locale.itemName(lang(), args.item) end end - local style = TOAST_STYLE[key] or { icon = "sparkle", color = Color3.fromRGB(70, 80, 120) } + local style = TOAST_STYLE[key] or { icon = "sparkle", color = Theme.SKY } toastN += 1 + -- 오래된 알림은 3개까지만 남깁니다. + local alive = {} + for _, t in toasts:GetChildren() do + if t:IsA("Frame") then + table.insert(alive, t) + end + end + table.sort(alive, function(a, b) + return a.LayoutOrder < b.LayoutOrder + end) + for i = 3, #alive do + alive[i]:Destroy() + end local toast = Theme.frame(toasts, "Toast", Theme.WHITE) - toast.Size = UDim2.new(1, -20, 0, 50) + toast.Size = UDim2.new(1, -20, 0, 46) toast.LayoutOrder = -toastN -- 새 알림이 위에 - Theme.corner(toast, 16) - local st = Theme.stroke(toast, INK, 3.5) - Theme.gradient(toast, Theme.lighten(style.color, 0.18), Theme.darken(style.color, 0.12)) + Theme.round(toast) + local st = Theme.stroke(toast, style.color, 3.5) local sc = Instance.new("UIScale") sc.Parent = toast + local dot = Theme.frame(toast, "Dot", style.color) + dot.AnchorPoint = Vector2.new(0, 0.5) + dot.Position = UDim2.new(0, 4, 0.5, 0) + dot.Size = UDim2.fromOffset(38, 38) + dot.ZIndex = 2 + Theme.round(dot) + Theme.gradient(dot, Theme.lighten(style.color, 0.5), Theme.lighten(style.color, 0.2)) local ic = Theme.icon(toast, "Icon", style.icon) - ic.Size = UDim2.fromOffset(46, 46) - ic.AnchorPoint = Vector2.new(0, 0.5) - ic.Position = UDim2.new(0, 4, 0.5, 0) - ic.ZIndex = 2 - local t = Theme.text(toast, "Text", false, 2.5) - t.Position = UDim2.fromOffset(54, 7) - t.Size = UDim2.new(1, -66, 1, -14) + ic.ZIndex = 3 + ic.AnchorPoint = Vector2.new(0.5, 0.5) + ic.Position = UDim2.new(0, 23, 0.5, 0) + ic.Size = UDim2.fromOffset(32, 32) + local t = Theme.text(toast, "Text") + t.Position = UDim2.fromOffset(52, 8) + t.Size = UDim2.new(1, -68, 1, -16) t.ZIndex = 2 t.Text = L(key, args) - popIn(toast) + Theme.pop(toast) task.delay(2.8, function() local info = TweenInfo.new(0.4) TweenService:Create(toast, info, { BackgroundTransparency = 1 }):Play() + TweenService:Create(dot, info, { BackgroundTransparency = 1 }):Play() TweenService:Create(t, info, { TextTransparency = 1 }):Play() TweenService:Create(ic, info, { ImageTransparency = 1 }):Play() TweenService:Create(st, info, { Transparency = 1 }):Play() - local ts = t:FindFirstChildOfClass("UIStroke") - if ts then - TweenService:Create(ts, info, { Transparency = 1 }):Play() - end task.wait(0.45) toast:Destroy() end) end - -- 목록을 열면 다음에 살 업그레이드가 보이게(바로 위에 산 것 한 줄) 내려 둡니다. - local function scrollToNext() - local bought = attr(state, "Bought", 0) - local from = if bought >= 10 then 11 else 1 - local rowH = (if layoutNow.touch then 64 else 58) + 8 - scroll.CanvasPosition = Vector2.new(0, math.max(0, (bought - from) * rowH - rowH)) - end - - local function show(p: Frame?) - panel.Visible = p == panel - settings.Visible = p == settings - dim.Visible = p ~= nil - if p then - popIn(p) + local function show(which: string?) + panel.Visible = which == "shop" + settings.Visible = which == "settings" + if which == "kitchen" then + kitchen.open() + else + kitchen.close() end - if p == panel then - scrollToNext() - task.defer(scrollToNext) -- 줄을 막 다시 그렸으면 캔버스 크기가 다음 프레임에 정해집니다. + dim.Visible = which ~= nil + if which == "shop" then + Theme.pop(panel) + elseif which == "settings" then + Theme.pop(settings) end end + kitchen.onClose(function() + if not panel.Visible and not settings.Visible then + dim.Visible = false + end + end) local conns: { RBXScriptConnection } = {} local function on(sig: RBXScriptSignal, fn: (...any) -> ()) @@ -872,15 +761,21 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () send("buy") end) on(listBtn.button.Activated, function() - show(if panel.Visible then nil else panel) + show(if panel.Visible then nil else "shop") end) - on(closeBtn.button.Activated, function() + on(shopPanel.close.button.Activated, function() show(nil) end) - on(settingsBtn.button.Activated, function() - show(if settings.Visible then nil else settings) + on(dim.Activated, function() + -- 요리 중에는 바깥을 눌러도 닫지 않습니다(실수로 닫히지 않게). + if not kitchen.isOpen() then + show(nil) + end end) - on(settingsClose.button.Activated, function() + on(settingsBtn.button.Activated, function() + show(if settings.Visible then nil else "settings") + end) + on(setPanel.close.button.Activated, function() show(nil) end) for l, b in langButtons do @@ -915,24 +810,19 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () gui = gui, refresh = refresh, notify = notify, + kitchen = kitchen, setLayout = function(size: Vector2, isTouch: boolean) screen = size - local changed = touch ~= isTouch touch = isTouch relayout() - if changed then - listKey = "" -- 목록 줄 높이가 터치 여부로 달라집니다. - refresh() - end + refresh() end, layout = function(): Layout.Result return layoutNow end, - open = function(which: string?) - show(if which == "shop" then panel elseif which == "settings" then settings else nil) - end, + open = show, menuOpen = function(): boolean - return panel.Visible or settings.Visible + return panel.Visible or settings.Visible or kitchen.isOpen() end, destroy = function() for _, c in conns do @@ -941,6 +831,7 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () for _, t in tweens do t:Cancel() end + kitchen.destroy() gui:Destroy() end, } diff --git a/bunsik-tycoon/src/client/Kitchen.luau b/bunsik-tycoon/src/client/Kitchen.luau new file mode 100644 index 0000000..b4c7d1a --- /dev/null +++ b/bunsik-tycoon/src/client/Kitchen.luau @@ -0,0 +1,1043 @@ +--!strict +-- 요리 창: 조리대 버튼을 누르면 열립니다. +-- 1) 메뉴 고르기: 해금된 메뉴 카드. 주문이 있는 메뉴에는 손님 얼굴과 주문 수가 붙고 통통 튑니다. +-- 주문이 없는 메뉴는 흐리게(못 고름), 아직 안 산 메뉴는 자물쇠. +-- 2) 조리: 메뉴마다 다른 2~3단계(Recipes). 단계마다 톡톡 누르기 / 꾹 누르기 / 문지르기 중 하나이고, +-- 창 안 어디를 눌러도 됩니다(실패 없음). 손가락 그림이 할 동작을 보여 주고, 조리 도구 그림 위로 재료가 쌓입니다. +-- 3) 완성: 접시가 튀어나오고 마스코트가 기뻐합니다. 서버에 "cook"(고른 메뉴)을 보내고, +-- 아직 만들 주문이 있고 손에 자리가 있으면 메뉴 고르기로 돌아가고, 아니면 창을 닫습니다. +-- 진행 상태는 Recipes(순수 로직, 단위 테스트)에 있고, 이 모듈은 그리기와 입력만 맡습니다. + +local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") +local SoundService = game:GetService("SoundService") +local TweenService = game:GetService("TweenService") +local UserInputService = game:GetService("UserInputService") + +local Shared = ReplicatedStorage:WaitForChild("Shared") +local Economy = require(Shared:WaitForChild("Economy")) +local Icons = require(Shared:WaitForChild("Icons")) +local Locale = require(Shared:WaitForChild("Locale")) +local Recipes = require(Shared:WaitForChild("Recipes")) +local Sounds = require(Shared:WaitForChild("Sounds")) +local Layout = require(script.Parent:WaitForChild("Layout")) +local Theme = require(script.Parent:WaitForChild("Theme")) + +local Kitchen = {} + +export type KitchenHandle = { + frame: Frame, + open: () -> (), + close: () -> (), + isOpen: () -> boolean, + onClose: (fn: () -> ()) -> (), + onOpen: (fn: () -> ()) -> (), + setLayout: (lay: Layout.Result) -> (), + refresh: () -> (), + flow: () -> Recipes.Flow, + choose: (menu: string) -> boolean, + input: (kind: Recipes.StepKind, amount: number) -> string?, + destroy: () -> (), +} + +local COLOR = Theme.ORANGE +local DONE_TIME = 1.2 -- "완성!"을 보여 주는 시간 + +-- 단계의 도구 이름 → 아이콘 그림 +local TOOL_ICON: { [string]: string } = { + roll = "mat", + fire = "flame", + skewer = "Eomuk", +} + +-- "Tteokbokki=2,Gimbap=1" → { Tteokbokki = 2, Gimbap = 1 } +function Kitchen.parseOrders(s: string?): { [string]: number } + local out = {} + if typeof(s) ~= "string" then + return out + end + for _, part in string.split(s, ",") do + local k, v = string.match(part, "^(%w+)=(%d+)$") + if k and v then + out[k] = tonumber(v) :: number + end + end + return out +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 + +-- i번째 단계의 진행률(0~1): 지난 단계는 1, 아직 안 한 단계는 0 +local function stepFrac(flow: Recipes.Flow, i: number): number + if flow.phase == "done" or flow.step > i then + return 1 + elseif flow.step < i or flow.phase ~= "cook" then + return 0 + end + return if flow.need > 0 then flow.progress / flow.need else 0 +end + +local function count(frac: number, n: number): number + return math.clamp(math.ceil(frac * n - 1e-6), 0, n) +end + +-- 조리 도구 그림 위에 올리는 것들. 좌표는 무대(정사각형) 기준 0~1. +local function item( + parent: Instance, + name: string, + icon: string, + x: number, + y: number, + w: number, + h: number +): ImageLabel + local i = Theme.icon(parent, name, icon) + Theme.place(i, x, y, w, h) + i.ZIndex = 26 + return i +end + +type Scene = (flow: Recipes.Flow) -> () + +-- 메뉴별 무대: 그림을 만들고, 진행 상태에 맞춰 보이게 하는 함수를 돌려줍니다. +local SCENES: { [string]: (stage: Frame) -> Scene } = { + Tteokbokki = function(stage) + local sauce = item(stage, "Sauce", "sauceBlob", 0.46, 0.56, 0.62, 0.3) + local spots = { { 0.32, 0.52, -20 }, { 0.5, 0.47, 10 }, { 0.62, 0.58, -5 }, { 0.42, 0.63, 25 } } + local cakes = {} + for i, p in spots do + local c = item(stage, "Cake" .. i, "riceCake", p[1], p[2], 0.2, 0.2) + c.Rotation = p[3] + cakes[i] = c + end + local bubbles = {} + for i, p in { { 0.36, 0.44 }, { 0.58, 0.5 }, { 0.48, 0.62 } } do + bubbles[i] = item(stage, "Bubble" .. i, "bubble", p[1], p[2], 0.09, 0.09) + end + local spatula = item(stage, "Tool", "spatula", 0.6, 0.4, 0.34, 0.34) + return function(flow) + local f1, f2, f3 = stepFrac(flow, 1), stepFrac(flow, 2), stepFrac(flow, 3) + local n = count(f1, #cakes) + for i, c in cakes do + c.Visible = i <= n + Theme.setIcon(c, if f3 > 0.3 then "riceCakeRed" else "riceCake") + end + sauce.ImageTransparency = 1 - f2 + for _, b in bubbles do + b.Visible = f2 > 0.5 + end + spatula.Visible = flow.step == 3 and flow.phase == "cook" + -- 문지른 만큼 주걱이 좌우로 휘휘 + spatula.Position = UDim2.fromScale(0.5 + 0.14 * math.sin(f3 * 18), 0.42) + spatula.Rotation = 25 * math.sin(f3 * 18) + end + end, + Gimbap = function(stage) + local colors = { + Color3.fromRGB(255, 225, 74), + Color3.fromRGB(255, 140, 26), + Color3.fromRGB(63, 174, 73), + Color3.fromRGB(255, 243, 160), + Color3.fromRGB(255, 143, 163), + } + local strips = {} + for i, col in colors do + local f = Theme.frame(stage, "Strip" .. i, col) + f.AnchorPoint = Vector2.new(0.5, 0.5) + f.Position = UDim2.fromScale(0.5, 0.42 + i * 0.045) + f.Size = UDim2.fromScale(0.56, 0.035) + f.ZIndex = 26 + Theme.round(f) + Theme.stroke(f, Theme.edge(col), 2) + strips[i] = f + end + -- 김으로 덮이는 판(말기) + local cover = Theme.frame(stage, "Cover", Color3.fromRGB(34, 46, 34)) + cover.AnchorPoint = Vector2.new(0.5, 1) + cover.Position = UDim2.fromScale(0.5, 0.72) + cover.Size = UDim2.fromScale(0.66, 0) + cover.ZIndex = 27 + Theme.corner(cover, 10) + local roll = Theme.kitchen(stage, "Roll", "gimbapRoll") + Theme.place(roll, 0.5, 0.5, 0.8, 0.8) + roll.ZIndex = 28 + local slices = {} + for i = 1, 5 do + slices[i] = item(stage, "Slice" .. i, "gimbapSlice", 0.14 + i * 0.12, 0.84, 0.15, 0.15) + slices[i].ZIndex = 29 + end + return function(flow) + local f1, f2, f3 = stepFrac(flow, 1), stepFrac(flow, 2), stepFrac(flow, 3) + local n = count(f1, #strips) + for i, s in strips do + s.Visible = i <= n and f2 < 1 + end + cover.Visible = f2 > 0 and f2 < 1 + cover.Size = UDim2.fromScale(0.66, 0.34 * f2) + roll.Visible = f2 >= 1 + roll.Size = UDim2.fromScale(0.8 * (1 - 0.6 * f3), 0.8) + roll.Position = UDim2.fromScale(0.5 - 0.24 * f3, 0.5) + local m = count(f3, #slices) + for i, s in slices do + s.Visible = i <= m + end + end + end, + Sundae = function(stage) + local pieces = {} + for i, x in { 0.36, 0.5, 0.64 } do + pieces[i] = item(stage, "Piece" .. i, "sundaePiece", x, 0.34, 0.24, 0.16) + pieces[i].Rotation = (i - 2) * 12 + end + local steams = {} + for i, x in { 0.34, 0.66 } do + steams[i] = item(stage, "Steam" .. i, "steam", x, 0.14, 0.22, 0.22) + end + local slices = {} + for i = 1, 5 do + slices[i] = item(stage, "Slice" .. i, "sundaeSlice", 0.14 + i * 0.12, 0.2, 0.14, 0.14) + end + return function(flow) + local f1, f2, f3 = stepFrac(flow, 1), stepFrac(flow, 2), stepFrac(flow, 3) + local n = count(f1, #pieces) - math.floor(f3 * #pieces + 1e-6) + for i, p in pieces do + p.Visible = i <= n + end + for _, s in steams do + s.Visible = f2 > 0 and f3 == 0 + s.ImageTransparency = 1 - math.min(1, f2 * 1.5) + end + local m = count(f3, #slices) + for i, s in slices do + s.Visible = i <= m + end + end + end, + Eomuk = function(stage) + local skewer = Theme.frame(stage, "Skewer") + skewer.AnchorPoint = Vector2.new(0.5, 0.5) + skewer.Size = UDim2.fromScale(0.4, 0.56) + skewer.ZIndex = 26 + local stick = Theme.frame(skewer, "Stick", Color3.fromRGB(232, 197, 143)) + stick.AnchorPoint = Vector2.new(0.5, 0.5) + stick.Position = UDim2.fromScale(0.5, 0.5) + stick.Size = UDim2.fromScale(0.07, 1) + stick.ZIndex = 26 + Theme.round(stick) + Theme.stroke(stick, Theme.edge(Color3.fromRGB(200, 150, 90)), 2) + local folds = {} + for i = 1, 3 do + local f = Theme.icon(skewer, "Fold" .. i, "fishCake") + Theme.place(f, if i % 2 == 0 then 0.58 else 0.42, 0.12 + i * 0.2, 0.9, 0.3) + f.ZIndex = 27 + folds[i] = f + end + local steams = {} + for i, x in { 0.3, 0.7 } do + steams[i] = item(stage, "Steam" .. i, "steam", x, 0.2, 0.2, 0.2) + end + return function(flow) + local f1, f2 = stepFrac(flow, 1), stepFrac(flow, 2) + local n = count(f1, #folds) + for i, f in folds do + f.Visible = i <= n + end + -- 꾹 누르는 동안 꼬치가 국물 속으로 퐁당 + skewer.Position = UDim2.fromScale(0.5, 0.3 + 0.14 * f2) + for _, s in steams do + s.Visible = f2 > 0.2 + end + end + end, + Twigim = function(stage) + local plate = Theme.kitchen(stage, "Plate", "plateBig") + Theme.place(plate, 0.5, 0.13, 0.5, 0.24) + plate.ZIndex = 25 + local shrimps = {} + for i, x in { 0.36, 0.64 } do + local raw = item(stage, "Raw" .. i, "shrimpRaw", x, 0.3, 0.3, 0.3) + local coated = item(stage, "Coated" .. i, "shrimpBatter", x, 0.3, 0.3, 0.3) + local fried = item(stage, "Fried" .. i, "Twigim", x, 0.3, 0.3, 0.3) + shrimps[i] = { raw = raw, coated = coated, fried = fried, x = x } + end + local bubbles = {} + for i, p in { { 0.3, 0.42 }, { 0.5, 0.38 }, { 0.7, 0.42 } } do + bubbles[i] = item(stage, "Bubble" .. i, "bubble", p[1], p[2], 0.08, 0.08) + end + return function(flow) + local f1, f2, f3 = stepFrac(flow, 1), stepFrac(flow, 2), stepFrac(flow, 3) + local out = count(f3, #shrimps) + plate.Visible = flow.step >= 3 or flow.phase == "done" + for i, s in shrimps do + -- 튀김옷(문지르기) → 기름 속으로(꾹) → 접시로(톡) + local onPlate = i <= out + local y = if onPlate then 0.12 else 0.3 + 0.12 * f2 + local x = if onPlate then 0.38 + (i - 1) * 0.24 else s.x + for _, img in { s.raw, s.coated, s.fried } do + img.Position = UDim2.fromScale(x, y) + img.Size = UDim2.fromScale(if onPlate then 0.22 else 0.3, if onPlate then 0.22 else 0.3) + end + s.raw.ImageTransparency = f1 + s.coated.ImageTransparency = if f2 > 0 then f2 else 1 - f1 + s.fried.ImageTransparency = 1 - f2 + end + for _, b in bubbles do + b.Visible = f2 > 0 and f2 < 1 + end + end + end, +} + +function Kitchen.build(root: Frame, state: Instance, send: (string, any?) -> ()): KitchenHandle + 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 tweens: { Tween } = {} + local conns: { RBXScriptConnection } = {} + local closeFns: { () -> () } = {} + local openFns: { () -> () } = {} + local layoutNow: Layout.Result? = nil + + local panel = Theme.panel(root, "Kitchen", COLOR) + local frame = panel.frame + frame.ZIndex = 22 + local content = Theme.frame(panel.body, "Content") + content.Position = UDim2.fromOffset(0, Layout.HEADER_H) + content.Size = UDim2.new(1, 0, 1, -Layout.HEADER_H) + content.ZIndex = 3 + + -- 1) 메뉴 고르기 + local menuPage = Theme.frame(content, "MenuPage") + menuPage.Size = UDim2.fromScale(1, 1) + menuPage.ZIndex = 3 + local say = Theme.frame(menuPage, "Say") + say.Position = UDim2.fromScale(0.03, 0.03) + say.Size = UDim2.fromScale(0.94, 0.2) + say.ZIndex = 3 + local sayFace = Theme.icon(say, "Mascot", "mascot") + sayFace.Size = UDim2.fromScale(0.1, 1.1) + sayFace.AnchorPoint = Vector2.new(0, 0.5) + sayFace.Position = UDim2.fromScale(0, 0.5) + sayFace.ZIndex = 5 + local sayBubble = Theme.frame(say, "Bubble", Theme.WHITE) + sayBubble.Position = UDim2.fromScale(0.08, 0.1) + sayBubble.Size = UDim2.fromScale(0.92, 0.8) + sayBubble.ZIndex = 4 + Theme.round(sayBubble) + Theme.stroke(sayBubble, Theme.LINE, 3) + local sayText = Theme.text(sayBubble, "Text") + sayText.Position = UDim2.fromScale(0.04, 0.14) + sayText.Size = UDim2.fromScale(0.92, 0.72) + sayText.ZIndex = 5 + local menuRow = Theme.frame(menuPage, "Menus") + menuRow.Position = UDim2.fromScale(0.03, 0.28) + menuRow.Size = UDim2.fromScale(0.94, 0.68) + menuRow.ZIndex = 3 + local rowList = Instance.new("UIListLayout") + rowList.FillDirection = Enum.FillDirection.Horizontal + rowList.HorizontalAlignment = Enum.HorizontalAlignment.Center + rowList.VerticalAlignment = Enum.VerticalAlignment.Center + rowList.Padding = UDim.new(0.015, 0) + rowList.SortOrder = Enum.SortOrder.LayoutOrder + rowList.Parent = menuRow + + type MenuCard = { + holder: Frame, + button: Theme.Button, + icon: ImageLabel, + name: TextLabel, + badge: Frame, + badgeText: TextLabel, + lock: ImageLabel, + bob: Tween?, + } + local menuCards: { [string]: MenuCard } = {} + local choosePointer = Theme.icon(menuPage, "Pointer", "hand") + choosePointer.Size = UDim2.fromOffset(58, 58) + choosePointer.AnchorPoint = Vector2.new(0.5, 0) + choosePointer.ZIndex = 12 + choosePointer.Visible = false + + -- 2) 조리 + local cookPage = Theme.frame(content, "CookPage") + cookPage.Size = UDim2.fromScale(1, 1) + cookPage.ZIndex = 3 + local steps = Theme.frame(cookPage, "Steps") + steps.Position = UDim2.fromScale(0.03, 0.04) + steps.Size = UDim2.fromScale(0.26, 0.18) + steps.ZIndex = 3 + local stepList = Instance.new("UIListLayout") + stepList.FillDirection = Enum.FillDirection.Horizontal + stepList.VerticalAlignment = Enum.VerticalAlignment.Center + stepList.Padding = UDim.new(0.04, 0) + stepList.SortOrder = Enum.SortOrder.LayoutOrder + stepList.Parent = steps + local stepDots: { Frame } = {} + for i = 1, 3 do + local d = Theme.frame(steps, "Step" .. i, Theme.WHITE) + d.Size = UDim2.fromScale(0.28, 1) + d.LayoutOrder = i + d.ZIndex = 4 + local ar = Instance.new("UIAspectRatioConstraint") + ar.AspectRatio = 1 + ar.Parent = d + Theme.round(d) + Theme.stroke(d, Theme.LINE, 3) + local ic = Theme.icon(d, "Icon", "star") + Theme.place(ic, 0.5, 0.5, 0.78, 0.78) + ic.ZIndex = 5 + local ok = Theme.icon(d, "Done", "check") + Theme.place(ok, 0.82, 0.18, 0.5, 0.5) + ok.ZIndex = 6 + stepDots[i] = d + end + local instr = Theme.text(cookPage, "Instruction") + instr.Position = UDim2.fromScale(0.3, 0.04) + instr.Size = UDim2.fromScale(0.67, 0.18) + instr.ZIndex = 4 + -- 무대(정사각형): 조리 도구 그림 + 재료 + local stage = Theme.frame(cookPage, "Stage", Theme.WHITE) + stage.AnchorPoint = Vector2.new(0.5, 0.5) + stage.Position = UDim2.fromScale(0.34, 0.61) + stage.Size = UDim2.fromScale(0.74, 0.74) + stage.SizeConstraint = Enum.SizeConstraint.RelativeYY + stage.ZIndex = 24 + Theme.corner(stage, 28) + Theme.stroke(stage, Theme.LINE, 3) + Theme.gradient(stage, Color3.fromRGB(255, 252, 246), Color3.fromRGB(255, 236, 214)) + local base = Theme.kitchen(stage, "Base", "pan") + Theme.place(base, 0.5, 0.56, 0.9, 0.9) + base.ZIndex = 25 + local layer = Theme.frame(stage, "Layer") + layer.Size = UDim2.fromScale(1, 1) + layer.ZIndex = 25 + -- 오른쪽: 지금 쓰는 도구 + 손가락 + 동작 이름 + 진행 막대 + local tool = Theme.frame(cookPage, "Tool", Theme.WHITE) + tool.AnchorPoint = Vector2.new(0.5, 0.5) + tool.Position = UDim2.fromScale(0.8, 0.5) + tool.Size = UDim2.fromScale(0.42, 0.42) + tool.SizeConstraint = Enum.SizeConstraint.RelativeYY + tool.ZIndex = 24 + Theme.round(tool) + Theme.stroke(tool, Theme.edge(Theme.YELLOW), 4) + Theme.gradient(tool, Color3.fromRGB(255, 250, 220), Color3.fromRGB(255, 226, 150)) + local toolScale = Instance.new("UIScale") + toolScale.Parent = tool + local toolIcon = Theme.icon(tool, "Icon", "riceCakes") + Theme.place(toolIcon, 0.5, 0.5, 0.8, 0.8) + toolIcon.ZIndex = 25 + local hand = Theme.icon(cookPage, "Hand", "hand") + hand.AnchorPoint = Vector2.new(0.3, 0) + hand.Size = UDim2.fromScale(0.16, 0.16) + hand.SizeConstraint = Enum.SizeConstraint.RelativeYY + hand.ZIndex = 30 + local gesture = Theme.text(cookPage, "Gesture", Theme.edge(COLOR)) + gesture.AnchorPoint = Vector2.new(0.5, 0.5) + gesture.Position = UDim2.fromScale(0.8, 0.8) + gesture.Size = UDim2.fromScale(0.34, 0.11) + gesture.ZIndex = 26 + local pbar = Theme.frame(cookPage, "Progress", Color3.fromRGB(240, 228, 236)) + pbar.AnchorPoint = Vector2.new(0.5, 0.5) + pbar.Position = UDim2.fromScale(0.8, 0.92) + pbar.Size = UDim2.fromScale(0.3, 0.07) + pbar.ZIndex = 25 + Theme.round(pbar) + Theme.stroke(pbar, Theme.LINE, 2) + local pfill = Theme.frame(pbar, "Fill", Theme.MINT) + pfill.Size = UDim2.fromScale(0, 1) + pfill.ZIndex = 26 + Theme.round(pfill) + Theme.gradient(pfill, Color3.fromRGB(120, 235, 170), Theme.MINT) + -- 창 안 어디를 눌러도 되는 입력판(투명) + local pad = Instance.new("TextButton") + pad.Name = "Pad" + pad.Text = "" + pad.AutoButtonColor = false + pad.BackgroundTransparency = 1 + pad.Size = UDim2.fromScale(1, 1) + pad.ZIndex = 40 + pad.Parent = cookPage + + -- 3) 완성 + local donePage = Theme.frame(content, "DonePage") + donePage.Size = UDim2.fromScale(1, 1) + donePage.ZIndex = 3 + local burst = Theme.kitchen(donePage, "Burst", "burst") + Theme.place(burst, 0.5, 0.5, 1.1, 1.1) + burst.SizeConstraint = Enum.SizeConstraint.RelativeYY + burst.ZIndex = 4 + table.insert( + tweens, + TweenService:Create(burst, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1), { + Rotation = 360, + }) + ) + tweens[#tweens]:Play() + local dishPlate = Theme.kitchen(donePage, "Plate", "plateBig") + Theme.place(dishPlate, 0.5, 0.62, 0.6, 0.6) + dishPlate.SizeConstraint = Enum.SizeConstraint.RelativeYY + dishPlate.ZIndex = 5 + local dish = Theme.icon(donePage, "Dish", "Tteokbokki") + Theme.place(dish, 0.5, 0.5, 0.52, 0.52) + dish.SizeConstraint = Enum.SizeConstraint.RelativeYY + dish.ZIndex = 6 + local dishScale = Instance.new("UIScale") + dishScale.Parent = dish + local doneText = Theme.text(donePage, "Text", Theme.edge(Theme.PINK)) + doneText.TextColor3 = Theme.WHITE + doneText.AnchorPoint = Vector2.new(0.5, 0.5) + doneText.Position = UDim2.fromScale(0.5, 0.12) + doneText.Size = UDim2.fromScale(0.6, 0.18) + doneText.ZIndex = 7 + local cheer = Theme.kitchen(donePage, "Mascot", "mascotCheer") + Theme.place(cheer, 0.16, 0.62, 0.62, 0.62) + cheer.SizeConstraint = Enum.SizeConstraint.RelativeYY + cheer.ZIndex = 6 + + -- 효과음(조리음은 꾹 누르기·문지르기 동안 반복) + local sfx = SoundService:FindFirstChild("Sfx") :: SoundGroup? + local function sound(id: string, volume: number, speed: number, looped: boolean?): Sound + local s = Instance.new("Sound") + s.SoundId = id + s.Volume = volume + s.PlaybackSpeed = speed + s.Looped = looped == true + s.SoundGroup = sfx + s.Parent = frame + return s + end + local tapSound = sound(Sounds.POP, 0.6, 1) + local sizzle = sound(Sounds.SIZZLE, 0.5, 1, true) + local doneSound = sound(Sounds.BUY, 0.7, 1.1) + + local flow = Recipes.newFlow(Economy.START.cook) + local scene: Scene? = nil + local sceneMenu: string? = nil + local isOpen = false + local holding = false + local rubbing = false + local lastPos: Vector2? = nil + local loudUntil = 0 + local gestureTween: Tween? = nil + local doneToken = 0 + + local function stats() + return Economy.statsAt(attr(state, "Bought", 0)) + end + local choose: (menu: string) -> boolean + local function orders(): { [string]: number } + return Kitchen.parseOrders(attr(state, "Orders", "")) + end + local function handFull(): boolean + return attr(state, "Carry", 0) >= stats().carry + end + + local function buildScene(menu: string) + if sceneMenu == menu then + return + end + sceneMenu = menu + for _, c in layer:GetChildren() do + c:Destroy() + end + Icons.applyKitchen(base, Recipes.LIST[menu].stage) + scene = SCENES[menu](layer) + end + + local function stopGesture() + if gestureTween then + gestureTween:Cancel() + gestureTween = nil + end + end + + -- 손가락이 할 동작을 보여 줍니다: 톡톡(도구 위에서 콕콕), 꾹(도구를 누르고 있음), 문지르기(무대 위를 좌우로) + local function showGesture(kind: Recipes.StepKind) + stopGesture() + if kind == "rub" then + hand.Position = UDim2.fromScale(0.22, 0.55) + hand.Rotation = -10 + gestureTween = TweenService:Create( + hand, + TweenInfo.new(0.55, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), + { Position = UDim2.fromScale(0.42, 0.62), Rotation = 10 } + ) + elseif kind == "hold" then + hand.Position = UDim2.fromScale(0.8, 0.5) + hand.Rotation = 0 + gestureTween = TweenService:Create( + hand, + TweenInfo.new(0.9, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), + { Position = UDim2.fromScale(0.8, 0.46) } + ) + else + hand.Position = UDim2.fromScale(0.8, 0.5) + hand.Rotation = 0 + gestureTween = TweenService:Create( + hand, + TweenInfo.new(0.22, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, -1, true), + { Position = UDim2.fromScale(0.8, 0.44) } + ) + end + if gestureTween then + gestureTween:Play() + end + end + + local function drawCook() + local menu = flow.menu + if not menu then + return + end + buildScene(menu) + if scene then + scene(flow) + end + local r = Recipes.LIST[menu] + for i, d in stepDots do + local s = r.steps[i] + d.Visible = s ~= nil + if s then + Theme.setIcon(d:FindFirstChild("Icon") :: ImageLabel, TOOL_ICON[s.tool] or s.tool) + local doneStep = i < flow.step or flow.phase == "done" + local current = i == flow.step and flow.phase == "cook" + local st = d:FindFirstChildOfClass("UIStroke") :: UIStroke + st.Color = if current then Theme.edge(Theme.YELLOW) elseif doneStep then Theme.MINT else Theme.LINE + st.Thickness = if current then 4 else 3 + d.BackgroundColor3 = if current + then Color3.fromRGB(255, 244, 200) + elseif doneStep then Color3.fromRGB(220, 250, 232) + else Theme.WHITE; + (d:FindFirstChild("Done") :: ImageLabel).Visible = doneStep; + (d:FindFirstChild("Icon") :: ImageLabel).ImageTransparency = if current or doneStep then 0 else 0.5 + end + end + local s = Recipes.current(flow) + if s then + instr.Text = L(s.key) + Theme.setIcon(toolIcon, TOOL_ICON[s.tool] or s.tool) + local n = flow.need + gesture.Text = if s.kind == "tap" + then L("gestureTap", { n = math.max(0, math.ceil(n - flow.progress - 1e-6)) }) + elseif s.kind == "hold" then L("gestureHold") + else L("gestureRub") + pfill.Size = UDim2.fromScale(if n > 0 then flow.progress / n else 0, 1) + pfill.Visible = flow.progress > 0 + end + end + + local function setPage(which: string) + menuPage.Visible = which == "menu" + cookPage.Visible = which == "cook" + donePage.Visible = which == "done" + hand.Visible = which == "cook" + if which ~= "cook" then + stopGesture() + holding = false + rubbing = false + sizzle:Stop() + end + end + + local function drawMenus() + local st = stats() + local o = orders() + local full = handFull() + local first: MenuCard? = nil + local any = false + for i, menu in Economy.MENU_ORDER do + local mc = menuCards[menu] + if not mc then + local holder = Theme.frame(menuRow, "Menu_" .. menu) + holder.LayoutOrder = i + holder.Size = UDim2.fromScale(0.185, 0.92) + holder.ZIndex = 4 + local b = Theme.button(holder, "Button", Theme.PINK, 24) + b.button.Size = UDim2.fromScale(1, 1) + b.button.ZIndex = 4 + local ic = Theme.icon(b.face, "Icon", menu) + Theme.place(ic, 0.5, 0.4, 0.78, 0.56) + ic.ZIndex = 5 + local name = Theme.text(b.face, "Name", Theme.edge(Theme.PINK)) + name.AnchorPoint = Vector2.new(0.5, 0.5) + name.Position = UDim2.fromScale(0.5, 0.82) + name.Size = UDim2.fromScale(0.86, 0.2) + name.ZIndex = 5 + local badge = Theme.frame(b.face, "Orders", Theme.WHITE) + badge.AnchorPoint = Vector2.new(1, 0) + badge.Position = UDim2.new(1, -6, 0, 6) + badge.Size = UDim2.fromOffset(70, 36) + badge.ZIndex = 8 + Theme.round(badge) + Theme.stroke(badge, Theme.edge(Theme.SKY), 3) + local face = Theme.icon(badge, "Face", "customer") + face.Size = UDim2.fromOffset(32, 32) + face.AnchorPoint = Vector2.new(0, 0.5) + face.Position = UDim2.new(0, 3, 0.5, 0) + face.ZIndex = 9 + local bt = Theme.text(badge, "Text", nil, true) + bt.Position = UDim2.fromOffset(36, 5) + bt.Size = UDim2.new(1, -42, 1, -10) + bt.ZIndex = 9 + local lock = Theme.icon(b.face, "Lock", "lock") + Theme.place(lock, 0.5, 0.4, 0.42, 0.42) + lock.ZIndex = 6 + local menuName = menu + table.insert( + conns, + b.button.Activated:Connect(function() + choose(menuName) + end) + ) + mc = { + holder = holder, + button = b, + icon = ic, + name = name, + badge = badge, + badgeText = bt, + lock = lock, + bob = nil, + } + menuCards[menu] = mc + end + local card = mc :: MenuCard + local unlocked = table.find(st.menus, menu) ~= nil + local n = o[menu] or 0 + local ok = unlocked and n > 0 and not full + card.button.setColor( + if ok then Theme.PINK elseif unlocked then Theme.GRAY else Color3.fromRGB(150, 145, 165) + ) + card.icon.ImageTransparency = if unlocked then (if ok then 0 else 0.35) else 0.75 + card.lock.Visible = not unlocked + card.name.Text = if unlocked then Locale.menuName(lang(), menu) else L("locked") + local edge = card.name:FindFirstChildOfClass("UIStroke") + if edge then + edge.Color = Theme.edge(card.button.color()) + end + card.badge.Visible = unlocked and n > 0 + card.badgeText.Text = `x{n}` + card.button.button.Active = ok + -- 고를 수 있는 카드만 둥실둥실(상태가 바뀔 때만 다시 시작해서 움찔거리지 않게) + if ok and not card.bob then + card.bob = Theme.bob(card.button.button, 6, 0.9) + elseif not ok and card.bob then + card.bob:Cancel() + card.bob = nil + card.button.button.Position = UDim2.fromScale(0, 0) + end + if ok then + first = first or card + any = true + end + end + sayText.Text = if full then L("cookHandFull") elseif any then L("chooseMenu") else L("cookWait") + -- 튜토리얼 중에는 손가락이 고를 메뉴를 가리킵니다. + local tut = attr(state, "Tut", 0) + choosePointer.Visible = first ~= nil and tut == 1 + if first then + local h = first.holder + choosePointer.Parent = h + choosePointer.Position = UDim2.fromScale(0.78, 0.5) + choosePointer.Rotation = -20 + end + end + + local function refresh() + panel.title.Text = L("cookTitle") + doneText.Text = L("cookDone") + if not isOpen then + return + end + if flow.phase == "menu" then + drawMenus() + else + drawCook() + end + end + + local function close() + if not isOpen then + return + end + isOpen = false + doneToken += 1 + frame.Visible = false + setPage("menu") + Recipes.reset(flow, stats().cook) + for _, fn in closeFns do + fn() + end + end + + local function finish() + local menu = flow.menu :: string + send("cook", menu) + setPage("done") + Theme.setIcon(dish, menu) + dishScale.Scale = 0.3 + TweenService:Create(dishScale, TweenInfo.new(0.45, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { + Scale = 1, + }):Play() + doneSound:Play() + doneToken += 1 + local token = doneToken + task.delay(DONE_TIME, function() + if token ~= doneToken or not isOpen or flow.phase ~= "done" then + return + end + Recipes.reset(flow, stats().cook) + -- 아직 만들 주문이 있고 손에 자리가 있으면 바로 다음 접시 + local o = orders() + local more = false + for _ in o do + more = true + end + if more and not handFull() then + setPage("menu") + refresh() + else + close() + end + end) + end + + -- 입력(테스트에서도 바로 부름) + local function input(kind: Recipes.StepKind, amount: number): string? + local res = Recipes.input(flow, kind, amount) + if not res then + return nil + end + if kind == "tap" then + tapSound:Play() + toolScale.Scale = 0.85 + TweenService:Create(toolScale, TweenInfo.new(0.2, Enum.EasingStyle.Back), { Scale = 1 }):Play() + else + loudUntil = os.clock() + 0.25 + end + if res == "step" then + local s = Recipes.current(flow) + if s then + showGesture(s.kind) + end + holding = false + rubbing = false + Theme.pop(tool, 0.5) + end + drawCook() + if res == "done" then + finish() + end + return res + end + + function choose(menu: string): boolean + if flow.phase ~= "menu" then + return false + end + local st = stats() + if not table.find(st.menus, menu) or (orders()[menu] or 0) <= 0 or handFull() then + return false + end + Recipes.reset(flow, st.cook) + if not Recipes.choose(flow, menu) then + return false + end + setPage("cook") + drawCook() + local s = Recipes.current(flow) + if s then + showGesture(s.kind) + end + return true + end + + local function open() + if isOpen then + return + end + isOpen = true + Recipes.reset(flow, stats().cook) + setPage("menu") + frame.Visible = true + Theme.pop(frame) + refresh() + for _, fn in openFns do + fn() + end + end + + -- 입력판: 누르기·떼기·움직이기 + local function pointerDown(io: InputObject): boolean + local t = io.UserInputType + return t == Enum.UserInputType.MouseButton1 or t == Enum.UserInputType.Touch + end + table.insert( + conns, + pad.InputBegan:Connect(function(io: InputObject) + if not pointerDown(io) or flow.phase ~= "cook" then + return + end + local s = Recipes.current(flow) + if not s then + return + end + if s.kind == "tap" then + input("tap", 1) + elseif s.kind == "hold" then + holding = true + else + rubbing = true + lastPos = Vector2.new(io.Position.X, io.Position.Y) + end + end) + ) + -- PC: E·스페이스 키도 누르기와 같음(톡톡, 꾹) + local function isKey(io: InputObject): boolean + return io.KeyCode == Enum.KeyCode.E or io.KeyCode == Enum.KeyCode.Space + end + table.insert( + conns, + UserInputService.InputBegan:Connect(function(io: InputObject, processed: boolean) + if not isOpen or processed or not isKey(io) or flow.phase ~= "cook" then + return + end + local s = Recipes.current(flow) + if s and s.kind == "tap" then + input("tap", 1) + elseif s and s.kind == "hold" then + holding = true + end + end) + ) + table.insert( + conns, + UserInputService.InputEnded:Connect(function(io: InputObject) + if pointerDown(io) or isKey(io) then + holding = false + rubbing = false + end + end) + ) + table.insert( + conns, + UserInputService.InputChanged:Connect(function(io: InputObject) + if not isOpen or flow.phase ~= "cook" then + return + end + local s = Recipes.current(flow) + if not s or s.kind ~= "rub" then + lastPos = nil + return + end + local t = io.UserInputType + local pos = Vector2.new(io.Position.X, io.Position.Y) + -- 마우스는 누르지 않고 패널 위에서 움직이기만 해도 됩니다(어린아이도 쉽게). + local over = false + if t == Enum.UserInputType.MouseMovement then + local p, sz = pad.AbsolutePosition, pad.AbsoluteSize + over = pos.X >= p.X and pos.Y >= p.Y and pos.X <= p.X + sz.X and pos.Y <= p.Y + sz.Y + end + if + (t == Enum.UserInputType.Touch and rubbing) + or over + or (rubbing and t == Enum.UserInputType.MouseMovement) + then + if lastPos then + local k = if layoutNow then layoutNow.scale else 1 + local d = (pos - lastPos).Magnitude / k + if d > 0 and d < 400 then + input("rub", d / Recipes.RUB_UNIT) + end + end + lastPos = pos + else + lastPos = nil + end + end) + ) + table.insert( + conns, + RunService.Heartbeat:Connect(function(dt: number) + if not isOpen then + return + end + if holding and flow.phase == "cook" then + input("hold", dt) + end + local loud = flow.phase == "cook" and (holding or os.clock() < loudUntil) + if loud and not sizzle.IsPlaying then + sizzle:Play() + elseif not loud and sizzle.IsPlaying then + sizzle:Stop() + end + end) + ) + table.insert(conns, panel.close.button.Activated:Connect(close)) + table.insert( + conns, + state.AttributeChanged:Connect(function() + if isOpen and flow.phase == "menu" then + drawMenus() + end + end) + ) + + setPage("menu") + refresh() + + return { + frame = frame, + open = open, + close = close, + isOpen = function() + return isOpen + end, + onClose = function(fn) + table.insert(closeFns, fn) + end, + onOpen = function(fn) + table.insert(openFns, fn) + end, + setLayout = function(lay: Layout.Result) + layoutNow = lay + local r = lay.kitchen + frame.AnchorPoint = Vector2.new(0.5, 0.5) + frame.Position = UDim2.fromOffset(r.x + r.w / 2, r.y + r.h / 2) + frame.Size = UDim2.fromOffset(r.w, r.h) + panel.close.button.Size = UDim2.fromOffset(lay.rows.closeH, lay.rows.closeH) + end, + refresh = refresh, + flow = function() + return flow + end, + choose = choose, + input = input, + destroy = function() + for _, c in conns do + c:Disconnect() + end + for _, t in tweens do + t:Cancel() + end + stopGesture() + for _, mc in menuCards do + if mc.bob then + mc.bob:Cancel() + end + end + end, + } +end + +return Kitchen diff --git a/bunsik-tycoon/src/client/Layout.luau b/bunsik-tycoon/src/client/Layout.luau index 7af2f1f..25f09e3 100644 --- a/bunsik-tycoon/src/client/Layout.luau +++ b/bunsik-tycoon/src/client/Layout.luau @@ -2,6 +2,9 @@ -- 화면 UI 배치 계산(로블록스 서비스 없이 숫자만 다룸, lune 단위 테스트로 검사). -- 입력은 UI가 쓸 수 있는 화면 크기(상단 바·노치를 뺀 안전 영역, 픽셀)와 터치 화면 여부입니다. -- 결과 좌표는 기준 단위이고, 화면 픽셀 = 기준 단위 × scale 입니다. +-- 배치 원칙(어지럽지 않게): 늘 보이는 것은 7개뿐 — 돈(위 가운데), 버튼 3개(상점·2배·부스트)는 한 묶음, +-- 설정(오른쪽 위), 다음 업그레이드 막대(아래 가운데), 손에 든 접시(막대 바로 위). 나머지는 창으로 엽니다. +-- PC는 버튼 묶음을 왼쪽에 세로로, 휴대폰은 왼쪽 위에 가로로 둡니다. -- 터치 화면에서는 로블록스 기본 조이스틱 자리(왼쪽 40% × 아래 2/3)와 점프 버튼 자리(오른쪽 아래)에 -- 누르는 버튼을 두지 않습니다. 두 자리의 크기는 로블록스 PlayerModule(TouchJump, DynamicThumbstick)에서 가져왔습니다. @@ -9,6 +12,8 @@ local Layout = {} export type Rect = { x: number, y: number, w: number, h: number } +export type Grid = { cols: number, rows: number, pad: number, gap: number, top: number, cardW: number, cardH: number } + export type Result = { scale: number, width: number, -- 기준 단위 화면 너비 @@ -18,14 +23,16 @@ export type Result = { carry: Rect, hint: Rect, toasts: Rect, - card: Rect, - buy: Rect, -- 카드 안의 [사기] 버튼(화면 기준 위치) + card: Rect, -- 다음 업그레이드 막대 + buy: Rect, -- 막대 안의 [사기] 버튼(화면 기준 위치) settings: Rect, - list: Rect, + list: Rect, -- 상점(업그레이드) 버튼 double: Rect, boost: Rect, - panel: Rect, + panel: Rect, -- 상점 창 + grid: Grid, -- 상점 창 안 카드 배치(창 기준) settingsPanel: Rect, + kitchen: Rect, -- 요리 창 -- 설정 창 안쪽 줄(설정 창 기준 y) rows: { langButtonH: number, @@ -38,10 +45,10 @@ export type Result = { }, } -local CARD_W, CARD_H = 500, 112 -local CARD_TAB = 16 -- 카드 위로 튀어나온 "다음 업그레이드" 이름표 높이(카드 사각형 안) -local BUY_W, BUY_H = 140, 70 -local PANEL_W = 540 +Layout.HEADER_H = 58 -- 창 위쪽 색 띠 높이(Theme.panel과 같음) + +local CARD_W, CARD_H = 470, 84 +local BUY_W, BUY_H = 132, 64 local function rect(x: number, y: number, w: number, h: number): Rect return { x = x, y = y, w = w, h = h } @@ -71,30 +78,27 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res local W, H = w / s, h / s local cx = W / 2 - -- 돈: 왼쪽에 동전 아이콘이 튀어나온 알약 모양 - local money = rect(cx - 160, 6, 320, 64) - local carry = rect(cx - 60, 74, 120, 30) - - -- 네모 아이콘 버튼(아이콘 위, 이름 아래) - local settings, list, double, boost - local hintW + local money, settings, list, double, boost, hint if touch then - -- 왼쪽 위: 2배 수익, 돈 부스트(조이스틱 자리 H/3 위쪽). 오른쪽 위: 설정, 업그레이드 목록. - double = rect(8, 6, 84, 84) - boost = rect(100, 6, 84, 84) - list = rect(W - 92, 6, 84, 84) - settings = rect(W - 92 - 76, 6, 68, 68) - hintW = math.min(640, W - 2 * 196) + money = rect(cx - 125, 6, 250, 54) + list = rect(8, 6, 84, 84) + double = rect(100, 10, 76, 76) + boost = rect(184, 10, 76, 76) + settings = rect(W - 72, 6, 64, 64) + local hintW = math.min(600, W - 40) + hint = rect(cx - hintW / 2, 98, hintW, 72) else - settings = rect(W - 78, 6, 68, 68) - list = rect(W - 110, H / 2 - 50, 100, 100) - double = rect(10, H / 2 - 112, 100, 100) - boost = rect(10, H / 2 + 12, 100, 100) - hintW = 640 + money = rect(cx - 140, 8, 280, 58) + settings = rect(W - 70, 8, 60, 60) + local top = H / 2 - 170 + list = rect(12, top, 96, 96) + double = rect(18, top + 96 + 20, 84, 84) + boost = rect(18, top + 96 + 20 + 84 + 30, 84, 84) -- 위에 "+금액" 꼬리표가 붙어서 더 띄움 + local hintW = math.min(620, W - 2 * 130) + hint = rect(cx - hintW / 2, 76, hintW, 72) end - local hint = rect(cx - hintW / 2, 110, hintW, 58) - -- 아래 카드: 터치 화면에서는 점프 버튼 왼쪽까지 밀어 둡니다. + -- 아래 막대: 터치 화면에서는 점프 버튼 왼쪽까지 밀어 둡니다. local cardX = cx - CARD_W / 2 if touch then local zones = Layout.touchZones(w, h) @@ -102,33 +106,53 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res end cardX = math.max(cardX, 10) local card = rect(cardX, H - 8 - CARD_H, CARD_W, CARD_H) - local bodyH = CARD_H - CARD_TAB - local buy = rect(card.x + CARD_W - 12 - BUY_W, card.y + CARD_TAB + (bodyH - BUY_H) / 2, BUY_W, BUY_H) + local buy = rect(card.x + CARD_W - 10 - BUY_W, card.y + (CARD_H - BUY_H) / 2, BUY_W, BUY_H) + local carry = rect(card.x + CARD_W / 2 - 90, card.y - 48, 180, 42) - local toastsW = math.min(560, hintW) - local toasts = rect(cx - toastsW / 2, 176, toastsW, math.max(0, card.y - 6 - 176)) + local toastsTop = hint.y + hint.h + 8 + local toastsW = math.min(480, hint.w) + local toasts = rect(cx - toastsW / 2, toastsTop, toastsW, math.max(0, carry.y - 6 - toastsTop)) - local panelH = math.min(450, H - 12) - local panel = rect(cx - PANEL_W / 2, math.max(6, H * 0.48 - panelH / 2), PANEL_W, panelH) + -- 상점 창: 지금 단계 업그레이드 10개를 5x2 카드로(넘기지 않아도 다 보임) + local pw = if touch then math.min(820, W - 24) else 740 + local ph = math.min(if touch then 392 else 440, H - 12) + local panel = rect(cx - pw / 2, math.max(6, H * 0.5 - ph / 2), pw, ph) + local pad, gap = 16, 10 + local top = Layout.HEADER_H + 12 + local grid: Grid = { + cols = 5, + rows = 2, + pad = pad, + gap = gap, + top = top, + cardW = (pw - 2 * pad - 4 * gap) / 5, + cardH = (ph - top - pad - gap) / 2, + } - -- 설정 창 줄: 제목(10~54), 언어 이름(64), 언어 버튼(100~), 마우스(PC만), 효과음, 개발자(주인만) + -- 설정 창 줄: 제목 띠(0~58), 언어 이름(70), 언어 버튼(106~), 마우스(PC만), 효과음, 개발자(주인만) local langButtonH = if touch then 52 else 44 - local toggleH = if touch then 48 else 40 - local y = 104 + langButtonH + 16 + local toggleH = if touch then 50 else 42 + local y = 106 + langButtonH + 18 local mouseY: number? = nil if not touch then mouseY = y - y += 92 + y += toggleH + 40 end local sfxY = y - y += toggleH + 14 + y += toggleH + 16 local devY: number? = nil if dev then devY = y - y += 34 + toggleH + 14 + y += 36 + toggleH + 16 end - local setH = y + 8 - local settingsPanel = rect(cx - PANEL_W / 2, math.max(6, H * 0.48 - setH / 2), PANEL_W, setH) + local setW = 560 + local setH = math.min(y + 8, H - 12) + local settingsPanel = rect(cx - setW / 2, math.max(6, H * 0.5 - setH / 2), setW, setH) + + -- 요리 창: 휴대폰은 거의 화면 가득 + local kw = if touch then math.min(880, W - 16) else 800 + local kh = math.min(if touch then 396 else 480, H - 8) + local kitchen = rect(cx - kw / 2, math.max(4, H * 0.5 - kh / 2), kw, kh) return { scale = s, @@ -146,7 +170,9 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res double = double, boost = boost, panel = panel, + grid = grid, settingsPanel = settingsPanel, + kitchen = kitchen, rows = { langButtonH = langButtonH, mouseY = mouseY, @@ -154,7 +180,7 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res toggleH = toggleH, devY = devY, devButtonH = toggleH, - closeH = if touch then 52 else 46, + closeH = if touch then 50 else 48, -- 창 제목 띠(58) 안에 들어가는 크기 }, } end diff --git a/bunsik-tycoon/src/client/Main.client.luau b/bunsik-tycoon/src/client/Main.client.luau index 593b6b5..1efd26c 100644 --- a/bunsik-tycoon/src/client/Main.client.luau +++ b/bunsik-tycoon/src/client/Main.client.luau @@ -93,7 +93,29 @@ 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) +Stove.attach(stove, player, function() + hud.open("kitchen") +end) +-- 요리 창이 열려 있는 동안은 캐릭터가 움직이지 않게(휴대폰에서 문지르다 조이스틱이 움직이지 않게) 조작을 멈추고, +-- 조리대 버튼(E)도 꺼서 E 키를 요리 동작(톡톡·꾹)에 씁니다. +local ProximityPromptService = game:GetService("ProximityPromptService") +local controls: any = nil +pcall(function() + local PlayerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")) :: any + controls = PlayerModule:GetControls() +end) +hud.kitchen.onOpen(function() + ProximityPromptService.Enabled = false + if controls then + controls:Disable() + end +end) +hud.kitchen.onClose(function() + ProximityPromptService.Enabled = true + if controls then + controls:Enable() + end +end) Plots.start(world:WaitForChild("Plots"), player, player.UserId, send) Guide.start(player) diff --git a/bunsik-tycoon/src/client/Stove.luau b/bunsik-tycoon/src/client/Stove.luau index 90373ec..2f32f21 100644 --- a/bunsik-tycoon/src/client/Stove.luau +++ b/bunsik-tycoon/src/client/Stove.luau @@ -1,57 +1,35 @@ --!strict -- 내 가게 조리대에만 "요리하기" 버튼(ProximityPrompt)을 만듭니다. 다른 사람 가게에서는 버튼이 안 보입니다. --- 서버가 조리대 속성(CookMenu, CookTime)으로 알려 준 상태를 그대로 보여 주고, 다 누르면 서버에 "cook"을 보냅니다. +-- 버튼을 누르면(PC는 E 키) 요리 창(Kitchen)이 열리고, 메뉴를 골라 조리 과정을 마치면 창이 서버에 "cook"을 보냅니다. +-- 서버가 조리대 속성(CookMenu: 만들 주문이 있으면 메뉴 키, HandFull)으로 알려 준 상태에 따라 버튼을 켜고 끕니다. 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 +function Stove.attach(stove: BasePart, state: Instance, openKitchen: () -> ()): ProximityPrompt local prompt = Instance.new("ProximityPrompt") prompt.Name = "CookPrompt" prompt.KeyboardKeyCode = Enum.KeyCode.E prompt.MaxActivationDistance = 10 prompt.RequiresLineOfSight = false + prompt.HoldDuration = 0 prompt.Exclusivity = Enum.ProximityPromptExclusivity.OneGlobally - local sizzle = Instance.new("Sound") - 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() 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] - prompt.ActionText = `{m.icon} ` .. Locale.t(lang, "cookAction", { menu = Locale.menuName(lang, menu) }) - prompt.Enabled = true - else - prompt.Enabled = false - end + prompt.ActionText = Locale.t(lang, "cookAction") + prompt.Enabled = typeof(menu) == "string" and menu ~= "" 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) + prompt.Triggered:Connect(openKitchen) refresh() prompt.Parent = stove return prompt diff --git a/bunsik-tycoon/src/client/Theme.luau b/bunsik-tycoon/src/client/Theme.luau index 79478a5..509788f 100644 --- a/bunsik-tycoon/src/client/Theme.luau +++ b/bunsik-tycoon/src/client/Theme.luau @@ -1,6 +1,9 @@ --!strict --- 화면 UI 꾸미기 도구: 색, 굵은 테두리, 위아래 그러데이션, 입체 버튼(아래 그림자 판), 반짝 지나가는 빛, --- 누르면 쏙 들어가는 애니메이션, 아이콘. 인기 시뮬레이터·타이쿤 게임의 "굵은 테두리 + 흰 글자" 스타일을 따릅니다. +-- 화면 UI 꾸미기 도구("사탕" 스타일): 밝은 색, 아주 둥근 모서리, 같은 계열의 진한 테두리, 누르면 쏙 들어가는 입체 버튼. +-- 규칙(어지럽지 않게): +-- - 바탕은 흰색·크림색, 색은 버튼마다 하나만. 테두리와 글자 외곽선은 그 색을 진하게 한 색. +-- - 글꼴은 두 가지: 숫자·영어는 둥근 Fredoka(NUM), 한국어 등 글은 굵은 글꼴(FONT, 한글은 로블록스 기본 한글 글꼴로 대체됨). +-- - 계속 움직이는 효과는 "지금 누를 수 있는 것"(살 수 있는 업그레이드 등)에만 씁니다. -- 트윈만 쓰고 RenderStepped는 쓰지 않아서 서버(원격 테스트)에서도 만들 수 있습니다. local TweenService = game:GetService("TweenService") @@ -10,22 +13,23 @@ local Icons = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Ico local Theme = {} -Theme.INK = Color3.fromRGB(59, 30, 18) -- 테두리·글자 외곽선(진한 갈색) -Theme.CREAM = Color3.fromRGB(255, 246, 228) +Theme.TEXT = Color3.fromRGB(84, 52, 80) -- 흰 바탕 위 글자(진한 자두색) +Theme.SOFT = Color3.fromRGB(150, 120, 145) -- 흐린 글자 Theme.WHITE = Color3.new(1, 1, 1) -Theme.BROWN = Color3.fromRGB(120, 72, 40) +Theme.CREAM = Color3.fromRGB(255, 248, 238) +Theme.LINE = Color3.fromRGB(240, 222, 214) -- 흰 바탕 위 얇은 칸 선 --- 버튼 색(위쪽 밝은 색). 아래쪽·그림자 판은 자동으로 어둡게 만듭니다. -Theme.RED = Color3.fromRGB(255, 84, 64) -Theme.ORANGE = Color3.fromRGB(255, 150, 40) -Theme.YELLOW = Color3.fromRGB(255, 205, 50) -Theme.GREEN = Color3.fromRGB(110, 225, 60) -Theme.BLUE = Color3.fromRGB(70, 175, 255) -Theme.PURPLE = Color3.fromRGB(180, 100, 255) -Theme.GRAY = Color3.fromRGB(175, 175, 180) -Theme.NAVY = Color3.fromRGB(40, 48, 80) +Theme.PINK = Color3.fromRGB(255, 94, 132) -- 대표 색(떡볶이) +Theme.YELLOW = Color3.fromRGB(255, 196, 48) +Theme.MINT = Color3.fromRGB(46, 204, 128) +Theme.SKY = Color3.fromRGB(74, 172, 255) +Theme.LAVENDER = Color3.fromRGB(158, 116, 255) +Theme.ORANGE = Color3.fromRGB(255, 140, 50) +Theme.GRAY = Color3.fromRGB(184, 178, 196) +Theme.RED = Color3.fromRGB(255, 76, 76) -Theme.FONT = Font.new("rbxasset://fonts/families/FredokaOne.json", Enum.FontWeight.Bold) +Theme.FONT = Font.new("rbxasset://fonts/families/BuilderSans.json", Enum.FontWeight.Heavy) +Theme.NUM = Font.new("rbxasset://fonts/families/FredokaOne.json", Enum.FontWeight.Bold) function Theme.darken(c: Color3, k: number): Color3 return c:Lerp(Color3.new(0, 0, 0), k) @@ -35,6 +39,11 @@ function Theme.lighten(c: Color3, k: number): Color3 return c:Lerp(Color3.new(1, 1, 1), k) end +-- 그 색의 테두리·글자 외곽선 색 +function Theme.edge(c: Color3): Color3 + return c:Lerp(Color3.fromRGB(60, 20, 50), 0.55) +end + function Theme.corner(parent: Instance, r: number, scale: number?): UICorner local c = Instance.new("UICorner") c.CornerRadius = UDim.new(scale or 0, r) @@ -42,6 +51,10 @@ function Theme.corner(parent: Instance, r: number, scale: number?): UICorner return c end +function Theme.round(parent: Instance): UICorner + return Theme.corner(parent, 0, 0.5) +end + function Theme.stroke(parent: Instance, color: Color3, thickness: number, contextual: boolean?): UIStroke local s = Instance.new("UIStroke") s.Color = color @@ -52,7 +65,7 @@ function Theme.stroke(parent: Instance, color: Color3, thickness: number, contex return s end --- 위(밝음) → 아래(어두움) 그러데이션. 배경색은 흰색으로 두고 색은 그러데이션이 냅니다. +-- 위(밝음) → 아래 그러데이션. 배경색은 흰색으로 두고 색은 그러데이션이 냅니다. function Theme.gradient(parent: GuiObject, top: Color3, bottom: Color3): UIGradient local g = parent:FindFirstChildOfClass("UIGradient") or Instance.new("UIGradient") g.Color = ColorSequence.new(top, bottom) @@ -72,19 +85,21 @@ function Theme.frame(parent: Instance, name: string, color: Color3?): Frame return f end --- 흰 글자 + 진한 테두리(기본). dark=true면 진한 갈색 글자(밝은 바탕용). -function Theme.text(parent: Instance, name: string, dark: boolean?, strokeK: number?): TextLabel +-- 글자. outline을 주면 흰 글자 + 그 색 외곽선(색 바탕용), 없으면 진한 자두색 글자(흰 바탕용). +function Theme.text(parent: Instance, name: string, outline: Color3?, numeric: boolean?): TextLabel local t = Instance.new("TextLabel") t.Name = name t.BackgroundTransparency = 1 - t.FontFace = Theme.FONT + t.FontFace = if numeric then Theme.NUM else Theme.FONT t.TextScaled = true t.TextWrapped = true t.AutoLocalize = false t.Text = "" - t.TextColor3 = if dark then Theme.INK else Theme.WHITE - if not dark then - Theme.stroke(t, Theme.INK, strokeK or 2.5, true) + if outline then + t.TextColor3 = Theme.WHITE + Theme.stroke(t, outline, 2.5, true) + else + t.TextColor3 = Theme.TEXT end t.Parent = parent return t @@ -100,32 +115,23 @@ function Theme.icon(parent: Instance, name: string, icon: string): ImageLabel return i end +function Theme.kitchen(parent: Instance, name: string, art: string): ImageLabel + local i = Instance.new("ImageLabel") + i.Name = name + i.BackgroundTransparency = 1 + i.ScaleType = Enum.ScaleType.Fit + Icons.applyKitchen(i, art) + i.Parent = parent + return i +end + Theme.setIcon = Icons.apply --- 반짝 지나가는 빛: 같은 모양(둥근 모서리)의 흰 판 위에서 투명도 그러데이션이 왼쪽→오른쪽으로 지나갑니다. -function Theme.shine(face: GuiObject, radius: number, period: number): Tween - local s = Theme.frame(face, "Shine", Theme.WHITE) - s.Size = UDim2.fromScale(1, 1) - s.ZIndex = 6 - Theme.corner(s, radius) - local g = Instance.new("UIGradient") - g.Rotation = 20 - g.Transparency = NumberSequence.new({ - NumberSequenceKeypoint.new(0, 1), - NumberSequenceKeypoint.new(0.42, 1), - NumberSequenceKeypoint.new(0.5, 0.45), - NumberSequenceKeypoint.new(0.58, 1), - NumberSequenceKeypoint.new(1, 1), - }) - g.Offset = Vector2.new(-1, 0) - g.Parent = s - local tw = TweenService:Create( - g, - TweenInfo.new(0.7, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, -1, false, period), - { Offset = Vector2.new(1, 0) } - ) - tw:Play() - return tw +-- 가운데 기준 배치(scale 좌표). 아이콘·그림 놓을 때 씁니다. +function Theme.place(o: GuiObject, x: number, y: number, w: number, h: number) + o.AnchorPoint = Vector2.new(0.5, 0.5) + o.Position = UDim2.fromScale(x, y) + o.Size = UDim2.fromScale(w, h) end export type Button = { @@ -134,12 +140,13 @@ export type Button = { base: Frame, -- 아래 그림자 판(입체감) scale: UIScale, setColor: (Color3) -> (), + color: () -> Color3, } --- 입체 버튼: 아래로 DEPTH만큼 어두운 판이 보이고, 누르면 윗면이 내려가며 살짝 작아집니다. +-- 입체 버튼: 아래로 DEPTH만큼 진한 판이 보이고, 누르면 윗면이 내려가며 살짝 작아집니다. local DEPTH = 5 -function Theme.button(parent: Instance, name: string, color: Color3, radius: number, strokeK: number?): Button +function Theme.button(parent: Instance, name: string, color: Color3, radius: number?): Button local b = Instance.new("TextButton") b.Name = name b.BackgroundTransparency = 1 @@ -150,38 +157,51 @@ function Theme.button(parent: Instance, name: string, color: Color3, radius: num local scale = Instance.new("UIScale") scale.Parent = b - local base = Theme.frame(b, "Base", Theme.darken(color, 0.45)) + local base = Theme.frame(b, "Base", color) base.Size = UDim2.new(1, 0, 1, -DEPTH) base.Position = UDim2.fromOffset(0, DEPTH) - Theme.corner(base, radius) - Theme.stroke(base, Theme.INK, strokeK or 3) - local face = Theme.frame(b, "Face", Theme.WHITE) face.Size = UDim2.new(1, 0, 1, -DEPTH) face.ZIndex = 2 - Theme.corner(face, radius) - Theme.stroke(face, Theme.INK, strokeK or 3) + for _, f in { base, face } do + if radius then + Theme.corner(f, radius) + else + Theme.round(f) + end + end + local baseStroke = Theme.stroke(base, color, 3) + local faceStroke = Theme.stroke(face, color, 3) -- 윗부분 반사광(흰 반투명 띠) local gloss = Theme.frame(face, "Gloss", Theme.WHITE) - gloss.BackgroundTransparency = 0.72 - gloss.Size = UDim2.new(1, -10, 0.36, 0) - gloss.Position = UDim2.fromOffset(5, 4) + gloss.BackgroundTransparency = 0.6 + gloss.AnchorPoint = Vector2.new(0.5, 0) + gloss.Size = UDim2.new(1, -16, 0.3, 0) + gloss.Position = UDim2.new(0.5, 0, 0, 4) gloss.ZIndex = 3 - Theme.corner(gloss, math.max(4, radius - 4)) + if radius then + Theme.corner(gloss, math.max(6, radius - 6)) + else + Theme.round(gloss) + end + local current = color local function setColor(c: Color3) - Theme.gradient(face, Theme.lighten(c, 0.12), Theme.darken(c, 0.12)) - base.BackgroundColor3 = Theme.darken(c, 0.45) + current = c + Theme.gradient(face, Theme.lighten(c, 0.18), c) + base.BackgroundColor3 = Theme.darken(c, 0.3) + baseStroke.Color = Theme.edge(c) + faceStroke.Color = Theme.edge(c) end setColor(color) local down = false local hover = false local function animate() - local target = if down then 0.92 elseif hover then 1.06 else 1 + local target = if down then 0.92 elseif hover then 1.05 else 1 TweenService:Create( scale, - TweenInfo.new(if down then 0.06 else 0.18, if down then Enum.EasingStyle.Quad else Enum.EasingStyle.Back), + TweenInfo.new(if down then 0.06 else 0.2, if down then Enum.EasingStyle.Quad else Enum.EasingStyle.Back), { Scale = target } ):Play() face.Position = UDim2.fromOffset(0, if down then DEPTH - 1 else 0) @@ -207,24 +227,143 @@ function Theme.button(parent: Instance, name: string, color: Color3, radius: num animate() end) - return { button = b, face = face, base = base, scale = scale, setColor = setColor } + return { + button = b, + face = face, + base = base, + scale = scale, + setColor = setColor, + color = function() + return current + end, + } +end + +-- 아이콘 버튼: 둥근 네모 안에 큰 아이콘, 아래에 짧은 이름(테두리에 걸침) +function Theme.iconButton(parent: Instance, name: string, color: Color3, icon: string): (Button, TextLabel, ImageLabel) + local b = Theme.button(parent, name, color, 22) + local ic = Theme.icon(b.face, "Icon", icon) + ic.AnchorPoint = Vector2.new(0.5, 0.5) + ic.Position = UDim2.fromScale(0.5, 0.44) + ic.Size = UDim2.fromScale(0.72, 0.72) + ic.ZIndex = 4 + local label = Theme.text(b.button, "Label", Theme.edge(color)) + label.AnchorPoint = Vector2.new(0.5, 1) + label.Position = UDim2.new(0.5, 0, 1, 2) + label.Size = UDim2.fromScale(1.1, 0.3) + label.ZIndex = 5 + return b, label, ic +end + +-- 글자 버튼 +function Theme.textButton(parent: Instance, name: string, color: Color3, radius: number?): (Button, TextLabel) + local b = Theme.button(parent, name, color, radius) + local label = Theme.text(b.face, "Label", Theme.edge(color)) + label.Size = UDim2.new(1, -18, 0.62, 0) + label.Position = UDim2.fromScale(0.5, 0.5) + label.AnchorPoint = Vector2.new(0.5, 0.5) + label.ZIndex = 4 + local function recolor(c: Color3) + local s = label:FindFirstChildOfClass("UIStroke") + if s then + s.Color = Theme.edge(c) + end + end + local set = b.setColor + b.setColor = function(c: Color3) + set(c) + recolor(c) + end + return b, label end -- 빨간 동그라미 알림 배지(예: 살 수 있는 업그레이드가 있으면 "!") function Theme.badge(parent: Instance, name: string): (Frame, TextLabel) local f = Theme.frame(parent, name, Theme.RED) - f.Size = UDim2.fromOffset(30, 30) + f.Size = UDim2.fromOffset(28, 28) f.AnchorPoint = Vector2.new(0.5, 0.5) - f.Position = UDim2.new(1, -12, 0, 12) + f.Position = UDim2.new(1, -6, 0, 6) f.ZIndex = 8 - Theme.corner(f, 1, 1) - Theme.stroke(f, Theme.INK, 2.5) - Theme.gradient(f, Color3.fromRGB(255, 110, 90), Color3.fromRGB(220, 40, 30)) - local t = Theme.text(f, "Text", false, 2) - t.Size = UDim2.new(1, -6, 1, -6) - t.Position = UDim2.fromOffset(3, 3) + Theme.round(f) + Theme.stroke(f, Theme.WHITE, 3) + local t = Theme.text(f, "Text", Theme.edge(Theme.RED), true) + t.Size = UDim2.new(1, -8, 1, -8) + t.Position = UDim2.fromOffset(4, 4) t.ZIndex = 9 return f, t end +-- 둥실둥실(위아래로 살짝) 움직임. 지금 누를 수 있는 것에만 씁니다. +function Theme.bob(o: GuiObject, pixels: number, period: number): Tween + local p = o.Position + local tw = TweenService:Create( + o, + TweenInfo.new(period / 2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), + { Position = p + UDim2.fromOffset(0, -pixels) } + ) + tw:Play() + return tw +end + +-- 통 튀기(크기). UIScale이 있는 것에 씁니다. +function Theme.pop(o: Instance, from: number?) + local s = o:FindFirstChildOfClass("UIScale") + if s then + s.Scale = from or 0.6 + TweenService:Create(s, TweenInfo.new(0.32, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }) + :Play() + end +end + +-- 창 틀: 흰 본문(아주 둥근 모서리) + 위쪽 색 띠에 가운데 제목 + 오른쪽 위 빨간 동그라미 X. +export type Panel = { + frame: Frame, + body: Frame, + title: TextLabel, + close: Button, + headerH: number, +} + +function Theme.panel(parent: Instance, name: string, color: Color3): Panel + local headerH = 58 + local p = Theme.frame(parent, name) + p.Visible = false + p.ZIndex = 20 + local scale = Instance.new("UIScale") + scale.Parent = p + local body = Theme.frame(p, "Body", Theme.CREAM) + body.Size = UDim2.fromScale(1, 1) + body.ZIndex = 2 + Theme.corner(body, 30) + Theme.stroke(body, Theme.edge(color), 4) + local header = Theme.frame(body, "Header", color) + header.Size = UDim2.new(1, 0, 0, headerH) + header.ZIndex = 2 + Theme.corner(header, 30) + Theme.gradient(header, Theme.lighten(color, 0.15), color) + -- 띠 아래쪽 모서리는 각지게(본문과 이어지게) + local fill = Theme.frame(header, "Fill", color) + fill.Position = UDim2.new(0, 0, 1, -30) + fill.Size = UDim2.new(1, 0, 0, 30) + fill.ZIndex = 2 + Theme.gradient(fill, color, color) + local title = Theme.text(header, "Title", Theme.edge(color)) + title.AnchorPoint = Vector2.new(0.5, 0.5) + title.Position = UDim2.fromScale(0.5, 0.5) + title.Size = UDim2.new(0.6, 0, 0, 38) + title.ZIndex = 4 + local close = Theme.button(p, "Close", Theme.RED) + close.button.AnchorPoint = Vector2.new(0.5, 0.5) + -- 색 띠 오른쪽 안에(화면 밖으로 안 나가게). 크기는 Layout.rows.closeH + close.button.Size = UDim2.fromOffset(48, 48) + close.button.Position = UDim2.new(1, -36, 0, headerH / 2) + close.button.ZIndex = 6 + local x = Theme.icon(close.face, "X", "close") + x.Size = UDim2.fromScale(0.6, 0.6) + x.AnchorPoint = Vector2.new(0.5, 0.5) + x.Position = UDim2.fromScale(0.5, 0.5) + x.ZIndex = 4 + return { frame = p, body = body, title = title, close = close, headerH = headerH } +end + return Theme diff --git a/bunsik-tycoon/src/server/Build.luau b/bunsik-tycoon/src/server/Build.luau index aee6888..668b6d2 100644 --- a/bunsik-tycoon/src/server/Build.luau +++ b/bunsik-tycoon/src/server/Build.luau @@ -1,6 +1,8 @@ --!strict -- 파트로 모형을 만드는 작은 도구. Union은 Place Publishing API로 못 올리므로 Part 조합만 씁니다. +local Icons = require(game:GetService("ReplicatedStorage").Shared.Icons) + local Build = {} export type PartProps = { @@ -136,6 +138,45 @@ function Build.billboard(adornee: Instance, text: string, size: UDim2, offset: V return gui end +-- 손님 주문 말풍선: 흰 동그라미 안에 직접 그린 음식 그림(글을 못 읽어도 알 수 있게). 다 받으면 하트로 바뀝니다(setBubbleIcon). +function Build.orderBubble(adornee: Instance, menu: string, size: number, offset: Vector3): BillboardGui + local gui = Instance.new("BillboardGui") + gui.Size = UDim2.fromOffset(size, size) + gui.StudsOffset = offset + gui.LightInfluence = 0 + gui.MaxDistance = 120 + gui.Adornee = adornee :: any + gui.Parent = adornee + local bubble = Instance.new("Frame") + bubble.Name = "Bubble" + bubble.Size = UDim2.fromScale(1, 1) + bubble.BackgroundColor3 = Color3.new(1, 1, 1) + bubble.Parent = gui + local corner = Instance.new("UICorner") + corner.CornerRadius = UDim.new(0.5, 0) + corner.Parent = bubble + local stroke = Instance.new("UIStroke") + stroke.Thickness = 3 + stroke.Color = Color3.fromRGB(255, 94, 132) -- 화면 UI 대표 색(Theme.PINK) + stroke.Parent = bubble + local icon = Instance.new("ImageLabel") + icon.Name = "Icon" + icon.BackgroundTransparency = 1 + icon.AnchorPoint = Vector2.new(0.5, 0.5) + icon.Position = UDim2.fromScale(0.5, 0.5) + icon.Size = UDim2.fromScale(0.8, 0.8) + icon.Parent = bubble + Icons.apply(icon, menu) + return gui +end + +function Build.setBubbleIcon(gui: BillboardGui, name: string) + local icon = gui:FindFirstChild("Icon", true) :: ImageLabel? + if icon then + Icons.apply(icon, name) + end +end + -- 모델 전체를 하나로 묶습니다(첫 파트 기준). 손에 들기, 트윈 이동용. function Build.weldAll(model: Model, root: BasePart) for _, d in model:GetDescendants() do diff --git a/bunsik-tycoon/src/server/Game.luau b/bunsik-tycoon/src/server/Game.luau index 9ccaa4c..f3c08d0 100644 --- a/bunsik-tycoon/src/server/Game.luau +++ b/bunsik-tycoon/src/server/Game.luau @@ -30,6 +30,7 @@ local neighbors: { [number]: Neighbor.Neighbor } = {} -- 플레이어가 없는 local guestAt: { [Player]: PlotController.PlotController } = {} -- 손님으로 앉아 있는 가게 local bonusAt: { [Player]: number } = {} -- 다음 시식 보너스를 받을 수 있는 시각 +local COOK_RANGE = 20 -- 요리 화면에서 만든 접시는 조리대에서 이만큼 안에 있어야 받습니다 local VISIT_RANGE = 16 -- 입구에서 이만큼 안에 있어야 손님으로 들어갈 수 있습니다 local Remotes = ReplicatedStorage:WaitForChild("Remotes") @@ -258,11 +259,16 @@ local function onAction(player: Player, kind: any, arg: any) return end if kind == "cook" then - -- 버튼을 누르고 있는 시간만큼은 지나야 다음 접시를 만들 수 있습니다. + -- 요리 화면에서 다 만들었을 때(arg = 고른 메뉴). 요리 과정을 아주 빨리 해도 걸리는 시간은 지나야 다음 접시를 만들 수 있고, + -- 조리대 가까이 있어야 합니다. local now = os.clock() - if now - controller.lastCook >= controller.shop.stats.cook * 0.8 then + local menu = if typeof(arg) == "string" and Economy.MENUS[arg] then arg else nil + local char = player.Character + local root = char and char:FindFirstChild("HumanoidRootPart") :: BasePart? + local near = not root or (root.Position - controller.slot.refs.stove.Position).Magnitude <= COOK_RANGE + if menu and near and now - controller.lastCook >= controller.shop.stats.cook * 0.4 then controller.shop.now = now - controller:cook() + controller:cook(menu) end elseif kind == "buy" then local ok, err = controller:buy() diff --git a/bunsik-tycoon/src/server/PlotBuilder.luau b/bunsik-tycoon/src/server/PlotBuilder.luau index 9243501..d77582d 100644 --- a/bunsik-tycoon/src/server/PlotBuilder.luau +++ b/bunsik-tycoon/src/server/PlotBuilder.luau @@ -456,7 +456,7 @@ local function buildMenuStand(parent: Instance, cf: CFrame, menu: string, slot: end local dish = Food.dish(menu, at(0.9, 3.2, 0), m) dish.Name = "Display" - local icon = Build.billboard(stand, Economy.MENUS[menu].icon, UDim2.fromOffset(56, 56), Vector3.new(0, 4.6, 0)) + local icon = Build.orderBubble(stand, menu, 56, Vector3.new(0, 4.6, 0)) icon.Name = "MenuIcon" icon.MaxDistance = 70 end diff --git a/bunsik-tycoon/src/server/PlotController.luau b/bunsik-tycoon/src/server/PlotController.luau index f76e9b7..efdd7b6 100644 --- a/bunsik-tycoon/src/server/PlotController.luau +++ b/bunsik-tycoon/src/server/PlotController.luau @@ -175,11 +175,13 @@ function PlotController.sync(self: PlotController) o:SetAttribute("Tut", self.tut) o:SetAttribute("Plot", self.slot.index) o:SetAttribute("Carry", #shop.hand) + o:SetAttribute("Hand", table.concat(shop.hand, ",")) o:SetAttribute("Earned", self.data.Earned or 0) self.slot.model:SetAttribute("Level", shop.bought) end --- 조리대 속성: CookMenu(만들 메뉴, 없으면 ""), CookTime(누르는 시간), HandFull +-- 조리대 속성: CookMenu(먼저 만들 메뉴, 없으면 ""), CookTime(화구 수준), HandFull +-- 주인 속성 Orders: 요리 화면에 보여 줄 메뉴별 주문 수("Tteokbokki=2,Gimbap=1", 메뉴 순서대로) function PlotController.refreshPrompt(self: PlotController) local shop = self.shop local stove = self.slot.refs.stove @@ -188,6 +190,14 @@ function PlotController.refreshPrompt(self: PlotController) stove:SetAttribute("CookMenu", menu or "") stove:SetAttribute("CookTime", shop.stats.cook) stove:SetAttribute("HandFull", full) + local counts = Shop.openCounts(shop) + local parts = {} + for _, m in Economy.MENU_ORDER do + if counts[m] then + table.insert(parts, `{m}={counts[m]}`) + end + end + self.owner:SetAttribute("Orders", table.concat(parts, ",")) end function PlotController.refreshHelper(self: PlotController) @@ -302,8 +312,8 @@ function PlotController.updateGuide(self: PlotController) end end -function PlotController.cook(self: PlotController): string? - local menu = Shop.cook(self.shop) +function PlotController.cook(self: PlotController, choice: string?): string? + local menu = Shop.cook(self.shop, choice) if not menu then return nil end @@ -386,10 +396,7 @@ function PlotController.serve(self: PlotController, id: number): number? end self:layoutHand() if view then - local label = view.bubble:FindFirstChild("Text") :: TextLabel? - if label then - label.Text = "😋" - end + Build.setBubbleIcon(view.bubble, "heart") local anchor = if view.npc then view.npc.root else view.seat if anchor then floatText(anchor, "+" .. Locale.number(earn)) @@ -423,8 +430,7 @@ function PlotController.onEvent(self: PlotController, e: Shop.Event) end local npc = Npc.spawn(self.slot.refs.dynamic, CFrame.new(path[1]), self.rng) npc.root.CFrame = Npc.standCFrame(npc, path[1], path[2]) - local icon = Economy.MENUS[e.menu].icon - local bubble = Build.billboard(npc.root, icon, UDim2.fromOffset(70, 70), Vector3.new(0, 4, 0)) + local bubble = Build.orderBubble(npc.root, e.menu, 64, Vector3.new(0, 4, 0)) bubble.Name = "Order" self.views[e.id] = { npc = npc, seat = nil, bubble = bubble, dish = nil } Npc.walk(npc, path, Economy.WALK_IN) @@ -559,7 +565,7 @@ function PlotController.addGuest(self: PlotController, userId: number, character seat.Size = Vector3.new(2, 0.4, 2) seat.CFrame = PlotBuilder.seatCFrame(self.slot.cf, c.seat) * CFrame.new(0, 0.2, 0) seat.Parent = self.slot.refs.dynamic - local bubble = Build.billboard(seat, Economy.MENUS[c.menu].icon, UDim2.fromOffset(70, 70), Vector3.new(0, 5, 0)) + local bubble = Build.orderBubble(seat, c.menu, 64, Vector3.new(0, 5, 0)) bubble.Name = "Order" self.views[c.id] = { npc = nil, seat = seat, bubble = bubble, dish = nil } seat:Sit(humanoid) diff --git a/bunsik-tycoon/src/shared/Economy.luau b/bunsik-tycoon/src/shared/Economy.luau index 1df295e..7c489ce 100644 --- a/bunsik-tycoon/src/shared/Economy.luau +++ b/bunsik-tycoon/src/shared/Economy.luau @@ -60,9 +60,9 @@ Economy.START = { } Economy.MENUS = { - Tteokbokki = { price = 10, icon = "🌶️" }, - Gimbap = { price = 20, icon = "🍙" }, - Sundae = { price = 35, icon = "🌭" }, + Tteokbokki = { price = 15, icon = "🌶️" }, + Gimbap = { price = 25, icon = "🍙" }, + Sundae = { price = 40, icon = "🌭" }, Eomuk = { price = 50, icon = "🍢" }, Twigim = { price = 70, icon = "🍤" }, } :: { [string]: Menu } diff --git a/bunsik-tycoon/src/shared/Icons.luau b/bunsik-tycoon/src/shared/Icons.luau index c8a08c5..03fde4b 100644 --- a/bunsik-tycoon/src/shared/Icons.luau +++ b/bunsik-tycoon/src/shared/Icons.luau @@ -1,11 +1,15 @@ --!strict --- 화면 UI 아이콘. 그림 한 장(art/ui_icons.png, tools/icons.py로 직접 그림)을 128px 칸으로 잘라 씁니다. --- 칸 순서를 바꾸면 tools/icons.py --luau 출력으로 아래 표를 다시 맞추고, 그림을 새로 올려 ASSET을 바꿉니다. +-- 화면 UI 그림. 직접 그린 그림 두 장을 칸으로 잘라 씁니다. +-- ASSET(art/ui_icons.png, tools/icons.py): 128px 칸 8x8. 버튼 아이콘, 메뉴, 요리 재료·도구 +-- KITCHEN_ASSET(art/kitchen.png, tools/kitchen_art.py): 256px 칸 4x4. 조리 도구(팬·도마·찜기·냄비·튀김기), 마스코트 떡이 +-- 칸 순서를 바꾸면 각 도구의 --luau 출력으로 아래 표를 다시 맞추고, 그림을 새로 올려(tools/cloud.py image) ID를 바꿉니다. local Icons = {} -Icons.ASSET = "rbxassetid://89649261251254" +Icons.ASSET = "rbxassetid://111384470366371" Icons.CELL = Vector2.new(128, 128) +Icons.KITCHEN_ASSET = "rbxassetid://118704012792360" +Icons.KITCHEN_CELL = Vector2.new(256, 256) Icons.OFFSET = { coin = Vector2.new(0, 0), @@ -40,6 +44,44 @@ Icons.OFFSET = { arrowDown = Vector2.new(640, 384), scroll = Vector2.new(768, 384), hand = Vector2.new(896, 384), + riceCake = Vector2.new(0, 512), + riceCakeRed = Vector2.new(128, 512), + riceCakes = Vector2.new(256, 512), + sauceBowl = Vector2.new(384, 512), + sauceBlob = Vector2.new(512, 512), + spatula = Vector2.new(640, 512), + bubble = Vector2.new(768, 512), + steam = Vector2.new(896, 512), + fillings = Vector2.new(0, 640), + mat = Vector2.new(128, 640), + knife = Vector2.new(256, 640), + gimbapSlice = Vector2.new(384, 640), + sundaeRaw = Vector2.new(512, 640), + sundaePiece = Vector2.new(640, 640), + sundaeSlice = Vector2.new(768, 640), + fishCake = Vector2.new(896, 640), + batter = Vector2.new(0, 768), + shrimpRaw = Vector2.new(128, 768), + shrimpBatter = Vector2.new(256, 768), + tongs = Vector2.new(384, 768), + customer = Vector2.new(512, 768), + mascot = Vector2.new(640, 768), + heart = Vector2.new(768, 768), + cart = Vector2.new(896, 768), + pot = Vector2.new(0, 896), +} :: { [string]: Vector2 } + +Icons.KITCHEN = { + pan = Vector2.new(0, 0), + board = Vector2.new(256, 0), + steamer = Vector2.new(512, 0), + pot = Vector2.new(768, 0), + fryer = Vector2.new(0, 256), + mascot = Vector2.new(256, 256), + mascotCheer = Vector2.new(512, 256), + gimbapRoll = Vector2.new(768, 256), + plateBig = Vector2.new(0, 512), + burst = Vector2.new(256, 512), } :: { [string]: Vector2 } -- ImageLabel/ImageButton에 아이콘을 씌웁니다. @@ -49,4 +91,11 @@ function Icons.apply(image: ImageLabel, name: string) image.ImageRectSize = Icons.CELL end +-- 큰 요리 그림(조리 도구, 마스코트) +function Icons.applyKitchen(image: ImageLabel, name: string) + image.Image = Icons.KITCHEN_ASSET + image.ImageRectOffset = Icons.KITCHEN[name] or Vector2.zero + image.ImageRectSize = Icons.KITCHEN_CELL +end + return Icons diff --git a/bunsik-tycoon/src/shared/Locale.luau b/bunsik-tycoon/src/shared/Locale.luau index 0cf370f..e7205e3 100644 --- a/bunsik-tycoon/src/shared/Locale.luau +++ b/bunsik-tycoon/src/shared/Locale.luau @@ -20,11 +20,34 @@ local STRINGS: { [string]: { [string]: string } } = { nextUp = "다음 업그레이드", doubleOn = "적용 중", close = "닫기", - cookAction = "{menu} 만들기", + cookAction = "요리하기", + cook_Twigim_3 = "집게로 건져요", + cook_Twigim_2 = "기름에 바삭하게 튀겨요", + cook_Twigim_1 = "새우에 튀김옷을 입혀요", + cook_Eomuk_2 = "국물에 퐁당 담가요", + cook_Eomuk_1 = "어묵을 꼬치에 끼워요", + cook_Sundae_3 = "먹기 좋게 썰어요", + cook_Sundae_2 = "김이 나게 푹 쪄요", + cook_Sundae_1 = "순대를 찜기에 넣어요", + cook_Gimbap_3 = "송송 썰어요", + cook_Gimbap_2 = "돌돌 말아요", + cook_Gimbap_1 = "김 위에 재료를 올려요", + cook_Tteokbokki_3 = "주걱으로 휘휘 저어요", + cook_Tteokbokki_2 = "빨간 양념을 부어요", + cook_Tteokbokki_1 = "떡을 팬에 넣어요", + gestureRub = "문질문질!", + gestureHold = "꾹 누르고 있기", + gestureTap = "톡톡! {n}번", + cookDone = "완성!", + chooseMenu = "무엇을 만들까요? 손님이 주문한 걸 골라요!", + cookTitle = "요리하기", + btnBoost = "부스트", + btnDouble = "2배 돈", + btnShop = "상점", cookWait = "손님 기다리는 중", - cookHandFull = "손이 꽉 찼어요", + cookHandFull = "손이 꽉 찼어요! 먼저 손님에게 가져다줘요", stoveObject = "조리대", - tut1 = "손님이 왔어요! 빛나는 조리대로 가서 버튼을 꾹 누르세요", + tut1 = "손님이 왔어요! 빛나는 조리대로 가서 요리를 시작해요", tut2 = "다 만들었어요! 접시를 손님 자리로 가져가세요", tut3 = "돈을 벌었어요! 아래 [사기] 버튼으로 테이블을 사세요", tutDone = "잘했어요! 계속 손님을 받고 가게를 키워 보세요", @@ -111,11 +134,34 @@ local STRINGS: { [string]: { [string]: string } } = { nextUp = "Next Upgrade", doubleOn = "Active", close = "Close", - cookAction = "Cook {menu}", + cookAction = "Cook", + cook_Twigim_3 = "Pick it up with the tongs", + cook_Twigim_2 = "Fry it until crispy", + cook_Twigim_1 = "Coat the shrimp in batter", + cook_Eomuk_2 = "Dip it in the hot soup", + cook_Eomuk_1 = "Put the fish cake on the skewer", + cook_Sundae_3 = "Slice it up", + cook_Sundae_2 = "Steam it nice and hot", + cook_Sundae_1 = "Put the sundae in the steamer", + cook_Gimbap_3 = "Slice it", + cook_Gimbap_2 = "Roll it up", + cook_Gimbap_1 = "Put fillings on the seaweed", + cook_Tteokbokki_3 = "Stir it with the spatula", + cook_Tteokbokki_2 = "Pour in the red sauce", + cook_Tteokbokki_1 = "Put the rice cakes in the pan", + gestureRub = "Rub rub!", + gestureHold = "Press and hold", + gestureTap = "Tap! x{n}", + cookDone = "Done!", + chooseMenu = "What shall we cook? Pick what a customer ordered!", + cookTitle = "Cooking", + btnBoost = "Boost", + btnDouble = "2x Cash", + btnShop = "Shop", cookWait = "Waiting for customers", - cookHandFull = "Hands are full", + cookHandFull = "Hands are full! Serve the customer first", stoveObject = "Stove", - tut1 = "A customer is here! Go to the glowing stove and hold the button", + tut1 = "A customer is here! Go to the glowing stove and start cooking", tut2 = "Done! Bring the dish to the customer's seat", tut3 = "You earned money! Tap [Buy] at the bottom to get a table", tutDone = "Great job! Keep serving and grow your shop", @@ -202,11 +248,34 @@ local STRINGS: { [string]: { [string]: string } } = { nextUp = "次のアップグレード", doubleOn = "適用中", close = "閉じる", - cookAction = "{menu}を作る", + cookAction = "料理する", + cook_Twigim_3 = "トングで取り出そう", + cook_Twigim_2 = "カリッと揚げよう", + cook_Twigim_1 = "エビに衣をつけよう", + cook_Eomuk_2 = "スープにつけよう", + cook_Eomuk_1 = "おでんを串にさそう", + cook_Sundae_3 = "食べやすく切ろう", + cook_Sundae_2 = "ほかほかに蒸そう", + cook_Sundae_1 = "スンデを蒸し器に入れよう", + cook_Gimbap_3 = "トントン切ろう", + cook_Gimbap_2 = "くるくる巻こう", + cook_Gimbap_1 = "のりの上に具をのせよう", + cook_Tteokbokki_3 = "ヘラでぐるぐる混ぜよう", + cook_Tteokbokki_2 = "赤いタレをかけよう", + cook_Tteokbokki_1 = "おもちをフライパンに入れよう", + gestureRub = "こすこす!", + gestureHold = "長押し", + gestureTap = "タップ!{n}回", + cookDone = "できた!", + chooseMenu = "何を作る?お客さんの注文を選んでね!", + cookTitle = "料理する", + btnBoost = "ブースト", + btnDouble = "2倍", + btnShop = "ショップ", cookWait = "お客さんを待っています", - cookHandFull = "手がいっぱいです", + cookHandFull = "手がいっぱい!先にお客さんに運んでね", stoveObject = "コンロ", - tut1 = "お客さんが来たよ!光っているコンロに行って、ボタンを長押ししてね", + tut1 = "お客さんが来たよ!光っているコンロに行って料理を始めよう", tut2 = "できた!お皿をお客さんの席まで運んでね", tut3 = "お金をかせいだよ!下の[買う]ボタンでテーブルを買ってね", tutDone = "よくできました!お客さんを迎えて、お店を大きくしよう", @@ -293,11 +362,34 @@ local STRINGS: { [string]: { [string]: string } } = { nextUp = "下一个升级", doubleOn = "已生效", close = "关闭", - cookAction = "制作{menu}", + cookAction = "做菜", + cook_Twigim_3 = "用夹子夹出来", + cook_Twigim_2 = "炸得脆脆的", + cook_Twigim_1 = "给虾裹上面糊", + cook_Eomuk_2 = "放进汤里泡一泡", + cook_Eomuk_1 = "把鱼饼串到签子上", + cook_Sundae_3 = "切成小块", + cook_Sundae_2 = "热乎乎地蒸", + cook_Sundae_1 = "把米肠放进蒸锅", + cook_Gimbap_3 = "切成片", + cook_Gimbap_2 = "卷起来", + cook_Gimbap_1 = "在紫菜上放馅料", + cook_Tteokbokki_3 = "用铲子搅一搅", + cook_Tteokbokki_2 = "倒入红色酱料", + cook_Tteokbokki_1 = "把年糕放进锅里", + gestureRub = "来回搓!", + gestureHold = "按住不放", + gestureTap = "点一点!{n}次", + cookDone = "完成!", + chooseMenu = "做什么呢?选客人点的菜吧!", + cookTitle = "做菜", + btnBoost = "加速", + btnDouble = "双倍", + btnShop = "商店", cookWait = "等待客人中", - cookHandFull = "手里拿满了", + cookHandFull = "手里拿满了!先端给客人吧", stoveObject = "灶台", - tut1 = "客人来了!走到发光的灶台,按住按钮", + tut1 = "客人来了!走到发光的灶台开始做菜吧", tut2 = "做好了!把盘子端到客人的座位上", tut3 = "赚到钱了!点下面的[购买]按钮买一张桌子", tutDone = "做得好!继续招待客人,把店做大吧", diff --git a/bunsik-tycoon/src/shared/Recipes.luau b/bunsik-tycoon/src/shared/Recipes.luau new file mode 100644 index 0000000..a97fe22 --- /dev/null +++ b/bunsik-tycoon/src/shared/Recipes.luau @@ -0,0 +1,188 @@ +--!strict +-- 메뉴별 조리 과정(요리 화면의 단계)과 진행 상태 기계. 로블록스 API를 쓰지 않아서 lune 테스트와 시뮬레이터에서 그대로 씁니다. +-- 단계 종류(모두 실패 없음, 어린아이도 끝까지 할 수 있게): +-- tap = 재료를 톡톡 누르기(need번) +-- hold = 꾹 누르고 있기(need초) +-- rub = 손가락·마우스로 문지르기(이동 거리 need × RUB_UNIT 기준 단위) +-- "화구" 업그레이드(stats.cook 2.5 → 1.5 → 1)를 사면 누르는 횟수·시간이 같은 비율로 줄어듭니다. + +local Recipes = {} + +export type StepKind = "tap" | "hold" | "rub" + +export type Step = { + kind: StepKind, + key: string, -- 안내 글 Locale 키(cook_<메뉴>_<번호>) + base: number, -- 화구 Lv0 기준 횟수·초·문지르기 양 + tool: string, -- 누르는 물건 그림(Kitchen 그림 이름) +} + +export type Recipe = { + stage: string, -- 조리 도구 그림(팬, 도마, 찜기, 냄비, 튀김기) + steps: { Step }, +} + +Recipes.BASE_COOK = 2.5 -- Economy.START.cook과 같음 +Recipes.RUB_UNIT = 260 -- 문지르기 1번 = 기준 단위 260만큼 움직이기 + +Recipes.LIST = { + Tteokbokki = { + stage = "pan", + steps = { + { kind = "tap", key = "cook_Tteokbokki_1", base = 4, tool = "riceCakes" }, + { kind = "hold", key = "cook_Tteokbokki_2", base = 1.0, tool = "sauceBowl" }, + { kind = "rub", key = "cook_Tteokbokki_3", base = 3, tool = "spatula" }, + }, + }, + Gimbap = { + stage = "board", + steps = { + { kind = "tap", key = "cook_Gimbap_1", base = 4, tool = "fillings" }, + { kind = "rub", key = "cook_Gimbap_2", base = 3, tool = "roll" }, + { kind = "tap", key = "cook_Gimbap_3", base = 4, tool = "knife" }, + }, + }, + Sundae = { + stage = "steamer", + steps = { + { kind = "tap", key = "cook_Sundae_1", base = 3, tool = "sundaeRaw" }, + { kind = "hold", key = "cook_Sundae_2", base = 1.2, tool = "fire" }, + { kind = "tap", key = "cook_Sundae_3", base = 4, tool = "knife" }, + }, + }, + Eomuk = { + stage = "pot", + steps = { + { kind = "tap", key = "cook_Eomuk_1", base = 4, tool = "fishCake" }, + { kind = "hold", key = "cook_Eomuk_2", base = 1.4, tool = "skewer" }, + }, + }, + Twigim = { + stage = "fryer", + steps = { + { kind = "rub", key = "cook_Twigim_1", base = 3, tool = "batter" }, + { kind = "hold", key = "cook_Twigim_2", base = 1.2, tool = "fire" }, + { kind = "tap", key = "cook_Twigim_3", base = 3, tool = "tongs" }, + }, + }, +} :: { [string]: Recipe } + +-- 화구 수준에 맞춘 단계 목표(횟수는 정수, 최소 2번) +function Recipes.need(step: Step, cook: number): number + local k = cook / Recipes.BASE_COOK + if step.kind == "tap" then + return math.max(2, math.floor(step.base * k + 0.5)) + end + return step.base * k +end + +-- 시뮬레이터용: 아이가 쉬지 않고 했을 때 걸리는 시간(초). 메뉴 고르기·완성 연출 포함. +Recipes.TIME_TAP = 0.3 -- 한 번 누르는 데 +Recipes.TIME_RUB = 0.35 -- 문지르기 1번에 +Recipes.TIME_STEP = 0.4 -- 단계가 바뀔 때 안내를 보는 시간 +Recipes.TIME_CHOOSE = 1.0 -- 조리대 버튼 + 메뉴 고르기 +Recipes.TIME_DONE = 0.6 -- "완성!" 연출 + +function Recipes.expectedTime(menu: string, cook: number): number + local r = Recipes.LIST[menu] + local t = Recipes.TIME_CHOOSE + Recipes.TIME_DONE + for _, s in r.steps do + local n = Recipes.need(s, cook) + t += Recipes.TIME_STEP + if s.kind == "tap" then + t += n * Recipes.TIME_TAP + elseif s.kind == "rub" then + t += n * Recipes.TIME_RUB + else + t += n + end + end + return t +end + +-- 요리 화면 한 번의 진행 상태 +export type Phase = "menu" | "cook" | "done" +export type Flow = { + phase: Phase, + cook: number, -- 화구 수준(stats.cook) + menu: string?, + step: number, -- 지금 단계(1부터) + progress: number, -- 지금 단계 진행량(0 ~ need) + need: number, +} + +function Recipes.newFlow(cook: number): Flow + return { phase = "menu", cook = cook, menu = nil, step = 0, progress = 0, need = 0 } +end + +function Recipes.current(flow: Flow): Step? + local r = flow.menu and Recipes.LIST[flow.menu] + return r and r.steps[flow.step] +end + +local function startStep(flow: Flow, i: number) + local r = Recipes.LIST[flow.menu :: string] + flow.step = i + flow.progress = 0 + local s = r.steps[i] + flow.need = if s then Recipes.need(s, flow.cook) else 0 +end + +-- 메뉴를 고르면 첫 단계부터 시작합니다. +function Recipes.choose(flow: Flow, menu: string): boolean + if flow.phase ~= "menu" or not Recipes.LIST[menu] then + return false + end + flow.menu = menu + flow.phase = "cook" + startStep(flow, 1) + return true +end + +-- 입력을 넣습니다. kind가 지금 단계와 다르면 무시합니다. +-- 돌려주는 값: nil(무시), "progress", "step"(다음 단계로), "done"(완성) +function Recipes.input(flow: Flow, kind: StepKind, amount: number): string? + if flow.phase ~= "cook" then + return nil + end + local s = Recipes.current(flow) + if not s or s.kind ~= kind or amount <= 0 then + return nil + end + flow.progress = math.min(flow.need, flow.progress + amount) + if flow.progress < flow.need - 1e-9 then + return "progress" + end + local r = Recipes.LIST[flow.menu :: string] + if flow.step >= #r.steps then + flow.phase = "done" + return "done" + end + startStep(flow, flow.step + 1) + return "step" +end + +-- 완성 뒤 다음 접시를 만들 때(메뉴 고르기로 돌아감) +function Recipes.reset(flow: Flow, cook: number) + flow.phase = "menu" + flow.cook = cook + flow.menu = nil + flow.step = 0 + flow.progress = 0 + flow.need = 0 +end + +-- 지금 단계까지 포함한 전체 진행률(0~1). 위쪽 단계 표시에 씁니다. +function Recipes.fraction(flow: Flow): number + local r = flow.menu and Recipes.LIST[flow.menu] + if not r then + return 0 + end + if flow.phase == "done" then + return 1 + end + local part = if flow.need > 0 then flow.progress / flow.need else 0 + return ((flow.step - 1) + part) / #r.steps +end + +return Recipes diff --git a/bunsik-tycoon/src/shared/Shop.luau b/bunsik-tycoon/src/shared/Shop.luau index 1a33037..9e66085 100644 --- a/bunsik-tycoon/src/shared/Shop.luau +++ b/bunsik-tycoon/src/shared/Shop.luau @@ -121,6 +121,15 @@ function Shop.nextCookMenu(self: Shop): string? return if open[1] then open[1].menu else nil end +-- 메뉴별로 아직 접시가 정해지지 않은 주문 수(요리 화면의 "주문" 표시) +function Shop.openCounts(self: Shop): { [string]: number } + local counts = {} + for _, c in Shop.openOrders(self) do + counts[c.menu] = (counts[c.menu] or 0) + 1 + end + return counts +end + function Shop.handFull(self: Shop): boolean return #self.hand >= self.stats.carry end @@ -176,12 +185,19 @@ function Shop.tick(self: Shop, now: number): { Event } return events end --- 플레이어가 조리대에서 다 만들었을 때. 만든 메뉴를 돌려줍니다. -function Shop.cook(self: Shop): string? +-- 플레이어가 요리 화면에서 다 만들었을 때. 만든 메뉴를 돌려줍니다. +-- menu를 주면 그 메뉴를 기다리는 주문이 있을 때만 만들고, 없으면 먼저 온 손님 메뉴를 만듭니다. +function Shop.cook(self: Shop, menu: string?): string? if Shop.handFull(self) then return nil end - local menu = Shop.nextCookMenu(self) + if menu then + if not Shop.openCounts(self)[menu] then + return nil + end + else + menu = Shop.nextCookMenu(self) + end if menu then table.insert(self.hand, menu) end diff --git a/bunsik-tycoon/src/shared/Sounds.luau b/bunsik-tycoon/src/shared/Sounds.luau index de677eb..2a22694 100644 --- a/bunsik-tycoon/src/shared/Sounds.luau +++ b/bunsik-tycoon/src/shared/Sounds.luau @@ -6,4 +6,5 @@ return { COIN = "rbxassetid://96594483709547", -- 서빙하고 돈 받을 때 BUY = "rbxassetid://90178922626515", -- 업그레이드 구매, 돈 부스트 LEVELUP = "rbxassetid://134931950463198", -- 실내 분식집 확장 + POP = "rbxassetid://114946217416724", -- 요리 화면에서 톡톡 누를 때 } diff --git a/bunsik-tycoon/tests/Economy.spec.luau b/bunsik-tycoon/tests/Economy.spec.luau index c801f90..406a132 100644 --- a/bunsik-tycoon/tests/Economy.spec.luau +++ b/bunsik-tycoon/tests/Economy.spec.luau @@ -46,9 +46,9 @@ T.eq(Economy.statsAt(99).seats, 8, "범위를 넘어도 안전") Economy.statsAt(20) T.eq(#Economy.START.menus, 1, "START.menus 불변") -T.eq(Economy.dishPrice("Tteokbokki", s0, 1), 10, "떡볶이 10") -T.eq(Economy.dishPrice("Sundae", Economy.statsAt(7), 1), 52, "순대 35 x 1.5 = 52(내림)") -T.eq(Economy.dishPrice("Tteokbokki", s0, 2), 20, "2배 수익") +T.eq(Economy.dishPrice("Tteokbokki", s0, 1), 15, "떡볶이 15") +T.eq(Economy.dishPrice("Gimbap", Economy.statsAt(7), 1), 37, "김밥 25 x 1.5 = 37(내림)") +T.eq(Economy.dishPrice("Tteokbokki", s0, 2), 30, "2배 수익") T.eq( Economy.boostAmount(s0), diff --git a/bunsik-tycoon/tests/Layout.spec.luau b/bunsik-tycoon/tests/Layout.spec.luau index d1381ac..d0f69f0 100644 --- a/bunsik-tycoon/tests/Layout.spec.luau +++ b/bunsik-tycoon/tests/Layout.spec.luau @@ -74,6 +74,21 @@ for _, d in DEVICES do -- 창(업그레이드 목록, 설정)은 화면 안에 다 들어감 T.check(inside(L.panel, L.width, L.height), `{tag}: 업그레이드 창 화면 안`) T.check(inside(L.settingsPanel, L.width, L.height), `{tag}: 설정 창 화면 안`) + T.check(inside(L.kitchen, L.width, L.height), `{tag}: 요리 창 화면 안`) + local g = L.grid + T.check( + g.pad * 2 + g.cols * g.cardW + (g.cols - 1) * g.gap <= L.panel.w + 1e-6, + `{tag}: 상점 카드가 창 너비 안` + ) + T.check( + g.top + g.rows * g.cardH + (g.rows - 1) * g.gap + g.pad <= L.panel.h + 1e-6, + `{tag}: 상점 카드가 창 높이 안` + ) + T.check( + g.cardW * L.scale >= 90 and g.cardH * L.scale >= 90, + `{tag}: 상점 카드가 손가락으로 누를 만큼 큼` + ) + T.check(L.kitchen.w * L.scale >= 0.6 * d.w or L.kitchen.w >= 780, `{tag}: 요리 창이 충분히 큼`) T.eq(L.rows.devY ~= nil, dev, `{tag}: 개발자 줄은 주인에게만`) T.eq(L.rows.mouseY == nil, d.touch, `{tag}: 마우스 회전 줄은 PC만`) @@ -90,7 +105,7 @@ for _, d in DEVICES do local p = px(r, L.scale) T.check(not overlap(p, zones.stick), `{tag}: {name} 버튼이 조이스틱 자리 피함`) T.check(not overlap(p, zones.jump), `{tag}: {name} 버튼이 점프 버튼 자리 피함`) - T.check(p.h >= 36, `{tag}: {name} 버튼 높이 {math.floor(p.h)}px ≥ 36`) + T.check(p.h >= 44, `{tag}: {name} 버튼 높이 {math.floor(p.h)}px ≥ 44(어린이 손가락)`) end T.check(L.rows.langButtonH * L.scale >= 36, `{tag}: 언어 버튼 누르기 쉬움`) T.check(L.rows.toggleH * L.scale >= 34, `{tag}: 켜기/끄기 버튼 누르기 쉬움`) diff --git a/bunsik-tycoon/tests/Locale.spec.luau b/bunsik-tycoon/tests/Locale.spec.luau index 3e00f59..0b09056 100644 --- a/bunsik-tycoon/tests/Locale.spec.luau +++ b/bunsik-tycoon/tests/Locale.spec.luau @@ -2,6 +2,7 @@ local fs = require("@lune/fs") local Economy = require("../src/shared/Economy") local Locale = require("../src/shared/Locale") +local Recipes = require("../src/shared/Recipes") local T = require("./check") local ko = Locale.keys("ko") @@ -19,6 +20,11 @@ for _, lang in Locale.LANGS do for key in Economy.MENUS do T.check(Locale.menuName(lang, key) ~= "menu_" .. key, `{lang} 메뉴 이름 {key}`) end + for _, r in Recipes.LIST do + for _, st in r.steps do + T.check(Locale.t(lang, st.key) ~= st.key, `{lang} 요리 안내 {st.key}`) + end + end for _, p in Economy.PURCHASES do T.check(Locale.itemName(lang, p.id) ~= "item_" .. p.id, `{lang} 업그레이드 이름 {p.id}`) end diff --git a/bunsik-tycoon/tests/Recipes.spec.luau b/bunsik-tycoon/tests/Recipes.spec.luau new file mode 100644 index 0000000..1ffa0ad --- /dev/null +++ b/bunsik-tycoon/tests/Recipes.spec.luau @@ -0,0 +1,74 @@ +-- 요리 과정 검사: lune run tests/Recipes.spec.luau +local Economy = require("../src/shared/Economy") +local Recipes = require("../src/shared/Recipes") +local T = require("./check") + +T.eq(Recipes.BASE_COOK, Economy.START.cook, "기준 화구 수준 = 처음 조리 시간") +for _, menu in Economy.MENU_ORDER do + local r = Recipes.LIST[menu] + T.check(r ~= nil, `{menu} 요리 과정 있음`) + T.check(#r.steps >= 2 and #r.steps <= 3, `{menu} 단계 2~3개`) + local kinds = {} + for i, s in r.steps do + T.eq(s.key, `cook_{menu}_{i}`, `{menu} {i}단계 안내 글 키`) + kinds[s.kind] = true + end + local n = 0 + for _ in kinds do + n += 1 + end + T.check(n >= 2, `{menu}: 단계마다 조작이 달라 지루하지 않음`) + -- 아이가 한 접시에 쓰는 시간: 처음 3~7초, 화구를 다 사면 더 짧아짐 + local t0 = Recipes.expectedTime(menu, 2.5) + local t2 = Recipes.expectedTime(menu, 1) + T.check(t0 >= 3 and t0 <= 7, `{menu} 처음 {t0}초`) + T.check(t2 < t0 * 0.75, `{menu} 화구 Lv2면 {t2}초로 빨라짐`) +end + +-- 서로 다른 메뉴는 과정이 다름 +local seen = {} +for menu, r in Recipes.LIST do + local sig = r.stage + for _, s in r.steps do + sig ..= s.kind .. s.tool + end + T.check(seen[sig] == nil, `{menu} 과정이 다른 메뉴와 같지 않음`) + seen[sig] = true +end + +-- 누르는 횟수는 정수, 최소 2번 +T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 2.5), 4, "화구 Lv0: 4번") +T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 1.5), 2, "화구 Lv1: 2번(2.4 반올림)") +T.eq(Recipes.need({ kind = "tap", key = "", base = 4, tool = "" }, 1), 2, "화구 Lv2: 최소 2번") +T.check( + math.abs(Recipes.need({ kind = "hold", key = "", base = 1, tool = "" }, 1.5) - 0.6) < 1e-9, + "꾹 누르기 0.6초" +) + +-- 진행 상태: 떡볶이(톡톡 4 → 꾹 1초 → 문지르기 3) +local f = Recipes.newFlow(2.5) +T.eq(Recipes.input(f, "tap", 1), nil, "메뉴 고르기 전에는 입력 무시") +T.eq(Recipes.choose(f, "Nope"), false, "없는 메뉴는 못 고름") +T.eq(Recipes.choose(f, "Tteokbokki"), true, "떡볶이 고름") +T.eq(f.phase, "cook", "조리 시작") +T.eq(Recipes.choose(f, "Gimbap"), false, "조리 중에는 다시 못 고름") +T.eq(Recipes.input(f, "hold", 1), nil, "다른 조작은 무시(실패 없음)") +T.eq(Recipes.input(f, "tap", 1), "progress", "톡 1") +T.eq(Recipes.input(f, "tap", 1), "progress", "톡 2") +T.eq(Recipes.input(f, "tap", 1), "progress", "톡 3") +T.eq(Recipes.fraction(f), (0 + 3 / 4) / 3, "전체 진행률") +T.eq(Recipes.input(f, "tap", 1), "step", "톡 4 → 다음 단계") +T.eq(f.step, 2, "2단계") +T.eq(Recipes.input(f, "hold", 0.5), "progress", "꾹 0.5초") +T.eq(Recipes.input(f, "hold", 0.6), "step", "꾹 1초 넘음 → 다음 단계") +T.eq(Recipes.input(f, "rub", 0), nil, "움직임 0은 무시") +T.eq(Recipes.input(f, "rub", 2), "progress", "문지르기 2") +T.eq(Recipes.input(f, "rub", 5), "done", "문지르기 끝 → 완성") +T.eq(f.phase, "done", "완성 상태") +T.eq(Recipes.fraction(f), 1, "완성 진행률 1") +T.eq(Recipes.input(f, "tap", 1), nil, "완성 뒤 입력 무시") +Recipes.reset(f, 1) +T.eq(f.phase, "menu", "다음 접시: 메뉴 고르기로") +T.eq(f.cook, 1, "화구 수준 갱신") + +T.done("Recipes.spec") diff --git a/bunsik-tycoon/tests/Shop.spec.luau b/bunsik-tycoon/tests/Shop.spec.luau index b452768..a8fdddd 100644 --- a/bunsik-tycoon/tests/Shop.spec.luau +++ b/bunsik-tycoon/tests/Shop.spec.luau @@ -28,8 +28,8 @@ T.eq(Shop.cook(s), "Tteokbokki", "조리하면 떡볶이") T.eq(Shop.cook(s), nil, "손이 꽉 차면 더 못 만듦") T.eq(Shop.nextCookMenu(s), nil, "열린 주문 없음") local earn = Shop.serve(s, 1) -T.eq(earn, 10, "떡볶이 10원") -T.eq(s.money, 10, "돈 10") +T.eq(earn, 15, "떡볶이 15원") +T.eq(s.money, 15, "돈 15") T.eq(#s.hand, 0, "접시를 내려놓음") T.eq(Shop.serve(s, 1), nil, "같은 손님에게 두 번 못 줌") T.eq(s.customers[1].state, "eating", "먹는 중") @@ -49,7 +49,7 @@ T.eq(s.customers[1], nil, "손님 목록에서 빠짐") local p, err = Shop.buyNext(s) T.eq(p and p.id, "Table2", "첫 구매는 테이블 2") T.eq(err, nil, "구매 성공") -T.eq(s.money, 0, "돈 차감") +T.eq(s.money, 5, "돈 차감(15 - 10)") T.eq(s.stats.seats, 2, "테이블 2개") local p2, err2 = Shop.buyNext(s) T.eq(p2, nil, "돈이 모자라면 실패") @@ -61,7 +61,7 @@ d.moneyMult = 2 Shop.tick(d, 0) Shop.tick(d, 3) Shop.cook(d) -T.eq(Shop.serve(d, 1), 20, "2배 수익이면 20원") +T.eq(Shop.serve(d, 1), 30, "2배 수익이면 30원") -- 메뉴는 해금된 것을 돌아가며 주문 local m = Shop.new(0, 2, 0) -- 테이블2, 김밥 해금 @@ -74,7 +74,20 @@ T.eq(m.customers[2].menu, "Gimbap", "두 번째 손님 김밥") Shop.tick(m, 9) T.eq(Shop.cook(m), "Tteokbokki", "먼저 온 손님 메뉴부터") T.eq(Shop.serve(m, 2), nil, "김밥 손님에게 떡볶이 불가") -T.eq(Shop.serve(m, 1), 10, "떡볶이 손님에게 성공") +T.eq(Shop.serve(m, 1), 15, "떡볶이 손님에게 성공") + +-- 요리 화면에서 메뉴 고르기: 주문이 있는 메뉴만 만들 수 있음 +local pick = Shop.new(0, 2, 0) +Shop.tick(pick, 0) +Shop.tick(pick, 6) +local counts = Shop.openCounts(pick) +T.eq(counts.Tteokbokki, 1, "떡볶이 주문 1") +T.eq(counts.Gimbap, 1, "김밥 주문 1") +T.eq(Shop.cook(pick, "Sundae"), nil, "주문 없는 메뉴는 못 만듦") +T.eq(Shop.cook(pick, "Gimbap"), "Gimbap", "나중에 온 손님 메뉴를 골라 만들 수 있음") +T.eq(Shop.openCounts(pick).Gimbap, nil, "만든 김밥만큼 주문이 채워짐") +T.eq(Shop.openCounts(pick).Tteokbokki, 1, "떡볶이 주문은 그대로") +T.eq(Shop.cook(pick, "Tteokbokki"), nil, "손이 꽉 차면 못 만듦") -- 알바생: 카운터에 접시를 만들어 두고, 플레이어는 집어서 나름 local h = Shop.new(0, 8, 0) @@ -140,11 +153,11 @@ for _, e in Shop.tick(g, 6.5) do end T.check(not spawnedWhileFull, "플레이어 손님 자리에는 NPC가 안 옴") Shop.cook(g) -- 1번 손님 떡볶이 -T.eq(Shop.serve(g, 1), 10, "NPC 손님은 1배") +T.eq(Shop.serve(g, 1), 15, "NPC 손님은 1배") local gid = (guest :: any).id T.eq(Shop.nextCookMenu(g), (guest :: any).menu, "플레이어 손님 주문도 조리대에 뜸") Shop.cook(g) -T.eq(Shop.serve(g, gid), 20, "플레이어 손님은 2배") +T.eq(Shop.serve(g, gid), 30, "플레이어 손님은 2배") local guestLeave = nil for _, e in Shop.tick(g, 6.5 + Economy.EAT + 0.1) do if e.kind == "leave" and e.guest then diff --git a/bunsik-tycoon/tests/cloud/dump_gui.luau b/bunsik-tycoon/tests/cloud/dump_gui.luau index 27b2969..d18bceb 100644 --- a/bunsik-tycoon/tests/cloud/dump_gui.luau +++ b/bunsik-tycoon/tests/cloud/dump_gui.luau @@ -56,6 +56,7 @@ local function dump(o: Instance, i: number): { [string]: any }? d.BackgroundColor3 = c3(o.BackgroundColor3) d.BackgroundTransparency = o.BackgroundTransparency d.ClipsDescendants = o.ClipsDescendants + d.SizeConstraint = o.SizeConstraint.Name end if o:IsA("ScrollingFrame") then d.CanvasPosition = { o.CanvasPosition.X, o.CanvasPosition.Y } @@ -139,61 +140,80 @@ local function dump(o: Instance, i: number): { [string]: any }? return d end +local Recipes = require(game:GetService("ReplicatedStorage").Shared.Recipes) + +-- kitchen = { menu, step, frac } 이면 요리 창을 열어 그 단계까지 진행합니다(step = "done"이면 완성 화면). +local PHONE = { w = 750, h = 332, inset = 58, touch = true } +local PC = { w = 1366, h = 710, inset = 58, touch = false } +local function shot(name: string, dev: { [string]: any }, attrs: { [string]: any }, extra: { [string]: any }?) + local t = { name = name, w = dev.w, h = dev.h, inset = dev.inset, touch = dev.touch, attrs = attrs } + for k, v in extra or {} do + t[k] = v + end + return t +end local SHOTS = { - { - name = "phone_iphone15", - w = 750, - h = 332, - inset = 58, - touch = true, - attrs = { Money = 1234, Bought = 4, Carry = 1, Tut = 0 }, - }, - { name = "phone_tut", w = 750, h = 332, inset = 58, touch = true, attrs = { Money = 12, Bought = 0, Tut = 3 } }, - { - name = "phone_shop", - w = 750, - h = 332, - inset = 58, - touch = true, - attrs = { Money = 150, Bought = 5 }, - open = "Panel", - }, - { - name = "phone_settings", - w = 750, - h = 332, - inset = 58, - touch = true, - attrs = { Money = 150, Bought = 5 }, - open = "SettingsPanel", - }, - { name = "pc_1366", w = 1366, h = 710, inset = 58, touch = false, attrs = { Money = 1234, Bought = 4, Carry = 1 } }, - { - name = "pc_shop", - w = 1366, - h = 710, - inset = 58, - touch = false, - attrs = { Money = 760, Bought = 12, Double = true }, - open = "Panel", - }, - { - name = "pc_settings", - w = 1366, - h = 710, - inset = 58, - touch = false, - attrs = { Money = 760, Bought = 12, Dev = true }, - open = "SettingsPanel", - }, - { - name = "tablet_ipad", - w = 1024, - h = 710, - inset = 58, - touch = true, - attrs = { Money = 98765, Bought = 15, Carry = 2 }, - }, + shot("phone_main", PHONE, { Money = 85, Bought = 4, Carry = 1, Hand = "Gimbap", Tut = 0 }, { toast = true }), + shot("phone_tut", PHONE, { Money = 15, Bought = 0, Tut = 3 }), + shot("phone_shop", PHONE, { Money = 150, Bought = 5 }, { open = "shop" }), + shot("phone_settings", PHONE, { Money = 150, Bought = 5 }, { open = "settings" }), + shot( + "phone_kitchen_menu", + PHONE, + { Money = 300, Bought = 6, Orders = "Tteokbokki=1,Gimbap=2", Tut = 1 }, + { kitchen = { menu = nil } } + ), + shot( + "phone_kitchen_tteok", + PHONE, + { Money = 300, Bought = 6, Orders = "Tteokbokki=1" }, + { kitchen = { menu = "Tteokbokki", step = 3, frac = 0.5 } } + ), + shot("pc_main", PC, { Money = 1234, Bought = 4, Carry = 1, Hand = "Tteokbokki" }, { toast = true }), + shot("pc_buyable", PC, { Money = 160, Bought = 5, Carry = 0, Tut = 0 }), + shot("pc_shop", PC, { Money = 760, Bought = 12, Double = true }, { open = "shop" }), + shot("pc_settings", PC, { Money = 760, Bought = 12, Dev = true }, { open = "settings" }), + shot( + "pc_kitchen_menu", + PC, + { Money = 300, Bought = 13, Orders = "Gimbap=1,Sundae=2,Eomuk=1" }, + { kitchen = { menu = nil } } + ), + shot( + "pc_kitchen_gimbap", + PC, + { Money = 300, Bought = 13, Orders = "Gimbap=1" }, + { kitchen = { menu = "Gimbap", step = 2, frac = 0.6 } } + ), + shot( + "pc_kitchen_sundae", + PC, + { Money = 300, Bought = 13, Orders = "Sundae=1" }, + { kitchen = { menu = "Sundae", step = 2, frac = 0.7 } } + ), + shot( + "pc_kitchen_eomuk", + PC, + { Money = 300, Bought = 13, Orders = "Eomuk=1" }, + { kitchen = { menu = "Eomuk", step = 2, frac = 0.4 } } + ), + shot( + "pc_kitchen_twigim", + PC, + { Money = 300, Bought = 17, Orders = "Twigim=1" }, + { kitchen = { menu = "Twigim", step = 3, frac = 0.5 } } + ), + shot( + "pc_kitchen_done", + PC, + { Money = 300, Bought = 6, Orders = "Tteokbokki=1" }, + { kitchen = { menu = "Tteokbokki", step = "done" } } + ), + shot( + "tablet_ipad", + { w = 1024, h = 710, inset = 58, touch = true }, + { Money = 98765, Bought = 15, Carry = 2, Hand = "Eomuk,Sundae" } + ), } local shots = {} @@ -210,14 +230,32 @@ for _, s in SHOTS do if s.attrs.Tut == nil then state:SetAttribute("Tut", 0) end - if s.name == "phone_iphone15" or s.name == "pc_1366" then + if s.toast then hud.notify("purchased", { item = "Stove1" }) end if s.open then - hud.open(if s.open == "Panel" then "shop" else "settings") + hud.open(s.open) + end + local k = s.kitchen + if k then + hud.open("kitchen") + if k.menu then + hud.kitchen.choose(k.menu) + local r = Recipes.LIST[k.menu] + local cook = hud.kitchen.flow().cook + for i, st in r.steps do + local need = Recipes.need(st, cook) + if k.step == "done" or i < k.step then + hud.kitchen.input(st.kind, need) + elseif i == k.step then + hud.kitchen.input(st.kind, need * k.frac) + break + end + end + end end hud.refresh() - task.wait(0.2) + task.wait(0.3) local zones = Layout.touchZones(s.w, s.h) table.insert(shots, { name = s.name, @@ -233,4 +271,5 @@ end local images = {} images[Icons.ASSET:match("%d+")] = "art/ui_icons.png" +images[Icons.KITCHEN_ASSET:match("%d+")] = "art/kitchen.png" return HttpService:JSONEncode({ shots = shots, images = images }) diff --git a/bunsik-tycoon/tests/cloud/integration.luau b/bunsik-tycoon/tests/cloud/integration.luau index f39ed91..c35e987 100644 --- a/bunsik-tycoon/tests/cloud/integration.luau +++ b/bunsik-tycoon/tests/cloud/integration.luau @@ -26,7 +26,9 @@ local function section(name: string) end local Economy = require(ReplicatedStorage.Shared.Economy) +local Icons = require(ReplicatedStorage.Shared.Icons) local Locale = require(ReplicatedStorage.Shared.Locale) +local Recipes = require(ReplicatedStorage.Shared.Recipes) section("맵") local World = require(Server.World) @@ -98,7 +100,10 @@ local customers = 0 for _, ch in dyn:GetChildren() do if ch.Name == "Customer" then customers += 1 - check(ch:FindFirstChild("Order", true) ~= nil, "손님 주문 말풍선") + local bubble = ch:FindFirstChild("Order", true) + check(bubble ~= nil, "손님 주문 말풍선") + local icon = bubble and bubble:FindFirstChild("Icon", true) :: ImageLabel? + eq(icon and icon.ImageRectOffset, Icons.OFFSET.Tteokbokki, "말풍선에 떡볶이 그림") end end eq(customers, 1, "첫 손님 NPC 1명") @@ -107,13 +112,23 @@ eq(slots[1].refs.stove:GetAttribute("OwnerId"), 111, "조리대 주인") check((owner:FindFirstChild("Guide") :: ObjectValue).Value ~= nil, "튜토리얼 화살표 목표(조리대)") c:update(3) eq(c.shop.customers[1].state, "waiting", "손님이 앉음") -eq(c:cook(), "Tteokbokki", "조리") +eq(owner:GetAttribute("Orders"), "Tteokbokki=1", "요리 창에 보여 줄 주문 수") +eq(c:cook("Gimbap"), nil, "주문 없는 메뉴(김밥)는 못 만듦") +eq(c:cook("Tteokbokki"), "Tteokbokki", "고른 메뉴로 조리") +eq(owner:GetAttribute("Hand"), "Tteokbokki", "손에 든 접시 종류") +eq(owner:GetAttribute("Orders"), "", "주문이 다 채워짐") eq(owner:GetAttribute("Tut"), 2, "튜토리얼 2단계") eq(owner:GetAttribute("Carry"), 1, "접시 1개 듦") eq(slots[1].refs.stove:GetAttribute("CookMenu"), "", "더 만들 것 없음") -eq(c:serve(1), 10, "서빙 10원") -eq(owner:GetAttribute("Money"), 10, "돈 10") -eq(data.Money, 10, "세이브 데이터 돈 10") +eq(c:serve(1), 15, "서빙 15원") +eq(owner:GetAttribute("Money"), 15, "돈 15") +eq(data.Money, 15, "세이브 데이터 돈 15") +local served1 = dyn:FindFirstChild("Customer"):FindFirstChild("Order", true) +eq( + served1 and (served1:FindFirstChild("Icon", true) :: ImageLabel).ImageRectOffset, + Icons.OFFSET.heart, + "받은 손님 말풍선은 하트" +) eq(owner:GetAttribute("Tut"), 3, "튜토리얼 3단계") check(dyn:FindFirstChild("Dish_Tteokbokki") ~= nil, "테이블에 접시") local ok = c:buy() @@ -398,7 +413,6 @@ eq( section("화면 UI(서버에서 생성)") local Hud = require(StarterPlayer.StarterPlayerScripts.Client.Hud) -local Icons = require(ReplicatedStorage.Shared.Icons) local state = Instance.new("Folder") state:SetAttribute("Lang", "ko") state:SetAttribute("Money", 25) @@ -415,42 +429,57 @@ local function label(o: Instance?): string? return t and t.Text end local moneyText = root:FindFirstChild("Money"):FindFirstChild("Text", true) :: TextLabel -eq(moneyText.Text, "25원", "돈 표시") +eq(moneyText.Text, "25", "돈 표시(숫자만, 동전 그림 옆)") local nextCard = root:FindFirstChild("Next") :: Frame local nextTitle = nextCard:FindFirstChild("Title", true) :: TextLabel eq(nextTitle.Text, "김밥 해금", "다음 업그레이드") -eq( - (nextCard:FindFirstChild("Tab", true):FindFirstChild("Text") :: TextLabel).Text, - "다음 업그레이드", - "카드 이름표" -) local nextIcon = nextCard:FindFirstChild("IconBox", true):FindFirstChild("Icon") :: ImageLabel eq(nextIcon.Image, Icons.ASSET, "다음 업그레이드 아이콘 그림") eq(nextIcon.ImageRectOffset, Icons.OFFSET.Gimbap, "김밥 해금 아이콘") -check((root:FindFirstChild("Hint") :: Frame).Visible, "튜토리얼 안내 보임") +eq((nextCard:FindFirstChild("Cost", true) :: TextLabel).Text, "25 / 40", "진행 막대 글자") +local hintFrame = root:FindFirstChild("Hint") :: Frame +check(hintFrame.Visible, "튜토리얼 말풍선 보임") +check(hintFrame:FindFirstChild("Mascot") ~= nil, "말풍선에 마스코트") check((nextCard:FindFirstChild("Pointer") :: ImageLabel).Visible, "튜토리얼 3: [사기] 가리키는 손") local buyBtn = nextCard:FindFirstChild("Buy") :: TextButton eq(label(buyBtn), "사기", "사기 버튼 글자") -check(not (buyBtn:FindFirstChild("Shine", true) :: Frame).Visible, "돈이 모자라면 반짝임 없음") +local Theme = require(StarterPlayer.StarterPlayerScripts.Client.Theme) +eq( + (buyBtn:FindFirstChild("Base") :: Frame).BackgroundColor3, + Theme.darken(Theme.GRAY, 0.3), + "돈이 모자라면 회색" +) local listButton = root:FindFirstChild("ListButton") :: TextButton -check(not (listButton:FindFirstChild("Badge") :: Frame).Visible, "돈이 모자라면 업그레이드 배지 없음") +eq(label(listButton), "상점", "상점 버튼 글자(짧게)") +check(not (listButton:FindFirstChild("Badge") :: Frame).Visible, "돈이 모자라면 상점 배지 없음") state:SetAttribute("Money", 60) -check((buyBtn:FindFirstChild("Shine", true) :: Frame).Visible, "살 수 있으면 [사기] 반짝임") -check((listButton:FindFirstChild("Badge") :: Frame).Visible, "살 수 있으면 업그레이드 버튼에 ! 배지") +eq((buyBtn:FindFirstChild("Base") :: Frame).BackgroundColor3, Theme.darken(Theme.MINT, 0.3), "살 수 있으면 초록") +check((listButton:FindFirstChild("Badge") :: Frame).Visible, "살 수 있으면 상점 버튼에 ! 배지") check(root:FindFirstChild("Gain") ~= nil, "돈이 늘면 +돈 글자가 떠오름") -eq((root:FindFirstChild("Gain") :: TextLabel).Text, "+35원", "늘어난 돈") +eq((root:FindFirstChild("Gain") :: TextLabel).Text, "+35", "늘어난 돈") for _, d in Icons.OFFSET do check(d.X % 128 == 0 and d.Y % 128 == 0 and d.X < 1024 and d.Y < 1024, "아이콘 칸 위치") end +for _, d in Icons.KITCHEN do + check(d.X % 256 == 0 and d.Y % 256 == 0 and d.X < 1024 and d.Y < 1024, "요리 그림 칸 위치") +end +-- 손에 든 접시 +local carryFrame = root:FindFirstChild("Carry") :: Frame +check(not carryFrame.Visible, "빈손이면 접시 표시 숨김") +state:SetAttribute("Carry", 1) +state:SetAttribute("Hand", "Tteokbokki") +check(carryFrame.Visible, "접시를 들면 표시") +eq((carryFrame:FindFirstChild("Slot1") :: ImageLabel).ImageRectOffset, Icons.OFFSET.Tteokbokki, "든 음식 그림") +state:SetAttribute("Carry", 0) +state:SetAttribute("Hand", "") state:SetAttribute("Lang", "en") -eq(moneyText.Text, "₩60", "영어 돈 표시") +eq(moneyText.Text, "60", "영어 돈 표시") eq(nextTitle.Text, "Unlock Gimbap", "영어 다음 업그레이드") state:SetAttribute("Lang", "zh") eq(nextTitle.Text, "解锁紫菜包饭", "중국어 다음 업그레이드") state:SetAttribute("Lang", "en") local settingsBtn = root:FindFirstChild("Settings") :: TextButton check(settingsBtn ~= nil, "오른쪽 위 설정 버튼") -eq(label(settingsBtn), "Settings", "설정 버튼 글자") local settingsPanel = root:FindFirstChild("SettingsPanel") :: Frame check(settingsPanel ~= nil and not settingsPanel.Visible, "설정 창은 처음엔 닫힘") for _, l in { "auto", "ko", "en", "ja", "zh" } do @@ -462,26 +491,29 @@ state:SetAttribute("Sfx", false) eq(label(settingsPanel:FindFirstChild("Sfx")), "Off", "효과음 끔 표시") check(not hud.menuOpen(), "창 닫힘") hud.open("shop") -check(hud.menuOpen() and (root:FindFirstChild("Panel") :: Frame).Visible, "업그레이드 창 열기") -check((root:FindFirstChild("Dim") :: Frame).Visible, "창 뒤 어둡게") -local rowsFrame = root:FindFirstChild("Panel"):FindFirstChild("List", true) :: ScrollingFrame +check(hud.menuOpen() and (root:FindFirstChild("Panel") :: Frame).Visible, "상점 창 열기") +check((root:FindFirstChild("Dim") :: TextButton).Visible, "창 뒤 어둡게") +local cardsFrame = root:FindFirstChild("Panel"):FindFirstChild("Cards", true) :: Frame +local n1 = 0 +for _, ch in cardsFrame:GetChildren() do + if ch.Name:sub(1, 3) == "Row" then + n1 += 1 + end +end +eq(n1, 10, "상점: 지금 단계 10개가 한 화면에(넘기지 않음)") check( - rowsFrame:FindFirstChild("Row2"):FindFirstChild("BuyRow") ~= nil, - "목록의 다음 업그레이드에 사기 버튼" -) -check(rowsFrame:FindFirstChild("Row1"):FindFirstChild("Done") ~= nil, "산 업그레이드는 체크 표시") -check( - rowsFrame:FindFirstChild("Row5"):FindFirstChild("IconBox"):FindFirstChild("Lock") ~= nil, - "잠긴 업그레이드 자물쇠" + cardsFrame:FindFirstChild("Row2"):FindFirstChild("BuyRow") ~= nil, + "상점의 다음 업그레이드에 사기 버튼" ) +check(cardsFrame:FindFirstChild("Row1"):FindFirstChild("Done", true) ~= nil, "산 업그레이드는 체크 표시") +check(cardsFrame:FindFirstChild("Row5"):FindFirstChild("Lock", true) ~= nil, "잠긴 업그레이드 자물쇠") hud.open("settings") check(settingsPanel.Visible and not (root:FindFirstChild("Panel") :: Frame).Visible, "창은 하나만 열림") hud.open(nil) -check(not hud.menuOpen() and not (root:FindFirstChild("Dim") :: Frame).Visible, "창 닫기") +check(not hud.menuOpen() and not (root:FindFirstChild("Dim") :: TextButton).Visible, "창 닫기") state:SetAttribute("Bought", #Economy.PURCHASES) check(not buyBtn.Visible, "다 사면 사기 버튼 숨김") check(not (root:FindFirstChild("Boost") :: TextButton).Visible, "다 사면 돈 부스트 숨김") -check(root:FindFirstChild("Dev") == nil, "개발자 버튼은 설정 창 안으로") local devMoneyBtn = settingsPanel:FindFirstChild("devMoney") :: TextButton check(not devMoneyBtn.Visible, "개발자 버튼은 기본으로 숨김") local setH = settingsPanel.Size.Y.Offset @@ -490,7 +522,7 @@ check(devMoneyBtn.Visible, "게임 주인에게 개발자 버튼(설정 창)") check(settingsPanel.Size.Y.Offset > setH, "개발자 줄만큼 설정 창이 길어짐") local doubleBtn = root:FindFirstChild("Double") :: TextButton check(doubleBtn.Visible, "2배 수익 버튼(상품 ID 설정됨)") -eq(label(doubleBtn), "Double Money", "2배 수익 버튼 글자") +eq(label(doubleBtn), "2x Cash", "2배 수익 버튼 글자") state:SetAttribute("Double", true) eq(label(doubleBtn), "Active", "2배 수익 산 뒤") check((doubleBtn:FindFirstChild("Owned") :: ImageLabel).Visible, "2배 수익 산 뒤 체크") @@ -502,7 +534,17 @@ eq( Icons.OFFSET.check, "구매 알림 아이콘" ) --- 휴대폰 배치(아이폰 15 가로, 상단 바·노치 뺀 영역): 루트가 화면을 채우고, 결제 버튼은 왼쪽 위, 마우스 줄 숨김 +for _ = 1, 5 do + hud.notify("purchased", { item = "Table2" }) +end +local toastCount = 0 +for _, ch in root.Toasts:GetChildren() do + if ch:IsA("Frame") then + toastCount += 1 + end +end +check(toastCount <= 3, `알림은 3개까지만 쌓임 ({toastCount})`) +-- 휴대폰 배치(아이폰 15 가로, 상단 바·노치 뺀 영역): 루트가 화면을 채우고, 버튼 묶음은 왼쪽 위, 마우스 줄 숨김 hud.setLayout(Vector2.new(750, 332), true) local lay = hud.layout() local scaleObj = root:FindFirstChildOfClass("UIScale") :: UIScale @@ -528,7 +570,130 @@ check((settingsPanel:FindFirstChild("MouseLook") :: TextButton).Visible, "PC: check(math.abs(scaleObj.Scale - math.min(1366 / 1100, 710 / 620)) < 1e-6, "PC: 배율(상단 바 뺀 높이 기준)") hud.destroy() -section("조리 버튼(클라이언트 모듈)") +section("요리 창(메뉴 고르기 → 조리 과정 → 완성)") +local kstate = Instance.new("Folder") +kstate:SetAttribute("Lang", "ko") +kstate:SetAttribute("Money", 0) +kstate:SetAttribute("Bought", 6) -- 떡볶이·김밥·순대 해금 +kstate:SetAttribute("Tut", 1) +kstate:SetAttribute("Orders", "Gimbap=2") +local ksent = {} +local khud = Hud.build(Instance.new("Folder"), kstate, function(kind, arg) + table.insert(ksent, { kind, arg }) +end) +local kroot = khud.gui:FindFirstChild("Root") :: Frame +local kitchen = khud.kitchen +local kframe = kroot:FindFirstChild("Kitchen") :: Frame +check(not kframe.Visible, "요리 창은 처음엔 닫힘") +khud.open("kitchen") +check(kframe.Visible and kitchen.isOpen() and khud.menuOpen(), "요리 창 열림(커서 풀림)") +check((kroot:FindFirstChild("Dim") :: TextButton).Visible, "요리 창 뒤 어둡게") +local menuPage = kframe:FindFirstChild("MenuPage", true) :: Frame +check(menuPage.Visible, "처음엔 메뉴 고르기") +local function menuCard(m: string): Frame + return menuPage:FindFirstChild("Menu_" .. m, true) :: Frame +end +for _, m in Economy.MENU_ORDER do + check(menuCard(m) ~= nil, `메뉴 카드 {m}`) +end +check((menuCard("Gimbap"):FindFirstChild("Orders", true) :: Frame).Visible, "주문 있는 김밥에 손님 표시") +eq((menuCard("Gimbap"):FindFirstChild("Orders", true):FindFirstChild("Text") :: TextLabel).Text, "x2", "주문 수 2") +check( + not (menuCard("Tteokbokki"):FindFirstChild("Orders", true) :: Frame).Visible, + "주문 없는 떡볶이는 표시 없음" +) +check((menuCard("Eomuk"):FindFirstChild("Lock", true) :: ImageLabel).Visible, "안 산 어묵은 자물쇠") +check(not (menuCard("Sundae"):FindFirstChild("Lock", true) :: ImageLabel).Visible, "산 순대는 자물쇠 없음") +check( + (menuPage:FindFirstChild("Pointer") or menuCard("Gimbap"):FindFirstChild("Pointer", true)) ~= nil, + "튜토리얼 손가락" +) +eq(kitchen.choose("Tteokbokki"), false, "주문 없는 메뉴는 못 고름") +eq(kitchen.choose("Eomuk"), false, "안 산 메뉴는 못 고름") +eq(kitchen.choose("Gimbap"), true, "김밥 고름") +local cookPage = kframe:FindFirstChild("CookPage", true) :: Frame +check(cookPage.Visible and not menuPage.Visible, "조리 화면으로") +eq((cookPage:FindFirstChild("Instruction") :: TextLabel).Text, "김 위에 재료를 올려요", "1단계 안내") +check( + (cookPage:FindFirstChild("Base", true) :: ImageLabel).Image == Icons.KITCHEN_ASSET, + "조리 도구 그림(도마)" +) +eq((cookPage:FindFirstChild("Base", true) :: ImageLabel).ImageRectOffset, Icons.KITCHEN.board, "김밥은 도마") +local flowK = kitchen.flow() +local need1 = flowK.need +eq((cookPage:FindFirstChild("Gesture") :: TextLabel).Text, `톡톡! {need1}번`, "톡톡 남은 횟수") +eq(kitchen.input("hold", 1), nil, "다른 동작은 무시") +eq(kitchen.input("tap", 1), "progress", "톡 1") +eq((cookPage:FindFirstChild("Gesture") :: TextLabel).Text, `톡톡! {need1 - 1}번`, "남은 횟수 줄어듦") +local strip1 = cookPage:FindFirstChild("Strip1", true) :: Frame +check(strip1 ~= nil and strip1.Visible, "누를 때마다 재료가 올라감") +for _ = 2, need1 do + kitchen.input("tap", 1) +end +eq(flowK.step, 2, "2단계(말기)") +eq((cookPage:FindFirstChild("Instruction") :: TextLabel).Text, "돌돌 말아요", "2단계 안내") +eq((cookPage:FindFirstChild("Gesture") :: TextLabel).Text, "문질문질!", "문지르기 안내") +eq(kitchen.input("rub", flowK.need), "step", "다 문지름 → 3단계") +check((cookPage:FindFirstChild("Roll", true) :: ImageLabel).Visible, "김밥이 말림") +eq(#ksent, 0, "완성 전에는 서버에 안 보냄") +eq(kitchen.input("tap", flowK.need), "done", "썰기 끝 → 완성") +eq(ksent[1] and ksent[1][1], "cook", "서버에 cook") +eq(ksent[1] and ksent[1][2], "Gimbap", "고른 메뉴를 보냄") +local donePage = kframe:FindFirstChild("DonePage", true) :: Frame +check(donePage.Visible, "완성 화면") +eq((donePage:FindFirstChild("Dish") :: ImageLabel).ImageRectOffset, Icons.OFFSET.Gimbap, "완성 접시 그림") +-- 주문이 남아 있고 손에 자리가 있으면 다시 메뉴 고르기, 아니면 닫힘 +kstate:SetAttribute("Orders", "Gimbap=1") +kstate:SetAttribute("Carry", 0) +task.wait(1.5) +check(kitchen.isOpen() and menuPage.Visible, "주문이 남으면 다음 접시 고르기") +kitchen.choose("Gimbap") +for _ = 1, 20 do + local st = Recipes.current(kitchen.flow()) + if not st then + break + end + kitchen.input(st.kind, kitchen.flow().need) +end +kstate:SetAttribute("Carry", 1) -- 손이 꽉 참(쟁반 없음) +kstate:SetAttribute("Orders", "") +task.wait(1.5) +check(not kitchen.isOpen() and not kframe.Visible, "더 만들 것이 없으면 창이 닫힘") +check(not (kroot:FindFirstChild("Dim") :: TextButton).Visible, "닫히면 어둡게도 꺼짐") +-- 메뉴마다 과정이 다르고 끝까지 갈 수 있음 +for _, m in Economy.MENU_ORDER do + kstate:SetAttribute("Bought", 20) + kstate:SetAttribute("Carry", 0) + kstate:SetAttribute("Orders", `{m}=1`) + khud.open("kitchen") + check(kitchen.choose(m), `{m} 고름`) + eq( + (cookPage:FindFirstChild("Base", true) :: ImageLabel).ImageRectOffset, + Icons.KITCHEN[Recipes.LIST[m].stage], + `{m} 조리 도구 그림` + ) + local guard = 0 + while kitchen.flow().phase == "cook" and guard < 10 do + local st = Recipes.current(kitchen.flow()) :: Recipes.Step + check( + Icons.OFFSET[({ roll = "mat", fire = "flame", skewer = "Eomuk" } :: any)[st.tool] or st.tool] ~= nil, + `{m} 도구 그림 {st.tool}` + ) + kitchen.input(st.kind, kitchen.flow().need) + guard += 1 + end + eq(kitchen.flow().phase, "done", `{m} 완성`) + eq(ksent[#ksent][2], m, `{m} 서버에 보냄`) + khud.open(nil) + check(not kitchen.isOpen(), `{m} 창 닫기`) +end +-- 요리 창은 화면 안에(휴대폰) +khud.setLayout(Vector2.new(667, 317), true) +local kl = khud.layout().kitchen +check(kl.x >= 0 and kl.y >= 0 and kl.x + kl.w <= khud.layout().width + 1e-6, "휴대폰: 요리 창 화면 안") +khud.destroy() + +section("조리대 버튼(클라이언트 모듈)") local Stove = require(StarterPlayer.StarterPlayerScripts.Client.Stove) local stove = slots[3].refs.stove local pstate = Instance.new("Folder") @@ -536,10 +701,9 @@ pstate:SetAttribute("Lang", "ko") local prompt = Stove.attach(stove, pstate, function() end) check(not prompt.Enabled, "주문 없으면 버튼 꺼짐") stove:SetAttribute("CookMenu", "Gimbap") -stove:SetAttribute("CookTime", 1.5) check(prompt.Enabled, "주문 있으면 버튼 켜짐") -eq(prompt.ActionText, "🍙 김밥 만들기", "버튼 글자") -eq(prompt.HoldDuration, 1.5, "누르는 시간") +eq(prompt.ActionText, "요리하기", "버튼 글자") +eq(prompt.HoldDuration, 0, "누르면 바로 요리 창(꾹 누르지 않음)") prompt:Destroy() section("효과음(직접 만든 오디오 에셋)") @@ -556,17 +720,16 @@ for name, id in Sounds do end end -section("UI 아이콘 그림(직접 그린 이미지 에셋)") -do - local Icons = require(ReplicatedStorage.Shared.Icons) - local num = tonumber(string.match(Icons.ASSET, "%d+")) +section("UI 그림(직접 그린 이미지 에셋)") +for _, asset in { Icons.ASSET, Icons.KITCHEN_ASSET } do + local num = tonumber(string.match(asset, "%d+")) local okInfo, info = pcall(function() return game:GetService("MarketplaceService"):GetProductInfoAsync(num :: number, Enum.InfoType.Asset) end) - check(okInfo, "아이콘 그림 정보 조회") + check(okInfo, `그림 {num} 정보 조회`) if okInfo then - eq(info.AssetTypeId, 1, "아이콘 그림은 이미지") - eq(info.Creator.CreatorTargetId, game.CreatorId, "아이콘 그림은 게임 주인 소유") + eq(info.AssetTypeId, 1, `그림 {num}은 이미지`) + eq(info.Creator.CreatorTargetId, game.CreatorId, `그림 {num}은 게임 주인 소유`) end end diff --git a/bunsik-tycoon/tools/cloud.py b/bunsik-tycoon/tools/cloud.py index dc20743..946a8f7 100644 --- a/bunsik-tycoon/tools/cloud.py +++ b/bunsik-tycoon/tools/cloud.py @@ -6,6 +6,7 @@ python3 tools/cloud.py products # 게임패스·개발자 상품 만들기(이미 있으면 건너뜀) python3 tools/cloud.py place # 서버 인원 6명, 설명 설정 python3 tools/cloud.py audio sfx/coin.ogg "이름" # 효과음 업로드, 에셋 ID 출력 + python3 tools/cloud.py image art/kitchen.png "이름" # 그림 업로드, 에셋 ID 출력 API 키는 ~/.config/ejclaw/secrets.json 의 roblox.opencloud/bunsik-tycoon 에서 읽습니다. """ @@ -145,11 +146,12 @@ def place(): return request("PATCH", url, body) -def upload_audio(path, name): +def upload_audio(path, name, asset_type="Audio", mime="audio/ogg", + description="Bunsik Tycoon sound effect (synthesized, original)."): meta = { - "assetType": "Audio", + "assetType": asset_type, "displayName": name, - "description": "Bunsik Tycoon sound effect (synthesized, original).", + "description": description, "creationContext": {"creator": {"userId": str(CREATOR_USER)}}, } boundary = "----bunsik" + str(int(time.time() * 1000)) @@ -158,7 +160,7 @@ def upload_audio(path, name): body = (f"--{boundary}\r\nContent-Disposition: form-data; name=\"request\"\r\n" f"Content-Type: application/json\r\n\r\n{json.dumps(meta)}\r\n").encode() body += (f"--{boundary}\r\nContent-Disposition: form-data; name=\"fileContent\"; " - f"filename=\"{os.path.basename(path)}\"\r\nContent-Type: audio/ogg\r\n\r\n").encode() + f"filename=\"{os.path.basename(path)}\"\r\nContent-Type: {mime}\r\n\r\n").encode() body += data + f"\r\n--{boundary}--\r\n".encode() op = request("POST", "https://apis.roblox.com/assets/v1/assets", body, f"multipart/form-data; boundary={boundary}") for _ in range(60): @@ -179,6 +181,10 @@ def main(argv): if argv[:1] == ["audio"]: print(upload_audio(argv[1], argv[2])) return 0 + if argv[:1] == ["image"]: + # 그림 업로드(화면 UI 그림 모음). 에셋 ID 출력 + print(upload_audio(argv[1], argv[2], "Image", "image/png", "Bunsik Tycoon UI art (drawn in code, original).")) + return 0 if argv[:1] == ["asset"]: print(json.dumps(asset_status(argv[1]), ensure_ascii=False)) return 0 diff --git a/bunsik-tycoon/tools/gui_render.py b/bunsik-tycoon/tools/gui_render.py index bb744bc..466ea98 100644 --- a/bunsik-tycoon/tools/gui_render.py +++ b/bunsik-tycoon/tools/gui_render.py @@ -5,7 +5,7 @@ cairo로 그립니다. 서버에서는 실제 화면을 볼 수 없어서 배치 지원: Frame/TextLabel/TextButton/ImageLabel/ImageButton/ScrollingFrame, UDim2·AnchorPoint·Rotation·ZIndex, UICorner, UIStroke(테두리·글자), UIGradient(색·투명도·회전·오프셋), UIPadding, UIListLayout, UIScale, -UITextSizeConstraint, TextScaled/TextWrapped/정렬, ImageRectOffset/Size, ClipsDescendants. +UITextSizeConstraint, SizeConstraint, TextScaled/TextWrapped/정렬, ImageRectOffset/Size, ClipsDescendants. python3 tools/gui_render.py dump.json out_dir [--bg scene.png] """ @@ -200,8 +200,9 @@ class Renderer: kids = [ch for ch in node.get("children", []) if ch.get("Visible", True)] for ch in kids: s = ch.get("UIScale", 1) - cw = udim(ch["Size"][0], w, k) * s - chh = udim(ch["Size"][1], h, k) * s + sc = ch.get("SizeConstraint", "RelativeXY") + cw = udim(ch["Size"][0], h if sc == "RelativeYY" else w, k) * s + chh = udim(ch["Size"][1], w if sc == "RelativeXX" else h, k) * s ar = ch.get("UIAspectRatio") if ar: if cw / max(chh, 1e-6) > ar: diff --git a/bunsik-tycoon/tools/icons.py b/bunsik-tycoon/tools/icons.py index 455e34a..f8b0842 100644 --- a/bunsik-tycoon/tools/icons.py +++ b/bunsik-tycoon/tools/icons.py @@ -659,6 +659,407 @@ def hand(c): fill_stroke(c, lin(0, 6, 0, 122, "#ffe9d0", "#f5c89a")) +# ---------------------------------------------------------------- 요리 화면 재료·도구 (칸 32~63) + +def ellipse(c, cx, cy, rx, ry): + c.save() + c.translate(cx, cy) + c.scale(rx, ry) + c.arc(0, 0, 1, 0, 2 * math.pi) + c.restore() + + +def bowl(c, top, inner, lw=LW): + """옆에서 본 둥근 그릇. inner: 그릇 안 음식 색(위쪽 타원).""" + c.move_to(12, 60) + c.line_to(116, 60) + c.curve_to(114, 98, 92, 116, 64, 116) + c.curve_to(36, 116, 14, 98, 12, 60) + c.close_path() + fill_stroke(c, lin(0, 60, 0, 116, *top), lw) + ellipse(c, 64, 60, 52, 14) + fill_stroke(c, rgb(inner), 5) + + +def rice_cake(c): + # 떡 한 개(가로) + rrect(c, 14, 44, 100, 40, 20) + fill_stroke(c, lin(0, 44, 0, 84, "#fff8ee", "#f3e3cc")) + rrect(c, 26, 52, 44, 8, 4) + c.set_source_rgba(1, 1, 1, 0.9) + c.fill() + + +def rice_cake_red(c): + # 양념 묻은 떡 + rrect(c, 14, 44, 100, 40, 20) + fill_stroke(c, lin(0, 44, 0, 84, "#ff8a6a", "#d92f1c")) + rrect(c, 26, 52, 44, 8, 4) + c.set_source_rgba(1, 1, 1, 0.6) + c.fill() + + +def rice_cakes(c): + # 떡이 담긴 그릇(누르는 도구) + for x, y, a in ((42, 46, -0.5), (64, 36, 0.2), (86, 46, 0.5), (54, 52, 0.1), (76, 54, -0.3)): + c.save() + c.translate(x, y) + c.rotate(a) + rrect(c, -18, -8, 36, 16, 8) + c.restore() + fill_stroke(c, lin(0, y - 8, 0, y + 8, "#ffffff", "#efdcc2"), 4) + bowl(c, ("#8fd3ff", "#3b82f6"), "#f3e3cc") + shine(c, 30, 84, 6, 12, 0.5) + + +def sauce_bowl(c): + # 고추장 양념 그릇 + 숟가락 + c.set_line_cap(cairo.LINE_CAP_ROUND) + for w, col in ((14 + LW, INK), (12, rgb("#e2e8f0"))): + c.move_to(78, 54) + c.line_to(110, 10) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + bowl(c, ("#ffffff", "#cbd5e1"), "#e8341c") + shine(c, 40, 56, 14, 4, 0.5) + shine(c, 30, 84, 6, 12, 0.5) + + +def sauce_blob(c): + # 팬에 부은 빨간 양념(넓은 타원, 테두리 없음) + ellipse(c, 64, 64, 62, 46) + c.set_source(rad(64, 64, 64, "#ff6a4a", "#e8341c", "#c41e10")) + c.fill() + for x, y, r in ((40, 50, 6), (80, 70, 5), (60, 84, 4), (90, 46, 4)): + c.arc(x, y, r, 0, 2 * math.pi) + c.set_source_rgba(1, 0.8, 0.7, 0.55) + c.fill() + + +def spatula(c): + # 볶음 주걱(대각선) + c.save() + c.translate(64, 64) + c.rotate(-0.75) + rrect(c, -6, -10, 12, 72, 6) + fill_stroke(c, lin(-6, 0, 6, 0, "#e0a96d", "#a8662e"), 5) + rrect(c, -22, -60, 44, 54, 14) + fill_stroke(c, lin(0, -60, 0, -6, "#fff3c4", "#ffb84a"), 6) + for dx in (-8, 0, 8): + rrect(c, dx - 2, -50, 4, 30, 2) + c.set_source_rgba(*INK, 0.35) + c.fill() + c.restore() + + +def bubble(c): + c.arc(64, 64, 40, 0, 2 * math.pi) + c.set_source_rgba(1, 1, 1, 0.35) + c.fill_preserve() + c.set_source_rgba(1, 1, 1, 0.95) + c.set_line_width(8) + c.stroke() + shine(c, 50, 48, 10, 7, 0.9) + + +def steam(c): + c.set_line_cap(cairo.LINE_CAP_ROUND) + for w, col in ((18, (0.62, 0.72, 0.85, 0.8)), (11, (1, 1, 1, 1))): + for x in (34, 64, 94): + c.move_to(x, 118) + c.curve_to(x - 22, 92, x + 22, 70, x, 44) + c.curve_to(x - 14, 30, x + 10, 18, x, 8) + c.set_source_rgba(*col) + c.set_line_width(w) + c.stroke() + + +def fillings(c): + # 김밥 재료 쟁반(단무지·당근·시금치·달걀·햄) + rrect(c, 8, 70, 112, 40, 14) + fill_stroke(c, lin(0, 70, 0, 110, "#ffe9c7", "#e6b77a")) + for i, col in enumerate(("#ffe14a", "#ff8c1a", "#3fae49", "#fff3a0", "#ff8fa3")): + x = 18 + i * 20 + rrect(c, x, 22 + (i % 2) * 8, 14, 62, 7) + fill_stroke(c, rgb(col), 4) + + +def mat(c): + # 김발(대나무 말이) + rrect(c, 10, 22, 108, 84, 10) + fill_stroke(c, lin(0, 22, 0, 106, "#d9f2a4", "#94c25a")) + for i in range(1, 9): + x = 10 + i * 12 + c.move_to(x, 26) + c.line_to(x, 102) + c.set_source_rgba(*INK, 0.35) + c.set_line_width(3) + c.stroke() + shine(c, 30, 36, 12, 6, 0.6) + + +def knife(c): + c.save() + c.translate(64, 64) + c.rotate(-0.6) + rrect(c, -10, 18, 20, 44, 8) + fill_stroke(c, lin(-10, 0, 10, 0, "#7c4a24", "#4a2a12"), 5) + c.move_to(-14, 20) + c.line_to(-14, -46) + c.curve_to(-14, -60, 4, -64, 16, -52) + c.line_to(16, 20) + c.close_path() + fill_stroke(c, lin(-14, 0, 16, 0, "#ffffff", "#cbd5e1", "#94a3b8"), 6) + rrect(c, -8, -44, 6, 50, 3) + c.set_source_rgba(1, 1, 1, 0.8) + c.fill() + c.restore() + + +def gimbap_slice(c): + c.arc(64, 64, 52, 0, 2 * math.pi) + fill_stroke(c, rgb("#1f2a1f")) + c.arc(64, 64, 40, 0, 2 * math.pi) + c.set_source_rgb(1, 1, 1) + c.fill() + for dx, dy, col in ((-12, -10, "#ff8c1a"), (12, -8, "#ffd23a"), (0, 12, "#3fae49"), (-14, 12, "#ff8fa3"), (14, 12, "#fff3a0")): + c.arc(64 + dx, 64 + dy, 9, 0, 2 * math.pi) + c.set_source_rgb(*rgb(col)) + c.fill() + + +def sundae_raw(c): + # 접시에 담긴 통순대(누르는 도구) + ellipse(c, 64, 92, 58, 22) + fill_stroke(c, lin(0, 70, 0, 114, "#ffffff", "#cbd5e1")) + c.move_to(20, 84) + c.curve_to(14, 40, 70, 30, 72, 60) + c.curve_to(74, 84, 108, 84, 110, 60) + c.set_line_cap(cairo.LINE_CAP_ROUND) + for w, col in ((30 + LW, INK), (30, rgb("#5a2e3c"))): + c.move_to(20, 84) + c.curve_to(14, 40, 70, 30, 72, 60) + c.curve_to(74, 84, 108, 84, 110, 60) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + c.move_to(24, 70) + c.curve_to(24, 48, 60, 40, 64, 56) + c.set_line_width(5) + c.set_source_rgba(1, 1, 1, 0.45) + c.stroke() + + +def sundae_piece(c): + # 순대 한 토막(옆) + rrect(c, 10, 40, 108, 48, 24) + fill_stroke(c, lin(0, 40, 0, 88, "#8a5a6a", "#5a2e3c", "#3a1a24")) + rrect(c, 24, 48, 50, 8, 4) + c.set_source_rgba(1, 1, 1, 0.4) + c.fill() + + +def sundae_slice(c): + c.arc(64, 64, 50, 0, 2 * math.pi) + fill_stroke(c, rad(64, 64, 54, "#8a5a6a", "#5a2e3c", "#3a1a24")) + for dx, dy in ((-16, -12), (12, -16), (16, 10), (-10, 16), (0, 0), (-20, 4)): + c.arc(64 + dx, 64 + dy, 6, 0, 2 * math.pi) + c.set_source_rgba(1, 0.85, 0.8, 0.7) + c.fill() + + +def fish_cake(c): + # 납작한 어묵 한 장(누르는 도구) + c.save() + c.translate(64, 64) + c.rotate(-0.15) + rrect(c, -52, -36, 104, 72, 14) + c.restore() + fill_stroke(c, lin(0, 28, 0, 100, "#ffe2a8", "#f2b46b", "#d98a3a")) + c.save() + c.translate(64, 64) + c.rotate(-0.15) + rrect(c, -40, -26, 50, 8, 4) + c.restore() + c.set_source_rgba(1, 1, 1, 0.6) + c.fill() + + +def batter(c): + # 튀김옷 그릇 + bowl(c, ("#ffd1dc", "#ff7aa2"), "#fff6d6") + for x, y in ((48, 58), (76, 62), (62, 56)): + c.arc(x, y, 4, 0, 2 * math.pi) + c.set_source_rgba(*INK, 0.2) + c.fill() + shine(c, 30, 84, 6, 12, 0.5) + + +def shrimp(c, body, tail, dots): + c.save() + c.translate(64, 64) + c.rotate(-0.5) + c.move_to(-54, 0) + c.curve_to(-54, -28, 30, -28, 40, -6) + c.line_to(40, 6) + c.curve_to(30, 28, -54, 28, -54, 0) + c.close_path() + c.restore() + fill_stroke(c, body) + c.save() + c.translate(64, 64) + c.rotate(-0.5) + polygon(c, [(38, -2), (60, -20), (54, 0), (60, 20), (38, 2)]) + c.restore() + fill_stroke(c, rgb(tail), 5) + if dots: + for x, y in ((36, 72), (50, 64), (64, 56), (46, 82), (60, 74), (74, 66), (30, 62)): + c.arc(x, y, 3.5, 0, 2 * math.pi) + c.set_source_rgba(1, 1, 1, 0.6) + c.fill() + + +def shrimp_raw(c): + shrimp(c, lin(20, 20, 110, 110, "#ffd0c2", "#ff9e8a", "#f07a66"), "#ff6b4a", False) + for i in range(4): + c.save() + c.translate(64, 64) + c.rotate(-0.5) + c.move_to(-30 + i * 16, -16) + c.curve_to(-26 + i * 16, -4, -26 + i * 16, 4, -30 + i * 16, 16) + c.restore() + c.set_source_rgba(*INK, 0.3) + c.set_line_width(3) + c.stroke() + + +def shrimp_batter(c): + shrimp(c, lin(20, 20, 110, 110, "#fffdf2", "#fff1c9", "#f5dfa0"), "#ff6b4a", True) + + +def tongs(c): + c.set_line_cap(cairo.LINE_CAP_ROUND) + c.set_line_join(cairo.LINE_JOIN_ROUND) + for w, col in ((14 + LW, INK), (14, rgb("#cbd5e1"))): + c.move_to(40, 118) + c.line_to(30, 20) + c.line_to(54, 10) + c.move_to(88, 118) + c.line_to(98, 20) + c.line_to(74, 10) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + rrect(c, 30, 96, 68, 22, 10) + fill_stroke(c, lin(0, 96, 0, 118, "#ff8a5a", "#d92f1c"), 6) + + +def customer(c): + # 손님 얼굴(주문 수 표시) + c.arc(64, 70, 46, 0, 2 * math.pi) + fill_stroke(c, rad(64, 70, 50, "#fff1e0", "#ffd7b0", "#f5b885")) + c.move_to(18, 64) + c.curve_to(18, 10, 110, 10, 110, 64) + c.curve_to(96, 40, 40, 36, 18, 64) + c.close_path() + fill_stroke(c, lin(0, 20, 0, 64, "#6b4a3a", "#3f2a20"), 5) + for x in (48, 80): + c.arc(x, 74, 6, 0, 2 * math.pi) + c.set_source_rgb(*INK) + c.fill() + c.arc(x + 2, 72, 2, 0, 2 * math.pi) + c.set_source_rgb(1, 1, 1) + c.fill() + c.arc(64, 88, 10, 0.15 * math.pi, 0.85 * math.pi) + c.set_source_rgb(*INK) + c.set_line_width(4) + c.stroke() + for x in (36, 92): + ellipse(c, x, 90, 8, 5) + c.set_source_rgba(1, 0.5, 0.55, 0.5) + c.fill() + + +def mascot_face(c): + # 떡이(떡볶이 떡 캐릭터) 얼굴 + 요리사 모자 + rrect(c, 14, 40, 100, 78, 36) + fill_stroke(c, lin(0, 40, 0, 118, "#ffffff", "#ffe4d6")) + # 모자 + for x, y, r in ((40, 30, 20), (64, 20, 24), (88, 30, 20)): + c.arc(x, y, r, 0, 2 * math.pi) + fill_stroke(c, rgb("#ffffff"), 5) + rrect(c, 30, 30, 68, 20, 6) + fill_stroke(c, rgb("#ffffff"), 5) + rrect(c, 34, 32, 60, 14, 4) + c.set_source_rgb(1, 1, 1) + c.fill() + # 눈·입·볼 + for x in (46, 82): + ellipse(c, x, 76, 7, 9) + c.set_source_rgb(*INK) + c.fill() + c.arc(x + 2, 72, 3, 0, 2 * math.pi) + c.set_source_rgb(1, 1, 1) + c.fill() + c.move_to(54, 90) + c.curve_to(58, 102, 70, 102, 74, 90) + c.close_path() + fill_stroke(c, rgb("#ff6b6b"), 4) + for x in (32, 96): + ellipse(c, x, 92, 9, 6) + c.set_source_rgba(1, 0.45, 0.5, 0.55) + c.fill() + + +def heart(c): + c.move_to(64, 112) + c.curve_to(10, 74, 8, 30, 38, 22) + c.curve_to(52, 18, 62, 28, 64, 38) + c.curve_to(66, 28, 76, 18, 90, 22) + c.curve_to(120, 30, 118, 74, 64, 112) + c.close_path() + fill_stroke(c, lin(0, 20, 0, 112, "#ff9fb5", "#ff4d7a")) + shine(c, 40, 42, 10, 7, 0.7) + + +def cart(c): + # 상점(업그레이드) 버튼: 위쪽 화살표가 붙은 가게 차양 + rrect(c, 18, 56, 92, 58, 10) + fill_stroke(c, lin(0, 56, 0, 114, "#fff7ec", "#f3d9b8")) + rrect(c, 50, 78, 28, 36, 6) + fill_stroke(c, lin(0, 78, 0, 114, "#ffb35a", "#e07a1f"), 5) + for i in range(5): + x = 10 + i * 22 + c.move_to(x, 30) + c.line_to(x + 22, 30) + c.line_to(x + 22, 52) + c.curve_to(x + 22, 64, x, 64, x, 52) + c.close_path() + fill_stroke(c, rgb("#ff5a7a" if i % 2 == 0 else "#ffffff"), 5) + rrect(c, 8, 18, 112, 16, 8) + fill_stroke(c, rgb("#ff5a7a"), 5) + + +def pot_icon(c): + # 요리하기(냄비) 아이콘 + rrect(c, 14, 50, 100, 60, 20) + fill_stroke(c, lin(0, 50, 0, 110, "#ff8a6a", "#d92f1c")) + rrect(c, 4, 58, 16, 14, 6) + fill_stroke(c, rgb("#7c4a24"), 5) + rrect(c, 108, 58, 16, 14, 6) + fill_stroke(c, rgb("#7c4a24"), 5) + ellipse(c, 64, 50, 52, 12) + fill_stroke(c, rgb("#ffcf5a"), 5) + for x in (44, 64, 84): + c.move_to(x, 34) + c.curve_to(x - 8, 24, x + 8, 16, x, 6) + c.set_source_rgba(1, 1, 1, 0.95) + c.set_line_width(6) + c.stroke() + shine(c, 32, 70, 8, 12, 0.5) + + ICONS = [ ("coin", coin), ("moneyBag", money_bag), ("bolt", bolt), ("gear", gear), ("upgrade", upgrade), ("plate", plate), ("lock", lock), ("check", check), @@ -668,6 +1069,13 @@ ICONS = [ ("Twigim", twigim), ("globe", globe), ("speaker", speaker), ("mouse", mouse), ("wrench", wrench), ("star", star), ("sparkle", sparkle), ("rays", rays), ("glow", glow), ("arrowDown", arrow_down), ("scroll", scroll), ("hand", hand), + ("riceCake", rice_cake), ("riceCakeRed", rice_cake_red), ("riceCakes", rice_cakes), ("sauceBowl", sauce_bowl), + ("sauceBlob", sauce_blob), ("spatula", spatula), ("bubble", bubble), ("steam", steam), + ("fillings", fillings), ("mat", mat), ("knife", knife), ("gimbapSlice", gimbap_slice), + ("sundaeRaw", sundae_raw), ("sundaePiece", sundae_piece), ("sundaeSlice", sundae_slice), ("fishCake", fish_cake), + ("batter", batter), ("shrimpRaw", shrimp_raw), ("shrimpBatter", shrimp_batter), ("tongs", tongs), + ("customer", customer), ("mascot", mascot_face), ("heart", heart), ("cart", cart), + ("pot", pot_icon), ] diff --git a/bunsik-tycoon/tools/kitchen_art.py b/bunsik-tycoon/tools/kitchen_art.py new file mode 100644 index 0000000..974798c --- /dev/null +++ b/bunsik-tycoon/tools/kitchen_art.py @@ -0,0 +1,322 @@ +#!/usr/bin/env python3 +"""요리 화면의 큰 그림(조리 도구, 마스코트 떡이)을 256px 칸 4x4 한 장(art/kitchen.png)으로 직접 그립니다. +칸 이름과 위치는 src/shared/Icons.luau 의 KITCHEN 표와 같아야 합니다(--luau 로 확인). + + python3 tools/kitchen_art.py # art/kitchen.png + python3 tools/kitchen_art.py --sheet x.png +""" +import math +import os +import sys + +import cairo + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from icons import INK, ellipse, fill_stroke, lin, rad, rgb, rrect, shine # noqa: E402 + +OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "art", "kitchen.png") +CELL = 256 +GRID = 4 +LW = 9 + + +def fs(c, paint, lw=LW): + fill_stroke(c, paint, lw) + + +def flame_row(c, y=236, n=4): + # 그릇 바닥을 핥는 작은 불꽃(그릇을 그린 다음에 그림) + for i in range(n): + x = 128 + (i - (n - 1) / 2) * 40 + c.move_to(x, y) + c.curve_to(x - 16, y - 4, x - 12, y - 22, x - 3, y - 32) + c.curve_to(x, y - 22, x + 8, y - 24, x + 6, y - 36) + c.curve_to(x + 18, y - 20, x + 16, y - 4, x, y) + c.close_path() + fs(c, lin(0, y - 36, 0, y, "#fff36b", "#ffa51f", "#ff5a1f"), 5) + + +def burner(c): + # 가스 화구 받침(불꽃 아래) + rrect(c, 44, 228, 168, 22, 10) + fs(c, lin(0, 228, 0, 250, "#94a3b8", "#475569"), 7) + + +def pan(c): + pan_body(c) + flame_row(c) + burner(c) + + +def pan_body(c): + # 손잡이 + rrect(c, 196, 132, 58, 22, 10) + fs(c, lin(0, 132, 0, 154, "#7c4a24", "#4a2a12")) + # 팬(위에서 비스듬히) + ellipse(c, 118, 150, 108, 52) + fs(c, lin(0, 98, 0, 202, "#4b5563", "#1f2937")) + ellipse(c, 118, 144, 92, 40) + c.set_source(lin(0, 104, 0, 184, "#6b7280", "#374151")) + c.fill() + shine(c, 70, 124, 22, 7, 0.35) + + +def board(c): + # 나무 도마 + 김 + 밥 + rrect(c, 8, 70, 240, 150, 26) + fs(c, lin(0, 70, 0, 220, "#f5c98a", "#d99a52")) + for y in (100, 140, 180): + c.move_to(24, y) + c.curve_to(90, y - 8, 160, y + 8, 232, y) + c.set_source_rgba(*INK, 0.12) + c.set_line_width(3) + c.stroke() + rrect(c, 36, 84, 184, 122, 10) + fs(c, lin(0, 84, 0, 206, "#2e3b2e", "#141c14"), 6) + rrect(c, 46, 94, 164, 86, 18) + c.set_source(lin(0, 94, 0, 180, "#ffffff", "#f1ede4")) + c.fill() + for x, y in ((70, 110), (100, 130), (140, 112), (170, 140), (120, 160), (80, 158), (190, 108)): + ellipse(c, x, y, 6, 3.5) + c.set_source_rgba(*INK, 0.08) + c.fill() + + +def steamer(c): + steamer_body(c) + flame_row(c) + burner(c) + + +def steamer_body(c): + # 냄비 몸통 + 대나무 찜기 테두리 + 뚜껑 없음(속이 보임) + rrect(c, 34, 112, 188, 92, 22) + fs(c, lin(0, 112, 0, 204, "#e2e8f0", "#94a3b8")) + rrect(c, 22, 96, 212, 40, 18) + fs(c, lin(0, 96, 0, 136, "#f6d58e", "#d9a24a")) + for x in range(40, 230, 24): + c.move_to(x, 100) + c.line_to(x, 132) + c.set_source_rgba(*INK, 0.25) + c.set_line_width(3) + c.stroke() + ellipse(c, 128, 100, 96, 22) + fs(c, lin(0, 78, 0, 122, "#fff3d0", "#e9c983"), 6) + for x in range(48, 212, 18): + c.move_to(x, 88) + c.line_to(x, 112) + c.set_source_rgba(*INK, 0.15) + c.set_line_width(2) + c.stroke() + + +def pot(c): + pot_body(c) + flame_row(c) + burner(c) + + +def pot_body(c): + rrect(c, 12, 118, 24, 22, 8) + fs(c, rgb("#7c4a24"), 6) + rrect(c, 220, 118, 24, 22, 8) + fs(c, rgb("#7c4a24"), 6) + rrect(c, 30, 100, 196, 106, 30) + fs(c, lin(0, 100, 0, 206, "#ff8a6a", "#d92f1c")) + ellipse(c, 128, 102, 98, 26) + fs(c, lin(0, 76, 0, 128, "#ffe08a", "#f2b046"), 7) + for x, y in ((90, 98), (150, 108), (176, 94)): + c.arc(x, y, 5, 0, 2 * math.pi) + c.set_source_rgba(1, 1, 1, 0.7) + c.fill() + # 파 송송 + for x, y in ((70, 104), (120, 92), (196, 104), (140, 114)): + c.arc(x, y, 6, 0, 2 * math.pi) + fs(c, rgb("#5cc95c"), 3) + shine(c, 60, 150, 10, 22, 0.35) + + +def fryer(c): + fryer_body(c) + flame_row(c) + burner(c) + + +def fryer_body(c): + rrect(c, 26, 96, 204, 112, 26) + fs(c, lin(0, 96, 0, 208, "#cbd5e1", "#64748b")) + ellipse(c, 128, 100, 100, 26) + fs(c, lin(0, 74, 0, 126, "#ffe58a", "#f5b52a"), 7) + for x, y, r in ((80, 100, 6), (120, 92, 4), (164, 104, 5), (190, 96, 4), (100, 110, 3)): + c.arc(x, y, r, 0, 2 * math.pi) + c.set_source_rgba(1, 1, 1, 0.75) + c.fill() + shine(c, 56, 150, 10, 24, 0.4) + + +def mascot_body(c, cheer): + # 떡이: 하얀 가래떡 몸 + 요리사 모자 + 빨간 앞치마 + arm_y = 70 if cheer else 150 + c.set_line_cap(cairo.LINE_CAP_ROUND) + for x0, x1 in ((62, 22), (194, 234)): + for w, col in ((26 + LW, INK), (26, rgb("#fff7ef"))): + c.move_to(x0, 150) + c.line_to(x1, arm_y) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + rrect(c, 52, 70, 152, 176, 64) + fs(c, lin(0, 70, 0, 246, "#ffffff", "#ffe6da")) + # 앞치마 + c.move_to(76, 176) + c.line_to(180, 176) + c.line_to(176, 234) + c.curve_to(150, 248, 106, 248, 80, 234) + c.close_path() + fs(c, lin(0, 176, 0, 244, "#ff7a8a", "#ff4d6a"), 6) + c.arc(128, 206, 10, 0, 2 * math.pi) + fs(c, rgb("#ffd23a"), 4) + # 모자 + for x, y, r in ((88, 54, 34), (128, 38, 40), (168, 54, 34)): + c.arc(x, y, r, 0, 2 * math.pi) + fs(c, rgb("#ffffff"), 7) + rrect(c, 70, 58, 116, 32, 10) + fs(c, rgb("#ffffff"), 7) + rrect(c, 76, 52, 104, 30, 8) + c.set_source_rgb(1, 1, 1) + c.fill() + # 얼굴 + for x in (102, 154): + if cheer: + c.arc(x, 130, 11, math.pi, 2 * math.pi) + c.set_source_rgb(*INK) + c.set_line_width(7) + c.stroke() + else: + ellipse(c, x, 128, 10, 13) + c.set_source_rgb(*INK) + c.fill() + c.arc(x + 3, 122, 4, 0, 2 * math.pi) + c.set_source_rgb(1, 1, 1) + c.fill() + c.move_to(112, 146) + c.curve_to(116, 166 if cheer else 160, 140, 166 if cheer else 160, 144, 146) + c.close_path() + fs(c, rgb("#ff6b6b"), 5) + for x in (82, 174): + ellipse(c, x, 150, 14, 9) + c.set_source_rgba(1, 0.45, 0.5, 0.55) + c.fill() + if cheer: + for x, y in ((24, 40), (232, 36), (14, 120), (242, 118)): + c.move_to(x, y - 16) + c.line_to(x + 5, y - 5) + c.line_to(x + 16, y) + c.line_to(x + 5, y + 5) + c.line_to(x, y + 16) + c.line_to(x - 5, y + 5) + c.line_to(x - 16, y) + c.line_to(x - 5, y - 5) + c.close_path() + fs(c, rgb("#ffd23a"), 4) + + +def mascot(c): + mascot_body(c, False) + + +def mascot_cheer(c): + mascot_body(c, True) + + +def gimbap_roll(c): + # 돌돌 만 김밥 한 줄(옆), 오른쪽 끝 단면 + rrect(c, 10, 92, 220, 72, 36) + fs(c, lin(0, 92, 0, 164, "#3a4a3a", "#141c14")) + shine(c, 90, 106, 60, 6, 0.25) + c.arc(212, 128, 38, 0, 2 * math.pi) + fs(c, rgb("#1f2a1f"), 7) + c.arc(212, 128, 29, 0, 2 * math.pi) + c.set_source_rgb(1, 1, 1) + c.fill() + for dx, dy, col in ((-9, -8, "#ff8c1a"), (9, -7, "#ffd23a"), (0, 9, "#3fae49"), (-11, 9, "#ff8fa3"), (11, 9, "#fff3a0")): + c.arc(212 + dx, 128 + dy, 7, 0, 2 * math.pi) + c.set_source_rgb(*rgb(col)) + c.fill() + + +def plate_big(c): + # 완성 접시 받침(위에서 비스듬히) + ellipse(c, 128, 150, 116, 58) + fs(c, lin(0, 92, 0, 208, "#ffffff", "#d7dde6")) + ellipse(c, 128, 146, 82, 38) + c.set_source_rgba(*INK, 0.15) + c.set_line_width(4) + c.stroke() + + +def burst(c): + # 완성 축하 빛(테두리 없음) + for i in range(12): + a0 = i * math.pi / 6 + a1 = a0 + math.pi / 12 + c.move_to(128, 128) + c.line_to(128 + 130 * math.cos(a0), 128 + 130 * math.sin(a0)) + c.line_to(128 + 130 * math.cos(a1), 128 + 130 * math.sin(a1)) + c.close_path() + g = cairo.RadialGradient(128, 128, 10, 128, 128, 128) + g.add_color_stop_rgba(0, 1, 0.95, 0.6, 1) + g.add_color_stop_rgba(1, 1, 0.85, 0.3, 0) + c.set_source(g) + c.fill() + + +BIG = [ + ("pan", pan), ("board", board), ("steamer", steamer), ("pot", pot), + ("fryer", fryer), ("mascot", mascot), ("mascotCheer", mascot_cheer), ("gimbapRoll", gimbap_roll), + ("plateBig", plate_big), ("burst", burst), +] + + +def draw(): + surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID) + for i, (name, fn) in enumerate(BIG): + c = cairo.Context(surf) + c.translate((i % GRID) * CELL, (i // GRID) * CELL) + c.rectangle(0, 0, CELL, CELL) + c.clip() + c.translate(128, 128) + c.scale(0.94, 0.94) + c.translate(-128, -128) + fn(c) + return surf + + +def main(argv): + surf = draw() + if "--luau" in argv: + for i, (name, _) in enumerate(BIG): + print(f"\t{name} = Vector2.new({(i % GRID) * CELL}, {(i // GRID) * CELL}),") + return + if "--sheet" in argv: + out = argv[argv.index("--sheet") + 1] + sheet = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID) + c = cairo.Context(sheet) + c.set_source_rgb(0.55, 0.75, 0.6) + c.paint() + c.set_source_surface(surf, 0, 0) + c.paint() + for i, (name, _) in enumerate(BIG): + c.set_source_rgb(0, 0, 0) + c.move_to((i % GRID) * CELL + 6, (i // GRID) * CELL + 18) + c.set_font_size(16) + c.show_text(name) + sheet.write_to_png(out) + print(out) + return + surf.write_to_png(OUT) + print(os.path.normpath(OUT)) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/bunsik-tycoon/tools/sfx.py b/bunsik-tycoon/tools/sfx.py index 592c43a..94ed250 100644 --- a/bunsik-tycoon/tools/sfx.py +++ b/bunsik-tycoon/tools/sfx.py @@ -95,6 +95,14 @@ def sizzle(sec=3.0): return s[:-fade] +def pop(): + # 요리 화면 톡톡: 통통 튀는 짧은 소리(높은 음에서 빠르게 내려감) + x = t(0.12) + f = 900 * np.exp(-x * 18) + 380 + phase = 2 * np.pi * np.cumsum(f) / SR + return np.sin(phase) * env(len(x), 0.001, 0.035) + + def save(name, sig): sig = sig / max(1e-9, np.max(np.abs(sig))) * 0.85 pcm = (sig * 32767).astype(np.int16) @@ -116,6 +124,7 @@ def main(): save("buy", buy()) save("levelup", levelup()) save("sizzle", sizzle()) + save("pop", pop()) if __name__ == "__main__": diff --git a/bunsik-tycoon/tools/simlib.luau b/bunsik-tycoon/tools/simlib.luau index ed9658a..c9b5c0c 100644 --- a/bunsik-tycoon/tools/simlib.luau +++ b/bunsik-tycoon/tools/simlib.luau @@ -1,7 +1,9 @@ -- 경제 시뮬레이터 본체: 실제 게임 로직(src/shared/Shop)을 봇이 쉬지 않고 최적으로 플레이합니다. -- 실행은 tools/sim.luau, 검사는 tests/Sim.spec.luau -- 봇 가정: 조리대 <-> 테이블 편도 WALK/2초, 알바생이 있으면 직접 조리하지 않고 나르기만 합니다. +-- 조리 시간은 요리 화면을 쉬지 않고 했을 때의 시간(Recipes.expectedTime: 메뉴 고르기 + 단계 + 완성 연출)입니다. local Economy = require("../src/shared/Economy") +local Recipes = require("../src/shared/Recipes") local Shop = require("../src/shared/Shop") local Sim = {} @@ -31,7 +33,8 @@ function Sim.run(mult: number, limit: number): { { t: number, id: string, cost: local canCook = not shop.stats.helper and not Shop.handFull(shop) and Shop.nextCookMenu(shop) ~= nil if canCook then pending = "cook" - busyUntil = t + shop.stats.cook + local menu = Shop.nextCookMenu(shop) :: string + busyUntil = t + Recipes.expectedTime(menu, shop.stats.cook) elseif #shop.hand > 0 and (Shop.handFull(shop) or #shop.counter == 0) then pending = "arrive_tables" busyUntil = t + Economy.WALK / 2