feat(game): 创建游戏核心框架(常量、配置、状态管理、地图渲染、主场景)

This commit is contained in:
Cloud Bot
2026-03-21 07:56:48 +00:00
parent 80024a5200
commit 85377f1cb2
5 changed files with 489 additions and 0 deletions

40
game/constants.ts Normal file
View File

@@ -0,0 +1,40 @@
// 游戏地图常量
export const MAP_COLS = 16
export const MAP_ROWS = 12
export const TILE_SIZE = 80 // 每格80px总计 1280x960Phaser 会缩放适配
export const GAME_WIDTH = 1280
export const GAME_HEIGHT = 720
// HUD 高度(顶部状态栏)
export const HUD_HEIGHT = 60
// S型路径折线关键坐标点
// 路径:从左侧(0,2) → 右至(11,2) → 下至(11,9) → 右至(15,9)
export const PATH_WAYPOINTS = [
{ x: 0, y: 2 },
{ x: 11, y: 2 },
{ x: 11, y: 9 },
{ x: 15, y: 9 },
] as const
// 游戏初始数值
export const INITIAL_HC = 200
export const INITIAL_KPI = 100
export const STAMINA_MAX = 100
export const STAMINA_REGEN = 5 // 每秒恢复量
export const COFFEE_COST = 10 // 瑞幸咖啡 HC 成本
// 颜色常量Phaser 使用 0x 十六进制)
export const COLOR_PATH = 0x3d2b1f // 路径格子:深褐色
export const COLOR_BUILDABLE = 0x1e3a5f // 可建塔格子:深蓝色
export const COLOR_HOVER = 0x2d5a8e // 悬停高亮:亮蓝色
export const COLOR_BORDER = 0x0a1628 // 格子边框:深夜蓝
export const COLOR_HUD_BG = 0x0a1628 // HUD 背景色
// 地图装饰性标记文字
export const MAP_LABELS: { col: number; row: number; text: string }[] = [
{ col: 2, row: 5, text: '面试间' },
{ col: 8, row: 5, text: '财务室' },
{ col: 4, row: 10, text: 'P8会议室' },
{ col: 13, row: 5, text: '茶水间' },
]