- 全部代码重写,改为拖拽合成(drag-and-drop merge) - 拖拽方块到相邻同等级方块上完成合成 - 拖到空格移动,拖到无效位置弹回 - Cocos Creator 3.8.8 全面适配 - 移除 GameManager.ts → 改为 GameController.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
/**
|
|
* 方块与棋盘配置
|
|
*/
|
|
export interface LevelConfig {
|
|
level: number;
|
|
color: string;
|
|
name: string;
|
|
}
|
|
|
|
/** 8 个等级 — 颜色由浅到深,名称由低到高 */
|
|
export const LEVELS: LevelConfig[] = [
|
|
{ level: 1, color: '#A8E6CF', name: '草' },
|
|
{ level: 2, color: '#4CAF50', name: '木' },
|
|
{ level: 3, color: '#2196F3', name: '水' },
|
|
{ level: 4, color: '#9C27B0', name: '风' },
|
|
{ level: 5, color: '#FF9800', name: '火' },
|
|
{ level: 6, color: '#F44336', name: '雷' },
|
|
{ level: 7, color: '#E91E63', name: '光' },
|
|
{ level: 8, color: '#FFD700', name: '神' },
|
|
];
|
|
|
|
/** 棋盘尺寸 */
|
|
export const ROWS = 12;
|
|
export const COLS = 8;
|
|
export const CELL = 64; // 格子像素
|
|
export const PAD = 6; // 格子间距
|
|
export const MAX_LEVEL = 8; // 最高等级
|
|
|
|
/** 自动生成间隔(秒) */
|
|
export const SPAWN_INTERVAL = 3.0;
|
|
|
|
/** 合并基础分 */
|
|
export const MERGE_BASE_SCORE = 10;
|
|
|
|
/** 获取等级配置 */
|
|
export function conf(level: number): LevelConfig {
|
|
return LEVELS[Math.min(Math.max(level - 1, 0), LEVELS.length - 1)];
|
|
}
|
|
|
|
/** 随机生成初始等级(低等级高概率) */
|
|
export function randLevel(): number {
|
|
const r = Math.random();
|
|
if (r < 0.45) return 1;
|
|
if (r < 0.75) return 2;
|
|
if (r < 0.90) return 3;
|
|
if (r < 0.97) return 4;
|
|
return 5;
|
|
}
|